“要多想”
💬 Chat
End-to-end encrypted chat. 基于 Firebase Realtime Database. Peers (loading...) online Message .button{ border: none; padding: 8px 16px; text-align: center; text-decoration: none; display: inline-block; font-size: 16px; background-color: #e8eef2; color: #2c3e50; } Speak (your id): broadcast (ctrl or shift + enter) Action board id: connecting... refresh my token danger destroy the board var user_id = ""; Source code https://github.com/zrt/chat
绕过清华校园网的二层隔离
写了个脚本绕过校园网二层隔离,自动化里面提到的加路由的方法。 依赖 ipcalc 计算子网地址。apt install ipcalc。 #!/bin/bash IPA=$(ip address list dev eth0 | awk ' /inet/ {print $2}' | head -1) GATE=$(ip route list dev...
PyScript 尝试
- numpy - matplotlib PyScript让你可以在 html 里写 Python ,感觉很有趣。 比如下面这个图(大概要等5分钟😂): <div id="plot"></div> <py-script output="plot"> import matplotlib.pyplot as plt import numpy as np x = np.random.randn(1000) y = np.random.randn(1000) fig, ax = plt.subplots() ax.scatter(x, y)...
Python 协程 (async/await)
用Telegram 机器人库 Telethon的时候发现他家的 API 接口走的都是 async。 这就来学一下 Python 的 async 和 await (官方文档),需要 Python 版本3.7以上...
gRPC
参考 https://grpc.io/docs/what-is-grpc/introduction/ gRPC 是 Google 开发的远程调用(RPC)库,使用 Protocol Buffers 定义接口并传输数据。可以实现函数的跨语言、跨平台调用。
大端序与小端序的C++存取
把int等数字转换成字节流,需要考虑字节的顺序,有大端序或小端序两种。这两种顺序很多平台、算法、协议里都有用到。 大端序 int数字 0xAABB...
Apache 反向代理使用 Basic Auth
生成密码 sudo htpasswd -c /etc/apache2/.htpasswd {username} 修改 /etc/apache2/sites-available/{site}.conf 文件,添加: <Proxy *> Order deny,allow Allow from all Authtype Basic Authname "Password Required" AuthUserFile /etc/apache2/.htpasswd Require valid-user </Proxy> 3. 重启 Apache 服务 sudo systemctl restart apache2
创建一个 Service/Systemctl 服务
写入{taskname}.service文件到/etc/systemd/system/文件夹。 sudo systemctl daemon-reload sudo systemctl enable {taskname}.service sudo systemctl start {taskname}.service systemctl status {taskname}...
Python 使用子进程调用函数并得到 exit code
Python 的 subprocess 并不支持直接调用函数。可以用 multiprocessing 库来搞。 def twosum(a, b): exit(a+b) from multiprocessing import Process if __name__ == '__main__': p = Process(target=twosum, args=(2, 33)) p.start() p.join() print('exit code:', p.exitcode) 如果需要传输其他类型的变量,可以用 multiprocessing 里的 Queue 。