Installing Scipy on Mac OS X Mountain lion

A quick note: if you are stuck try these:

export CC=clang
export CXX=clang
export FFLAGS=-ff2c

in the terminal, and then run:

pip install git+http://github.com/scipy/scipy/

There goes my 2 hours. Enjoy!

A simple and dirty batch job scheduler in python

Last week I needed to feed jobs defined in an internal web interface to the computation engine. Below is the code I wrote, which looks at the MySQL table for the defined jobs, and executes a command line code. Can it be done better? let me know.

Let's import the necessary libraries first:

#!/usr/bin/python
import sys, os, time
from time import gmtime, strftime
import string
import MySQLdb as mdb
import atexit
import threading
import subprocess
import shlex

Next, define how to connect to mysql:

# Connect to DB -----------
db_host = "127.0.0.1"
db_db = "test"
db_user = "root"
db_password = "tooth"

con = mdb.connect(db_host, db_user,
        db_password, db_db);

app_path = "/Users/danialt/software/"
db_port = 3306
pr = {}

Continue reading

TikZ: A better way to draw scientific and technical diagrams

In preparation of my last paper I needed to draw a detailed complex diagram. Since I use LaTeX and source control (git) I did not want to use Adobe Illustrator (which I don't have a license), Inkscape (great package, though still very limited for complex diagrams), and other common ones such as Corel. Needless to say that all their formats are binary and not source-control friendly.

After a quick search I found TikZ. It had a wow effect on me right away. In TikZ, you can use the full power of LaTeX (as in typesetting), and in addition enhance your diagrams with the power of programming. You can create this kind of diagrams in a minute:

Tikz fun diagram

Continue reading