FastIris

There are only 2 bus companies in Singapore. SBS Transit being the largest and whose buses I travel on most frequently.

They released an iPhone app called iris, for poor people like me who cannot afford our own mode of transportation,  which we can use to check the time the next bus will arrive at a specified bus stop.

It was frustrating to use. I hated the loading screen which wastes a few seconds of my time. And then I had to spend a few taps to get to my favourites list which I’ve added the bus numbers that I frequently use.

On top of that, there are frequent unknown errors and I would have to try and reload the bus timings again and each load takes a long time to complete.

I happened to learn about the mitm proxy tool from an article that exposed how the Path app was sending user’s address book info in plain text to their servers.

This tool can be used to analyze traffic data between a phone and the internet. So I set it up and used it to analyze the HTTP requests made from the iris app.

It made a lot of requests which explains why it’s always so slow.

So knowing the structure of the data that was sent and received from the iris servers allowed me to write my own web app to get the information I want. And the result…

fastiris

It worked perfectly. And very fast.

I’ve added it as a bookmark icon on my phone. One tap, it brings me to the browser and loads my web app. Instantly, I’m shown a list of bus numbers that I frequently use. Tapping on the bus number, will load the next and subsequent time remaining till that bus arrives at the bus stop. That’s all I need.

There’s even a short cut to load the timings for 2 buses that I travel on everyday to get to work.

It uses cache.manifest to make the browser cache the jQuery file and the index file, this made loading the app almost instant.

I’ve also added 2 fields at the bottom which takes in the bus number and bus stop number so I can check the bus timings for other buses just in case.

tl;dr: programming and computers are fun.

Can’t open NetBeans’ preferences on MacOSX

This problem has happened to me before and I forgot how I fixed it. Thus, this warrants a blog post to remind me how I fixed it!

The problem: Editor fonts look weird and the Preferences window refuses to open.

This may be because Java 1.7 is installed or in use. NetBeans on OSX does not work well with this version. You need to uninstall it by deleting the JavaVirtualMachine from the /Library/Java/JavaVirtualMachines folder.

Google for 1.6 to find the download on Apple’s website. Or if it’s already installed, run java -version in terminal to find out what version is active.

So much hate to the point it just seems silly

TL;DR: Buy things that suit your needs well and shut the hell up unless someone asks for your opinion.

I don’t mind when people bash Apple’s products if they have good reason.

But nowadays people are doing it simply because it’s cool to do so.

It hurts a little when you’re targeted because of the other fanatics who believe in the same brand as you do, and yet you’re not as extreme as them.

Now I know how some Christians feel when I used to show my dislike towards their religion. (This happened during the days when I was young and foolish!)

Because these situations are so similar.

I used to dislike Christianity because of some extreme believers pushing their beliefs onto me, but then I learned that not all Christians are like that.

Hey, I’m just a regular guy who’s eager to give up his money for products that work well, for content that entertains me well, for services that serve me well.

Louis CK said it best. Everything’s amazing, nobody’s happy.

Hosting websites on an AWS EC2 micro instance

A few months ago, I signed up for an account with Amazon Web Services to take advantage of the first year free usage on EC2.

It was a great learning experience as I get to configure everything in detail.

With shared hosting, someone else does the setup and maintenance for you. You can configure a few things in detail but you can’t have full control. It’s like public transport, you cannot change the parts in the vehicle, but you can choose where you want to sit, but you have to share the ride with a lot of strangers.

And it sucks if you have to share it with a serial fartist. i.e. Some silly person who took down the whole server with poorly written codes that take up lots of CPU, or whose website is the target of a DDOS attack and all other websites on the same server got brought down with it.

There’s also co-location and dedicated hosting but those are not affordable to the average web developer.

Then comes the age of cloud computing.

You get full control of a server at the cost slightly higher than shared hosting. You have dedicated CPU and RAM resources so no other server on the same physical machine as you can affect you. (Though I’m not sure what happens if those servers get DDOSed).

Long story short, my shared hosting account with DreamHost was expiring and so I migrated my remaining sites to my AWS micro instance server and here’s the things that happened and what you need to do if you want to run multiple websites on a micro instance as well.

At first, I did not configure my Apache and MySQL installations to work on low RAM machines (micro instances get only 613MB of RAM). They came with the default configuration settings that are meant for dedicated machines that have higher amounts of RAM.

A micro instance does not have a swap file configured. You have to do it yourself and here’s a simple guide:

Switch to root and follow these steps to add the swap space –

Type the following command with count being equal to the desired block size:
dd if=/dev/zero of=/swapfile bs=1M count=1024

Setup the swap file with the command:
mkswap /swapfile

To enable the swap file immediately but not automatically at boot time:
swapon /swapfile

To enable it at the boot time, add the following entry into /etc/fstab:
/swapfile swap swap defaults 0 0

 

Source: Adding swap space to Amazon EC2 Linux Micro Instance to Increase the Performance

Next, edit your apache config file and look for the Server-Pool Size Regulation section.

Most likely you are using the prefork MPM. Reduce the MaxClients to about 10. This varies depending on how much RAM each process takes. From my observations, my httpd processes take up about 40M of RAM at most. So I use 10, which allows me to have 10 running httpd proccesses all taking up 400M of RAM.

It would also be a good idea to reduce the MaxRequestsPerChild to something around 1000 in case of memory leaks. Situations where a process takes up more than 40M of RAM and keeps growing.

Better explanation here.

Without the above. My apache kept spawning child processes so much that it used up all available RAM and my MySQL process got killed off frequently. That means all my sites that are database driven are immediately crippled.

On a related note, back when I was a child, I loved how I could change parts on those Tamiya cars which gave me the illusion that it would run faster. Looks like my fetish for performance tuning is still there.

RL

I really like your framework. I use it at work and at personal projects.

I’ve recommended it to others even though there’s no benefit for me.

But I have a problem and a few others have the same problem too.

But you won’t make the patch for us because you have other more important things to attend to.

You said if we want that feature, we should code it and submit a pull request for it.

So I coded the patch, learned how to work with GitHub, submitted a pull request.

Other people who shared the same problem were happy.

Days go by and yet there’s no response from you.

I wondered if there’s a problem with my solution so I tried to propose an alternative.

But you said the original solution was fine, just be patient because you guys have real lives too.

Weeks later, still no response.

And now, I sit here wondering why did I even bother in the first place.

Just a small rant.