Golang Mistakes that I Encounter

Irregular updates Go Gotcha: math/rand Thread Safety Isn’t Universal Ran into a subtle trap with Go’s math/rand package regarding concurrency. It’s easy to assume all random generation is thread-safe, but that’s not quite right. The Key Difference: rand.Intn() (Package Level): Thread-safe! Uses a global source with an internal mutex. Good for most concurrent uses. myRand.Intn() (Method on *rand.Rand): NOT thread-safe by default! If you create your own *rand.Rand instance (myRand) and share it between goroutines, calling its methods concurrently without your own locking will cause data races. Example I Encountered: ...

April 23, 2025 · Last updated on April 23, 2025 · 1 min · KKKZOZ

Effective MacOS Shortcuts

Summarize the various keyboard shortcuts I am currently using. Key Mapping Map Caps Lock to Hyper key (Using Karabiner) System Wide Open Apps Use Karabiner Open apps with Hyper key: Hyper + Q: Open QQ Hyper + W: Open WeChat Hyper + E: Open Browser (Easy to press) Hyper + A: Open Alacritty Hyper + S: Open Sublime Hyper + D: Open VSCode (Easy to press) Hyper + Z: Open Zotero Hyper + X: Open Typora (Easy to press) Hyper + C: Open VSCode (Easy to press) Hyper + P: Open PowerPoint Hyper + L: Open Excel Hyper + H: Hide Current Window (Combo: Hyper + A, then + H to peek new messages) Open Utilities Option + W: Bob Translate Option + .: Raycast Note Cmd + Space: Trigger Raycast Option + Space: Trigger EuDic Ctrl + Option + Space: Trigger Emoji Search (Raycast) Windows Utilities Option + H: First Two Thirds ...

April 19, 2025 · Last updated on July 28, 2025 · 2 min · KKKZOZ

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. 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 July 28, 2025 · 13 min · KKKZOZ

The Usage of jj

Operations Basic # Create a change whose ancestor is <chang-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> Squash @ xrnotmor [email protected] 2025-05-31 19:20:11 4f515fd4 │ D ○ xwvsolxp [email protected] 2025-05-31 19:19:57 811e63a7 │ C ○ urtyqupy [email protected] 2025-05-31 19:19:45 22f25b64 │ B ○ mwtsztxw [email protected] 2025-05-31 19:19:27 a552b9bc │ A ◆ zzzzzzzz root() 00000000 The most direct jj squash: merge current change (@) into its parent: ...

April 4, 2025 · Last updated on July 16, 2025 · 6 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. 将网页转化为 PDF, 并且可以忽略一些花里胡哨的元素, 适合对技术博客等进行处理后放入 Zotero 中 Wikiwand2 AI-driven wiki aggregator created to enhance user experience on Wikipedia by streamlining knowledge consumption As featured on TechCrunch, Lifehacker, Gizmodo, Fast Company and The Next Web: Wikiwand is an award-winning interface that optimizes Wikipedia’s amazing content for a quicker and significantly improved reading experience! ...

April 1, 2025 · Last updated on July 28, 2025 · 2 min · KKKZOZ