install GDAL in virtualenv

Posted by Dan on Friday the 1st of December, 2017

On Ubuntu

apt-get install Gdal
pip install GDAL --global-option=build_ext --global-option="-I/usr/include/gdal"

Dump/Restore Postgres DB to/from archive

Posted by Dan on Saturday the 18th of March, 2017

Dump a Postgres DB to a Gzip archive:

pg_dump db -U user | gzip > db.sql.gz

Restore dumped Gzip:

gunzip -c db.sql.gz | psql -U user db

Remove all files or directories except one

Posted by Dan on Thursday the 28th of April, 2016

To remove all directories except one specified:

ls | grep -v directory_name | xargs rm -rf

remove all files except one specified:

ls | grep -v file_name | xargs rm

Custom Django Project Template

Posted by Dan on Sunday the 13th of July, 2014

I have created a base Django project template to enable rapidly starting Django projects, it uses some basic features that I use frequently.

This base template includes:

  • Fabric deployment scripts
  • Bootstrap static files with less.js
  • Base templates
  • Nginx, Gunicorn and Supervisor templates for deployment
  • Multiple settings per environment


To create a project with this template:

Make a virtual environment activate it and install Django.

Start the project

1 startproject --template= myproject 



Virtualenv 1.7 changed default behavior

Posted by Dan on Saturday the 28th of January, 2012

The default behaviour of virtualenv has changed, 1.7 now creates your virtual environment with what was the --no-site-packages option as default.

To create an environment with global packages there is a new option:

virtualenv --system-site-packages ENV

Embedding Pictures from Google+ using jQuery

Posted by Dan on Saturday the 17th of December, 2011

Currently the Google+ API doesn't allow access to a users photo albums and images, however it is possible to access your images stored on Google+ using the Picasa web albums data API

I have written a simple jQuery plugin to get pictures from an album and display them in a simular style and effect to the albums on Google+, you can see a demo of this here and on the front page of my site you can view the jQuery plugin on github.

Install & Setup

Make sure you have at least jQuery 1.4.2.

Download the plugin from here and include the css and js file as below:

<link rel="stylesheet" href="style.css" type="text/css" media="screen, projection" />
<script type="text/javascript" src="pluspics.js"></script>

Run the following script to setup and run the gallery plugin.

<script type="text/javascript">
		userId: 'your_user_id',
		albumId: 'your_album_id',
		numImages: 3,
		title: 'Images'

Put an empty container div on the page where you want the gallery to display.

<div id="container-id"></div>