Skip to content

Instantly share code, notes, and snippets.

James Tiplady BigglesZX

Block or report user

Report or block BigglesZX

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
BigglesZX /
Created Oct 30, 2018
Find and sort node_modules folders by size, to aid pruning
find . -type d -name "node_modules" -prune -exec du -sh {} \; | sort -nrk1
# find directories matching the name `node_modules`
# prune out unnecessary entries from within top-level `node_modules` results
# run `du` against the results to calculate size
# pipe to sort, first column as key, reverse natural
BigglesZX /
Last active Mar 22, 2017
Amazon S3 IAM User Notes

Setting up S3-bucket-specific IAM users for new sites

This provides a new site with a unique IAM access key/secret that allows read/write access to a single S3 bucket, e.g. to allow a Django site to upload media files. This assumes the bucket itself has already been created.

Note: I originally created this gist as a note-to-self so conventions shown here are particular to my setup; YMMV.

  1. Log in to the AWS Console and head to the IAM section
  2. Click Users to access the IAM user list
  3. Click Add User
  4. Enter username in the format of sitename-s3 (replacing sitename)
BigglesZX /
Last active Jun 2, 2017
Key Django upgrade touch points (1.6/1.7 -> 1.11)
  • New initial migrations (moving away from South)
  • Redundant items in config
  • Old-style static URL / template discovery / context processors settings
  • Old-style middleware
  • Deprecated test runners
  • Old-style quoted-string URL patterns
  • Old URL patterns() construction
  • Use of render_to_response and RequestContext (particularly a problem with silent failing CSRF)
  • Old-school way of referencing inside apps - app name prefix required in many dot notations now
BigglesZX /
Last active Aug 29, 2015
Django management command to copy translations from Loco endpoints to local PO files
from django.conf import settings
from import BaseCommand, CommandError
from os.path import join
from urllib import urlretrieve
class Command(BaseCommand):
help = 'Imports translations from Loco'
def handle(self, *args, **options):
BigglesZX /
Last active Aug 29, 2015
Generate a unique code for an instance of a Django model on save
This uses the DB to ensure uniqueness of the code. Better than checking separately
with the DB and then saving, which introduces a race condition.
class UserProfile(BaseModel):
code = models.CharField(max_length=4,
def generate_code(self):
BigglesZX /
Created Sep 6, 2014
Default Django 1.7 file
WSGI config for myproject project.
It exposes the WSGI callable as a module-level variable named ``application``.
For more information on this file, see
import os
BigglesZX /
Created Aug 14, 2014
Keybase verification

Keybase proof

I hereby claim:

  • I am BigglesZX on github.
  • I am biggleszx ( on keybase.
  • I have a public key whose fingerprint is 0361 EC11 E816 C0A0 C151 859B 36CB 1F0D BFFB 46BF

To claim this, I am signing this object:

BigglesZX / multiDeferred.js
Last active Aug 29, 2015
Basic implementation of a mutable collection of Deferreds that can be addressed as one
View multiDeferred.js
var MultiDeferred = function() { = [];
this.d = new $.Deferred();
return this;
MultiDeferred.prototype.check = function() {
if ( {
var resolved = true;
$.each(, function(i, p) {
if (p.state() === 'rejected') this.d.reject();
BigglesZX / Procfile
Last active Aug 29, 2015
Standard config + addons for Heroku Django apps
View Procfile
web: collectstatic --noinput; newrelic-admin run-program gunicorn appname.wsgi:application -b "$PORT" -w 4
BigglesZX / localstorage-userdata-polyfill.js
Created Dec 5, 2013
HTML5 LocalStorage polyfill for IE7 using the userData behaviour
View localstorage-userdata-polyfill.js
// if localStorage isn't available but IE's userData API is, polyfill it
// polyfill pattern based on
if (Modernizr && !Modernizr.localstorage) {
// set up storage element
var storageNamespace = 'localStoragePolyfill',
storage = document.createElement('div');
if (typeof storage.addBehavior !== 'undefined') { = '_storage'; = 'none'; = 'url("#default#userData")';
You can’t perform that action at this time.