0%

待整理的脚本(持续更新ing)

记录一些常用/重要,但容易忘记的命令

Python 注册全局变量以在所有代码中使用

1
globals()["seed"] = 42

Python 动态修改源码 (Monkey Patching)

1
2
3
4
5
6
7
8
9
# 在源码中
class A:
def forward(self):
...

# 在项目中
def new_forward(self):
...
A.forward = new_forward

wget 下载文件,保存为时间戳

1
wget -O `date +%s`.jpg https://www.baidu.com/img/bd_logo1.png

Nginx 端口转发

1
2
3
4
5
server {
listen 4747;
server_name localhost;
proxy_pass http://x.x.x.x:4747;
}