merge fix
This commit is contained in:
parent
971a21a83d
commit
946f5059d7
@ -1,14 +0,0 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
PATH=/bin:/sbin:/usr/local/bin
|
||||
export PATH
|
||||
read -p "Please input (in/out)" cz
|
||||
|
||||
if [ ${cz} == "in" ]; then
|
||||
cp -v ~/.profile ~/.bashrc ~/.vimrc ./
|
||||
cp -rv ~/.ssh ./
|
||||
fi
|
||||
|
||||
if [ ${cz} == "out" ]; then
|
||||
cp -iv ./.profile ./.bashrc ./.vimrc ~/
|
||||
fi
|
@ -1,39 +0,0 @@
|
||||
1.配置dhcp
|
||||
vim /etc/network/interfaces
|
||||
auto eth0
|
||||
iface eth0 inet dhcp
|
||||
#iface eth0 inet static
|
||||
#address 192.168.0.108
|
||||
#netmask 255.255.255.0
|
||||
#gateway 192.168.0.101
|
||||
#network 192.168.0.108
|
||||
|
||||
service network restart //cpwl
|
||||
2.配置dns
|
||||
vim /etc/resolv.conf
|
||||
nameserver 114.114.114.114
|
||||
nameserver 8.8.8.8
|
||||
search localdomain
|
||||
|
||||
3.更新应用
|
||||
apt update
|
||||
apt upgrade
|
||||
|
||||
4.安装配置ibus
|
||||
apt install ibus
|
||||
apt install ibus-pinyin
|
||||
ibus-setup
|
||||
|
||||
5.安装gcc,g++,gdb,cmake
|
||||
apt update
|
||||
apt install build-essential gdb
|
||||
gcc --version
|
||||
g++ --version
|
||||
gdb --version
|
||||
apt intall cmake
|
||||
cmake --version
|
||||
|
||||
6.安装各工具
|
||||
tree
|
||||
dnsmap
|
||||
nload
|
19
README.md
19
README.md
@ -1,19 +0,0 @@
|
||||
存放计算机类笔记的仓库
|
||||
======================
|
||||
|
||||
## 使用说明以及环境
|
||||
+ 今后我尽量改写成makedown的文本
|
||||
|
||||
|
||||
## 项目结构
|
||||
|
||||
|
||||
## 更新连接
|
||||
|
||||
|
||||
## 历史版本 Histroy
|
||||
|
||||
|
||||
## 作者列表 AUTHORS
|
||||
+ ely
|
||||
|
@ -1,63 +0,0 @@
|
||||
以下是一些常见的linux系统头文件:
|
||||
|
||||
1. **`stdio.h`** - 标准输入输出函数,如 `printf`、`scanf`、`fopen`、`fclose` 等。
|
||||
|
||||
2. **`stdlib.h`** - 标准库函数,如 `malloc`、`free`、`rand`、`exit` 等。
|
||||
|
||||
3. **`string.h`** - 字符串操作函数,如 `strcpy`、`strlen`、`strcat` 等。
|
||||
|
||||
4. **`errno.h`** - 定义错误码。
|
||||
|
||||
5. **`limits.h`** - 定义各种数据类型的最大值和最小值。
|
||||
|
||||
6. **`fcntl.h`** - 文件控制选项,用于文件描述符的操作。
|
||||
|
||||
7. **`sys/types.h`** - 包含数据类型定义,如 `size_t`、`off_t` 等。
|
||||
|
||||
8. **`sys/stat.h`** - 文件状态信息和文件控制操作。
|
||||
|
||||
9. **`sys/time.h`** - 时间相关的系统调用和结构。
|
||||
|
||||
10. **`sys/resource.h`** - 资源限制和优先级设置。
|
||||
|
||||
11. **`sys/wait.h`** - 进程等待和状态查询。
|
||||
|
||||
12. **`sys/ioctl.h`** - 设备控制操作。
|
||||
|
||||
13. **`sys/socket.h`** - 提供套接字接口。
|
||||
|
||||
14. **`netinet/in.h`** - 提供网络通信所需的数据结构和宏。
|
||||
|
||||
15. **`arpa/inet.h`** - 提供网络地址转换函数。
|
||||
|
||||
16. **`netdb.h`** - 网络数据库操作。
|
||||
|
||||
17. **`signal.h`** - 信号处理。
|
||||
|
||||
18. **`setjmp.h`** - 非局部跳转。
|
||||
|
||||
19. **`time.h`** - 时间和日期函数。
|
||||
|
||||
20. **`pthread.h`** - POSIX 线程库。
|
||||
|
||||
21. **`dlfcn.h`** - 动态链接函数。
|
||||
|
||||
22. **`dirent.h`** - 目录操作。
|
||||
|
||||
23. **`grp.h`** - 组数据库操作。
|
||||
|
||||
24. **`pwd.h`** - 密码数据库操作。
|
||||
|
||||
25. **`termios.h`** - 终端控制。
|
||||
|
||||
26. **`sys/mman.h`** - 内存管理。
|
||||
|
||||
27. **`sys/shm.h`** - 共享内存。
|
||||
|
||||
28. **`sys/ipc.h`** - 进程间通信。
|
||||
|
||||
29. **`sys/msg.h`** - 消息队列。
|
||||
|
||||
30. **`sys/sem.h`** - 信号量。
|
||||
|
||||
这些头文件为 C 语言程序提供了与操作系统交互的接口。不同的程序可能会根据需要包含不同的头文件。
|
@ -1,16 +0,0 @@
|
||||
C++代码性能优化的方法
|
||||
1. 使用const关键字
|
||||
2. 避免频繁进行内存分配和释放
|
||||
3. 尽量减少值传递,多用引用来传递参数
|
||||
4. 局部变量VS静态变量(多次调用局部更快,因为局部变量可以读入寄存器,静态不行)
|
||||
5. ++i和i++引申出的效率问题(某些情况下,使用迭代器可能比使用指针更优:迭代器++i可以减少一次构造和析构)
|
||||
6. 避免使用多重继承
|
||||
7. 低级代码使用位运算替代算术运算
|
||||
8. 使用编译器自带的优化选项
|
||||
9. 将小粒度函数声明为内联函数(inline)
|
||||
10. 循环内定义,还是循环外定义对象:由构造函数和复制操作的效率比较决定
|
||||
11. 小函数放在同一循环内效率高,大函数分开放效率更高(由cpu寄存器决定)
|
||||
12. 尽量少使用dynamic_cast
|
||||
13. 减少除法运算的使用,除数尽量使用常量,让编译器有空间优化
|
||||
14. 多用直接初始化
|
||||
15. 循环展开加速
|
@ -1,52 +0,0 @@
|
||||
#include<bits/stdc++.h>//万能头,包括大部分头文件。
|
||||
#include <ctype.h>//字符处理
|
||||
#include <cctype>
|
||||
#include <cerrno>
|
||||
#include <clocale>
|
||||
#include <cmath>
|
||||
#include <complex> //复数类
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
#include <ctime>
|
||||
#include <cwchar>
|
||||
#include <errno.h>//定义错误码
|
||||
#include <float.h>//浮点数处理
|
||||
#include <fstream.h>//文件输入/输出
|
||||
#include <fstream>
|
||||
#include <iomanip.h>//参数化输入/输出
|
||||
#include <iostream.h> //数据流输入/输出
|
||||
#include <limits.h> //定义各种数据类型最值常量
|
||||
#include <locale.h> //定义本地化函数
|
||||
#include <math.h> //定义数学函数
|
||||
#include <stdio.h> //定义输入/输出函数
|
||||
#include <stdlib.h> //定义杂项函数及内存分配函数
|
||||
#include <string.h> //字符串处理
|
||||
#include <strstrea.h> //基于数组的输入/输出
|
||||
#include <time.h> //定义关于时间的函数
|
||||
#include <wchar.h> //宽字符处理及输入/输出
|
||||
#include <wctype.h> //宽字符分类
|
||||
#include <algorithm> //STL 通用算法
|
||||
#include <bitset> //STL 位集容器
|
||||
#include <deque> //STL 双端队列容器
|
||||
#include <exception> //异常处理类
|
||||
#include <functional> //STL 定义运算函数(代替运算符)
|
||||
#include <limits>
|
||||
#include <list> //STL 线性列表容器
|
||||
#include <map> //STL 映射容器
|
||||
#include <iomanip>
|
||||
#include <ios> //基本输入/输出支持
|
||||
#include <iosfwd> //输入/输出系统使用的前置声明
|
||||
#include <iostream>
|
||||
#include <istream> //基本输入流
|
||||
#include <ostream> //基本输出流
|
||||
#include <queue> //STL 队列容器
|
||||
#include <set> //STL 集合容器
|
||||
#include <sstream> //基于字符串的流
|
||||
#include <stack> //STL 堆栈容器
|
||||
#include <stdexcept> //标准异常类
|
||||
#include <streambuf> //底层输入/输出支持
|
||||
#include <string> //字符串类
|
||||
#include <utility> //STL 通用模板类
|
||||
#include <vector> //STL 动态数组容器
|
||||
#include <windows.h>
|
@ -1,105 +0,0 @@
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
using namespace std;
|
||||
|
||||
void c_io(); // c IO
|
||||
void stream_io(); // c++ 流IO
|
||||
void stream_fio(); // c++ 流文件IO
|
||||
|
||||
int main() {
|
||||
c_io();
|
||||
return 0;
|
||||
}
|
||||
|
||||
void c_io() {
|
||||
int i = 14;
|
||||
double d = 3.3;
|
||||
char c = 'e';
|
||||
const char * str = "Hello";
|
||||
|
||||
// scanf & printf
|
||||
// in
|
||||
scanf("%d %lf %c %s", &i, &d, &c, &str);
|
||||
|
||||
// out
|
||||
printf("%d---%3d---%x---%o \n", i, i, i, i); //int型
|
||||
printf("%3.3f \n", d); //double型
|
||||
printf("%c \n", c); //char
|
||||
printf("%s \n", str); //str
|
||||
printf("%p \n", i); //地址
|
||||
|
||||
c = getchar(); //读入一个char, 最快
|
||||
putchar();
|
||||
|
||||
fgets();
|
||||
}
|
||||
|
||||
void stream_io() {
|
||||
// ios::sync_with_stdio(false);cin.tie(0),cout.tie(0); 关闭缓冲加速
|
||||
|
||||
int i = 14;
|
||||
double d = 3.3;
|
||||
char c = 'e';
|
||||
const char * str = "Hello";
|
||||
|
||||
cin.get(c); //返回一个流引用
|
||||
c = cin.get(); //返回char,略快
|
||||
cin.get(str, 100, '\n'); //读入字符串
|
||||
|
||||
cin.width(10); //设置场宽
|
||||
}
|
||||
void stream_fio() {
|
||||
|
||||
//文件流的创建 打开 关闭
|
||||
fstream fin;
|
||||
fstream fout;
|
||||
|
||||
fin.open("in");
|
||||
fout.open("out");
|
||||
|
||||
fin.close();
|
||||
fout.close();
|
||||
/*
|
||||
open函数的原型如下:
|
||||
void open(char const *,int filemode,int =filebuf::openprot);
|
||||
它有3个参数,第1个是要打开的文件名,第2个是文件的打开方式,第3个是文件的保护方式,一般都使用默认值。
|
||||
第2个参数可以取如下所示的值:
|
||||
打开方式 解释
|
||||
ios::in 打开文件进行读操作,这种方式可避免删除现存文件的内容
|
||||
ios::out 打开文件进行写操作,这是默认模式
|
||||
ios::ate 打开一个已有的输入或输出文件并查找到文件尾开始
|
||||
ios::app 在文件尾追加方式写文件
|
||||
ios::binary 指定文件以二进制方式打开,默认为文本方式
|
||||
ios::trunc 如文件存在,将其长度截断为零并清除原有内容,如果文件存在先删除,再创建
|
||||
除ios_base::app方式之外,文件刚刚打开时当前读写位置的文件指针都定位于文件的开始位置,而ios_base::app使文件当前的写指针定位于文件尾
|
||||
|
||||
函数 功能
|
||||
bad() 如果进行非法操作,返回true,否则返回false
|
||||
clear() 设置内部错误状态,如果用缺省参量调用则清除所有错误位
|
||||
eof() 如果提取操作已经到达文件尾,则返回true,否则返回false
|
||||
good() 如果没有错误条件和没有设置文件结束标志,返回true,否则返回false
|
||||
fail() 与good相反,操作失败返回false,否则返回true
|
||||
is_open() 判定流对象是否成功地与文件关联,若是,返回true,否则返回false
|
||||
*/
|
||||
|
||||
// 二进制文件读写
|
||||
fin.write((char*)&data, sizeof data);
|
||||
fin.read((char*)&data, sizeof data);
|
||||
|
||||
/*
|
||||
随机存取
|
||||
seekg(pos,ios::);
|
||||
seekg(pos);
|
||||
seekp(pos,ios::);
|
||||
seekp(pos);
|
||||
|
||||
tellg();
|
||||
tellp();
|
||||
|
||||
文件位置
|
||||
ios::beg
|
||||
ios::cur
|
||||
ios::end
|
||||
*/
|
||||
|
||||
}
|
Before Width: | Height: | Size: 405 KiB After Width: | Height: | Size: 405 KiB |
Before Width: | Height: | Size: 397 KiB After Width: | Height: | Size: 397 KiB |
Before Width: | Height: | Size: 478 KiB After Width: | Height: | Size: 478 KiB |
31
miscellaneous/mirrors.md
Normal file
31
miscellaneous/mirrors.md
Normal file
@ -0,0 +1,31 @@
|
||||
# 镜像合集
|
||||
- [python](# pip)
|
||||
- [Docker](# docker)
|
||||
- [soft](# soft)
|
||||
|
||||
## python
|
||||
以下是部分国内可用的镜像源列表,按不同类型分类整理:
|
||||
|
||||
### pip
|
||||
|
||||
| 清华大学 | https://pypi.tuna.tsinghua.edu.cn/simple/ | 更新及时,速度较快 |
|
||||
| 阿里云 | https://mirrors.aliyun.com/pypi/simple/ | 企业级支持,速度极快 |
|
||||
| 腾讯云 | https://mirrors.cloud.tencent.com/pypi/simple/ | 高速、可靠的云支持 |
|
||||
| 中国科学技术大学 | https://pypi.mirrors.ustc.edu.cn/simple/ | 稳定高效,适合科研场景 |
|
||||
| 华为云 | https://repo.huaweicloud.com/repository/pypi/simple/ | 稳定镜像,适用多种网络环境 |
|
||||
|
||||
|
||||
### docker
|
||||
|
||||
| DaoCloud | https://docker.m.daocloud.io | 国内老牌服务商 |
|
||||
| Docker.imgdb.de | https://docker.imgdb.de | 德国镜像站(全球化同步) |
|
||||
| Docker-0.unsee.tech | https://docker-0.unsee.tech | 亚洲节点加速站 |
|
||||
| Docker.hlmirror.com | https://docker.hlmirror.com | 国内高校镜像(理论场景专用) |
|
||||
| Docker.1ms.run | https://docker.1ms.run | 分钟级同步镜像站 |
|
||||
|
||||
|
||||
### soft
|
||||
| 清华大学开源软件镜像站 | https://mirrors.tuna.tsinghua.edu.cn/ | 综合性开源软件镜像 |
|
||||
| 阿里云开源镜像站 | https://mirrors.aliyun.com/ | 综合性开源软件镜像 |
|
||||
| 腾讯云开源镜像站 | https://mirrors.cloud.tencent.com/ | 综合性开源软件镜像 |
|
||||
| 南京邮电大学 | https://mirrors.njupt.edu.cn/ | 综合性开源软件镜像 |
|
@ -1,3 +1,18 @@
|
||||
# website
|
||||
+ game
|
||||
+ live
|
||||
+ program
|
||||
+ study
|
||||
+ tool
|
||||
|
||||
## game
|
||||
indienova.com # 冰与火之舞
|
||||
zh.minecraft.wiki
|
||||
https://slowroads.io/
|
||||
https://www.geo-fs.com/
|
||||
yorg.io
|
||||
|
||||
## live
|
||||
中国裁判文书网(https://wenshu.court.gov.cn/)
|
||||
国家企业信用信息公示系统(https://gs.gsxt.gov.cn/index.html)
|
||||
国家社会保险服务平台(https://si.12333.gov.cn/)
|
||||
@ -15,3 +30,24 @@
|
||||
中国法律服务网(https://www.12348.gov.cn/#/homepage)
|
||||
中国庭审公开网(https://tingshen.court.gov.cn/)
|
||||
中国关键词(http://keywords.china.org.cn/index.htm)
|
||||
|
||||
## program
|
||||
https://linux.vbird.org/ # 鸟哥linux
|
||||
https://www.52hb.com/ # 吾爱
|
||||
oi-wiki.org/lang
|
||||
https://zh.cppreference.com/w/
|
||||
|
||||
## study
|
||||
国家智慧教育公共服务平台(https://gjzwfw.www.gov.cn/)
|
||||
终身教育平台(https://le.ouchn.cn/home)
|
||||
国家数字图书馆(https://www.nlc.cn/web/index.shtml)
|
||||
国家哲学社会科学文献(https://www.ncpssd.org/)
|
||||
国家高等教育智慧教育平台(https://www.chinaooc.com.cn/)
|
||||
职业教育专业教学资源库(https://zyk.icve.com.cn/)
|
||||
|
||||
## tool
|
||||
kimi.moonshot.cn # kimi
|
||||
www.tbtool.cn # 图吧
|
||||
https://www.intel.cn/content/www/cn/zh/ark.html # intel CPU参数查询
|
||||
https://cn.aliyun.com/ # 阿里云
|
||||
https://next.itellyou.cn/ # 镜像站
|
@ -113,6 +113,38 @@
|
||||
patch -p<n>-R < <file.patch> # 还原
|
||||
```
|
||||
|
||||
> rsync
|
||||
> > 文件同步工具,它通过比较源和目标文件的大小、时间戳等信息,只同步发生变化的部分,提高了效率
|
||||
> > rsync [选项] 源文件/目录 目标文件/目录
|
||||
+ -a(archive):归档模式,用于完整同步
|
||||
+ -v(verbose):详细模式,显示同步过程中的详细信息。
|
||||
+ -u(update):仅在目标文件不存在或源文件更新时才同步。
|
||||
+ -z(compress):在传输过程中压缩文件数据。
|
||||
+ --delete:删除目标目录中多余的文件,使目标目录与源目录保持一致
|
||||
+ -e(rsh):指定远程连接时使用的工具(如 ssh)。
|
||||
+ --exclude:指定排除的文件或目录模式。
|
||||
+ --include:指定包含的文件或目录模式。
|
||||
+ -P --progress:显示同步进度。
|
||||
+ --bwlimit : 限速,用于单个大文件,避免占用过多带宽
|
||||
+ --dry-run:模拟同步操作,不实际执行,用于测试同步命令的效果。
|
||||
> > example
|
||||
1. 本地同步
|
||||
rsync -avP /path/to/source/ /path/to/destination/
|
||||
2. 从本地同步到远程
|
||||
rsync -avzP /path/to/source/ user@remote_host:/path/to/destination/
|
||||
3. 同步时删除多余文件
|
||||
rsync -av --delete /path/to/source/ /path/to/destination/
|
||||
4. 排除某些文件或目录
|
||||
rsync -av --exclude 'temp/*' --exclude '*.log' /path/to/source/ /path/to/destination/
|
||||
--exclude 'temp/*':排除 temp 目录下的所有文件。
|
||||
--exclude '*.log':排除所有 .log 文件。
|
||||
5. 包含某些文件或目录
|
||||
rsync -av --include 'data/*' --exclude '*' /path/to/source/ /path/to/destination/
|
||||
--include 'data/*':仅包含 data 目录下的文件。
|
||||
--exclude '*':排除其他所有文件。
|
||||
6. 模拟同步操作
|
||||
rsync -av --dry-run /path/to/source/ /path/to/destination/
|
||||
|
||||
|
||||
# 文件查找
|
||||
> find
|
||||
@ -213,6 +245,23 @@
|
||||
-a 全部参数
|
||||
-H 是否正常
|
||||
|
||||
> parted
|
||||
> > 磁盘分区管理工具
|
||||
> > parted [OPTIONS] [DEVICES] [COMMAND]
|
||||
+ -i 列出所有设备的分区信息
|
||||
+ -s 非交互模式
|
||||
> > 交互模式常用命令
|
||||
+ print 显示当前设备的分区表
|
||||
+ mklabel [gpt/msdos] 创建分区表
|
||||
+ mkpart [part-type] [fs-type] [start] [end] 创建一个分区
|
||||
`例: mkpart primary ext4 1MiB 1000MiB`
|
||||
+ rm [number] 删除指定编号的分区
|
||||
+ resizepart [number] [size] 重调大小
|
||||
+ set [number] [mode] 设置分区标志
|
||||
+ quit
|
||||
> > 非交互
|
||||
`sudo parted -s /dev/sdb mklabel gpt mkpart primary ext4 0% 100%`
|
||||
`sudo parted -s /dev/sdb rm 2`
|
||||
|
||||
|
||||
# 用户
|
||||
@ -271,12 +320,32 @@
|
||||
> nice renice
|
||||
> > 调整谦让度
|
||||
|
||||
> bg
|
||||
> > 让后台中的进程继续运行
|
||||
|
||||
> fg
|
||||
> > 把后台进程拉回前台
|
||||
|
||||
> jobs
|
||||
> > 列出后台进程
|
||||
|
||||
|
||||
|
||||
# 网络
|
||||
> ip
|
||||
> >
|
||||
> > 查看网络的各种信息
|
||||
> > address 地址等连接信息
|
||||
> > neigh arp相关
|
||||
+ ip neigh [OPTIONS] [COMMAND]
|
||||
+ ip neigh add [IP] lladdr [MAC] dev [eth0] 添加表项
|
||||
+ ip neigh del [IP] dev [eth0] 删除表项
|
||||
+ ip neigh flush all 清空
|
||||
_________________________________
|
||||
REACHABLE:表示邻居设备可达。
|
||||
STALE:表示邻居设备的条目已过期,但之前是可达的。
|
||||
DELAY:表示正在等待确认邻居设备是否可达。
|
||||
PROBE:表示正在积极探测邻居设备是否可达
|
||||
_________________________________
|
||||
|
||||
> ss
|
||||
> > 查看端口开放情况
|
||||
@ -353,14 +422,6 @@
|
||||
# nohup 命令挂机(退出登陆后依然执行)
|
||||
nohup [command] &
|
||||
`screen` 主要用于用户开启多个独立的会话(称为"窗口")在这些会话之间可以自由切换而不会中断已经运行的程序
|
||||
### 主要功能:
|
||||
1. **多会话管理**:可以同时运行多个独立的 shell 会话。
|
||||
2. **会话分离与重连**:可以从一个会话中分离出来,稍后再重新连接到该会话。
|
||||
3. **窗口分割**:在一个 screen 会话中,可以水平或垂直分割窗口,以同时查看和操作多个任务。
|
||||
4. **滚动记录**:可以查看会话的滚动记录,即使之前的输出已经滚出屏幕。
|
||||
5. **复制和粘贴**:在 screen 会话中,可以使用快捷键复制文本并粘贴到其他位置。
|
||||
6. **会话锁定**:可以锁定当前会话,防止他人查看或操作。
|
||||
7. **自动保存会话**:在网络断开或其他异常情况下,screen 可以自动保存当前会话状态。
|
||||
### 基本使用方法:
|
||||
1. **启动一个新的 screen 会话**:
|
||||
screen
|
||||
@ -370,16 +431,6 @@
|
||||
screen -r [会话ID或名称]
|
||||
4. **分离当前会话**:
|
||||
在 screen 会话中按 `Ctrl-a` 然后按 `d`。
|
||||
5. **在会话中创建新窗口**:
|
||||
在 screen 会话中按 `Ctrl-a` 然后按 `c`。
|
||||
6. **在窗口之间切换**:
|
||||
在 screen 会话中按 `Ctrl-a` 然后按 `n`(下一个窗口)或 `Ctrl-a` 然后按 `p`(上一个窗口)
|
||||
7. **分割窗口**:
|
||||
- 水平分割:在 screen 会话中按 `Ctrl-a` 然后按 `"`(双引号键)。
|
||||
- 垂直分割:在 screen 会话中按 `Ctrl-a` 然后按 `S`。
|
||||
8. **调整分割窗口的大小**:
|
||||
- 增加/减少水平大小:在 screen 会话中按 `Ctrl-a` 然后按方向键。
|
||||
- 增加/减少垂直大小:在 screen 会话中按 `Ctrl-a` 然后按 `Shift` 加上方向键。
|
||||
9. **退出 screen 会话**:
|
||||
- 关闭当前窗口:在 screen 会话中按 `Ctrl-a` 然后按 `k`。
|
||||
- 退出所有窗口并结束会话:在 screen 会话中按 `Ctrl-a` 然后按 `\`。
|
@ -1,4 +1,5 @@
|
||||
# linux键盘高级操作技巧
|
||||
man readline
|
||||
> 光标移动
|
||||
+ C a # 到行首
|
||||
+ C e # 到行末
|
||||
@ -7,6 +8,7 @@
|
||||
+ C l # clean
|
||||
+ A f # 下一个词
|
||||
+ A b # 上一个词
|
||||
___按住Ctrl的同时按方向键可以快速移动___
|
||||
|
||||
> 文本修改
|
||||
+ C t # 与上一个字符互换
|
||||
@ -22,3 +24,4 @@
|
||||
+ C n # 下一个命令
|
||||
+ C j # 复制
|
||||
+ C o # 执行当前项,并移到下一项
|
||||
+ C r # 搜索历史命令 Esc 选取
|
22
os/linux/knowledge/net.md
Normal file
22
os/linux/knowledge/net.md
Normal file
@ -0,0 +1,22 @@
|
||||
## 配置dhcp
|
||||
|
||||
vim /etc/network/interfaces
|
||||
auto eth0
|
||||
iface eth0 inet dhcp
|
||||
|
||||
|
||||
## 手动配置
|
||||
iface eth0 inet static
|
||||
address 192.168.0.108
|
||||
netmask 255.255.255.0
|
||||
gateway 192.168.0.101
|
||||
network 192.168.0.108
|
||||
|
||||
service network restart //cpwl
|
||||
|
||||
2.配置dns
|
||||
vim /etc/resolv.conf
|
||||
nameserver 114.114.114.114
|
||||
nameserver 8.8.8.8
|
||||
search localdomain
|
||||
|
10
program/c_cpp/linux/ioctl.md
Normal file
10
program/c_cpp/linux/ioctl.md
Normal file
@ -0,0 +1,10 @@
|
||||
# 有关ioctl的使用
|
||||
|
||||
`#include <sys/ioctl.h>`
|
||||
|
||||
## 查询当前终端的长宽大小
|
||||
```cpp
|
||||
struct winsize w;
|
||||
ioctl(STDOUT_FILENO, TIOCGWINSZ, &w);
|
||||
printf("%d\n%d\n", w.ws_col, w.ws_row);
|
||||
```
|
110
program/c_cpp/linux/net.md
Normal file
110
program/c_cpp/linux/net.md
Normal file
@ -0,0 +1,110 @@
|
||||
```cpp
|
||||
#include <iostream>
|
||||
#include <cstring>
|
||||
#include <unistd.h>
|
||||
#include <netdb.h>
|
||||
#include <cstdlib>
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include <arpa/inet.h>
|
||||
```
|
||||
|
||||
# tips
|
||||
+ 所有网络函数失败基本是返回 -1,errno被设置
|
||||
|
||||
# socket
|
||||
|
||||
|
||||
原型: int socket(int domain, int type, int protocol)
|
||||
|
||||
+ domain 协议族
|
||||
\ PF_INET # IPv4 互联网协议族
|
||||
\ PF_INET6 # IPv6 互联网协议族
|
||||
\ PF_LOCAL # 本地通讯地址族
|
||||
|
||||
+ type 数据传输类型
|
||||
\ SOCK_STREAM # 面向连接; 数据不丢失; 数据顺序不错乱; 双向通道;
|
||||
\ SOCK_DGRAM # 无连接; 数据可能丢; 数据可能错乱; 效率高;
|
||||
|
||||
+ protocol 最终使用协议
|
||||
\ IPPROTO_TCP
|
||||
\ IPPROTO_UDP
|
||||
\ 0 # 编译器自动识别
|
||||
|
||||
# 主机字节序和网络字节序
|
||||
|
||||
+ 大端序和小端序 (如果数据大于1B,CPU在内存中存放数据的方式)
|
||||
\ 大端序 低位字节在高位,高位字节在低位
|
||||
\ 小端序 低位字节在低位,高位字节在高位 (INTEL)
|
||||
|
||||
## 字节序不同的系统字节传输数据,可能会出现问题,所以网络字节序约定使用大端序
|
||||
+ c提供了4个库用于主机字节序和网络字节序之间的转换
|
||||
\ uint16_t htons(uint16_t hostshort); // 2字节的整数
|
||||
\ uint32_t htonl(uint32_t hostshort); // 4字节的整数
|
||||
\ uint16_t ntons(uint16_t netshort); // 2字节的整数
|
||||
\ uint32_t ntonl(uint32_t netshort); // 4字节的整数
|
||||
// h host主机
|
||||
// to 转换
|
||||
// n network网络
|
||||
// s short(2byte)
|
||||
// l long(4byte)
|
||||
|
||||
# IP地址和通讯端口
|
||||
+ IPv4(4byte) 端口(2byte)
|
||||
|
||||
# 大小端序的处理
|
||||
+ 在网络编程中数据收发有自动转换,只有sockaddr_in结构成员变量填充数据时,才需要考虑字节序
|
||||
|
||||
# 结构体
|
||||
|
||||
## sockaddr
|
||||
```cpp
|
||||
struct sockaddr { // connect() bind() 都需要
|
||||
unsigned short sa_family; // 协议族
|
||||
unsigned char sa_data[14]; // 14byte的端口和地址
|
||||
}
|
||||
```
|
||||
|
||||
## sockaddr_in
|
||||
```cpp
|
||||
struct sockaddr { // 为了方便操作,大小与sockaddr相同,可以强制转换
|
||||
unsigned short sin_family; // 协议族
|
||||
unsigned short sin_port; // 2byte端口号
|
||||
//struct in_addr sin_addr; // 4byte地址
|
||||
unsigned int sin_addr; // 4byte地址
|
||||
unsigned char sin_zero[8]; // 保留,长度对齐
|
||||
}
|
||||
```
|
||||
|
||||
# gethostbyname函数
|
||||
|
||||
+ 用 域名/主机名/字符串IP 转换成大端序
|
||||
```cpp
|
||||
struct hostent *gethostbyname(const char *name);
|
||||
struct hostent {
|
||||
char *h_name; // 主机名
|
||||
char **h_aliases; // 主机所有别名的字符串数组
|
||||
short h_addrtype; // 主机IP类型,IPv4或IPv6
|
||||
short h_length; // 主机IP长度
|
||||
char **h_addr_list; // 主机IP地址,以网络字节序存储
|
||||
}
|
||||
#define h_addr h_addr_list[0]
|
||||
|
||||
// 转换后,用 memcpy(&servaddr.sin_addr, h->h_addr, h->h_length);
|
||||
```
|
||||
|
||||
# 字符串IP和大端序IP的转换
|
||||
## atoi() 把字符串IP转换成大端序
|
||||
```cpp
|
||||
typedef unsigned int in_addr_t; //4byte大端序IP
|
||||
|
||||
// 字符串转大端序IP,转换后IP赋给sockaddr_in.in_addr.s_addr
|
||||
in_addr_t inet_addr(const char *cp);
|
||||
|
||||
// 字符串转大端序IP,转换后IP赋给sockaddr_in.in_addr
|
||||
int inet_aton(const char *cp, struct in_addr *inp);
|
||||
|
||||
//大转字符串,用于服务端解析IP
|
||||
char *inet_ntoa(struct in_addr in);
|
||||
```
|
||||
|
@ -32,6 +32,7 @@
|
||||
|
||||
## 查找
|
||||
```cpp
|
||||
size_t length(); // 返回string字符串的长度
|
||||
|
||||
int find(const string& str, int pos = 0) const; // 查找str在当前字符串第一次出现的位置,pos为开始查找的位置
|
||||
int find(const char* str, int pos = 0) const; // 查找str在当前字符串第一次出现的位置
|
@ -23,6 +23,8 @@
|
||||
|
||||
memmove(buf1 + 1, buf1, 4); //移动5个字节到前一个位置
|
||||
```
|
||||
___注:未进行长度指定的函数有溢出风险 例如:strcpy___
|
||||
|
||||
## 两种转换
|
||||
```cpp
|
||||
string str1;
|
16
program/c_cpp/universal/fast.md
Normal file
16
program/c_cpp/universal/fast.md
Normal file
@ -0,0 +1,16 @@
|
||||
# C++代码性能优化的方法
|
||||
+ 使用const关键字
|
||||
+ 避免频繁进行内存分配和释放
|
||||
+ 尽量减少值传递,多用引用来传递参数
|
||||
+ 局部变量VS静态变量(多次调用局部更快,因为局部变量可以读入寄存器,静态不行)
|
||||
+ ++i和i++的效率问题(使用迭代器可能比使用指针更优:迭代器++i可以减少一次构造和析构)
|
||||
+ 避免使用多重继承
|
||||
+ 低级代码使用位运算替代算术运算
|
||||
+ 使用编译器自带的优化选项
|
||||
+ 将小粒度函数声明为内联函数(inline)
|
||||
+ 循环内定义,还是循环外定义对象:由构造函数和复制操作的效率比较决定
|
||||
+ 小函数放在同一循环内效率高,大函数分开放效率更高(由cpu寄存器决定)
|
||||
+ 尽量少使用`dynamic_cast`
|
||||
+ 减少除法运算的使用,除数尽量使用常量,让编译器优化
|
||||
+ 多用直接初始化
|
||||
+ 循环展开加速
|
164
program/c_cpp/universal/io.md
Normal file
164
program/c_cpp/universal/io.md
Normal file
@ -0,0 +1,164 @@
|
||||
# c with cpp io
|
||||
|
||||
|
||||
# 目录
|
||||
- [c stdio](# c stdio)
|
||||
- [c fio](# c fio)
|
||||
- [cpp stdio](# cpp stdio)
|
||||
- [cpp fio](# cpp fio)
|
||||
|
||||
|
||||
## c stdio
|
||||
|
||||
> 头文件
|
||||
`#include <stdio.h>`
|
||||
|
||||
> scanf 格式化输入函数
|
||||
printf 格式化输出函数
|
||||
__控制符__
|
||||
+ %d %nd %ld %x %o 整数
|
||||
+ %f %n.mf %lf 浮点数
|
||||
+ %c
|
||||
+ %s
|
||||
+ %p ptr
|
||||
|
||||
> 文件流
|
||||
+ stdin
|
||||
+ stdout
|
||||
+ stderr
|
||||
|
||||
`int getchar(void);`
|
||||
`int putchar(int c);`
|
||||
|
||||
`int getc(FILE *stream);` getchar() 文件版
|
||||
`int putc(int c, FILE *stream);`
|
||||
|
||||
`char *fgets(char *s, int size, FILE *stream);`
|
||||
+ 换行符后(包含换行符)
|
||||
+ 文件尾
|
||||
+ size-1
|
||||
`fputs(const char *s, FILE *stream);` **不添加换行符**
|
||||
|
||||
`size_t fread(void *ptr, size_t size, size_t nmemb, FILE *stream);`
|
||||
+ size 读写的块大小
|
||||
+ nmemb 读写的块数量
|
||||
`size_t fwrite(const void *ptr, size_t size, size_t nmemb, FILE *stream);`
|
||||
|
||||
|
||||
|
||||
## c fio
|
||||
|
||||
`FILE *fp` 文件指针
|
||||
|
||||
`FILE *fopen(const char *pathname, const char *mode);` 错误返回NULL
|
||||
`int fclose(FILE *stream);` 关闭文件 返回0为正常关闭
|
||||
|
||||
**mode**
|
||||
+ "r" 读
|
||||
+ "w" 写,截0,新建
|
||||
+ "a" 写,尾+,新建
|
||||
+ "r+" 读写
|
||||
+ "w+" 读写,截0,新建
|
||||
+ "a+" 读写,仅尾+,新建
|
||||
+ "b" 搭配表二进制,仅win
|
||||
|
||||
`long ftell(FILE *stream);` 获取当前文件指针位置
|
||||
`int fseek(FILE *stream, long offset, int whence);` 移动文件指针
|
||||
+ offset 移动字节数
|
||||
+ whence 参考位置
|
||||
+ `SEEK_SET` 文件头
|
||||
+ `SEEK_CUR` 当前位置
|
||||
+ `SEEK_END` 文件尾
|
||||
|
||||
`int fflush(FILE *stream);` 刷新缓冲区
|
||||
`int setvbuf(FILE *stream, char *buf, int mode, size_t size);` 设置缓冲区,return 0
|
||||
+ buf 设置的缓冲区
|
||||
+ mode
|
||||
- `_IOFBF` 完全缓冲
|
||||
- `_IOLBF` 行缓冲
|
||||
- `_IONBF` 无缓冲
|
||||
+ size 指定缓冲区的大小,无缓冲时无效
|
||||
|
||||
`int ferror(FILE *stream);` 流异常时return非0
|
||||
|
||||
|
||||
## cpp stdio
|
||||
|
||||
> 头文件
|
||||
#include <iostream>
|
||||
|
||||
`ios::sync_with_stdio(false);cin.tie(0),cout.tie(0);` 关闭缓冲加速
|
||||
|
||||
>
|
||||
```cpp
|
||||
cin.get(c); //返回一个流引用
|
||||
c = cin.get(); //返回char,略快
|
||||
cin.get(str, 100, '\n'); //读入字符串
|
||||
cin.width(10); //设置场宽
|
||||
```
|
||||
|
||||
>
|
||||
```cpp
|
||||
std::flush // 立即刷新缓冲区
|
||||
std::endl // 换行加刷新
|
||||
```
|
||||
________________________________________________
|
||||
|
||||
## file IO
|
||||
|
||||
> 头文件
|
||||
#include <fstream>
|
||||
|
||||
```cpp
|
||||
//文件流的创建 打开 关闭
|
||||
fstream fin;
|
||||
fstream fout;
|
||||
|
||||
fin.open("in");
|
||||
fout.open("out");
|
||||
|
||||
fin.close();
|
||||
fout.close();
|
||||
/*
|
||||
open函数的原型如下:
|
||||
void open(char const *,int filemode,int =filebuf::openprot);
|
||||
它有3个参数,第1个是要打开的文件名,第2个是文件的打开方式,第3个是文件的保护方式,一般都使用默认值。
|
||||
第2个参数可以取如下所示的值:
|
||||
打开方式 解释
|
||||
ios::in 打开文件进行读操作,这种方式可避免删除现存文件的内容
|
||||
ios::out 打开文件进行写操作,这是默认模式
|
||||
ios::ate 打开一个已有的输入或输出文件并查找到文件尾开始
|
||||
ios::app 在文件尾追加方式写文件
|
||||
ios::binary 指定文件以二进制方式打开,默认为文本方式
|
||||
ios::trunc 如文件存在,将其长度截断为零并清除原有内容,如果文件存在先删除,再创建
|
||||
除ios_base::app方式之外,文件刚刚打开时当前读写位置的文件指针都定位于文件的开始位置,而ios_base::app使文件当前的写指针定位于文件尾
|
||||
|
||||
函数 功能
|
||||
bad() 如果进行非法操作,返回true,否则返回false
|
||||
clear() 设置内部错误状态,如果用缺省参量调用则清除所有错误位
|
||||
eof() 如果提取操作已经到达文件尾,则返回true,否则返回false
|
||||
good() 如果没有错误条件和没有设置文件结束标志,返回true,否则返回false
|
||||
fail() 与good相反,操作失败返回false,否则返回true
|
||||
is_open() 判定流对象是否成功地与文件关联,若是,返回true,否则返回false
|
||||
*/
|
||||
|
||||
// 二进制文件读写
|
||||
fin.write((char*)&data, sizeof data);
|
||||
fin.read((char*)&data, sizeof data);
|
||||
|
||||
/*
|
||||
随机存取
|
||||
seekg(pos,ios::);
|
||||
seekg(pos);
|
||||
seekp(pos,ios::);
|
||||
seekp(pos);
|
||||
|
||||
tellg();
|
||||
tellp();
|
||||
|
||||
文件位置
|
||||
ios::beg
|
||||
ios::cur
|
||||
ios::end
|
||||
*/
|
||||
```
|
55
program/python/basics/demo.py
Normal file
55
program/python/basics/demo.py
Normal file
@ -0,0 +1,55 @@
|
||||
a1 = int(input("input:")) # input
|
||||
print('%8d'%a1, '\n') # print
|
||||
# print(objects, sep=' ', wnd='\n')
|
||||
|
||||
|
||||
# 数据类型
|
||||
x1 = 123
|
||||
x2 = 123.123
|
||||
x3 = True
|
||||
x4 = "True"
|
||||
|
||||
print(x1, " ", type(x1))
|
||||
print(x2, " ", type(x2))
|
||||
print(x3, " ", type(x3))
|
||||
print(x4, " ", type(x4))
|
||||
print()
|
||||
|
||||
|
||||
# 运算符
|
||||
"""
|
||||
1. **
|
||||
2. * / % //
|
||||
3. + -
|
||||
4. <= < > >=
|
||||
5. <> == !=
|
||||
6. = %= /= //= -= += *= **=
|
||||
7. not or and
|
||||
"""
|
||||
|
||||
# 条件判断
|
||||
if (x1==a1) and (x3==True):
|
||||
print("OK!!!")
|
||||
elif x3==False:
|
||||
print("x3==False")
|
||||
else:
|
||||
print("x1:", x1)
|
||||
print("a1:", a1)
|
||||
print()
|
||||
|
||||
|
||||
# 循环控制
|
||||
for i in range(10): # 逐一访问序列中的元素
|
||||
while i>=9 and i<13: # 通过条件控制
|
||||
print(i)
|
||||
i+=1
|
||||
continue
|
||||
break
|
||||
|
||||
# range() 函数 创建一个整数列表
|
||||
"""
|
||||
# 基本格式
|
||||
range(start, stop,[step])
|
||||
# 开始 结束 步长
|
||||
range(5, 1, -1) # 可做到倒序输出
|
||||
"""
|
15
program/python/basics/dict.py
Normal file
15
program/python/basics/dict.py
Normal file
@ -0,0 +1,15 @@
|
||||
# 字典 dict
|
||||
dict1 = {'你好':'Hello'}
|
||||
dict2 = zip(li1,li2) # 通过两个列表创建字典
|
||||
del dict1['你好'] # 删除元素
|
||||
dict1['再见'] = 'bey' # 存在更新,不存在添加
|
||||
dict1.setdefault('好','OK') # 存在不修改,不存在添加
|
||||
|
||||
s = dict1.get('好','NO') # 不存在追加,存在返回原值不修改
|
||||
|
||||
for i,t in dict1.items(): # 遍历所有键值对
|
||||
print(i,t)
|
||||
for i in dict1.keys(): # 遍历所有键
|
||||
print(i)
|
||||
for i in dict1.values(): # 遍历所有值
|
||||
print(i)
|
7
program/python/basics/func.py
Normal file
7
program/python/basics/func.py
Normal file
@ -0,0 +1,7 @@
|
||||
# 函数
|
||||
def jc(n):
|
||||
ans = 1;
|
||||
for i in range(n):
|
||||
ans *= i
|
||||
return ans
|
||||
|
22
program/python/basics/list.py
Normal file
22
program/python/basics/list.py
Normal file
@ -0,0 +1,22 @@
|
||||
# 列表
|
||||
li1 = [] # 创建空列表
|
||||
li2 = list()
|
||||
li3 = list(s) # 转换字符串成列表
|
||||
li3.index('H') # 返回对应值的下标 反查
|
||||
li4 = s.split(' ') # 通过空格分割字符串成列表
|
||||
# li1[start:end:step]
|
||||
|
||||
for i,t in enumerate(li3): # 同时输出索引和值(列表本身也可以直接作为循环的序列)
|
||||
print(i,t)
|
||||
|
||||
# 列表的更新与排序
|
||||
li1.append([26,71]) # [26,71]作为一个元素追加到末尾
|
||||
li1.extend([26,71]) # 将[26,71]每一项合并到末尾
|
||||
li1.insert(1,520) # 将520插入位置1
|
||||
li1[0] = 1314 # so easy
|
||||
li1.remove(3) # 删除指定位置元素
|
||||
li1.pop() # 默认删除-1位置的元素
|
||||
li1.sort() # 对列表本身排序
|
||||
li1.sort(reverse=True) # 对列表本身排序(倒序)
|
||||
li2 = sorted.(li1) # 返回一个排序完的列表
|
||||
|
10
program/python/basics/set.py
Normal file
10
program/python/basics/set.py
Normal file
@ -0,0 +1,10 @@
|
||||
# 集合 set
|
||||
set1 = {4,3,2,1}
|
||||
set2 = set(li1)
|
||||
set3 = set1 & set2 # 交集
|
||||
set3 = set1 | set2 # 并集
|
||||
set3 = set1 - set2 # 差集
|
||||
set3.add(123) # 添加
|
||||
set3.remove(123) # 删除
|
||||
sum(set3) # 求总个数
|
||||
|
23
program/python/basics/string.py
Normal file
23
program/python/basics/string.py
Normal file
@ -0,0 +1,23 @@
|
||||
# 字符串
|
||||
s = str("Hello world")
|
||||
|
||||
print(s[3])
|
||||
print(s[-3])
|
||||
print(s[0:3]) # 字符串切片
|
||||
print(s[3:])
|
||||
print(s[:5])
|
||||
print(s[:-5])
|
||||
print(s[::-1]) # 倒序
|
||||
len(s) # 计算长度
|
||||
|
||||
# 字符串查询
|
||||
s.find('w')
|
||||
s.count('l')
|
||||
|
||||
s.replace('H','h') # H变成h
|
||||
s.casefold() # 大写转小写
|
||||
s.upper() # 小写转大写
|
||||
s.swapcase() # 转换大小写
|
||||
eval('12+3') # 计算值 返回15
|
||||
|
||||
|
3
program/python/basics/tuple.py
Normal file
3
program/python/basics/tuple.py
Normal file
@ -0,0 +1,3 @@
|
||||
# 元组tuple 元素不可修改的列表
|
||||
t1 = ()
|
||||
t1 = tuple(li1)
|
35
program/tool/gdb.txt
Normal file
35
program/tool/gdb.txt
Normal file
@ -0,0 +1,35 @@
|
||||
gdb c/c++ 代码调试工具
|
||||
使用 g++ -g 生成调试文件,不可以加 -O 选项
|
||||
|
||||
set [argc] # 传入参数
|
||||
l n # 列出源码
|
||||
r # 开始运行到第一个断点
|
||||
b n # 在第n行打断点
|
||||
break main if var_name > 10 # 满足条件时打断点
|
||||
d n # 删除断点
|
||||
c # 继续运行到下一个断点
|
||||
s # 单步执行
|
||||
si # 单步汇编
|
||||
n # 单步执行,不进入函数
|
||||
q # 退出
|
||||
|
||||
set var [] # 修改变量的值
|
||||
set $rsp = 0x7ccccccc # 修改寄存器的值
|
||||
|
||||
p # 查看特定变量或表达式的值
|
||||
bt # 查看函数调用栈
|
||||
bt full # 详细信息
|
||||
disassemble # 查看当前函数的汇编,可在后面加函数名看指定汇编
|
||||
x/10gx $rsp # 查看内存中由$rsp开始的10个八字节数据 g:八字节 x:16进制
|
||||
|
||||
info locals # 查看局部变量
|
||||
info registers # 查看寄存器状态
|
||||
info program # 查看程序运行信息
|
||||
info break # 查看断点信息
|
||||
info threads # 查看所有线程
|
||||
|
||||
使用gdb调试core文件
|
||||
使用ulimit -c unlimited 使挂掉的程序产生core文件
|
||||
gdb ./a.out core
|
||||
|
||||
gdb demo -p [pid] # 调试运行中的程序
|
39
program/tool/perf.md
Normal file
39
program/tool/perf.md
Normal file
@ -0,0 +1,39 @@
|
||||
# perf 功能强大的linux性能分析工具
|
||||
|
||||
`perf [command] [options] [arguments]`
|
||||
子命令 额外选项 要分析的程序或命令
|
||||
|
||||
## 性能概览
|
||||
`perf stat <command>`
|
||||
> 性能计数器
|
||||
```
|
||||
0.60 msec task-clock # 0.589 CPUs utilized cpu利用率
|
||||
0 context-switches # 0.000 /sec 上下文切换次数
|
||||
0 cpu-migrations # 0.000 /sec cpu切换
|
||||
68 page-faults # 113.661 K/sec 页错误次数
|
||||
1,772,372 cycles # 2.963 GHz 时钟周期
|
||||
1,247,336 instructions # 0.70 insn per cycle 指令数量
|
||||
229,972 branches # 384.396 M/sec 分支数量
|
||||
8,262 branch-misses # 3.59% of all branches 未命中分支
|
||||
|
||||
0.001016124 seconds time elapsed 总用时
|
||||
|
||||
0.000000000 seconds user
|
||||
0.001106000 seconds sys
|
||||
```
|
||||
|
||||
## 记录性能数据
|
||||
`perf record -g -o output.data <command>`
|
||||
+ -o 指定输出文件
|
||||
+ -g 启用调用图
|
||||
|
||||
`sudo perf record -a -g -o system.data`
|
||||
+ -a 采集系统级数据
|
||||
|
||||
|
||||
## 分析性能数据
|
||||
`perf report -i output.data`
|
||||
+ -i 指定输入文件
|
||||
|
||||
## 实时性能监控
|
||||
`sudo perf top`
|
@ -1,143 +0,0 @@
|
||||
a1 = int(input("input:")) # input
|
||||
print('%8d'%a1, '\n') # print
|
||||
# print(objects, sep=' ', wnd='\n')
|
||||
|
||||
|
||||
# 数据类型
|
||||
x1 = 123
|
||||
x2 = 123.123
|
||||
x3 = True
|
||||
x4 = "True"
|
||||
|
||||
print(x1, " ", type(x1))
|
||||
print(x2, " ", type(x2))
|
||||
print(x3, " ", type(x3))
|
||||
print(x4, " ", type(x4))
|
||||
print()
|
||||
|
||||
|
||||
# 运算符
|
||||
"""
|
||||
1. **
|
||||
2. * / % //
|
||||
3. + -
|
||||
4. <= < > >=
|
||||
5. <> == !=
|
||||
6. = %= /= //= -= += *= **=
|
||||
7. not or and
|
||||
"""
|
||||
|
||||
# 条件判断
|
||||
if (x1==a1) and (x3==True):
|
||||
print("OK!!!")
|
||||
elif x3==False:
|
||||
print("x3==False")
|
||||
else:
|
||||
print("x1:", x1)
|
||||
print("a1:", a1)
|
||||
print()
|
||||
|
||||
|
||||
# 循环控制
|
||||
for i in range(10): # 逐一访问序列中的元素
|
||||
while i>=9 and i<13: # 通过条件控制
|
||||
print(i)
|
||||
i+=1
|
||||
continue
|
||||
break
|
||||
|
||||
# range() 函数 创建一个整数列表
|
||||
"""
|
||||
# 基本格式
|
||||
range(start, stop,[step])
|
||||
# 开始 结束 步长
|
||||
range(5, 1, -1) # 可做到倒序输出
|
||||
"""
|
||||
|
||||
|
||||
# 字符串
|
||||
s = str("Hello world")
|
||||
|
||||
print(s[3])
|
||||
print(s[-3])
|
||||
print(s[0:3]) # 字符串切片
|
||||
print(s[3:])
|
||||
print(s[:5])
|
||||
print(s[:-5])
|
||||
print(s[::-1]) # 倒序
|
||||
len(s) # 计算长度
|
||||
|
||||
# 字符串查询
|
||||
s.find('w')
|
||||
s.count('l')
|
||||
|
||||
s.replace('H','h') # H变成h
|
||||
s.casefold() # 大写转小写
|
||||
s.upper() # 小写转大写
|
||||
s.swapcase() # 转换大小写
|
||||
eval('12+3') # 计算值 返回15
|
||||
|
||||
|
||||
|
||||
# 列表
|
||||
li1 = [] # 创建空列表
|
||||
li2 = list()
|
||||
li3 = list(s) # 转换字符串成列表
|
||||
li3.index('H') # 返回对应值的下标 反查
|
||||
li4 = s.split(' ') # 通过空格分割字符串成列表
|
||||
# li1[start:end:step]
|
||||
|
||||
for i,t in enumerate(li3): # 同时输出索引和值(列表本身也可以直接作为循环的序列)
|
||||
print(i,t)
|
||||
|
||||
# 列表的更新与排序
|
||||
li1.append([26,71]) # [26,71]作为一个元素追加到末尾
|
||||
li1.extend([26,71]) # 将[26,71]每一项合并到末尾
|
||||
li1.insert(1,520) # 将520插入位置1
|
||||
li1[0] = 1314 # so easy
|
||||
li1.remove(3) # 删除指定位置元素
|
||||
li1.pop() # 默认删除-1位置的元素
|
||||
li1.sort() # 对列表本身排序
|
||||
li1.sort(reverse=True) # 对列表本身排序(倒序)
|
||||
li2 = sorted.(li1) # 返回一个排序完的列表
|
||||
|
||||
|
||||
# 元组tuple 元素不可修改的列表
|
||||
t1 = ()
|
||||
t1 = tuple(li1)
|
||||
|
||||
|
||||
# 集合 set
|
||||
set1 = {4,3,2,1}
|
||||
set2 = set(li1)
|
||||
set3 = set1 & set2 # 交集
|
||||
set3 = set1 | set2 # 并集
|
||||
set3 = set1 - set2 # 差集
|
||||
set3.add(123) # 添加
|
||||
set3.remove(123) # 删除
|
||||
sum(set3) # 求总个数
|
||||
|
||||
|
||||
# 字典 dict
|
||||
dict1 = {'你好':'Hello'}
|
||||
dict2 = zip(li1,li2) # 通过两个列表创建字典
|
||||
del dict1['你好'] # 删除元素
|
||||
dict1['再见'] = 'bey' # 存在更新,不存在添加
|
||||
dict1.setdefault('好','OK') # 存在不修改,不存在添加
|
||||
|
||||
s = dict1.get('好','NO') # 不存在追加,存在返回原值不修改
|
||||
|
||||
for i,t in dict1.items(): # 遍历所有键值对
|
||||
print(i,t)
|
||||
for i in dict1.keys(): # 遍历所有键
|
||||
print(i)
|
||||
for i in dict1.values(): # 遍历所有值
|
||||
print(i)
|
||||
|
||||
|
||||
# 函数
|
||||
def jc(n):
|
||||
ans = 1;
|
||||
for i in range(n):
|
||||
ans *= i
|
||||
return ans
|
@ -1,3 +1,4 @@
|
||||
# git
|
||||
git config --global credential.helper store
|
||||
/\ /\ user.name " "
|
||||
|| || user.email " "
|
||||
@ -50,7 +51,7 @@ git branch #显示本地分支
|
||||
-d/D #删除分支 大写强制
|
||||
-m/M #修改主分支 大写强制
|
||||
-u <remote>/<branch> #设置追踪关系
|
||||
-vv #查看每个分支的最后提交信息和跟踪关系
|
||||
-vv #查看每个分支的最后提交信息和跟踪关系,常用于检查是否全部分支已同步
|
||||
--merged #列出所有已合并到当前分支的分支
|
||||
--no-merged #未合并
|
||||
|
@ -1,20 +0,0 @@
|
||||
gdb c/c++ 代码调试工具
|
||||
使用 g++ -g 生成调试文件,不可以加 -O 选项
|
||||
|
||||
set [argc] # 传入参数
|
||||
l n # 列出源码
|
||||
r # 开始运行到第一个断点
|
||||
b n # 在第n行打断点
|
||||
info break # 查看断点
|
||||
c # 继续运行到下一个断点
|
||||
s # 单步执行
|
||||
n # 单步执行,不进入函数
|
||||
p # 输出变量或表达式的值
|
||||
set var [] # 修改变量的值
|
||||
q # 退出
|
||||
bt # 查看函数调用栈
|
||||
|
||||
使用gdb调试core文件
|
||||
使用ulimit -c unlimited 使挂掉的程序产生core文件
|
||||
|
||||
gdb demo -p [pid] # 调试运行中的程序
|
@ -1,5 +0,0 @@
|
||||
#4 perf
|
||||
性能剖析工具
|
||||
可分析程序运行期间发生的系统硬件事件
|
||||
sudo perf record ./a.out
|
||||
sudo perf report -i perf.data
|
@ -24,15 +24,17 @@ nnoremap <space>v :vsp<space>
|
||||
nnoremap <space>d <c-w>w
|
||||
nnoremap <space>w :w<cr>
|
||||
nnoremap <space>q :q<cr>
|
||||
nnoremap <space>fq :q!<cr>
|
||||
nnoremap <space>tt :tabedit<space>
|
||||
nnoremap <space>to :tabonly<cr>
|
||||
nnoremap <space>tm :vert term<cr>
|
||||
inoremap jf <esc>
|
||||
inoremap jq <esc>:wq<cr>
|
||||
inoremap jw <c-x><c-n>
|
||||
inoremap jl <c-x><c-l>
|
||||
cnoremap jf <c-c>
|
||||
"inoremap jq <esc>:wq<cr>
|
||||
"inoremap jw <c-x><c-n>
|
||||
"nnoremap <space>to :tabonly<cr>
|
||||
|
||||
augroup numbertoggle 智能切换绝对行号和相对行号
|
||||
augroup numbertoggle "智能切换绝对行号和相对行号
|
||||
autocmd!
|
||||
autocmd BufEnter,FocusGained,InsertLeave,WinEnter * if &nu && mode() != "i" | set rnu | endif
|
||||
autocmd BufLeave,FocusLost,InsertEnter,WinLeave * if &nu | set nornu | endif
|
||||
|
@ -1,9 +1,52 @@
|
||||
# 小技巧
|
||||
使用 q[Key] 开始录制宏,再次点击q结束录制
|
||||
@[Key] 调用宏
|
||||
@@ 重复调用
|
||||
|
||||
# vim中打开终端
|
||||
`:term`或`:vert term`
|
||||
从终端转到普通模式:`<c-\>+<c-n>`
|
||||
|
||||
# 快捷键
|
||||
|
||||
## ]f
|
||||
> 移动
|
||||
## 0 gm
|
||||
行首行尾移动
|
||||
## ngg
|
||||
移动到第n行
|
||||
## fc tc
|
||||
搜索字符 ; , 可重复
|
||||
|
||||
> 插入
|
||||
## r R
|
||||
替换光标下的字符
|
||||
## n<< n>>
|
||||
多行左右移动
|
||||
|
||||
|
||||
> 删除
|
||||
## x
|
||||
删除光标下字符
|
||||
## J
|
||||
与下一行合并
|
||||
|
||||
> 复制
|
||||
## "x
|
||||
使用寄存器x进行下一次复制 粘贴 删除
|
||||
:reg 显示所有寄存器
|
||||
|
||||
|
||||
> 可视模式
|
||||
## o
|
||||
交换选择区域另一端和光标的位置
|
||||
## aw as ap ab aB
|
||||
选择一个单词 句子 段落 () {}
|
||||
## vi{
|
||||
选中一整个大括号内
|
||||
## va{
|
||||
选中一整个大括号全部
|
||||
|
||||
|
||||
## ]f
|
||||
在文件中若出现文件名,指针放在上面使用这个快捷键可直接打开
|
||||
|
||||
|
@ -1,5 +0,0 @@
|
||||
indienova.com # 冰与火之舞
|
||||
zh.minecraft.wiki
|
||||
https://slowroads.io/
|
||||
https://www.geo-fs.com/
|
||||
yorg.io
|
@ -1,4 +0,0 @@
|
||||
https://mirrors.tuna.tsinghua.edu.cn/ # 清华开源站
|
||||
https://linux.vbird.org/ # 鸟哥linux
|
||||
https://www.52hb.com/ # 吾爱
|
||||
|
@ -1,6 +0,0 @@
|
||||
国家智慧教育公共服务平台(https://gjzwfw.www.gov.cn/)
|
||||
终身教育平台(https://le.ouchn.cn/home)
|
||||
国家数字图书馆(https://www.nlc.cn/web/index.shtml)
|
||||
国家哲学社会科学文献(https://www.ncpssd.org/)
|
||||
国家高等教育智慧教育平台(https://www.chinaooc.com.cn/)
|
||||
职业教育专业教学资源库(https://zyk.icve.com.cn/)
|
@ -1,5 +0,0 @@
|
||||
kimi.moonshot.cn # kimi
|
||||
www.tbtool.cn # 图吧
|
||||
https://www.intel.cn/content/www/cn/zh/ark.html # intel CPU参数查询
|
||||
https://cn.aliyun.com/ # 阿里云
|
||||
https://next.itellyou.cn/ # 镜像站
|
Loading…
x
Reference in New Issue
Block a user