Prevent concurrent execution using file locking


I had some issues with puppet provisioning where two python executables were exiting with 1 instead of 0 (in unix means something went terribly wrong :D) and no logs were recorded eventhough I’ve written bunch of logging lines (that’s very unfortunate). It was later discovered that there were race conditions were these two python executables should not run concurrently. A solution to this was using file locking. As I only need one of them to be executed, possible way out is to stop execution if a lock is detected.

So I experiment with some simple codes like below:
Read the rest of this entry »

MySQL Profiling

If we ever wondered what’s the performance of a MySQL query and a SELECT query be more efficient (and hence faster)?

MySQL has an embedded profiling feature that we can use from stock MySQL.

To enable it, it’s pretty simple:

mysql> SET profiling = 1;
Read the rest of this entry »

2014 StanDesk 2200

2014 StanDesk 2200

A blatant rip-off of StanDesk 2200, with a twist of a lower budget.

Read the rest of this entry »

Hash#each vs. Hash#each_pair

Sometimes I find each and each_pair kind of confusing. Though Ruby’s API Doc has been one of the most well documented API Doc, it is not very helpful in showing the difference between each and each_pair.

Peeps from gave an excellent explanation:

Read the rest of this entry »


Kudos to Doulos Presbyterian Church for initiating this!
#PrayForMH370 with DPC & KPC