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 ruby-forum.com gave an excellent explanation:

Read the rest of this entry »


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

How to export a big MySQL database?

If you have large production MySQL database that you wish to backup or replicate for testing, it is important to handle the export gently :)

For me, I use mysqldump. Remember that you must include several optional flags, which will speed up the export and most importantly avoid stressing your production MySQL.

mysqldump -u[username] -p[password] [database_name] --no-autocommit --quick --opt > dump.sql

–no-autocommit: Insert “SET AUTOCOMMIT=0;” and “COMMIT;” into the SQL dump. Enable speedier import later on.

–quick It retrieve a row at a time from MySQL instead of the entire rowset. It is very useful for dumping large databases.

–opt: This is enabled by default and it is a shorthand for –add-drop-table, –add-locks, –create-options, –disable-keys, –extended-insert, –lock-tables, –quick, and –set-charset.

Read the rest of this entry »

Tuple + Tuple?

An interesting trivial task is to concatenate two tuples in python.

Let’s say we try this out:

a = ('dd')
b = ('aa','bb')
print a+b

Unfortunately likely we will get the following error:

Traceback (most recent call last):
File "test.py", line 20, in <module>
print a+b
TypeError: cannot concatenate 'str' and 'tuple' objects

Read the rest of this entry »