API Rate Limiting

Since WordPress’s new admin site is so awesome <insert emoji with heart eyes>, I think I should document my little learning notes here instead. Shall use a sub-domain for this WordPress in time to come!

Letterbox’s traffic went a bit off today, causing our instance’s CPU usage to spike. Apparently people were spamming API calls to our server, resulting in some form of DoS attack, well but it didn’t exactly crash/overload it.

Do things that don’t scale, right? It probably slipped our mind when designing the API, thinking that all users would be angels and not do weird stuff like that. Clearly we were wrong. Also this would be needed in time to come when the API calls start to exceed Facebook’s API rate limit.[1]

API Rate Limiting is basically restricting the number of times a particular end user is able to call the endpoint. There are a couple of ways to do this, and the way that we chose would be to utilize a Redis cache.

The idea is to have a key-value pair (user ID as the key and times accessed as value) that will update everytime a call is made, and Redis is perfect for handling little tasks like that.

There’re many considerations to take into account for such a simple implementation. A cursory look online points to having to deal with HTTP headers (agh damn networking), different time buckets and also pipelining. It is certainly good to dive more into the details in time to come, but then there’s finals.

So instead of reinventing the wheel, I opted to use express-limiterIt’s already written and works right out of the npm box. [2] The task is done in around 10 lines of code.

var redisClient = require('redis').createClient();
var limiter = require('express-limiter')(app, redisClient);

 path: '/matches',
 method: 'all',
 lookup: ['user.id', 'connection.remoteAddress'],
 total: 50,
 expire: 60000

These few lines of code simply set a 50 call limit to /match endpoint, and sends a 429 if there are anymore calls from the same user IP thereafter. It does not seem like much but I think as a frontend developer since forever, I’ve not been able to appreciate such backend concepts.

A little something I learnt today, besides SQL, DRC/TRC and Relational Algebra. Yup CS2102 is coming up next.

Oh and I realized at the end of writing this post why I wouldn’t document more craft related post here. Typing code into WordPress is still pretty painful. 




[1] Well… a problem for next time.
[2] Loses a lot of flexibility though.


Where the Actual Learning Takes Place

Just came back from lunch in a pretty cool suite and it gave me a little musing/flashback.

As my Economic teacher in Junior College used to tell us when we’re in the middle of a chaotic discussion about any concepts:

Go ahead. Discuss. This is where the actual learning takes place.

It’s been three semesters in NUS and I’ve been studying in solitude for the exams every single time. Perhaps the modules I did the best for were ones that I actively participated in discussions about concepts.

CS1101S only got slightly more interesting towards the end where I actively discussed with Alex about the concepts. CS1231, CS2100 and CS2020 was fun throughout since Ryan and gang were there for me. Those modules which I did the worse for were those that I did alone, like Calculus and General Biology. For this semester, Computer Networking was a total nightmare that will probably come back to bite me in the ass.

I remember writing a blog post way back during army that learning alone is tough. I was struggling with C++. There wasn’t anybody to direct your concerns to, nor have a casual conversation about concepts and ideas. True learning takes place best when there is active discussion.

Maybe this is something I missed out, and I wish I hadn’t. It is difficult to step out of this bubble that you surrounded yourself with.

Also, I feel it’s important to keep myself grounded. Remove myself from the attention that I’ve been getting lately and focus on personal growth and development. I’m not that great.

Afterall, glory isn’t permanent, skills are.

CS3216 Post Mortem

It was a bold decision to take this module in the first semester of my second year, and I certainly do not regret it. Not many people are given this opportunity and I certainly learned much much more from this module than all other modules combined.

That being said, I am probably very screwed for finals. The first paper is ~4 days away and I’m not prepared. At all. (Yet I’m still writing this post because this is how much I appreciate CS3216)



Never be over ambitious.

This was really the primary takeaway from this first assignment. Another would be to manage team dynamics properly. There wasn’t much team structure in this first assignment and I thought part of it was because it was poorly managed.

The product itself was a simple idea, match NUS students together in an anonymous chat. Thinking back now, what was the entire point of this? Does it really help students meet, and what problem does it solve? This idea was clearly not very well refined.

Technically, it gave me a (painful) insight into React.js and the different Flux architectures. But given another opportunity I would have chosen something simpler, or simply do Vanilla React.js to facilitate the learning curve.

Of course, learning fast is one of the main goals of CS3216. But it is important to set some clear boundaries of what are our limits and make appropriate adjustments if things are not working out.

Seminar on Medium

Simple UI doesn’t mean fluid UX.

Assignment 2 allowed me to develop a keen eye for good products and of course critique bad ones. We chose to critique Medium. Initially I thought that we’re outta our minds.

