Skip to content
Yejun Su

Recent writing

TILColor discrepancy between the terminal and Zed's integrated terminal

When running the pi coding agent in Zed’s integrated terminal, I found the appearance of the theme is not the same as in Ghostty.

The root cause is that, by default, Zed sets the minimum contrast to 45 between foreground and background colors in the terminal. If you want Zed to use the exact theme colors, set this to 0:

{
  "terminal": {
    "minimum_contrast": 0
  }
}

This turns off Zed’s contrast adjustment, which can make some color combinations harder to read.

My 4K monitor setup

I recently purchased an LG 27UP850K monitor with a 4K resolution (3840x2160). At its native resolution, everything is tiny. When scaled to the 1080p resolution (1920x1080), it displays the same content as a 1080p screen but with much sharper clarity. Then I scaled to the 2K resoluition (2560x1440), it warns “Using a scaled resolution may affect performance”. I finally switched back to the native 4K resolution because it displays much more content, which was my main reason for buying this monitor. [… 3 min read]

Kamal

I recently deployed a Rails application to Hetzner and AWS China. Deploying on Hetzner is simple, requiring just two steps: launching a server and deploying. In contrast, deploying on AWS China involves extra steps because Docker Hub is not accessible from servers located in China. [… 2 min read]

TILAccept per-project flake config

A project using devenv prompts: do you want to allow configuration setting 'extra-substituters' to be set to 'https://devenv.cachix.org' (y/N)?., but I cannot input y in the stdin. It happens in fish shell, and there is an issue: https://github.com/direnv/direnv/issues/1022.

The solution is to set accept-flake-config: true in the global nix setting (via):

{
  nix = {
    settings = {
      experimental-features = "nix-command flakes";
      accept-flake-config = true;
    };
  };
}

TILAvoid setting UV_ENV_FILE globally

I’m using the Atlassian Remote MCP Server in Claude Code to fetch Jira tickets. I installed it per-project using claude mcp add-json <name> <string>. Recently, I noticed it keeps failing in one project, although the config is exactly the same.

I checked the problem by locating the MCP server command and executing it within the project. The error raised: No environment file found at: `.env`. It reminded me that UV_ENV_FILE=.env is set globally, and it’s too convenient to be noticed. After removing the environment variable, the MCP server works.

If only one command needs a dotenv file, pass it to that command instead of exporting UV_ENV_FILE in your shell profile:

uv run --env-file .env python app.py

See uv’s dotenv documentation.

TILMultilingual export using ox-hugo

Hugo-modus supports multilingual now, it’ll display translation links for multilingual posts. As I’m blogging using Denote and Hugo, I changed the #+export_file_name by appending the locale such as: post-1.zh, expecting it to export post-1.zh.md but failed. The complete configuration is as the following:

#+hugo_base_dir: ~/code/hugo-modus/exampleSite
#+hugo_section: posts
#+export_file_name: post-1.zh

Then I found there is already a solution, which is as easy as appending .md, such as #+export_file_name: post-1.zh.md. The result is in the example site’s Chinese Markdown source.

TILTransform ox-hugo anchors to links

This blog is built with Hugo, and the content is exported from Org files to Hugo-compatible Markdown via ox-hugo. Each heading is followed by an anchor after the export:

## Heading {#heading}
### Another heading {#another-heading}

To make the anchors clickable, Kaushal Modi (the author of ox-hugo) recommends replacing anchors with links (source), the steps are as follows:

First, create a partial layouts/partials/headline-hash.html:

{{ . | replaceRE `(<h[2-9] id="([^"]+)".+)(</h[2-9]+>)` `${1}&nbsp;<a class="headline-hash opacity-0" href="#${2}">#</a> ${3}` | safeHTML }}

Next, apply the partial to .Content:

{{ partial "headline-hash.html" .Content }}

The result will look like this:

<h2 id="heading">Heading&nbsp;<a class="headline-hash" href="#heading">#</a> </h2>
<h3 id="another-heading">Another heading&nbsp;<a class="headline-hash" href="#another-heading">#</a> </h3>

TILFlushing content blocks

By default, multiple calls of the content_for helper using the same identifier will concatenate and output them together.

Set flush: true to flush all previous content_for calls:

<% content_for :example do %>
This block is flushed.
<% end %>

<% content_for :example, flush: true do %>
This block will display.
<% end %>

<%= content_for :example %>

Only the second block is rendered.

Static website with Hugo and Nix

This website is built with Hugo, a static site generator, and built with Nix. This approach ensures the build won’t break in the future because the content, generator and builder are all unchanged. [… 2 min read]

记一次拔智齿的经历

国庆放假几天牙疼,昨天去家门口的牙科诊所拍了个牙片,不看不知道,一看吓一跳,原来是一颗智齿长歪了,把前面的牙顶坏了。 牙科诊所的医生贴心地跟我说,去医院拔牙可以用医保,否则自费要1500元。我立刻就在公众号“同济大学附属口腔医院”预约了第二天八点半的门诊。 [… 4 min read]

Send Nix code from Emacs to Kitty

I’m learning Nix by following this tutorial and taking notes using Org Mode. I organized the notes with my thoughts and some code examples. Doom Emacs provides a function +eval/send-region-to-repl to run code in a language’s REPL buffer. It’s useful until multiple-line input comes, which prints like so: [… 1 min read]

A tour of functional thinking

There were several server downtime on May 4th and 5th, my colleagues found IOPS burst in database when school clicking the Pending Emails button, which will show the incoming emails one by one for school users to match them with specific students. [… 3 min read]

A tour of scientist gem

Schools with large amounts of families complain that when visiting the Families roster, the request is too slow to use and even times out. This is a tour about how we made a performance boost while keeping the functionality work as normal. [… 4 min read]

初识 scientist gem

最近项目中的一个功能有性能问题,改进方案很简单,就是用缓存代替实时计算,但是缓存需要及时更新,不能返回错误的结果。 这个过程需要用生产环境的数据来检验,但是又不能破坏现有的功能,正巧前几天读了 Changing Critical Code Paths With Scientist, 发现文中提到的 scientist gem 就是解决这个问题的。 [… 3 min read]