Skip to content

Instantly share code, notes, and snippets.

View benspaulding's full-sized avatar

Ben Spaulding benspaulding

View GitHub Profile

Test

This is only a test.

@benspaulding
benspaulding / analyze-repo
Last active August 29, 2015 14:14
Quick-and-dirty script to get some data about a repo
#!/usr/bin/env python
"""
Usage::
pip install gitpython
cd <repo>
analyze-repo
"""
from __future__ import absolute_import, division, print_function, unicode_literals
@benspaulding
benspaulding / settings.py
Created March 18, 2015 17:12
Skip migrations during Django tests
INSTALLED_APPS = (
# ...
)
# Skip migrations for tests
MIGRATION_MODULES = {
# Assumes that all values in INSTALLED_APPS are simply a package containing
# an application, not an application configuration class.
app.split('.').pop(): '{0}.migrations_not_used_in_tests'.format(app) for app in INSTALLED_APPS
}
@benspaulding
benspaulding / keybase.md
Created April 9, 2015 14:28
keybase.md

Keybase proof

I hereby claim:

  • I am benspaulding on github.
  • I am benspaulding (https://keybase.io/benspaulding) on keybase.
  • I have a public key whose fingerprint is 20B3 BFB1 AD12 033F 0774 85F5 970F 8167 377B 92A4

To claim this, I am signing this object:

diff --git a/gift-4-u.txt b/gift-4-u.txt
index ca36d0a..986e9c4 100644
--- a/gift-4-u.txt
+++ b/gift-4-u.txt
@@ -1,2 +1,2 @@
-I am sending this because you love patch files. :)
+I am sending this because you *really* love patch files. :)
From c693dfaa46218537fb66e6e30638ee81f5374fac Mon Sep 17 00:00:00 2001
From: Ben Spaulding <ben@benspaulding.com>
Date: Fri, 20 Mar 2009 00:22:21 -0500
Subject: [PATCH] Created ``yes`` filter in default filters.
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
I cannot count the times that I wanted to output a string if
the value was true, but output nothing otherwise. This leads
From 99ca027e7f09c5a7dfd0e6804cc90325c223ffea Mon Sep 17 00:00:00 2001
From: Ben Spaulding <ben@benspaulding.com>
Date: Fri, 20 Mar 2009 00:17:14 -0500
Subject: [PATCH] Created ``or_nothing`` filter in default filters.
The same thing can be accomplished with the ``default``
filter and an empty argument, but that feels hacky and
it looks dirty, too.
---
django/template/defaultfilters.py | 11 +++++++++++
#!/bin/sh
echo Starting lighttpd
# What does this do?
exec 2>&1
# Is there a reason for doing this rather than ``exec /etc/init.d/nginx start`` ?
exec /usr/sbin/lighttpd -D -f /etc/lighttpd/lighttpd.conf
class Foo(object):
bar = ['this', 'that']
class Baz(Foo):
# What is the best way to make the bar attr equal to the super class’s
# bar attr with some more items appended to the list?
#
# This obviously doesn't work, but it is the sort of thing I want.
# Middlware munging in staging settings.py
REMOVED_MIDDLEWARE_CLASSES = (
'django.middleware.cache.UpdateCacheMiddleware',
'django.middleware.cache.FetchFromCacheMiddleware',
)
ORIGINAL_MIDDLEWARE_CLASSES = MIDDLEWARE_CLASSES
MIDDLEWARE_CLASSES = []
for mwc in ORIGINAL_MIDDLEWARE_CLASSES:
if not mwc in REMOVED_MIDDLEWARE_CLASSES:
MIDDLEWARE_CLASSES.append(mwc)