A while back I wrote about working with stacked PRs using git-branchless, git-autofixup, and
git-pr . It worked well. But since then I switched to
 jj — and I’m not going back. 
 jj is a new version control system that is compatible with git. It can use an existing git repo as its backend. I
started using it as a drop-in replacement for git and expected it to feel roughly…
I have recently read a book called “Game Theory in Everyday Life” by Len Fisher. It is a great book that explains concepts of game theory in a simple and easy to understand way. It opens up a new perspective on how to look into familiar situations. 
 Let’s start with a very usual story from our software engineering work. 
 
 A Flaky CI Test 
 You submit a PR.…
Hôm nay tôi xem kỹ hơn một video về group theory của tác giả 3b1b . 
 Và thử diễn đạt lại theo cách hiểu của mình. 
 Bắt đầu từ symmetry (đối xứng) 
 Hiểu nôm na thì nó là nói về tính chất của một vật (entity) 
(hiểu là một cái gì đấy trừu tượng của toán học, có thể xuất phát từ việc trừu tượng hoá những vật cụ thể trong cuộc sống thực hoặc không).
I’m using dark mode everywhere. But many websites, including Google Docs, Apple Support, etc. still have white background without any option to turn on dark mode. 
 This is a simple Tampermonkey script to dim white pages a bit, so it won’t burn my eyes. Basically, it applies an overlay div with background rgba(20, 10, 0, 0.12) .The page will be a bit yellow. If you prefer gray, you…
