cd somewhere
git clone[OWNER]/[REPO].git --branch [SPECIFIC BRANCH] --single-branch
cd [REPO]
python develop
# Usually, restart dev server to prevent it using already loaded site-packages modules.
# Hack away on code in [REPO], python will use this one rather than the one in site-packages.
# When done, to switch back:
python develop --uninstall
cd ..
rm -rf [REPO]
import time
from collections import defaultdict, OrderedDict
from junorunner.testrunner import TestSuiteRunner
from junorunner.extended_runner import TextTestRunner, TextTestResult
class TimedTestSuiteRunner(TestSuiteRunner):
List the longest running tests in a suite
View gist:a8f87b0d95e73eb482c5
import sys
from django.apps import apps
from django.conf import settings
from import BaseCommand
from django.db import connections
from django.db.migrations.autodetector import MigrationAutodetector
from django.db.migrations.executor import MigrationExecutor
from django.db.migrations.state import ProjectState
from django.db.utils import OperationalError
def reorder_ordereddict(ordered_dict, key_order):
Return a new OrderedDict using a source ordered_dict and key_order iterable.
Any keys in ordered_dict that are not in key_order will be added
in their original order to the end of the returned OrderedDict.
KeyError will be raised for keys in key_order that are not in ordered_dict.
Intended for specifiying the order of Form.fields without having to create
them in the required order.
# If your test settings file doesn't import any other settings file
# then you can use the function directly:
def prevent_tests_migrate(db):
import django
from django.db import connections
from django.db.migrations.executor import MigrationExecutor
ma = MigrationExecutor(connections[db]).loader.migrated_apps
return dict(zip(ma, ['{a}.notmigrations'.format(a=a) for a in ma]))
View uwsgi-init.d
#!/usr/bin/env bash
# Provides: emperor
# Required-Start: $all
# Required-Stop: $all
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: uwsgi for wagtail
# Description: uwsgi for wagtail
View gist:6883345

Sublime Text 2 – Useful Shortcuts (PC)

Loosely ordered with the commands I use most towards the top. Sublime also offer full documentation.


Ctrl+C copy current line (if no selection)
Ctrl+X cut current line (if no selection)
Ctrl+⇧+K delete line
Ctrl+↩ insert line after
from textwrap import dedent
from urlparse import urlparse
from import BaseCommand
from django.core.urlresolvers import resolve, Resolver404
class Command(BaseCommand):
Take a fully qualified URL and show the resolved view
from django import forms
class MinimumRequiredFormSet(forms.models.BaseInlineFormSet):
Inline formset that enforces a minimum number of non-deleted forms
that are not empty
default_minimum_forms_message = "At least %s set%s of data is required"
import piface.pfio as pfio
from wiimote import WiimoteConnect
class WiiBot(WiimoteConnect):
Use Wiimote to control robot
Basic usage:
from wiibot import WiiBot