Hi there đź‘‹

Welcome to my blog

Working and Heirarchy of Need

Do we work to live? Or do we live to work? Is “working” supposed to be the source of sustenance for our life? Or is work the main purpose of our live? I think, for “work” in broader definition, the answer is both. To analyze it, we can use Maslow’s “Hierarchy of Need” as our framework. From the most basic to the most complex: Physiological need: food, water, warmth, rest Safety need: security, safety Belonging and social need: relationships, friends Esteem need: prestige, feeling of accomplished, respected, valued Self-actualization: achieving one’s full potential, growth, creativity, authenticity, meaningful goals So we do need work to support buy us food, shelter, safety, and to lesser extent, maintain our relationships. And sometimes, we can also gain esteem from work, for example if we reached a high position, or we received good review. ...

April 24, 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

Social Media & Creation

I personally don’t like social media due to the information overload aspect of it. It’s easy to blame big corps for like designing an app to increase retention / screen time. However, behind all that, there’s actually a very human nature of creating content. Human has been creating since very long time ago, like the cave paintings. People write songs, diaries and stories; things that people do not for mere survival, but to tell the world about their existence, “I was here”. ...

April 18, 2025 Â· Kevin

Bikeshedding

Bikeshedding (see wikipedia) is the way to say when someone focus on unnecessary details when there are bigger problems that matters much more attention. It is called bikeshedding because it’s like when someone debating about how the bike shed should be designed in a nuclear plant. One occassion I notice recently is when project manager taking votes for small decisions. Like whether we should make the color of the website blue or red, or etc., when we dont even know what it is for yet. ...

April 18, 2025 Â· Kevin

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

Time Complexity of Matrix Inverse

Today, I just learned from CZ4024 Cryptography and Network Security class about how should we calculate matrix determinant. I remember from high school that there are at least 2 ways that we can do it, using Laplace’s formula (a.k.a. cofactor method) and Gaussian elimination (a.k.a. row reduction). In the Laplace’s method, we can see really quickly that to calculate the determinant of an square matrix of dimension n, we need to calculate determinants of n square matrices of dimension n-1. ...

January 21, 2020 Â· Kevin