Hiding ruby gem 'is deprecated with no replacement' messages

I recently installed ruby 1.9.2 via rvm, and suddenly every command started spitting out hundreds of line of deprecation messages : ...

May 21, 2011 · 2 min · Dave Perrett

Excluding fields from rails json and xml output

Rails has a very handy ‘respond_to’ feature to render your pages in different formats : respond_to do |format| format.json { render :json => @user } format.xml { render :xml => @user } format.html end However, by default it outputs every field in the model, which exposes some data (encrypted-password and password-salt) that I’d rather keep to myself : ...

October 3, 2010 · 1 min · Dave Perrett

HABTM before_filter in rails models

I’ve been playing about with Devise and CanCan for rails authentication and authorization recently - this great pair of posts from Tony Amoyal have helped a great deal. I have a User model and a Role model, and wanted to automatically add the :user role to each user whenever roles are assigned. The roles were set in the controller as follows: ...

October 3, 2010 · 2 min · Dave Perrett

Push and delete remote git branches

This is easy to do, but I always forget how to do it, so this is more a reminder to myself than anything else. To create and checkout a branch in git : ...

March 17, 2010 · 1 min · Dave Perrett

How to find out if Ubuntu is 32 bit or 64 bit

To find out if Ubuntu is 32 bit or 64 bit, run uname : uname -m x86_64 = 64 bit i686 = 32 bit

March 6, 2010 · 1 min · Dave Perrett

sources.list For Ubuntu Hardy Heron 8.04

I keep having to look this up to add multiverse repositories (courtesy of tuxicity). ...

March 6, 2010 · 2 min · Dave Perrett

nginx error - 413 Request Entity Too Large

If you’re getting 413 Request Entity Too Large errors trying to upload with {{ “nginx.net/” | ext_link: “Nginx”}}, you need to increase the size limit in nginx.conf . Add ‘client_max_body_size xxM’ inside the server section, where xx is the size (in megabytes) that you want to allow. http { include mime.types; default_type application/octet-stream; sendfile on; keepalive_timeout 65; server { client_max_body_size 20M; listen 80; server_name localhost; # Main location location / { proxy_pass http://127....

November 18, 2009 · 1 min · Dave Perrett

Makefile - missing separator. Stop.

If you’re getting missing separator errors in your makefile, similar to the following : Makefile:22: *** missing separator. Stop. … make sure you are using real tabs instead of spaces. A global search and replace for four-spaces should fix things up.

November 12, 2009 · 1 min · Dave Perrett

NoReverseMatch : custom registration templates break django unit tests

I’ve over-ridden several of the built-in django auth and {{ “bitbucket.org/ubernostrum/django-registration/” | ext_link: “django-registration”}} templates so I can have my own custom-styled login and registration pages. This all worked fine until i tried to run the built-in django and django_registration test suites, when everything fell apart : ...

November 10, 2009 · 3 min · Dave Perrett

Sending Django email with Gmail

After spending a few hours struggling to get postfix to work with django on my local dev machine, I gave up and decided to use Gmail . To do it, add the following to your settings.py : ...

October 16, 2009 · 1 min · Dave Perrett