Mar. 28, 2025
Linus Torvalds 在他的书Just for Fun中谈到The Beauty of programming:
It’s a game much more involved than chess, a game where you can make up your own rules and where the end result is whatever you can make of it.
这与数学有着相似之处,同样是在人所创造的系统中玩耍
One of the biggest joys was learning that computers are like mathematics: You get to make up your own world with its own rules. In physics, you’re constrained by existing rules. But in math, as in programming, anything goes as long as it’s self-consistent.
Mar. 28, 2025
Synchronization is required for operation of execution. Two memory accesses form a data race if they are from different threads to the same location, at least one is a write, and they occur one after another.
we focus on the implementation of lock and unlock synchronization operations.
Lock and unlock can be used straightforwardly to create regions where only a single processor can operate, called a mutual exclusion
To implement this two operation, we need hardware primitives that atomically read and write into memory.
Mar. 26, 2025
Human’s ignorance makes one not able to present an algorithm for the exact nature of a certain task. For instance, write a realistic fiction or paint a expressionist canvases. The enough information is unknown for an algorithm to be invented to capture the nature of them. Those tasks may involve multiple variables and parameters that interacts in a nontrivial way. Indeed, comprehending the full nature of these interactions may well exceed human’s cognitive capacity.
Mar. 14, 2025
Overview
游戏的所有对象都由一个或多个特定字符来表示
##############
# #
# dv #
# v # #
# v # #
# s >>D # #
# v # #
# *A< * # #
# #
##############
main() {
Read board from file or stdin or create a default board
update game
write updated board to file or stdout
}
struct
typedef struct snake_t {
unsigned int tail_row;
unsigned int tail_col;
unsigned int head_row;
unsigned int head_col;
bool live;
} snake_t;
typedef struct game_t {
unsigned int num_rows;
char **board;
unsigned int num_snakes;
snake_t *snakes;
} game_t;
update_game()
board file预设了所有对象的位置:蛇,水果,墙
在加载board之后,一时刻的游戏运行逻辑:
蛇的移动实际上只需要更新头部和尾部的位置,即
update_head()
, update_tail()
两个函数根据下一刻的位置是空地,墙还是水果做不同的更新
而这两个函数的实现有许多helper完成,大概来说有:
Mar. 8, 2025
Clash Premium 的 TUN 模式 本质上是一种实现 透明代理(Transparent Proxy)的技术手段
透明代理的核心特点是:无需客户端主动配置代理,流量被“透明”地拦截并转发到代理服务器。例如:
- 用户访问
google.com
,流量被系统层自动劫持,通过代理服务器转发,而用户无需在浏览器中设置代理。
- 应用(如命令行工具、游戏客户端)完全无感知,代理过程对用户和应用程序是“透明”的。
工作原理
(1)流量劫持
- 虚拟网卡(TUN 设备):在系统中创建一个虚拟网络接口(TUN 设备),所有系统流量默认经过此设备。
- IP 层拦截:在 OSI 模型的 网络层(第3层) 直接捕获原始流量(包括 TCP、UDP、ICMP),无需依赖应用层协议(如 HTTP/Socks5)。
(2)代理规则决策
- Clash 内核根据配置的规则(如域名、IP、GEOIP)决定流量走向:
- 代理:将流量转发到指定的代理服务器。
- 直连:直接发送到目标服务器。
- 拒绝:直接丢弃(如广告拦截)。
(3)DNS 透明代理
- DNS 劫持:强制将系统的 DNS 请求转发到 Clash 内置的 DNS 服务器,防止 DNS 污染。
- 分域名解析:国内域名直连解析,国外域名通过代理服务器解
TUN 模式的优势
- 协议全覆盖:支持 TCP、UDP、ICMP,适合游戏、视频通话等场景。
- 无需应用适配:所有流量(包括系统服务、命令行工具)默认被劫持。
- 绕过防火墙检测:流量看起来像普通网络请求,而非代理协议(如 Socks5)。
流量处理流程
- DNS 请求:
- 系统发起 DNS 查询(如访问
google.com
)。
dns-hijack
规则拦截该请求,转发到 Clash 的 listen: 0.0.0.0:53
。
- Clash 根据域名判断:
- 若为国内域名 → 通过
nameserver
(114.114.114.114
)直连解析。
- 若为境外域名 → 通过
fallback
(8.8.8.8
)代理解析。
- 返回 Fake-IP(如
198.18.1.1
)给应用。
- 应用发起连接:
- 应用尝试连接 Fake-IP(
198.18.1.1
)。
auto-route
确保流量经过 TUN 设备,被 Clash 捕获。
- Clash 根据域名关联的规则(如
google.com
走代理)决定是否转发到代理服务器
Mar. 3, 2025
Intro
Hello, here is mio!
And here is a color code for blue
#47bde5
byby(’-'*