Skip to content

Instantly share code, notes, and snippets.

@davehughes
davehughes / detect-duplicate-south-migrations.sh
Created June 2, 2014 23:49
Detect duplicate indices in South migrations between two git commits
RETURN_CODE=0
MIGS_PATH="thefundersclub/migrations"
@davehughes
davehughes / .nesh-preload.js
Last active August 29, 2015 14:06
Nesh shell initialization
// Exports to Nesh shell
// + Add a shell alias 'alias nesh="nesh --eval {this file}"' to automatically
// trick out your shell with these natural code enhancements.
__ = _ = require('lodash');
config = require('./common').config();
db = require('./models');
Q = require('q');
mongo = require('monk')(config.db.mongo.url);
# post_commit and post_rollback transaction signals for Django with monkey patching
# Author Grégoire Cachet <gregoire.cachet@gmail.com>
# http://gist.github.com/247844
#
# Usage:
# You have to make sure to load this before you use signals.
# For example, create utils/__init__.py and then utils/transaction.py contening
# this gist in you project. Then add "import utils.transaction" in your project
# __init__.py file
#
@davehughes
davehughes / backbone-elemental-view.coffee
Created March 2, 2012 02:42
Experimental Backbone.View extension that takes a declarative approach to dealing with DOM elements.
# Copied from backbone.js
getValue = (object, prop) ->
if not (object and object[prop])
return null
if _.isFunction(object[prop]) then object[prop]() else object[prop]
eventSplitter = /^(\S+)\s*(.*)$/
namedSelectorPattern = /^{(.+)}$/
viewOptions = ['model', 'collection', 'el', 'id', 'attributes', 'className', 'tagName', 'elements']
@davehughes
davehughes / paginate.py
Created March 2, 2012 02:48
Django template filter for rendering an ellipsized paginator.
from django import template
from django.utils.safestring import mark_safe as safe
register = template.Library()
class PaginationNav(object):
def __init__(self, page_number=None, display=None, is_current=False):
self.page_number = page_number
self.is_current = is_current
self.display = display or page_number or ''
@davehughes
davehughes / modes.py
Created July 20, 2012 15:33
Implementation of cuisine modes that works by monkey-patching Fabric internals.
'''
Stack-based mode managers for mode_(sudo|user|local|remote).
'''
from fabric.api import env
MODE_STACKS = {}
env.cuisine_mode_sudo = False
env.cuisine_mode_local = False
class ModeStackManager(object):
@davehughes
davehughes / modes.py
Created July 20, 2012 16:00
Implementation of cuisine modes that works by monkey-patching Fabric internals.
'''
Stack-based mode managers for mode_(sudo|user|local|remote).
'''
from fabric.api import env
MODE_STACKS = {}
env.cuisine_mode_sudo = False
env.cuisine_mode_local = False
class ModeStackManager(object):
@davehughes
davehughes / monkey.py
Created July 31, 2012 18:53
Monkey patch to cuisine to improve mode_local behavior
import ssh
import subprocess
import time
from fabric.api import env, settings
from fabric.state import output
from fabric.operations import (_shell_wrap, _prefix_commands, _prefix_env_vars,
_sudo_prefix, _AttributeString)
from fabric.io import output_loop
from fabric.thread_handling import ThreadHandler
import itertools
DIMENSIONS = {
'city': [
'sf', 'nyc', 'la', 'chicago',
],
'color': [
'red', 'orange', 'yellow', 'green', 'blue', 'indigo', 'violet',
],
@davehughes
davehughes / rc300_backup.py
Created October 25, 2015 21:04 — forked from anonymous/rc300_backup.py
Basic script to upload a backup from the Boss RC-300 loop station to S3.
import datetime
import os
import StringIO
import tarfile
import boto
MOUNT_LOCATION = '/Volumes/BOSS_RC-300'
UPLOAD_REGION = '<your-region-here>'