Skip to content

Instantly share code, notes, and snippets.

View pbx's full-sized avatar

Paul Bissex pbx

View GitHub Profile
@relekang
relekang / util.py
Created May 28, 2012 21:13
Expire @cache_page in django
from django.core.cache import cache
from django.core.urlresolvers import reverse
from django.http import HttpRequest
from django.utils.cache import get_cache_key
def expire_page_cache(view, args=None):
"""
Removes cache created by cache_page functionality.
Parameters are used as they are in reverse()
"""

Sublime Text 2 - Useful Shortcuts

Tested in Mac OS X: super == command

Open/Goto


  • super+t: go to file
  • super+ctrl+p: go to project
  • super+r: go to methods
@gurglet
gurglet / git-post-checkout.sh
Created February 9, 2012 13:55
Git post checkout hook that reminds you of South migration changes when changing branches. Can be useful when you are when you are testing out a branch from someone else that requires migrations. Put the file in .git/hooks/post-checkout
#!/bin/bash
# Git post checkout hook.
# Reminds you of South migration changes when switching branches.
# Can be useful when you are when you are testing out a branch from
# someone else that requires migrations.
# Put the file in .git/hooks/post-checkout
PREVIOUS_HEAD=$1
NEW_HEAD=$2
@sebleier
sebleier / gist:1127937
Created August 5, 2011 16:39
This is how I kinda wished django migrations would work.
$ git checkout master
Already on 'master'
$ django-admin.py migrate
Error: Cannot migrate in a dirty state
$ git commit -am "Added migration to remove blog entry's pub_month and pub_day fields."
$ django-admin.py tag_migration add_column_to_foo # tags a migration identifier using git-tag
$ django-admin.py migrate
last known sha: c39168d21bb27754737a1036a50f57687cf6ae56
new migrations found between c39168..HEAD:
@revolunet
revolunet / views.py
Created February 3, 2011 17:04
add context to your django error pages
#
# by default, django 404 and 500 pages dont pass context to templates.
# as you almost *always* need context variables in your custom
# 404/500 templates, you might need MEDIA_URL for example
#
# you need to create a custom view for errors and register it in your urls.py
#
# in urls.py add :
#
# handler500 = handler404 = views.server_error