How a programmer experiences heart break
Thursday, June 22, 2017



It's like having a vital piece of functioning code ripped out of my program suddenly.

Analogy time.

I started out as a normal program with code required to function and perform day to day tasks. One day, I was introduced a small piece of new code, it became part of me; but it wasn't doing any critical function yet.

Over time, more and more functions and code are added to that block of code. My program started relying heavily on it and it made me run faster, tasks was shared with it and generally all was good. But no program is bug free, so I spent a lot of time debugging the errors and working out the kinks. But some bugs never really went away, hotfix patches would resolve those bugs, only for them to surface again after an arbitrary amount of time. It was a lot of work to keep up with the patch work.

After many rounds of careful analysis, it was decided that the code needed to be removed.

Even though the prep work has been done, deleting a huge block of code that has been supporting the program is a painful move. Unsurprisingly, the program crashed, and it crashed hard. Turns out that block of code was doing a lot more than the comments specified. Vital operations were disrupted and errors were throwing up everywhere, constant stack/heap overflows.

The best course of action is to start going through all of the error messages and addressing them one by one, which I did. Slowly but surely, I started writing out little functions that handles all the memory leaks. But they are pretty much just

emotions > /dev/null 2>&1 ?

In summary, the program still works. It's a little confused on what files to import, wishing that the missing block had adopted an adapter pattern. But

It'll continue to run, just a little different from now.


Home Server May 2017
Tuesday, May 02, 2017

It has been no secret that I've been working on a few personal projects of my own. My friends know how fucking excited I've been getting lately when I hit my milestones.

Since I've been repeating myself a lot lately and it's quite hard to explain quickly without the aid of diagrams, I created some diagrams.

Firstly, I'm using an open source solution called Docker for hosting my services and it's amazing and I urge you devs out there to check it out. In simple terms, it's a way of virtualizing services rather than the OS itself. The benefits are that there is less overhead, starting and stopping services are just a few simple commands away and you can duplicate as many services as you want across a cluster(swarm).

Right now I have a few services that are always turned on.

  1. Automated torrent downloading
  2. Google Drive-like service for files
  3. Internal DNS service
  4. Service manager for docker containers
  5. VPN service

I also have some development sites that runs on and off based on changing needs (eg. web, database service).

Secondly, I've been reading up quite a lot about reverse proxy and I've been wanting to set them up for months/years(?!) but just haven't had the time to get to them. In simple terms, a reverse proxy is kind of like a seamless way of redirecting users to the correct server based on the URL. It could be used for load balancing, or in my case, used as a transparent way for end users to access the services*.
* | why not DNS? Because DNS only resolves IP but cannot resolve port numbers. My services are only exposed by port and are (mostly) on a single machine so I had to do it this way.

However, I still have a DNS service running because I need to be able to resolve URLs to a physical machine. (no messing with host files anymore)

An overview of how it works is shown in the diagram below.


--- update ---
Made a mistake in the diagram, when accessing data.service it goes directly to the DNS service then to the NAS. Does not require nginx to resolve at all.

