Create a quick SMTP debug server

This creates a little server running on port 1025 to test if your apps are sending emails properly or not!

Installing HL 3040CN Brother printer in Debian 64-bit (The Real Manual)

Although the brother website has instructions for debian/ubuntu 64bit they only actually work for ubuntu (actually they might not even work with the latest ubuntu) … on debian the instructions should be more like this:

Enable multi-arch for 32bit

Install cups 32bit libs

Download the lpr and cups drivers from brother and install them:

You should be good to go if you device is connected via USB, otherwise you will need to go to your local cups and reconfigure the printer to the proper uri.

Running iPython cleanly inside a virtualenv

If you run ipython directly on the commandline without having it installed inside the virtualenv you are working on you may get some awkward behaviour since iPython will be running a mix of environments (system wide + virtualenv) … normally you would see an warning as follows

To avoid this I use an alias that makes sure iPython is loaded from inside the venv … here it is:

Edit: as of ipython 1.0 this is the new alias

now running ipy I will know for sure that I am running within the venv.

Parse JSON into ordered data-structure (in python)

In many cases it is essential (or at the least nicer) to preserve key order from a parsed JSON document, here is how to do it in python (using the std lib json module and OrderedDict available in python 2.7+)

GNU Make Tips & Tricks

I have 2 little unique tricks that I use in make files and would like to share, here they are …

Ask for “yes” before proceeding

Wait a few seconds before restarting, allows for operator cancel via Ctrl-C

Proxmox Change Node IP

Whether you need to change a proxmox node’s ip or change the hostname, the steps are the same. In my particular case, I have two networks, a fast network and a faster network, so I wanted to switch all my proxmox hosts to use the ip address associated with the faster network interface … to do that

For each node in the cluster, change the /etc/hosts file and make sure each hosts new ip address is associated with its name.

For each host, go ahead and run the following command

Set phantomjs user-agent string

Set the user agent for phantomjs driver

Pretty Print a CSV file

Have you ever had a csv (comma separated file) file that you wanted to see nicely and did not want to open up a spreadsheet editor just to be able to see it in a readable way. Well the following command works with most csv files and will do just that:

If you have commas within your data you might want to use the following longer but handy linux command:

My New Favourite Vim ColorScheme

I just fell in love with the 256-jungle colorscheme, it is awesome on so many different levels. Best of all, in vimdiff its not blinding and is actually readable.

How Swap works (in Linux)

I was recently asked how swap works, and it turns out, I knew nothing about how it really worked … i.e. when, what and why does a linux kernel move memory into swap space. Its probably because I hate swap and I actually disable it on my desktop/laptop/netbook systems I own. I decided to learn more about swap and found this awesome article on Linux weekly (LWN.net) which describes this behaviour exactly¬†http://lwn.net/Articles/83588/.