Dev Operations

This blog post will primarily document and summarize some issues I usually encounter in Unix environments, including but not limited to command line and Git operations. ![NOTE] UPDATE Contents related to git have been integrated to Git Essentials. Remote Address 很常见很弱智的一个错误, 但就是架不住偶尔会犯一次 在开启 http server 之类的操作时, 如果填的地址是 localhost:9000, 那么只有本机可以访问 如果想在其他主机上访问, 需要填为 :9000 Bash Shell Shell 分类: 登录 (Login) vs 非登录 (Non-Login): 登录 Shell: 通常是你通过验证身份(输入用户名和密码,或使用 SSH 密钥)后第一个启动的 Shell。比如: 直接在物理控制台登录 通过 ssh user@host 远程登录 使用 su - 或 sudo -i 切换用户(注意那个 - 或 -i 很关键,它们表示模拟一次完整的登录) 非登录 Shell: 不是通过上述登录过程直接启动的 Shell。比如: 在图形界面中已经登录后,打开一个新的终端窗口 在 Shell 中执行一个脚本 (bash script.sh) 在已有 Shell 中再启动一个新的 Shell (bash) 交互式 (Interactive) vs 非交互式 (Non-Interactive): 交互式 Shell: Shell 的标准输入、输出和错误都连接到终端,并且你可以在其中输入命令并看到输出。简单说,就是你正在与之交互的 Shell 非交互式 Shell: Shell 不是直接连接到终端进行交互的。最常见的例子是运行 Shell 脚本。Shell 从脚本文件读取命令,并将输出(如果未重定向)发送到标准输出,但它不期望用户实时输入命令 根据这两种分类, 可以组合出三种常见的 shell 类型: ...

April 17, 2025 · Last updated on August 10, 2025 · 9 min · KKKZOZ

jj-vcs Tutorial

Basic Operations Interact with Changes jj-vcs treats each unit of work as a “change.” You can interact with changes through commands that create, switch, and record them. # Create a change whose ancestor is <change-id> # This operation will check out to the new change # You can disable the behavior by add "--no-edit" jj new <change-id> # Update the change description or other metadata jj desc -m "<message>" # Update current change's description and create a new change on top jj commit -m "<message>" # "Check out" the change jj edit <change-id> Show Repo Status # Show the current change jj st # Show the current change's log jj log Workflows The Squash Workflow If you are familiar and comfortable with git’s index, you can try this workflow to get yourself started with jj-vcs. ...

April 4, 2025 · Last updated on August 10, 2025 · 8 min · KKKZOZ

Chrome Plugin Recommendations

This article records several of my favorite Chrome extensions. PrintFriendly1 Make web pages printer-friendly and convert them to PDFs. Easily remove ads and navigation, and customize what you print or PDF. Convert web pages to PDF, and ignore some non-essential elements, suitable for processing technical blogs and similar content before putting them into Zotero. Wikiwand2 AI-driven wiki aggregator created to enhance user experience on Wikipedia by streamlining knowledge consumption. ...

April 1, 2025 · Last updated on August 4, 2025 · 2 min · KKKZOZ

Pass The Wall

“Across the Great Wall we can reach every corner in the world.”1 Remote Port Forwarding 让云服务器方便快捷地使用本地代理 建立远程端口转发 ssh -R 1082:127.0.0.1:1082 s2-ljy -p 22 配置云服务器的代理环境变量 export HTTP_PROXY="http://127.0.0.1:1082" export HTTPS_PROXY="http://127.0.0.1:1082" Caution 这是临时设置, 仅对当前终端生效, 如果想永久设置, 请编辑 ~/.bashrc ...

March 30, 2025 · Last updated on August 1, 2025 · 2 min · KKKZOZ

Docker Network Introduction

Summarize common Docker Network operations. Default Bridge Network After a fresh Docker installation, you can find a default bridge network up and running. docker network ls Docker uses a software-based bridge network that allows containers connected to the same bridge network to communicate while isolating them from other containers not running in the same bridge network. docker run -dit --name busybox1 busybox docker run -dit --name busybox2 busybox docker inspect busybox1 | jq -r ' [0].NetworkSettings.IPAddress' docker inspect busybox2 | jq -r '.[0].NetworkSettings.IPAddress' # OK docker exec -it busybox2 ping 172.17.0.3 # Error docker exec -it busybox2 ping busybox1 Conclusion All containers will automatically connect to this default bridge network. Default bridge network allows container communication using IP addresses. ...

March 29, 2025 · Last updated on August 1, 2025 · 3 min · KKKZOZ

Handling Golang Errors

Using Error Wrapping An error often “bubbles up” a call chain of multiple functions. In other words, a function receives an error and passes it back to its caller through a return value. The caller might do the same, and so on, until a function up the call chain handles or logs the error. An error can be “wrapped” around another error using fmt.Errorf() and the special formatting verb %w. ...

February 4, 2025 · Last updated on August 3, 2025 · 4 min · KKKZOZ

Golang Struct and Interfaces

这里简单总结一下三种组合方式: interface 中嵌套 interface struct 中嵌套 struct struct 中嵌套 interface interface 中嵌套 interface 这种组合方式体现了接口隔离原则(ISP)和接口组合原则, 通过接口嵌套,我们可以构建更大的接口 // 基础读接口 type Reader interface { Read(p []byte) (n int, err error) } // 基础写接口 type Writer interface { Write(p []byte) (n int, err error) } // 组合接口 type ReadWriter interface { Reader // 嵌套 Reader 接口 Writer // 嵌套 Writer 接口 } struct 中嵌套 struct 这种组合方式体现了组合优于继承12的原则,是 Go 中实现代码复用的重要方式 // 地址信息 type Address struct { Street string City string Country string } // 用户信息 type User struct { Name string Age int Address // 嵌套 Address struct } // 使用示例 func main() { user := User{ Name: "张三", Age: 25, Address: Address{ Street: "中关村大街", City: "北京", Country: "中国", }, } // 可以直接访问嵌套字段 fmt.Println(user.Street) // 输出: 中关村大街 } struct 中嵌套 interface 这种组合方式体现了依赖倒置原则(DIP),常用于策略模式的实现 ...

January 28, 2025 · Last updated on August 1, 2025 · 2 min · KKKZOZ

Aerospace

Concepts Each workspace contains its own single root node Each non-leaf node is called a “Container” Each container can contain arbitrary number of children nodes Windows are the only possible leaf nodes. Windows contain zero children nodes Every container has two properties: Layout (Possible values: tiles, accordion) Orientation (Possible values: horizontal, vertical) Some examples: In total, AeroSpace provides 4 possible layouts: h_tiles horizontal tiles (in i3, it’s called “horizontal split”) v_tiles vertical tiles (in i3, it’s called “vertical split”) h_accordion horizontal accordion (analog of i3’s “tabbed layout”) v_accordion vertical accordion (analog of i3’s “stacked layout”) Accordion is a layout where windows are placed on top of each other. ...

December 24, 2024 · Last updated on August 1, 2025 · 2 min · KKKZOZ