
暂无个人介绍
版本1:#cpuid.s Sample program to extract the processor Vendor ID .section .data output: .ascii "The processor Vendor ID is 'xxxxxxxxxxxxxxxxx'\n" .section .text .global _start _start: mov $0,%eax cpuid mov $output,%edi mov %ebx,28(%edi) mov %edx,32(%edi) mov %ecx,36(%edi) mov $4,%eax mov $1,%ebx mov $output,%ecx mov $42,%edx int $0x80 mov $1,%eax mov $0,%ebx int $0x80 使用as编译,ld连接:as -o cpuid.o cpuid.s ld -o cpuid cpuid.o ./cpuid使用GCC进行汇编,需要修改脚本:将start换成main#cpuid.s Sample program to extract the processor Vendor ID .section .data output: .ascii "The processor Vendor ID is 'xxxxxxxxxxxxxxxxx'\n" .section .text .global main main: mov $0,%eax cpuid mov $output,%edi mov %ebx,28(%edi) mov %edx,32(%edi) mov %ecx,36(%edi) mov $4,%eax mov $1,%ebx mov $output,%ecx mov $42,%edx int $0x80 mov $1,%eax mov $0,%ebx int $0x80使用gcc汇编:gcc -o cpuid cpuid2.s但是会报错,错误信息如下:relocation R_X86_64_32 against `.data' can not be used when making a PIE object; recompile with -fPIE解决方法是:增加-no-pie选项gcc -o cpuid cpuid2.s -no-pie连接C库函数#cpuid.s View the CPUID Vendor ID string using C library calls .section .data output: .asciz "The processor Vendor ID is '%s'\n" .section .bss .lcomm buffer,12 .section .text .global _start _start: mov $0,%eax cpuid mov $buffer,%edi mov %ebx,(%edi) mov %edx,4(%edi) mov %ecx,8(%edi) push $buffer push $output call printf add $8,%esp push $0 call exit编译:as -o cpuid3.o cpuid3.s连接:ld -dynamic-linker /lib/ld-linux.so.2 -o cpuid3 -lc cpuid3.o执行报错,现阶段还不是太熟悉汇编语言,留待后续再解决
#include<stdio.h> int main(void){ //初始化 //int ages[3]={10,39,50}; int ages[3]={101,79,102}; int count=0; //遍历 for(int i=0;i<3;i++){ for(int j=0;j<3;j++){ /* 自己不给自己发请求 */ if(i==j){ continue; } else{ /* 满足以下条件就可以发送请求 1.age(A)>=age(B) 2.age(A)/2+7<age(B) */ if(ages[i]>=ages[j] && ages[i]/2+7<ages[j]) { /* 3.如果age(A)>100,则age(B)也必须大约100 */ if(ages[i]>100 && ages[j]>100){ printf("第%d个:%d->%d\n",++count,ages[i],ages[j]); } else{ continue; } } /* 不满足的直接略过 */ else{ continue; } } } } }
1.安装cscopesudo apt-get install cscope2.配置Emacspackage-instal xcscope3.修改.emacs文件;;xcscope (require 'xcscope) (cscope-setup) ;; 打开cscope时不更新,提高索引速度 (setq cscope-do-not-update-database t)4.在脚本目录(linux内核)建立database filecscope -b -q -k5.Emacs打开脚本并查询6.测试成功,返回需要1.38s7.总结:现在是只知其然而不知其所以然,待后续研究cscope后再做补充吧
1.配置无线网络 为了全面拥抱Debian,一狠心重装系统,但是悲剧的是只有有线网,没有无线网。于是怀疑是没有安装网卡驱动。 处理方法: 1.查看网卡型号:lspci | grep -i net 注意:Ethernet Controller是以太网 Network Controller是无线网,型号是BCM43142 2.搜了半天linux安装无线网卡驱动都不太实用,后来直接改用型号搜找到了篇文章,最终解决问题:https://blog.csdn.net/u012833250/article/details/52493806 根本原因:现在对网络不是太懂,留待后续补充说明把2.安装搜狗输入法 下载页面:https://pinyin.sogou.com/linux/?r=pinyin 安装方法: 现象: 一定要先配置fcitx,否则无法生效。原因: 猜测估计是搜狗的bug吧,我先安装了sogou再配置fcitx,虽然fcitx显示有搜狗输入法,但是一直无法生效;只有我卸载了搜狗(dpkg -r),按照文档指定的顺序才生效。结果: 3.修改PATH 处理方法:编辑/etc/profile文件,在最后添加一下两行 PATH=/usr/local/sbin:/usr/sbin:/sbin:$PATH export PATH 根本原因:留待以后补充4.“不在sudoers文件中,此事将被报告” 处理办法:编辑/etc/sudoers文件 # User privilege specification root ALL=(ALL:ALL) ALL 用户名 ALL=(ALL) ALL 根本原因:留待以后补充
1.列出安装的unit filessystemctl list-unit-files2.设置开机启动systemctl enable postgresql.service3.禁用开机启动systemctl disable postgresql.service4.查看服务状态systemctl status postgresql.service5.停止服务systemctl stop postgresql.service 6.开启服务systemctl start postgresql.service 7.重启服务systemctl restart postgresql.serviceTo be continued.....
1.初步怀疑是版本不对,卸载emacs sudo apt-get remove --purge eamcs问题: 因无法删除,故手工操作,删除了emaceen-common,结果: 导致了gnome界面无法使用,没有办法,只能重装gnome:解决方案: sudo apt-get install gnome -y总结: 不清楚的东西不要乱动,不然都是悲剧2.修改emacs配置 参考以下文档: https://blog.csdn.net/sanwu2010/article/details/23959561 auto-complete可以正常工作,但是auto-complete-clang还是一直不行。突然想起自己还没有检查clang是否还在,经检查,debian升级过程中还真的把clang/llvm搞没了。 总结: 修改之前需要检查下依赖,如果依赖不成立,后面的都是浮云。3.重新安装clang3.1.更新source.list(使用bulleye)deb http://apt.llvm.org/bullseye/ llvm-toolchain-bullseye maindeb-src http://apt.llvm.org/bullseye/ llvm-toolchain-bullseye main3.2.获取证书wget -O - http://llvm.org/apt/llvm-snapshot.gpg.key|sudo apt-key add -3.3.安装clangsudo apt-get install clang总结: 1.对linux和emacs还不够熟练 2.只要肯坚持,总能找到解决的办法
#include <stdio.h> #include <string.h> #define len 5 /*判断是否回文*/ int isCycle(char *str); int main(void) { /* 初始化数据 */ char string[][50] = {"abcd", "dcba", "lls", "s", "sssll"}; /* 存储拼接的字符串,长度需要翻倍 */ char target[100], *str; //数组遍历 for (int i = 0; i < len; i++) { for (int j = 0; j < len; j++) { if (i == j) { continue; } else { /* 复制第一个字符串 */ str = strcpy(target, string[i]); /* 拼接第二个字符串 */ str = strcat(target, string[j]); /* 判断是否回文并输出 */ if (isCycle(str)) { puts(str); } } } } return 0; } int isCycle(char *str) { int start = 0, end = strlen(str) - 1, flag = 1; while (start < end && flag == 1) { flag = str[start++] == str[end--] ? 1 : 0; } return flag; }
maven依赖:<groupId>org.apache.poi</groupId> <artifactId>poi</artifactId> <version>4.1.0</version>脚本:package Excelimport java.io.{File, FileInputStream, InputStream, PrintWriter}import org.apache.poi.hssf.usermodel.HSSFWorkbookimport org.apache.poi.ss.usermodel.{Cell, CellType}object TestExcel { def main(args: Array[String]): Unit = {//读取excel val file = new File(args(0)) val stream = new FileInputStream(file) //输出文件 var output=new PrintWriter("script.sql") //工作簿 val workBook = new HSSFWorkbook(stream) //获取sheets集合 val sheets = workBook.sheetIterator() //sheet递归 while (sheets.hasNext) { //获取当前sheet val sheet = sheets.next() //获取rows集合 val rows = sheet.rowIterator //行递归 while (rows.hasNext) { //获取当前row val row = rows.next() //获取cell集合 val cells = row.cellIterator() //sql语句 var sql = "insert into " + sheet.getSheetName + " values(" //内容 var content: String = "" //cell遍历 while (cells.hasNext) { var cell = cells.next() content += (cell.getCellType match { case CellType.NUMERIC => "," + cell.getNumericCellValue + "" case _ => ",'" + cell.getStringCellValue.toString.replace("'","\\'") + "'" } ) } //生成sql sql+=content.replaceFirst(",","")+");" //写入文件 output.write(sql) output.write("\n") } } output.close()}}
import scala.io.StdInimport java.time.format.DateTimeFormatterimport java.time.LocalDate._import java.io.PrintWriterimport java.time.LocalDateobject TestBasic { def main(args: Array[String]): Unit = {//输入作业名(不含后缀) val jobName = args(0) //指定日期格式 val pattern = DateTimeFormatter.ofPattern("yyyyMMdd") //获取开始日期 var startDt = LocalDate.parse(StdIn.readLine("开始日期(YYYYMMDD):"), pattern) //获取结束日期 val endDt = LocalDate.parse(StdIn.readLine("结束日期(YYYYMMDD):"), pattern) //打开文件(写入) val writer = new PrintWriter(jobName+".bat") while (startDt.isBefore(endDt)) { //写入内容 writer.write("dsql -c logon.env -f " + jobName + ".dsql TX_DATE=" + startDt.format(pattern) + ">" + jobName + "_" + startDt.format(pattern) + ".sql\n") startDt = startDt.plusDays(1) writer.write("\n") } //关闭文件 writer.close() //结束 println("work is done!")}}
Maven依赖:<dependency> <groupId>com.google.code.gson</groupId> <artifactId>gson</artifactId> <version>2.8.5</version> </dependency> <!-- https://mvnrepository.com/artifact/com.alibaba/fastjson --> <dependency> <groupId>com.alibaba</groupId> <artifactId>fastjson</artifactId> <version>1.2.51</version> </dependency>fastjson:import com.alibaba.fastjson._import scala.collection.JavaConversions._object TestFastJson { def main (args: Array[String]): Unit ={println("fastJson tests....") var badJsonStr="{\"employees\":\"{\"firstName\":\"三\",\"lastName\":\"张\"}\"}" try{ var badJsonObject=JSON.parseObject(badJsonStr) } catch{ //json格式不正确,报错 case e:Exception=>println(e.getMessage) } /*测试JsonObject*/ var jsonObjectStr="{\"firstName\":\"三\" , \"lastName\":\"张\"}" var jsonObject:JSONObject=JSON.parseObject(jsonObjectStr) println("firstName="+jsonObject.getString("firstName")+",lastName="+jsonObject.getString("lastName")) /*测试JsonArray*/ var jsonArrayStr="[{\"firstName\":\"三\",\"lastName\":\"张\"},{\"firstName\":\"四\",\"lastName\":\"李\"}]" //生成JsonArray对象 var jsonArray:JSONArray=JSON.parseArray(jsonArrayStr) //遍历JsonArray jsonArray.foreach(ja=>{ //scala不能推断出ja是JsonObject,只能手动转成JsonObject var json=JSON.parseObject(ja.toString) //输出 println("firstName="+json.getString("firstName")+",lastName="+json.getString("lastName")) })}}--gsonimport com.google.gson._import scala.collection.JavaConversions._/**Created by Administrator on 2018/10/21.*/object TestGson { def main(args: Array[String]) {println("gson tests....") var badJsonStr="{\"employees\":\"{\"firstName\":\"三\",\"lastName\":\"张\"}\"}" try{ var badJsonObject=new JsonParser().parse(badJsonStr).getAsJsonObject } catch{ //json格式不正确,报错 case e:Exception=>println(e.getMessage) } /*测试JsonObject*/ var jsonObjectStr="{\"firstName\":\"三\" , \"lastName\":\"张\"}" var jsonObject=new JsonParser().parse(jsonObjectStr).getAsJsonObject println("firstName="+jsonObject.get("firstName").getAsString+",lastName="+jsonObject.get("lastName").getAsString) /*测试JsonArray*/ var jsonArrayStr="[{\"firstName\":\"三\",\"lastName\":\"张\"},{\"firstName\":\"四\",\"lastName\":\"李\"}]" //生成JsonArray对象 var jsonArray=new JsonParser().parse(jsonArrayStr).getAsJsonArray //遍历JsonArray jsonArray.foreach(ja=>{ //scala可以识别ja是JsonObject,可以直接进行解析 println("firstName="+jsonObject.get("firstName").getAsString+",lastName="+jsonObject.get("lastName").getAsString) })}}
2023年04月
2022年11月
2022年03月
2022年02月
2022年01月
2021年11月
2021年10月
2021年09月