25 Dec Looking back at 2017
As we draw nearer to the end of 2017, I'm beginning to reflect upon this year and all that has happened. [Google](https://google.com/2017) has done a great job with the [year in search](https://www.youtube.com/watch?v=vI4LHl4yFuo) video, and I highly recommend that you take a look to see the year summarized in a short-but-great 2 minute video.
For me, this has been an interesting year indeed. Living in Chicago has been going OK, and I've definitely learned a lot in many aspects. This year, I gave my first talk at a [developer conference](http://2017.jsdc.tw/). I launched the first private beta of [Free Pee 2](https://www.iqwerty.net/freepee2/m). I finally began seriously practicing Chopin's Revolutionary Étude. I flew more than 60,000 miles.
continue reading
26 Nov Long polling: the poor man's push
Having a server push data to the client is one of the coolest things you can do for your web application. I'm sure we've all came across this issue before: when writing a chat app, you do something like `(() => setInterval(getMessages, 1000))()`. The problem is, you only get new messages every 1000ms. No matter what interval you choose, it's either going to be too long or too short. This is what "polling" is - the client periodically pings the server for new data.
Today, pushing data can be accomplished using [WebSockets](https://developer.mozilla.org/en-US/docs/Web/API/WebSocket). Your client can listen for updates simply by adding an event listener: `new WebSocket('ws://host:8080').addEventListener('message', ...);`. Many people use [Express](https://expressjs.com/) with a NodeJS backend for their WebSocket adventures. This is fairly easy to setup since all you need is some VPS somewhere. However, hosting is not free. I've used [Vultr](https://www.vultr.com/pricing/) before and it's quite nice, but it's still a monthly expense on top of the shared Apache hosting I currently buy. How can we achieve push without shiny new tech like NodeJS and Express? Enter long polling.
continue reading
28 Aug Software testing
In preparation for the [JavaScript Developers Conference](http://2017.jsdc.tw/) (JSDC 2017) for which I will be a [speaker](http://2017.jsdc.tw/speaker.html), I started going through my [GitHub](https://github.com/mlcheng) projects again... In particular, I noticed my tests were not as good as they could have been, especially for projects like [Free Pee 2.0](https://github.com/mlcheng/freepee-web) where I actually only test the API. This is a direct result of my stubbornness in refusing to use third party libraries for something I could write myself. In this case, I'm talking about [Jasmine](https://jasmine.github.io/) vs my very own Quantum.js's [testing framework](https://github.com/mlcheng/js-test).
In Quantum.js, tests _were_ fairly crude and straightforward. One unit, one assertion:
continue reading
22 Jul Chicago, so far
So it's been half a year since I moved to Chicago. Things are going well I suppose. I've experienced the harsh winter of Chicago, but I've also seen the infamous beautiful sunsets of this city.
![Chicago sunset](/_static/stuff/2017-07-22-IMG_20170502_195110.jpg)
continue reading
04 Apr The multiverse
Here's an interesting one. The multiverse hypothesizes that there are multiple universes that run parallel to each other. But that's just a very rough description. Apparently there are many definitions and many theories - and it's possibly not even real. But that's not the point. I just wanted to write a bit about a dream I had last night. Something interesting. Something about a multiverse. So here goes, as best as I can remember.
The dream started out on the day the world ended.
continue reading
11 Mar Strep throat
So imagine this: you wake up one morning and you feel a slight sore throat. OK, no problem, you've been sick before. Let the team know you'll be working from home, and drink lots of fluids. "Hope you get well soon!" coworkers cheerfully reply to your email.
The next day lymph nodes swell up. A small fever starts. You Uber to the urgent care clinic and they administer a flu swab. Negative. Then comes a strep [rapid swab](http://www.webmd.com/oral-health/rapid-strep-test-for-strep-throat). The nurse shoves a long cotton swab into your throat and moves it around. You push her hand away reflexively because OMG I almost just threw up all over your face!
continue reading