When the reverse proxy server (aka. nginx) is hit with a URL query, eg. (http://torrent.service), it looks in the configuration where to redirect the user to seamlessly in the background. The seamlessness/transparency is a very powerful tool. I will explain it in more detail after illustrating how the general flow of logic of this setup.


* | client machine must be configured to use my DNS server (forced over VPN)

When user visits any site ending with .service or .dev, the DNS service will return the address of the services. Because most of the services are hosted on one physical machine, the nginx (reverse proxy) service resolves the incoming request to the corresponding service/dev.
* | if user visits another site eg. google.com, it will be resolved normally to the internet (albeit with a very slight latency overhead)

Going back to why nginx (reverse proxy) is a powerful tool, it's really the transparency that makes it awesome. When the user visits http://torrent.service, the DNS resolves it to the machine (eg. 172.16.1.66:80*). The nginx service listening on port 80 takes that query and forward it to the service (eg. 172.16.1.50:12345). However, to the end user, the URL never changes, the visible IP never changes, it all works seamlessly in the background.
* | IP and port number separated by semi-colon

eg. You navigate to the "downloads" page. The visible URL changes to http://torrent.service/downloads, it looks like it's 172.16.1.66:80/downloads to the system, but it's actually 172.16.1.50:12345/downloads. It all takes place automagically.

It's great when everything comes together but I definitely had my fair share of problems when setting it up and have to combine multiple sources of answers online before I could get my services running the way that I want them to. There is still 2 amazing projects that I'm looking to tackle before school starts proper, my fingers are crossed.

I'll like to clarify that when I say service, it may be made up of one or more services. For example http://torrent.service is made up of Transmission (the downloader service), and Flexget (the background service that searches for latest episode).

To end it off, everything is hosted either on my secondhand Thinkpad X200 (released in 2008), or on a Raspberry Pi 3. So if there's anyone who's interested in sponsoring me for anything (I can even make a video about it), contact me.

Labels: , , ,


End of Year 2 Trimester 2
Friday, April 21, 2017

I barely survived the previous trimester.

Everyone was slogging day in day out and my gaming hours plummeted like United Airline's stock. [link] My grades weren't terrible but my feelings were. Cramming knowledge in the day, Skype meetings at night; that's the routine for most of my friends.

The first couple of weeks was fine, but then it suddenly escalated and we didn't have a breather for approximately 9 weeks *insert too damn high meme*. Even though it was tough, I'm glad to say that we did manage to build some decent software at least.

1. Android application that detects exercise
2. Crowd sourced story writing web platform
3. Multi-cast chat application (invite/leave/kick/register/switch)
4. Hadoop Map Reduce Twitter analyzer

Shot and edited 2 videos in the process of doing all those.

1. Android showcase [link]
2. Foley (sound design self-learning mod*)
*it's about pedagogy and I'm too lazy to explain it

Apart from the school work itself, I've also gotten more familiar with how Docker works and can host simple web applications on my server (which I now realize I totally forgot to write about).

Also managed to pick up a part time job for the school; can't really say much about it but at least there's a small income for it.

I closed my eyes and thought hard about the past 3-4 months, thinking if there's any interesting/funny story that I could share and write down for me to remember. But I came up with nothing. It was just really tiring throughout, dealing with people, bugs, and deadlines. I felt like I died a little on the inside dealing with the people.

Not all teammates are bad of course, but the ones that are; they're  freakin' terrible. Sometimes it's just easier to do it alone, or with one other friend that you can trust to have your back.

Moving on, my exams ended 2 days ago.
I've done pretty much nothing but play games for the past 2 days and I think I'm getting a little bored with the games. Going to work on my personal project tomorrow and hope that I can get it working.

Oh and tech stuffs that I've gotten myself in the past couple of months!

1. Cooler Master MasterKeys L Pro White (brown switches)
2. Cooler Master TKL wrist rest
3. Withings Activité Pop watch (activity tracker)
4. Clear screen protector for MBP 13" 2015
5. Braided USB cable

I guess I should work towards being more thrifty in the coming months. (unless there's an insane sale going on)

The Withings Activité Pop retails at $259 and there was an online sale for $99, couldn't miss such a deal. But the high quality version went on sale the next week for ~$126 and I totally regretted getting the lower quality one. Well, you win some you lose some.

Alright this has been a really boring post, more note to myself honestly. Till the next time.

Labels: , ,


First week[month] of school
Monday, January 30, 2017

-- Edit --
Well I wrote this post on the first week of school but I totally forgot about it.

Blink of an eye and I'm back to school. The anticipated mad rush of projects and tests will be chewing my ass out again.


This trimester is a little different because some profs allowed us to choose our own teammates. It's awesome that you get to work with your clique but it's also a toxic process where you can see the weird people get outcasted. Some even kicked* out of their own groups.
*kicked may be too harsh of a word


Anyway, I visited the Art Science museum with my girlfriend at MBS for the future world exhibition last month (December). Took some nice shots but the exhibition is kind of underwhelming to be honest. It's just a lot of pretty lights and some motion tracking stuffs.

Maybe I'm not that impressed as I'm in the IT industry.

The lights are really pretty though, and you can see tons of people spending long periods of time trying to get that perfect shot to go on their social media. We lingered awhile to soak in the feels before leaving this alternate universe.



This month we visited the Art Science Museum again, for the NASA exhibition. It would be awesome if we're both equally as hyped about it but this is definitely a treat for me. I've always been attracted space since young, pretty much borrowed every space book in my primary school library.

huge ass engine (replica)

It's a little bit disappointing in the sense that most of the stuffs there are replicas and not the real shit, but still, I have not seen any of the rockets to scale before so this was an eye opener.

The moon rover!

The inside of the space shuttle cockpit

There quite a lot of rocket parts on display, but a lot of them are rather boring like spacesuits and all. I think that this kind of exhibitions requires a guide to actually explain what everything is about. Because there wasn't any, I ended up taking the role of the guide for her.

Well, the first week has been fun, let's hope that the next few will be as smooth sailing.

To end it off, I made gif of the fireworks I shot during the New Year Countdown over at Waterway Point. My friend suddenly asked me to go cycle with him, and we so happened to cycle to that area, and just so happened to see a crowd and we poked our nose in. I guess we're pretty lucky to have caught this sight!

yup, we were standing THAT close

-- Update --
Since it's the end of January I might as well finish writing about the remainder of the month

Firstly, school ain't as easy as I hope it to be. The projects are piling on and there are many things to submit each week. Thankfully I've managed to be grouped with some great teammates and it definitely eased some of the pressure.

There are 4 active projects currently.

1. Create an android app that uses sensors/network to improve the user's health.
2. A community story writing web application, where each chapter could possibly be written by a different author.
3. Create an online lesson regarding foley work. (sound design)
4. Create a prototype for a job scheduling system.

And I heard that there's going to be another project coming soon this week, fuck.

Thankfully, not everything is as bad as it seems. The work given has been manageable thus far and can mostly be finished within a couple of hours. My friends and I also started to play badminton more frequently and I finally bought my own racket. Haven't owned one since I was a kid.

I've also just bought a new monitor yesterday, it was on a crazy offer of $250 and it's too irresistible to me.

Dell SE2717H
It's a 27" monitor that would replace my god-knows-how-many years old 23" Phillips monitor. Had a really hard time deciding if I would get a higher quality 24" for $350, or this lower quality 27" for $250. The dilemma was real and I wouldn't want to bore you with the details.

In summary, I finally have a big monitor on my desk, flanked by my awesome Dell U2414H. 

OH but the first thing I used it for is to do some crazy internship programming test that lasted 3 hours. There was only 3 questions but god it was rather mindfucking. Okay that's all I can think of, till the next post!

Labels: ,


3 tips for easing jams on travelator
Wednesday, December 28, 2016

This topic is always on my mind whenever I see a travelator in a crowded area. Finally decided to write about it probably because of the videos I've watched recently regarding traffic jams where they described something called the ripple effect.

This video does a good explanation of the problem with traffic and the idea is similar to what I'm going to talk about.


A little background information
I take the train to school everyday and there's a rather long travelator on the connector between the purple and yellow line (which I take). Whenever either train line arrives, a good portion of the commuters will alight and make a beeline for the connector. Unless I'm ahead of the pack, the travelator will always end up being jammed with humans and no one can walk freely on it.

The amount of people ain't the main reason for the jam, but the amount of people who don't know how traffic works causes it.

Here's an image I've drawn to illustrate the problem.

the moving speed is just an example

As you can see, the travelator is moving at 3 meters per second. Some people will to stand on the left hand side to facilitate people who want to move faster on the right hand side.

Person A and B is walking on the travelator at 4m/s, adding on to the 3m/s that the travelator is moving at, their net movement speed is 7m/s. When person B exits the travelator, he should walk at 7m/s so that person A would not bang into him. But since a typical person would not walk at nearly twice his speed, B continues walking at 4m/s.
Hence B exits the travelator at 4m/s.

Can you see the problem here?

Because B is only effectively +1m/s faster than the speed of the travelator, anybody who is walking more than 1m/s will eventually have to slow down, and by slowing down way too quickly, the people behind him have to slow down even faster and some even comes to a stop. The exact same ripple effect observed in vehicle traffic.

Even if B exits the travelator at 6m/s, it still means that the maximum available move speed of person A behind him is only 3m/s.

Of course this is only a problem when the amount of people on the travelator hits above a certain sweet spot; as long as the commuters are spread out it should not cause a jam. But during peak hours, do yourself and your friends a favour, follow these 3 simple tips to ease the jam on travelators!

1. Exit the travelator as fast as you can (faster than the net speed of your walking + travelator speed) or just clear out of the way.
2. If there's a jam infront, walk slowly. Don't walk fast and then get stuck and stand there, it makes the jam worse.
3. If you're a slow walker, just walk/stand on the left hand side it's not going to take that much longer.

Labels: , , , ,


Disparity between mental image and real life
Friday, December 09, 2016

I've been inspired by real life and what I've been studying intensively for these couple of days. (mental vs. conceptual model)

Feelings are a terribly illogical thing.

We get frustrated at some thing, or someone even though it is not their fault. We just have the wrong idea (mental image) of how things are supposed to work. The larger the difference between our mental image and real life, the more frustrated we (or at least I) seem to get.

Let's take for example, I wanted to turn on a TV. Pressing the red button on the remote is what I think will turn it on, but for this weird-ass model, the steps for turning it on requires entering a pin, twisting the remote left twice and pressing a green button to turn it on. It's by no means the fault of the TV, but because it is so different from what I had in mind, it ended up causing some immense level of frustration.

Even though I seem to be aware of this phenomenon, I can't seem to control how I feel towards things; hence the "illogical-lity" of it.

My mental image of someone, does not shape who that person is. He/she is who he/she is and that's fine, but by projecting my ideas of how you are like and finding out that there is a difference in that; that kinda sucks. It is not the fault of that person nor the viewer (a.k.a me), sometimes our perspective on reality just don't line up perfectly.

p.s. If you're reading this, I'm sorry.

Labels: ,


Challenge me
Thursday, November 10, 2016

The title ended up sounding more aggressive than it really is but that's what I want. Lately I've been getting pretty frustrated over discussions with my group mates. It's not that they are always wrong, in fact, they often have better ideas than me; but they are not willing to argue about it.

They either just let me have my way, or ignore my protests thinking that I'm wrong. Neither of which really helps us get things done effectively. I really don't know if I'm overly aggressive when it comes to arguing points, but I hate it when people think I'm wrong but are unwilling to step up and tell it to my face. Just convince me and the rest that you are right, and we can change course immediately.

It's really not that hard is it?

Labels: ,