Skip to content

Instantly share code, notes, and snippets.

@lincolnloop
lincolnloop / django.wsgi
Created March 13, 2009 03:22
Django mod_wsgi scripts
import os, sys
import site
# put virtualenv on pythonpath
site.addsitedir('/path/to/project/ve/lib/python2.5/site-packages')
# redirect prints to apache log
sys.stdout = sys.stderr
os.environ['DJANGO_SETTINGS_MODULE'] = 'myproject.settings'
@lincolnloop
lincolnloop / gist:78619
Created March 13, 2009 15:42
jQuery highlight and fade background on named anchors
// highlight and fade background on named anchors
// requires jquery.color.js http://plugins.jquery.com/project/color
function highlight(elemId){
var elem = $(elemId);
elem.css("backgroundColor", "#ffffff"); // hack for Safari
elem.animate({ backgroundColor: '#ffffaa' }, 1500);
setTimeout(function(){$(elemId).animate({ backgroundColor: "#ffffff" }, 3000)},1000);
}
if (document.location.hash) {
@lincolnloop
lincolnloop / gist:91456
Created April 7, 2009 21:05
Django virtualenv shortcuts for ~/.bashrc
# Django virtualenv helpers
VIRTUALENV_PROJECTS=~/projects
# work on virtualenv
function workon(){
cd $VIRTUALENV_PROJECTS/$1
source bin/activate
}
# Run Django management commands
class KeepQueryStringModelAdmin(admin.ModelAdmin):
"""
A ModelAdmin that "fixes" the default behavior of redirecting to the
default change list after a save.
This class remembers the change list query string that was used for the
change list and redirects to it after a save, maintaining the ordering,
filtering, & pagination.
Thanks to Vlada Macek http://djangopeople.net/tuttle/
cat > filemane
Mozilla/5.0 (iPad; U; CPU OS 3_2 like Mac OS X; en-us) AppleWebKit/531.21.10 (KHTML, like Gecko) Version/4.0.4 Mobile/7B334b Safari/531.21.10