React fundamentals and pitfalls

React fundamentals and pitfalls. Mostly from the official doc.

How to enable audio and CJK in wsl

For newly installed ubuntu 22.04 with wsl2 under Windows 11, there are some issues such as no sound is output if opening a web page that plays audio, as well as that the CJK characters can not be displayed properly if the page has CJK characters, and here are some quick solutions.

Difference between service worker and web worker

Web workers and service workers are both types of JavaScript workers that run in the background, separate from the main browser thread. However, they serve different purposes and have distinct characteristics.

Terraform quick reference

Quick reference for commonly used terraform commands and how-tos.

async parallel behavior with callback

The async library has a convenient method called parallel, which takes a collection of async functions to run and an optional callback to run once all the functions have completed successfully.

How to remove dual-boot ghost entry from uefi

After trying dual-boot of Windows 11 and Ubuntu, I decided to remove Ubuntu due to unknown but likely hardware driver issue causing my laptop’s fan to be constantly running noisily regardless of nearly zero CPU or low Memory usage. Following the steps from guides available all over the internet, I deleted the Ubuntu partition and extended the Windows partition back to original volume from Disk management tool. However, there is a leftover issue that is the UEFI (BIOS) now has a ghost boot entry for Ubuntu which does not seem to have a straightforward way to be deleted. After searching on the internet for awhile and finally I found below proved to be working reliably.

Minimal unified shortcuts across editors and platforms for programming

※ The cmd for macOS is the ctrl for windows.

Redis as simple distribution lock for simple cases

I came across a system issue recently that some of our batch jobs written as ruby rake tasks ended up having duplicated invocations, which causes either duplicated records in database or duplicated alerts in slack. It is definitely an infra issue but until it is fixed from infra side, I need figure out a way to address it from the coding perspective. Trying to rewrite everything as idempotent as possible is not an option and neither is enhancing application level validations or database uniqueness constraints, because not all jobs can be idempotent and not all jobs write to databases, besides the issues are caused by race conditions not from two threads but from two processes. After some research and experiment, I decided to use Redis as a simple distribution lock solution, which is already available in our application and needs zero extra setup, and it is a single instance therefore no replication sync concern. Redis is single-threaded architecture so no matter how many concurrent clients try to write to it, it is guaranteed to be in sequential and atomic. I figure out I could make use of this nature to fix the issue faced.

Minimum commands to survive tmux

tmux is a terminal multiplexer. It is very useful when we need run long-running tasks on remote servers on the background and check the results later without the need to keep a constant live ssh connection and worrying about network failure causing the task to exit unexpectedly. Here is a list of minimum commands to meet most of the use cases.

How to write single file source code executable in java

Since JDK 11, Java supports executing source file directly without the need to first compile to class file, which makes it possible to write scripting in Java, as is usually done with dynamic programming languages like python, ruby, or nodejs. This post serves as an example as well as a quick reference on how to achieve it.