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 cProfile import Profile | |
| import pstats | |
| def profile(sort_args=['cumulative'], print_args=[10]): | |
| profiler = Profile() | |
| def decorator(fn): | |
| def inner(*args, **kwargs): | |
| result = None |
| from django.conf import settings | |
| from django.db.models.deletion import Collector | |
| from django.db.utils import ConnectionRouter | |
| def deletable_objects(obj): | |
| """ | |
| Return a generator that yields (model, instance) tuples | |
| of instances related to obj (including obj itself). | |
| Essentially, programmatic access to the data Django Admin |
| import time | |
| import cwiid | |
| class Wiible(): | |
| buttons = [ | |
| "BTN_2", | |
| "BTN_1", | |
| "BTN_B", |
| import time | |
| import cwiid | |
| import threading | |
| class WiimoteBase(object): | |
| """ | |
| Base class for sending Wiimote button presses to class | |
| methods. Subclass to implement actions in the methods. |
| import piface.pfio as pfio | |
| from wiimote import WiimoteConnect | |
| class WiiBot(WiimoteConnect): | |
| """ | |
| Use Wiimote to control robot | |
| Basic usage: | |
| from wiibot import WiiBot |
| 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" |
| from textwrap import dedent | |
| from urlparse import urlparse | |
| from django.core.management.base import BaseCommand | |
| from django.core.urlresolvers import resolve, Resolver404 | |
| class Command(BaseCommand): | |
| """ | |
| Take a fully qualified URL and show the resolved view |
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 |
| #!/usr/bin/env bash | |
| ### BEGIN INIT INFO | |
| # 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 |
| # 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 | |
| django.setup() | |
| ma = MigrationExecutor(connections[db]).loader.migrated_apps | |
| return dict(zip(ma, ['{a}.notmigrations'.format(a=a) for a in ma])) |