Monthly Archives: August 2011

MYSQL drop all tables in database in linux

Taken from


mysql --user=$1 --password=$2 -BNe "show tables" $3 | tr 'n' ',' | sed -e 's/,$//' | awk '{print "SET FOREIGN_KEY_CHECKS = 0;DROP TABLE IF EXISTS " $1 ";SET FOREIGN_KEY_CHECKS = 1;"}' | mysql --user=$1 --password=$2 $3

Save code above in a file, say, mysql-drop-tables. Then change the permission to excecuteable

chmod +x mysql-delete-tables

Then run it

mysql-drop-tables dbuser dbpassword dbname

Here’s fhe file if you’re too lazy to copy paste


Installing PIL in virtualenv in Ubuntu

To install PIL in virtualenv in ubuntu, these are the steps:

  1. install the dependencies needed to build PIL

    sudo apt-get build-dep python-imaging
  2. then run these commands

    sudo ln -s /usr/lib/i386-linux-gnu/ /usr/lib/
    sudo ln -s /usr/lib/i386-linux-gnu/ /usr/lib/
    sudo ln -s /usr/lib/i386-linux-gnu/ /usr/lib/

    If you’re using 64bit system, switch i386-linux-gnu to x86_64-linux-gnu.

    If you don’t do it, you might see these messages when after building PIL, and you won’t have jpeg support.

    *** JPEG support not available
    *** ZLIB (PNG/ZIP) support not available
    *** FREETYPE2 support not available
  3. Last command, install PIL

    pip install PIL