Have you ever get bored with the same old commit messages, all starting with “update”, “fix” or “feat”? Do you know that emojis are the latest advancement in human language and communication? They can convey emotions and ideas in a single character and make your messages alive! Think about it, even when aliens come to Earth, they will quickly understand the…
A new day at work 
 Suppose that you, a good software engineer, just got hired by an e-commerce business. And you are joining a team to work on the profile service to manage customers and their addresses. 
 There are a Customer and an Address struct, with a couple of gorm tags for the database schema: 
 type Customer struct { 
 ID uuid . UUID `gorm:'type:uuid;primaryKey' json:'id'`…
The FConvey function is a standout feature of ezpkg.io/conveyz , designed to simplify focused testing in Go. Unlike the original smartystreets/goconvey framework, which requires developers to set FocusConvey at every nested block level, FConvey is smarter. It ensures that focusing on a single block propagates to all relevant nested and parent blocks, streamlining the debugging process. 
 In…
Have you ever needed to modify unstructured JSON data in Go? Maybe you’ve had to delete password and all blacklisted fields, rename keys from camelCase to snake_case , or convert all number ids to strings because JavaScript does not like int64 ? If your solution has been to unmarshal everything into a map[string]any using encoding/json and then marshal it back… well, let’s face it, that’s…
Handling errors in Go is simple and flexible – yet no structure! 
 It’s supposed to be simple, right? Just return an error , wrapped with a message, and move on. Well, that simplicity quickly turns into chaotic as our codebase grows with more packages, more developers, and more “quick fixes” that stay there forever. Over time, the logs are full of “failed to do…
Hi! I’m Oliver Nguyen, a software engineer working with Go & JS. 👋 
 I enjoy writing code and building tools to make writing code even faster! I love working in start-up environments, where I get to build everything from the ground up and improve them as companies grow. 
 Along the way, I share my knowledge and write about best practices in software development, covering topics like…
As a start-up company, we started with a simple architecture: All data were stored in a single centralized Postgres instance, shared by a few services. It has been working well and allows us to move fast, deliver features, enter the market, acquire clients, and grow exponentially. 
 Fast forward a couple of years, today we have thousands of clients and billions of records, it’s time to…
“How to Live on 24 Hours a Day” is a classic self-help book written by Arnold Bennett, first published in 1910. The book is a practical guide on time management and personal development, emphasizing the importance of making the most out of each day. 
 Bennett argues that time is the most valuable resource we have and that many people waste it without realizing it. He suggests simple but…
In JavaScript/Node world, we usually store scripts in package.json and run them using npm. In other worlds, we use
Makefile or create a directory and put all our scripts there. But there is a better way to manage and run scripts for
your team. No, I’m not talking about Warp or other pricey fancy tools. 
 I will share about direnv and our old friend bash : How we are using them…
Today, I encountered this code in my company codebase (the code and comments are rewritten for demo purpose and do not include any proprietary code) : 
 type GoroutineTracker struct { 
 wg sync . WaitGroup 
 // ... some other fields 
 } 
 // Go starts a new goroutine and tracks it with some metrics. 
 func ( g * GoroutineTracker ) Go ( ctx context . Context , name string ,…
As I work on various Go projects, I often find myself creating utility functions, extending existing packages, or developing packages to solve specific problems. Moving from one project to another, I usually have to copy or rewrite these solutions. So I created ezpkg.io to have all these utilities and packages in one place. Hopefully, you’ll find them useful as well. 
 
 
…
I usually push a lot of PRs in form of stacked PRs to GitHub. It’s quite annoying to go through each PR to see the check status. So I
created this plugin to show my PRs on the menu bar. — Now, everything is just a click away! 
 
 Features 
 1. Top PRs section 
 
 List of your chosen PRs, sorted by your order. 
 You can customize the list of PRs in this section by…
We’ll declare a Phantom Type: 
 type StringN < N > = string & { 
 length : N ; 
 readonly X : unique symbol ; 
 } 
 
 const isStringN = < N extends number >( length : N , s : string ) : 
 s is StringN < N > => s . length == length ; 
 
 export const stringN = < N extends number >( length : N , s : string ) : StringN < N > => { 
 if ( ! isStringN (…
We can use this pattern to output log with color in browser by adding CSS: 
 const logger = ( name ) => ({ 
 info : console.info.bind ( console , `%c ${ name } : %s` , 'color: #56d74b' ), 
 verbose : console.debug.bind ( console , `%c ${ name } : %s` , 'color: #70818e' ), 
 }) 

At work, I’m working on the flow compiler, which compile from flow documents into ETA flow descriptors. The use cases
are to provide our users the ability to automatically response to their customers’ messages. Users can define their own
flow and customize auto reply behaviours. This article gives a look into my work. Also see related article . 
 
 Package flow…
While working with Go and JavaScript, we have tools available for auto reloading the server when the code changes. For
JavaScript, we even have hot reload which reloads part of the page without reloading the whole page. But for Python, we
don’t have such tools, I tried livereload, but it does not work well for nested directories. So I decided to do it
myself. And there is a tool…
I wrote a simple script to download the HackerNews data from
 HackerNews API . It downloads the data in JSON format and stores it as a collection
of files. The first time it runs, it will create the directory data to store the data. Subsequent runs will update the
data in the directory. 
 At the time of this writing, the HackerNew database has about 35 million items. 
 Usage…
At work, I’m working on the flow compiler, which compile from flow documents into ETA flow descriptors. You can read more details in this article . 
 Flow documents are a collection of nodes and edges, which are JSON objects. They are used to describe the flow of an
automation chatbot. The flow compiler takes a flow document and compile it into an ETA flow descriptor, that is used…
I usually work with stacked PRs. It is a great way to organize my work and keep my commits small. This empowers
separation of concern and limit scope of each PR. Reviewers can go through each PR and review them one by one.
Smaller changes, better feedback! 
 
 I was using sapling . It worked really well in the first month, but the honeymoon ended too soon. Read more... 
 Using…
When using sapling, it can access my github with my credentials by asking me to gh auto login . I was wondering where
it stores these credentials: in the keychain, in a file, in the environment? It’s here: 
 $ cat ~/.config/gh/hosts.yml
 github.com:
 user: iOliverNguyen
 oauth_token: gho_████████████████████████████
 git_protocol: https

At work, we use gomega for testing. It works well, until one day it becomes too
verbose and goconvey becomes a better fit. To prevent the repository
from using two different sets of assertion functions, I decided to write an adapter to make goconvey work with
 gomega assertion functions. 
 gomega 
 gomega is a testing framework for Go. Here’s what it looks like: 
…
In the last post , I shared my experience with Sapling, Meta’s new Git client. It requires some workaround with direnv. This post explains the change in details. 
 At work, we are using direnv for quickly managing environment variables on our repository. When we
 cd into a directory, or a subtree, it automatically detects the file .envrc in the current directory (or the nearest
parent…
Sapling is a new source control system developed by Meta. Recently, it
gains the ability to work with GitHub. I’m curious about how it works, so I decided to give it a try and end up using it
daily on my company’s repositories. If you want to try it out, check their documentation
here . 
 Stacked PRs 
 
 When developing, I usually create a single commit for each…
We know that our blood contains white blood cells. And we probably heard of macrophages and T-Cells. But the immune
system has so much more. The book Immune 
from Philipp Dettmer, the author of Kurzgesagt channel, will provide insights
into the beautiful mechanisms of our immune system. This article is my summary of our immune system, what they are and
how they protect our body.…
gluon 
 Recently, I found gluon . It is a framework for building desktop applications
using web technologies. Unlike Electron, it uses the System installed Chromium or Firefox instead of the bundled
Chromium. This makes it possible to use the same version of Chromium or Firefox as the one used by the user’s browser.
This also makes the application significantly smaller. At…

 JavaScript is changing fast with a lot of new and exciting features to help us - developers write code better and
better. These features have been released for a while. Let’s check them out! 
 1. Private fields 
 
 Previously, all class fields must be defined in the constructor. And there is no private fields. All fields can be
accessed from outside. Of course, there are…
Linux 
 There are three standard file descriptions, STDIN, STDOUT, and STDERR. They are assigned to 0, 1, and 2 respectively. 
 File descriptor 3, 4 and so on can be accessed at: 
 /proc/12345/fd/3
 I found it when looking at this Patchset . Chromium
open --remote-debugging-pipe at file descriptor 3 for output and file descriptor 4 for input. 
 Windows?
TIL: Git 
 How to apply a patch from github into the current repository 
 gh pr diff --patch 4 | git am
 git am 
 Apply a series of patches from a mailbox.
According to neuroscientists, music can reduce anxiety and stress. They suggested a list of the ten most relaxing songs
to reduce anxiety: 
 
 “Weightless,” by Marconi Union 
 “Electra,” by Airstream 
 “Mellomaniac (Chill Out Mix),” by DJ Shah 
 “Watermark,” by Enya 
 “Strawberry Swing,” by Coldplay 
…
Ultralearning is a book from Scott Young. He spent time learning a
lot. Like spending 1 year in 4 non-English countries, each country in 3 months, to learn speaking foreign languages. 
 Make a metalearning map 
 Design your goals and scopes. Determine exactly what you want at the end. Spend the first 10% of time to answer: 
 
 What concepts do I need to understand? 
 What…
Shortcode are simple snippets inside your content files calling built-in or custom templates. 
 Include HTML file in a post 
 Create layouts/shortcodes/include-html.html : 
 {{ $file := .Get 0 }}
 {{ (printf '%s%s' .Page.File.Dir $file) | readFile | safeHTML }}
 Then use it in your content files: 
 {{< include-html 'embedded.html' >}}

Memory tips by BigThink.com 
 
 Chronic stress is really bad for our memory. It make us tired and loose attention. Stress hormones mobilize your brain
and body to respond, to fight, to flee, to react quickly - not to think. 
 Get enough sleep. If you don’t get enough sleep, your hippocampus might not have enough time to consolidate memories. 
 You remember when you pay…
WHERE conditions required 
 At work, we are using gorm for dealing with database. It’s a popular SQL manipulation
library in Go. 
 But recently, we got a scary error: 
 can not update row: id=00000000-0000-0000-0000-000000000000
 WHERE conditions required
 Which happened from this code snippet: 
 db , _ := gorm . Open ( ... ) 
 
 paper := & Paper { 
…
Compare and swap 
 Compare and swap is a familiar concept of atomic operation, for dealing with race condition. Suppose we want to build a
lock for multiple instances to execute some command, and only one can be executed at a given time. An instance must wait
for the lock to be released before it can take. 
 Instance 1: Current value is empty, set it to 1 and take the lock.
…
How to validate that a Protobuf message does not contain enum fields with zero value? Turn out that is not supported
directly by Protobuf! We need to look into how protojson package is implemented. 
 More and more companies are adopting gRPC with Protobuf for
communication between internal services. It has the benefits of high performance, supporting multiple programming
languages,…
What is it? 
 Eventual consistency is a fancy name of doing something and only expecting the changed state after a while. And there is
a guarantee that you will eventually get the expected state. Hence, consistency. 
 But that won’t work well with caching . And I had to deal with that recently when working with WhatsApp API. 
 When querying for a list of message templates…

 You can’t connect the dots looking forward; you can only connect them looking backwards. So you have to trust that the
dots will somehow connect in your future. 
 ⸺ Steve Jobs 
 Sometimes, stepping outside of your comfort zone and taking some side projects is a great way to improve as a developer.
The more skills you acquire, the more you can do. And you may need them…
Once upon a time, we could simply put an HTML and a script file into an FTP server, quickly have a working website and
call it a day. 
 Today, we have to jump through many hoops just to get the right things in the right places. Suppose Alice wants to spend
her weekend making a simple to-do app or whatever little idea she enjoys. First, she has to install a big heap of 10k
npm…
µjson is a minimal JSON parser and transformer that works on unstructured (and trusted) JSON . It works by parsing input and calling the given callback function when encountering each item. 
 Motivation 
 Sometimes we just want to make some minimal changes to a JSON document or do some generic transformations without fully unmarshalling it. For example, removing blacklisted keys from…