这里是一些零碎知识点的记录,内容比较随意。
打开 x64 Native Tools Command Prompt for VS 2017(不要使用 Windows 自带的 Cmd)
cd C:/boost_1_65_1/tools/build
bootstrap.bat
cp C:/boost_1_65_1/tools/build/bjam.exe C:/boost_1_65_1/
cd C:/boost_1_65_1
bjam add_ress-model=64
cmake -G "Visual Studio 15 Win64"
cmake --build . --config Release
不指定 Win64 的话,生成的 Visual Studio 工程是 Win32 的,也以不指定 --config Release
,默认编译的是 Debug 版。
Visual Studio 包管理器,不用手动引入库文件目录,自动加载,相当方便。
https://github.com/Microsoft/vcpkg
vcpkg install boost:x32-windows
vcpkg install boost:x64-windows
vcpkg --help
- Win + Tab :显示所有虚拟桌面
- Ctrl + Win + D :新键一个虚拟桌面
- Ctrl + Win + 左/右方向键 :切换上/下一个虚拟桌面
- Win + Ctrl + F4 :关闭当前的虚拟桌面
修改配置 /etc/systemd/logind.conf
#HandleLidSwitch=suspend
HandleLidSwitch=lock
然后执行下面命令使配置生效
systemctl restart systemd-logind
BOM(byte-order mark):字节顺序标记
Vim 有处理 BOM 的功能,先将编码设置为 UTF-8,:set fileencoding=utf-8
:set bomb
:set nobomb
:set bomb?
查找删除 BOM
grep -r -I -l $'^\xEF\xBB\xBF' /path
grep -r -I -l $'^\xEF\xBB\xBF' /path | xargs sed -i 's/^\xEF\xBB\xBF//;q'
Linux标准规范(Linux Standard Base)/ 最低有效位(Least Significant Bit)
最高有效位(Most Significant Bit)
iconv -f GB2312 -t UTF-8 source.cpp > destination.cpp
./foo_test 没有指定过滤条件,运行所有案例
./foo_test --gtest_filter=* 使用通配符*,表示运行所有案例
./foo_test --gtest_filter=FooTest.* 运行所有“测试案例名称(testcase_name)”为FooTest的案例
./foo_test --gtest_filter=*Null*:*Constructor* 运行所有“测试案例名称(testcase_name)”或“测试名称(test_name)”包含Null或Constructor的案例。
./foo_test --gtest_filter=-*DeathTest.* 运行所有非死亡测试案例。
./foo_test --gtest_filter=FooTest.*-FooTest.Bar 运行所有“测试案例名称(testcase_name)”为FooTest的案例,但是除了FooTest.Bar这个案例
wget http://repo.fdzh.org/chrome/google-chrome-mirrors.repo -P /etc/yum.repos.d/
yum install google-chrome-stable
可以把 CentOS 7 自带的 firefox 卸载
yum remove firefox
CentOS 7 自带的终端并不是很好用,Terminator 会相对好用一点。
yum install terminator
Ctrl
+PageUp
: 上一个标签Ctrl
+PageUp
: 下一个标签F11
: 全屏Ctrl
+Shift
+O
: 水平分割终端Ctrl
+Shift
+E
: 垂直分割终端Ctrl
+Shift
+W
: 关闭当前终端Ctrl
+Shift
+T
: 打开一个新的标签页Alt
+↑
: 切换至上面的终端Alt
+↓
: 切换至下面的终端Alt
+←
: 切换至左边的终端Alt
+↓
: 切换至右边的终端
Chrome 的插件,能让用户使用类似 Vim 的快捷键来操作 Chrome。
iconv 是内建 glibc 的组成部分,所以没有独立出 shared-library。
Little endian Big endian
git branch -a
先
git fetch origin
git checkout -t origin/newbranch
或者
git checkout -b newbranch origin/newbranch
void * memset(void * ptr, int value, size_t num);
void * memcpy(void * destination, void * source, size_t num);
在一个宏中的参数前面使用一个#,预处理器会把这个参数转换为一个字符数组。
#define ERROR_LOG(module) fprintf(stderr,"error: "#module"\n")
ERROR_LOG("add"); //转换为 fprintf(stderr,"error: "add"\n");
ERROR_LOG(devied =0); //转换为 fprintf(stderr,"error: devied=0\n");
“##” 是一种分隔连接方式,它的作用是先分隔,然后进行强制连接。
#define TYPE1(type,name) type name_##type##_type
#define TYPE2(type,name) type name##_##type##_type
TYPE1(int, c); //转换为: int name_int_type; (因为##号将后面分为 name_ 、type 、 _type三组,替换后强制连接)
TYPE2(int, d); //转换为: int d_int_type; (因为##号将后面分为 name、_、type 、_type四组,替换后强制连接)
采用这种方式是为了防范在使用宏过程中出现错误,主要有如下几点:
- 空的宏定义避免warning
#define foo() do{}while(0)
- 存在一个独立的block,可以用来进行变量定义,进行比较复杂的实现。
- 如果出现在判断语句过后的宏,这样可以保证作为一个整体来是实现
#define foo(x) \
action1(); \
action2();
在以下情况下
if(NULL == pPointer)
foo();
就会出现action1和action2不会同时被执行的情况,而这显然不是程序设计的目的。
4. 以上的第3种情况用单独的 {}
也可以实现,但是为什么一定要一个 do{}while(0)
呢,看以下代码
#define switch(x,y) {int tmp; tmp="x";x=y;y=tmp;}
if(x>y)
switch(x,y);
else
//error, parse error before else
otheraction();
在把宏引入代码中,会多出一个分号,从而会报错。这对这一点,可以将if和else语句用 {}
括起来,可以避免分号错误。
使用 do{…}while(0)
把它包裹起来,成为一个独立的语法单元,从而不会与上下文发生混淆。同时因为绝大多数的编译器都能够识别 do{…}while(0)
这种无用的循环并进行优化,所以使用这种方法也不会导致程序的性能降低。
Monaco 是一个来自 Mac 的字体,而 Consolas 是来自 Windows 的字体
rpm -qf target_file
yum whatprovides(provides) target_file
ulimit -c unlimited
g++ -g
gdb ./bin/test core
bt
cat /sys/class/power_supply/BAT1/capacity
rpm -ivh foo-1.0-l.i386.rpm
# 检查
rpm -ivh --test foo-1.0-l.i386.rpm
rpm -Uvh foo-2.0-l.i386.rpm
rpm -e foo
rpm -q foo
# 碰到一个人不出来的文件,想要知道它是属于那一个软件包
rpm -qf /etc/nginx/nginx.conf
# 想了解某个文件包将会在系统里安装那些文件
rpm -qpi koules-1.2-2.i386.rpm
# 不小心误删了几个文件,但不确定到底是那些文件,可以对整个系统进行校验,以了解哪些部分可能已经损坏
rpm -Va
# 一个 RPM 包的文件都安装到哪里去了
rpm -ql
# 查看依赖关系
rpm -qpR
# 查看 rpm 包信息
rpm -qpi foo-1.0.l.i386.rpm
- zC 对所在范围内所有嵌套的折叠点进行折叠
- zo 展开折叠
- zO 对所在范围内所有嵌套的折叠点展开
- [z 到当前打开的折叠的开始处。
- ]z 到当前打开的折叠的末尾处。
- zj 向下移动。到达下一个折叠的开始处。关闭的折叠也被计入。
- zk 向上移动到前一折叠的结束处。关闭的折叠也被计入。
Ctrl
+Alt
+↑
: 切换到上一个虚拟桌面Ctrl
+Alt
+↓
: 切换到下一个虚拟桌面Ctrl
+Alt
+Shift
+↑
: 将当前程序移动到上一个虚拟桌面Ctrl
+Alt
+Shift
+↓
: 将当前程序移动到下一个虚拟桌面
git submodule init
git submodule update
sysctl -n machdep.cpu.brand_string
system_profiler SPHardwareDataType
CPU 比较的网站:CPU-Monkey
Clone 一份裸仓库
git clone --bare git@github.com/chrisniael/oldrepo.git
以镜像的方式上传到新 Git 服务器上
cd oldrepo
git push --mirror git@shenyu.me/chrisniael/newrepo.git
cmake -DCMAKE_BUILD_TYPE=Release .
cmake -DCMAKE_BUILD_TYPE=Debug .
开放端口
firewall-cmd --zone=public --add-port=3000/tcp --permanent
firewall-cmd --reload
检查
firewall-cmd --list-all
firewall-cmd --state
git config --global credential.helper store
export LANG=en_US
xdg-user-dirs-gtk-update
netstat -anp | grep 80
gsettings set org.gnome.desktop.interface cursor-blink false
将 false\n 替换为 true\n
:%s/false\n/true\r/g
在网址里输入 about:config
,将字段 layout.css.devPixelsPerPx
改为 1.2
或更大。
#include <iostream>
#include <locale>
#include <string>
std::wcout.sync_with_stdio(false);
std::wcout.imbue(std::locale("zh_CN.UTF-8"));
std::wstring wstr(L"今天");
std::wcout << std::endl;
#include <iostream>
#include <fstream>
#include <string>
#include <locale>
#include <cstdlib>
std::wifstream wif(filename);
wif.imbue(std::locale("zh_CN.UTF-8"));
std::wcout.imbue(std::locale("zh_CN.UTF-8"));
std::wstring wstr;
while(std::getline(wif, wstr))
{
std::wcout << wstr << std::endl;
std::wcout << wstr.size() << std::endl;
}
修改文件 /etc/security/limits.conf
* soft nofile 65535
* hard nofile 65535
然后执行
ulimit -n 65535
生成密码文件
htpasswd -bc .passwd shenyu 123456
修改 nginx 配置
auth_basic "project-name-auth";
auth_basic_user_file path/.htpasswd;
热更 nginx 配置
nginx -s reload
git tag 1.0
git tag -am "your comment text." 1.0
git tag
git show 1.0
git push origin 1.0
git push origin --tags
for x in `gem list --no-versions`; do gem uninstall $x -a -x -I; done
yum remove ruby
source example.sh
# 更新 gem 自身
# 注意:在某些 Linux 发行版中为了系统稳定性此命令禁止执行
gem update --system
gem install gemname
gem install -l gemname.gem
gem install gemname --version=1.0
# 更新所有已安装的gem 包
gem update
# 更新指定的 gem 包
# 注意:gem update gemname 不会升级旧版本的包,此时你可以使用 gem install gemname --version=ver 代替
gem update gemname
# 删除指定的 gem 包,注意此命令将删除所有已安装的版本
gem uninstall gemname
# 删除某指定版本 gem 包
gem uninstall gemname --version=ver
# 查看本机已安装的所有 gem 包
gem list [--local]
gem sources --add https://gems.ruby-china.org/ --remove https://rubygems.org/
gem sources -l
std::ifstream f;
f.rdbuf()->pubsetbuf(0, 0);
f.open("example.txt")