Topics: 2014

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:

#PrayForMH370

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] […]

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