Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@nealtodd
nealtodd / reorder_ordereddict_snippet.py
Last active August 29, 2015 14:06
Reorder OrderedDict
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.
@nealtodd
nealtodd / gist:a8f87b0d95e73eb482c5
Created June 10, 2015 11:10
Django management command to detect missing migration files.
import sys
from django.apps import apps
from django.conf import settings
from django.core.management.base 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
@nealtodd
nealtodd / timed_testrunner.py
Created August 25, 2015 15:46
List the longest running tests in a Django test suite
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
@nealtodd
nealtodd / package_dev.sh
Last active July 6, 2016 10:57
Debugging / testing a third party package without hacking the pip installed version
cd somewhere
git clone https://github.com/[OWNER]/[REPO].git --branch [SPECIFIC BRANCH] --single-branch
cd [REPO]
python setup.py 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 setup.py develop --uninstall
cd ..
rm -rf [REPO]
@nealtodd
nealtodd / wagtail-on-zappa.md
Last active July 30, 2021 17:44 — forked from tomdyson/wagtail-on-zappa.md
Wagtail on AWS Lambda, with Zappa

Wagtail on AWS Lambda, with Zappa

Aim

A demonstration of Wagtail running on AWS Lambda + API Gateway using Zappa for deployment.

This is not a Production solution, it is an insecure setup focusing solely on getting Wagtail to run on Lambda in the simplest way possible (and at zero cost if it is not used beyond this demonstration (or close to zero depending on how much you exercise the S3 bucket)).

caveat emptor!