Skip to content

Instantly share code, notes, and snippets.


Carl Meyer carljm

View GitHub Profile
carljm / deploy.wsgi
Created Jan 27, 2011
A mod_wsgi deployment file for Django that handles a virtualenv, putting its paths in front
View deploy.wsgi
import os, sys, site
base = os.path.dirname(os.path.dirname(__file__))
project = os.path.join(base, 'project')
virtenv = os.path.join(base, 'env')
### virtual environment, with precedence over global env ###
# from
View Exception wrapping is dumb
def unwrap_template_syntax_error(function, *unwrap_exceptions):
A decorator to catch TemplateSyntaxError and unwrap it, reraising the
wrapped exception.
If unwrap_exceptions are passed, the unwrapping will only occur if the
wrapped exception is one of those exception types.
View virtualenv activate.csh
--- a/
+++ b/
@@ -867,5 +867,5 @@
files['activate'] = ACTIVATE_SH
- files = {'activate': ACTIVATE_SH}
+ files = {'activate': ACTIVATE_SH, 'activate.csh': ACTIVATE_CSH}
files[''] = ACTIVATE_THIS
for name, content in files.items():
@@ -1426,4 +1426,29 @@
carljm /
Created Mar 27, 2011
An example of a decorator for a view that returns a TemplateResponse, modifying the template context before it is rendered.
def paginate(ctx_name):
View decorator that handles pagination of a ListObject. Expects to find it
in the TemplateResponse context under the name ``ctx_name``.
This needs to not force delivery of the ListObject.
def decorator(view_func):
carljm /
Created May 18, 2011
ghetto gem-installer that reads something similar to a pip requirements file
for line in `cat ${vfile}`; do
if gem list | grep ${gem} | grep "(${version})"; then
echo "${gem} (${version}) is already installed"
gem install ${gem} -v ${version} --no-rdoc --no-ri
carljm / postactivate
Created Jul 12, 2011
Yo dawg, I heard you like Ruby...
View postactivate
# This hook is run after every virtualenv is activated.
export GEM_HOME=$VIRTUAL_ENV/gems/
export GEM_PATH=
export PATH=$VIRTUAL_ENV/gems/bin:$PATH
carljm / tutorial.mkdn
Created Aug 23, 2011 — forked from mirisuzanne/tutorial.mkdn
A new Susy tutorial
View tutorial.mkdn

Susy Tutorial

For this tutorial I'm assuming you are already comfortable with CSS, Sass (I'll use the SCSS syntax) and Compass. Please get set up with each one of those before attempting to use Susy. Sass and Compass both have their own setup instructions and tutorials that you can use.

There is also reference documentation in the works.

What Susy Does

CSS Systems

carljm /
Created Dec 9, 2011
Unittest2 test discovery and real dotted-path named test selection for Django
An alternative Django ``TEST_RUNNER`` which uses unittest2 test discovery from
a base path specified in settings, rather than requiring all tests to be in
``tests`` module of an app.
If you just run ``./ test``, it'll discover and run all tests
underneath the ``TEST_DISCOVERY_ROOT`` setting (a path). If you run
``./ test``, it'll run the tests in
that module (you can also pass multiple modules).
View gist:2561976
excludesfile = ~/.gitignore
carljm /
Created Jun 15, 2012
Using py.test with Django
import os
def pytest_sessionstart(session):
Set up the test environment.
Sets DJANGO_SETTINGS_MODULE and sets up a test database.
You can’t perform that action at this time.