Medium is so well designed and thought out. What is there to critique?

But at the end of the day, I’m glad that we chose a difficult app to critique. It shows us that even good apps have their flaws and weaknessses. The ability to nitpick on the fine points also allows us to do the same for our own products.

It forces yourself to think about what the user thinks. As very technical people, our ‘user experience’ is often clouded by our own knowledge of technology. Users are stupid. It’s tough to place yourself into their position.

This assignment taught us how to be stupid, somewhat. (Lol.)



Niche apps don’t get as much attention.

This was one of the more niche projects that I’ve done. The grades for this project was not up to expectations at all and I think it’s largely due to the fact of it being very niche.

Not many people would appreciate reading server logs from their mobile phones unless they are DevOps Engineers or really technical people. Given this fact, it is difficult to convince people to use such an app.

As always, I worked on the frontend using React.js and it taught me how to appreciate Flux architectures more. Although the focus was on a mobile web app, we built it on Ratchet with a very stock design. On hindsight, more could have been done to include branding. The inital plan was to come up with a functional MVP which serves the purpose of the app instead.

Despite a really poor grade, there were still lessons learnt from this assignment.



This was where the bulk of learning came from. Taking in lessons learnt from the first three assignments, this was a very well refined and validated idea. As the Product Manager, it has also given me the opportunity to negotiate, network with people, and manage a team.

Talking to People

It takes a bit of getting used to talking to strangers about an idea, and asking for feedback. It started with talking to people along AS6, to talking to even more random people at UTown to get photographs.

It allowed me to step out of my little bubble and discover things that I never thought I could do. It also removes the awkwardness that was present in me.


Our product was built on Ionic framework, which made this very easy to iterate and deploy on both iOS and Android. Angular.js abilities have also up-ed by quite a bit and I’m more familiar with SPA concepts.

Next steps would definitely be development on Native platforms, or a better Web platform.


Maketing was part of the grading scheme, but lots of it was done for the product because we take pride in what we do. Facebook page, posters, and partnering up with the right people has led us far and the results were pretty satisfactory.

Winning STePS

Yes, not to mention, we won the Best CS3216 Project for School of Computing’s Student Term Project Showcase. :) It was really tiring since we had to do our sales pitch non-stop. I lost my voice momentarily after STePS was over. It was insane.


Overall we’re very satisfied of how far Letterbox has progressed from just an idea into an actual project. Hopefully we can take this to even greater heights! :)

CS3216 has been the main highlight of this semester. The next year would be a total different ball game in Silicon Valley and NOC. There’s much more to learn and experience. That being said, Letterbox will not die, and will continue to grow into something that we can be really proud of.

Cheers. 🍻

Oh I’m a mess right now, inside out.

It’s only after recess week and my semester just took a turn for the worst. A series of events happened and I really feel bad about the way I took it in my stride.

First of all, midterm results were not satisfactory. I performed slightly below average for both papers. Given that I only had two papers to prepare for, this was a total letdown.

Seriously, I had a week to prepare for two papers and I performed lower than par for both?

Next up would be the preparations for technical interviews. Having done a summer of software engineering, my algorithmic thinking skills have more or less degraded. It’s true that the foundation from CS2020 will get me back up to speed in no time, but I should keep in mind to do some algorithm exercises every once in a while to warm myself up again.

Lastly, I have serious issues with my CS2105 assignments. 50% for the first assignment because I submitted it with the wrong file name, while another 50% gone because I used some boilerplate code online for the second assignment. I got 2 more assignments to go and hopefully it will go better than the first 2.

Why do I write posts like these every once in a while? It probably makes me feel that I am doing some reflection on my life, and to some extent make myself feel better about the situation I’m in right now. Which is exactly what these posts allow me to do, calm down. 

Here are my three re-evaluated priorities for the remaining 4-5 weeks of the semester:

Letterbox – my CS3216 baby

This project is what makes this semester so much more worth it. Having a project that I care about to work on. Not going to reveal too much about it here, but here’s the awesome logo that my teammate designed:


Really excited to ship this by Monday night if possible!

Technical Interviews

There will be a bout of interviews heading my way soon and I need to be prepared for them. That means to revise my algorithms as much as possible, and get familiar explaining them to people. There’s a couple of ways I can do this. 1. Do as much Hackerrank problems as possible, or 2. Go through my CS2020 concepts once more. (I still have my cheatsheet with me)

Or a combination of both if I have the time. I think the latter should be a better option since I need a serious refresher on my basic algorithms & data structures.


I’ve been neglecting this aspect of school a lot this semester. Putting in only minimal efforts for my other modules. Perhaps it’s time to start revising for finals considering that I am lagging behind in the first place. Set up a timetable to see how much time I have left again and proceed on from there.

