Author: hatem

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! python -m smtpd -n -c DebuggingServer localhost:1025

continue reading
No Comments

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 sudo dpkg –add-architecture i386 Install cups 32bit libs sudo apt-get install libcups2:i386 Download the lpr and…

continue reading
No Comments

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 WARNING: Attempting to work in a virtualenv. If…

continue reading
No Comments

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+) from collections import OrderedDict import json r = json.load(open(‘file.json’), object_pairs_hook=OrderedDict) print json.dumps(r, indent=2)

continue reading
No Comments

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 install: do-install production-deploy do-install: #… all deps gcc … production-deploy: production-ask rm -fr / %-ask: @python -c ‘raise SystemExit(not raw_input(“All Done! Are you sure you want to install to…

continue reading
No Comments

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…

continue reading
No Comments

Set phantomjs user-agent string

Set the user agent for phantomjs driver from selenium import webdriver from selenium.webdriver.common.desired_capabilities import DesiredCapabilities dcap = dict(DesiredCapabilities.PHANTOMJS) dcap[“phantomjs.page.settings.userAgent”] = ( “Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/53 ” “(KHTML, like Gecko) Chrome/15.0.87” ) driver = webdriver.PhantomJS(desired_capabilities=dcap)

continue reading
No Comments

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: column -s, -t

continue reading
No Comments

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.

continue reading
No Comments

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/…

continue reading
No Comments