Hi there 👋

Welcome to my blog

Candlenut Review

Today we visited Candlenut at Dempsey Hill Singapore. It’s a one-starred michelin peranakan restaurant. In fact, it is the only peranakan restaurant with michelin star. This restaurant share the building in a high ceiling old-style triangle roofed building with 2 other restaurants. The flooring is tiles and feels quite homey. High ceiling feels quite nice although I would prefer if we can have more clear separation from other restaurant dining halls to make it feel more special. ...

November 15, 2025 · Me

Exploring the origin of western music

Why is music is the way it is? You might know the song “do re mi”, which laid out the notes most commonly used as the building block for western music. Let’s take a listen of the notes “do re mi fa so la ti do”, of which most of us should be familiar with. Your browser does not support the audio element. These sequence / collection of notes is also called “scales”, or specifically western scale. Pretty much all songs are an arrangement of notes from a scale. ...

April 21, 2025 · Me

How GZIP works

I created a project gzip.go, which is a toy implementation to decrompress zip file. The blog content below is copied from the README. It aims to explain the techniques used in Gzip. gzip.go The implementation is largely derived from http://www.infinitepartitions.com/art001.html, but I try to add some overview explanations. Technique 1: Huffman Encoding What is encoding? Encoding is mapping from symbols to another symbols. In this case we will map the symbol to binary values, which we will simply call as codes. It is important that the encoded result must be decode-able. Some (invalid) mapping can cause the encoded data to be undecode-able because of ambiguity. ...

March 10, 2023 · Me

Iterative Policy Evaluation in Small Gridworld

I’m currently learning Reinforcement Learning course by David Silver (here) and currently on studying lecture 3 and I find one particular example interesting. Taking it out of the context of RL and putting it simply, the example is to evaluate a random walk along a grid and find the expected number of steps required to reach some terminal nodes. Solve by Simulation Probably the most trivial way to calculate that is too just simulate it and find the average steps needed. ...

March 16, 2020 · Me

How Email Actually (Apparently) Works

2 protocols I found out that actually the email infrastructure is consisted to 2 level of abstraction, the SMTP communication protocol and the email formatting. The analogy is close to SMTP protocol being the HTTP protocol and email formatting being the HTML formatting (in case of web). The protocol used by the SMTP server to communicate with each other is defined in RFC 821, which is superceeded by RFC 5321. And for the formatting of the email, RFC 822, superceeeded by RFC 5322. ...

January 24, 2020 · Kevin

How Regex is Matched

I have always wondered on how a regex like (a|b)*abb is matched with string like aabb (the regex pattern basically mean, match any number of a or b, followed with abb, like aaaaaabaabbaaaabb and abb). It may look obvious to us, but I start to wonder how does the regex matcher know whether the first a of aabb is matched to the (a|b)* and not to the a in abb before looking at the rest of the string? Another more confusing example is abbabb. How do they know to match the first abb in the string with the (a|b)*? I guessed that it will do some kind of trial and error and backtracking. That is possible, but how can be that logic be generated dynamically? ...

January 23, 2020 · Me

Tokenization is Hard

The most interesting thing I learned today is how hard tokenzation (as in lexical analysis) really is. At first I thought that it was just as simple as dropping off punctuation marks as demonstrated by Python ntlk library. from nltk.tokenize import sent_tokenize, word_tokenize data = "All work and no play makes jack a dull boy, all work and no play" print(word_tokenize(data)) Out: ['All', 'work', 'and', 'no', 'play', 'makes', 'jack', 'dull', 'boy', ',', 'all', 'work', 'and', 'no', 'play'] Yes the nltk did literally “tokenize” it in the literal definition of just grouping some sections of string together. But it might not consider the semantic of the tokenization. One easy example is Joe Carter goes to Standford University. Shall we treat Joe and Carter as a separate token or Joe Carter as a token? Same cases applies for Standford University. ...

January 22, 2020 · Kevin