Git笔记

windows上使含有中文的文件名正常显示

对于某些含有中文的文件名(比如文档),在 git status 时会出现 \347 这样的转义显示。将其修改为中文显示:

1
git config --global core.quotepath false

Boost学习笔记

notes

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
whereis python3  # /usr/bin/python3.5m
sudo apt install python3-dev # 此命令会安装python3相关头文件到/usr/include/python3*下

tar -xzvf boost_1_76_0.tar.gz
rm boost_1_76_0.tar.gz
cd boost_1_76_0/
sudo bootstrap.sh

# 这里需要配置 project_config
# 不进行此配置时的报错为:
# No python installation configured and autoconfiguration failed. See
# http://www.boost.org/libs/python/doc/building.html for configuration
# instructions or pass --without-python to suppress this message and
# silently skip all Boost.Python targets

vim project_config.jam
# 添加以下内容到 project-config-jam 结尾,注意配置文件中的空格不能省略
# Python configuration
# executable path : header path : library path
using python : 3.5 : /usr/bin/python3.5m : /usr/include/python3.5m : /usr/lib/python3.5 ;

sudo ./b2 # compile
sudo ./b2 install --with-python # install
# 可以在默认编译路径/usr/local/lib下找到相关的libboost*.so
# boost在/usr/local/include/boost下

mkdir demo_boost
cd demo_boost
vim test.cpp
1
2
3
4
5
6
7
8
9
10
11
// test.cpp
#include <boost/python.hpp>

char const* greet() {
return "hello, world";
}

BOOST_PYTHON_MODULE(test) {
using namespace boost::python;
def("greet", greet);
}
1
2
3
4
5
6
7
8
9
# 将/usr/local/lib添加到动态链接库查找路径中,否则链接时会出错 cannot find -lboost_python35

sudo vim /etc/ld.so.conf
# 添加以下内容到结尾
/usr/local/lib

sudo ldconfig
g++ -I/usr/include/python3.5m -fPIC test.cpp -lboost_python35 -shared -o test.so
vim test_py.py
1
2
3
4
5
# test_py.py
import test

print(dir(test))
print(test.greet())
1
python3 test_py.py

另一个例子

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
// demo.cpp
#include <boost/python.hpp>
#include <iostream>
#include <string>

class Bonjour
{
// Private attribute
std::string m_msg;
public:
// Constructor
Bonjour(std::string msg) :m_msg(msg) { }

// Destructor
~Bonjour() { std::cout << "destructed " << this << std::endl; }

// Methods
void greet() { std::cout << m_msg << std::endl; }

// Getter/Setter functions for the attribute
void set_msg(std::string msg) { this->m_msg = msg; }
std::string get_msg() const { return m_msg; }
};

BOOST_PYTHON_MODULE(demo)
{
using namespace boost::python;
class_<Bonjour>("Bonjour", init<std::string>())
.def("greet", &Bonjour::greet)
.add_property("msg", &Bonjour::get_msg, &Bonjour::set_msg);
}

references

tar解压缩命令:[linux tar.gz zip 解压缩 压缩命令

安装与编译linux下安装boost python详解

编译Linux 编译boost (for python3)

动态库问题cannot open shared object file: No such file or directory解决方法

VMware使用相关

压缩自增长的虚拟磁盘体积

运行前应保证虚拟磁盘所在的宿主机硬盘分区下有足够空间。

在虚拟机下,运行

1
2
sudo apt install open-vm-tools
sudo vmware-toolbox-cmd disk shrink /

将自增长的虚拟磁盘切换为预分配

在 VMware 安装目录下,运行

1
vmware-vdiskmanager -r "原vmdk名" -s 30GB -t 2 "新vmdk名"

可将自增长的虚拟磁盘切换为预分配30GB。

虚拟磁盘重命名

在 VMware 安装目录下,运行

1
vmware-vdiskmanager -n "原vmdk名" "新vmdk名"

Windows 上创建打开一个特定虚拟机的快捷方式

设置快捷方式目标

1
"...\VMware Workstation\vmrun.exe" -T ws start "...\UbuntuServer.vmx"

TCP/IP学习笔记:传输层

传输层

传输层也称为运输层(Transport Layer)。在此层的分组,TCP称为“报文段”,UDP称为“数据报“。

进程到进程的数据交付(多路复用与多路分解)和差错检查是两种最低限度的传输层服务,也是UDP所能提供的仅有的两种服务。

端口号

端口号为一个16比特的值,即范围为 0-65535。其中 0-1023 称为“周知端口号”。

UDP套接字由一个二元组全面标识:目的IP地址、目的端口号。

TCP套接字由一个四元组全面标识:源IP地址、源端口号、目的IP地址、目的端口号。

TCP与UDP的比较

相比TCP,UDP满足:

  1. 关于发送什么数据以及何时发送的应用层控制更精细
  2. 无需连接建立
  3. 无连接状态(无须保存与维护连接状态,节约资源)
  4. 分组的首部开销小。(TCP:20 Bytes,UDP:8 Bytes)

UDP

报文段格式

  • 源端口号 (2 bytes)
  • 目的端口号 (2 bytes)
  • 长度 (2 bytes)
  • 检验和 (2 bytes)
  • 应用数据

当一台主机接收一个UDP分组,它的目的端口与运行中的任一UDP套接字都不匹配,则该主机发送一个特殊的ICMP数据报。

可靠数据传输

解决流水线的差错恢复有2种基本方法:

  • 回退N步(Go-Back N,GBN),即“滑动窗口协议”(Sliding-Window Protocol)
  • 选择重传(Selective Repeat,SR)。选择重传协议通过让发送方仅重传那些它怀疑在接收方出错(即丢失/受损)的分组而避免了不必要的重传。这种个别的、按需的重传要求接收方逐个确认正确接收的分组。对于选择重传协议,其窗口长度必须小于等于序号空间的一半。

TCP

概念

  • 发起连接的称为客户,另一方称为服务器。
  • TCP可从缓存中取出并放入报文段中的数据数量受限于最大报文段长度MSS(Maximum Segment Size)。MSS通常根据最初确定的由本地发送主机发送的最大链路层帧长度(最大传输单元MTU,Maximum Transmission Unit)。该MSS要保证一个TCP报文段(当封装在一个IP数据报中)加上TCP/IP首部长度(通常为40字节 [TCP首部20字节,IP首部20字节])须能放入单个链路层帧中。以太网和PPP链路层协议都具有1500字节的MTU,因此MSS的典型值为1460字节。注意MSS是指在报文段里应用层数据的最大长度而非指包括首部的TCP报文段的最大长度。

Hexo与Icarus博客搭建遇到问题与解决

FontAwesome库很慢或404

修改 blog\themes\icarus\includes\helpers\cdn.js 文件

1
2
3
4
const icon_providers = {
/* fontawesome: 'https://use.fontawesome.com/releases/v5.4.1/css/all.css' */
fontawesome: 'https://cdn.bootcss.com/font-awesome/5.4.1/css/all.css'
};

修改后执行 hexo cl && hexo s 即可看到效果。

Reference: https://blog.csdn.net/t270153399/article/details/105345602

Your browser is out-of-date!

Update your browser to view this website correctly. Update my browser now

×