During the soft launch of Free Pee 2, I ran into a weird problem. Bathrooms that had Chinese descriptions wouldn't show up. Immediately, I thought of character encodings and database collation - but it didn't feel right because everything worked correctly in the original Free Pee app. Why did it suddenly stop working?

After lots of Google searches and Stack Overflow answers, I added $db->set_charset("utf8") to my mysqli object. It turned out that didn't solve the problem either. Finally, after almost giving up hope, I decided to re-save all my app files as UTF-8 (even though they've never been anything but UTF-8). To my surprise, that worked. I shrugged and moved on.

read on »

April 21, 2018 | 1 comment

As we draw nearer to the end of 2017, I'm beginning to reflect upon this year and all that has happened. Google has done a great job with the year in search 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. I launched the first private beta of Free Pee 2. I finally began seriously practicing Chopin's Revolutionary √Čtude. I flew more than 60,000 miles.

read on »

December 25, 2017 | 4 comments

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. Your client can listen for updates simply by adding an event listener: new WebSocket('ws://host:8080').addEventListener('message', ...);. Many people use Express 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 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.

read on »

November 26, 2017 | 1 comment

In preparation for the JavaScript Developers Conference (JSDC 2017) for which I will be a speaker, I started going through my GitHub 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 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 vs my very own Quantum.js's testing framework.

In Quantum.js, tests were fairly crude and straightforward. One unit, one assertion:

read on »

August 28, 2017 | 3 comments

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

read on »

July 22, 2017 | 4 comments

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.

read on »

April 4, 2017 | 2 comments

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. The nurse shoves a long cotton swab into your throat and moves it around. You push her hand away reflexively because DUDE I almost just threw up all over your face!

read on »

March 11, 2017 | 5 comments
© 2018 Michael Cheng
made in Taiwan