Category: technical

Multiple ENV vars with UWSGI

To send in multiple environment variables using the uwsgi ini, you just need to pass in multiple env parameters for example: [uwsgi] plugin = python27 enable-threads = true single-interpreter = true virtualenv = /path/to/leadsift/staging/builds/current env = NEW_RELIC_CONFIG_FILE=newrelic.ini env = NEW_RELIC_ENVIRONMENT=staging env = DJANGO_SETTINGS_MODULE=leadsift_app.settings.staging module = leadsift_app.wsgi:application

continue reading
No Comments

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