I once told myself that “having poor results for other modules due to CS3216 is bullshit.” I still think that is the case and I’m not willing to give my results up for this semester. It is possible to have the best for both and the only reason why it is not happening is because I have not been trying hard enough. 


Half-time, once more.

It’s the semester’s half-time again. This time I didn’t spend it studying my ass off in school. I actually did project after project and went home for a break. Having only two papers next week, I feel strangely confident. That’s a bad thing.

I have a tendency to stay in school most weekends for fear of disrupting my workflow. But this semester has been different, I have not been focusing on what is important.

This half-time was spent productively at home.

I got actually got things done at home. I revised for my papers and finished what I needed to do for my projects. Perhaps I needed a change of environment. A much more relaxed and slow paced environment. Having done a fast-paced internship over the entire summer without a proper break is probably taking its toll on me, finally.

Yet another pain is about me being busy. Sometimes I don’t even think I am busy doing things, I’m busy being busy. This is really worrying because that’s the pathway to being the best procrastinator in the world.

In other words I feel like I should probably get my shit back together for the remaining 6 weeks of the semester.

Randy Pausch said this in his famous The Last Lecture:

When you are doing something badly and no one’s bothering to tell you anymore, that’s a very bad place to be. Your critics are the ones still telling you they love you and they care.

I’ve got people in my life who still genuinely believe in me and I am ever grateful for their existence. Here’s to a better second half of the semester. 🍻


I wrote about not treating school seriously previously and felt that maybe it is time to do some life restructuring.

It’s already 3 weeks into school but I don’t feel like I’ve learnt or achieved much at all. I need to tidy up what’s currently on my plate since I have so many things to juggle at a single time. Mostly CS3216, NOC application and IFG basketball. (Which I didn’t make the team for this time)

Trying to do something on a regular basis develops a habit and I think habit is exactly what I need right now. So just three simple things to do regularly:

Finish up all other tutorials before touching CS3216

This has proven to be a problem so far this semester. I’ve been neglecting my other modules. Thank goodness they’re still pretty easy and straightforward, so not much time is needed to catch up. But building a project while being in school really distracts me from what I need to do. This feels something like CS1101S in my freshman year, but worse. This shall remain as my number one priority because it’s only going to get more hectic as the semester progresses.

Do one algorithm challenge in Python, every week.

Since I’m already doing my Database Management project and Networking assignments in Python, why not master this neat little language this semester? (Together with 3216) Doing algorithm questions in Python kills two birds with one stone. Both having a better grasp of the language and keep my fundamentals fresh in my head. It’s been quite a while since I’ve done any form of sorting, graph theory. I can’t even remember the previous time I used a recursive function.

Software engineering is all useful and cool, but I still need to polish up my fundamentals. Lacking any useful fundamental course this semester, this is the only way I can keep my theory in tip-top condition.

Waste no time on other useless things.

Relax time should be spent on purely resting and relaxing, not on things that will waste more energy. Social media is one huge bane of productivity since ‘social media breaktimes’ usually extend beyond what was initially planned.

Relaxation should be limited to these three activities:

  1. Music, play the guitar
  2. Reading
  3. Exercise

The general rule of thumb that I should follow is that if I’m doing nothing, I shouldn’t be on social media.

I was watching the sunset from my window ledge just now and reflected a bit on what has been going on lately. I might be good at coding, I might have a fiery passion for my craft. But I’m not the best, yet.

There are also other things that I am not good at, my weaknesses and flaws. Nor am I that talented in any other crafts or hobbies like guitar and photography.

If coding is my only talent, I better be damn good at it.

Here’s to more good news in time to come!

The view from my room:


Learning Through Mistakes

Just came back from a CS3216 talk on Growth Hacking by Zopim’s Bjorn (very cool name I swear) and Wei Xiang. It was a pretty inspiring and relatable talk especially after I completed an internship at a growing startup.

One of the more relatable point that was mentioned is learning through mistakes. Several questions were brought up on rewriting the tech stack and choosing the right stack from the beginning. I think Wei Xiang did a great job addressing these concerns that us budding software engineers often have. While there are really ways to learn by RTFM (Read the F-ing Manual), some things can only come with experience. Going through the process of making a mistake and recovering is actually the best process of learning. This gives me more confidence that what I’m doing for my project technically is correct (even though it might be all the wrong decisions made, but at the end of it I’ll learn something).

CS3216 is really fun, but I’ve been neglecting my other modules. Should probably start to take school a bit more seriously. I have no regrets taking this module so early on though. Skills acquired here will definitely be of great value!

Fingers crossed that all will go well! :)