Skip to content

Instantly share code, notes, and snippets.

@mmalone
mmalone / Reviewing profiles
Created November 13, 2009 23:57
Replacement Django runserver command that does profiling... because I've rewritten this too many times.
>>> import pstats
>>> p = pstats.Stats('p.1258156459.52174278XcQE.prof')
>>> p.strip_dirs().sort_stats(-1).print_stats(5)
Fri Nov 13 15:54:20 2009 p.1258156459.52174278XcQE.prof
124278 function calls (122386 primitive calls) in 0.589 CPU seconds
Ordered by: standard name
List reduced from 1014 to 5 due to restriction <5>
@epicserve
epicserve / Django Enviroment Setup on Mac OSX 10.6.2 (Snow Leopard).markdown
Created February 22, 2010 15:29
Django Enviroment Setup on Mac OSX 10.6.2 (Snow Leopard)

Django Enviroment Setup on Mac OSX 10.6.2 (Snow Leopard)

Install Homebrew

sudo mkdir /usr/local
sudo chown -R `whoami` /usr/local
curl -L http://github.com/mxcl/homebrew/tarball/master | tar xz --strip 1 -C /usr/local
brew install git
cd /usr/local
git init
from django.core.exceptions import ImproperlyConfigured
from django.core.management.base import BaseCommand, CommandError
from django.core import serializers
from django.utils.datastructures import SortedDict
from optparse import make_option
class Command(BaseCommand):
option_list = BaseCommand.option_list + (
make_option('--format', default='json', dest='format',
@bergie
bergie / README.md
Created May 18, 2011 11:33
Falsy Values tutorials
@nzjrs
nzjrs / skype-notify.py
Created June 3, 2011 13:14
Python script to make Skype co-operate with GNOME3 notifications
#!/usr/bin/env python
# Python script to make Skype co-operate with GNOME3 notifications.
#
#
# Copyright (c) 2011, John Stowers
#
# Adapted from skype-notify.py
# Copyright (c) 2009, Lightbreeze
#
#
@ipmb
ipmb / intense.py
Created June 24, 2011 22:35
Quick and dirty script to export django.contrib.comments as an IntenseDebate Export file to import it in Disqus.
from django.utils.html import escape
from django.contrib.comments.models import Comment
from django.utils.encoding import smart_str
post = u''
for i in Comment.objects.order_by('submit_date'):
if not i.content_object:
continue
post += u"""
@razum2um
razum2um / gist:1063986
Created July 4, 2011 21:47
django nested sets (level<=3) support
From bbb53d927c0949246c1735baaf34aa4261cfbb3c Mon Sep 17 00:00:00 2001
From: Vlad Bokov <razum2um@mail.ru>
Date: Tue, 5 Jul 2011 04:14:42 +0700
Subject: [PATCH] nested sets (level<=3) support
---
django/contrib/admin/options.py | 36 +++++++++++++++
.../admin/templates/admin/edit_inline/nested.html | 48 ++++++++++++++++++++
.../admin/templates/admin/edit_inline/tabular.html | 13 +++++-
3 files changed, 96 insertions(+), 1 deletions(-)

Selenium with Python

Author: Baiju Muthukadan
Email:baiju.m.mail AT gmail.com
Version: 0.3.2
@aniav
aniav / flakes.py
Created September 12, 2011 13:45 — forked from mpasternacki/flakes.py
Django management command to run pyflakes against Django project
import ast
import os
from pyflakes import checker, messages
import sys
from django.conf import settings
from django.core.management.base import BaseCommand
# BlackHole, PySyntaxError and checking based on
# https://github.com/patrys/gedit-pyflakes-plugin.git
@mhulse
mhulse / ssh tunneling.md
Last active July 26, 2023 15:22
SSH Tunneling: Map port from remote machine to your local machine so you can work from the remote DB (example using Django DB settings)...

SSH Tunneling

  1. In your local_settings.py file:

    DATABASES = {
    	'default': {
    		'ENGINE': 'django.db.backends.postgresql_psycopg2',
    		'NAME': 'django_%s' % (PROJECT_NAME,),
    

'USER': xxxx,