Skip to content

Instantly share code, notes, and snippets.

View carljm's full-sized avatar

Carl Meyer carljm

View GitHub Profile
@carljm
carljm / conftest.py
Created June 15, 2012 15:11
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.
[core]
excludesfile = ~/.gitignore
@carljm
carljm / tutorial.mkdn
Created August 23, 2011 19:31 — forked from mirisuzanne/tutorial.mkdn
A new Susy tutorial

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
carljm / install-gems.sh
Created May 18, 2011 19:29
ghetto gem-installer that reads something similar to a pip requirements file
#!/bin/bash
vfile=$1
for line in `cat ${vfile}`; do
gem=${line%%=*}
version=${line##*=}
if gem list | grep ${gem} | grep "(${version})"; then
echo "${gem} (${version}) is already installed"
else
gem install ${gem} -v ${version} --no-rdoc --no-ri
fi
--- a/virtualenv.py
+++ b/virtualenv.py
@@ -867,5 +867,5 @@
files['activate'] = ACTIVATE_SH
else:
- files = {'activate': ACTIVATE_SH}
+ files = {'activate': ACTIVATE_SH, 'activate.csh': ACTIVATE_CSH}
files['activate_this.py'] = ACTIVATE_THIS
for name, content in files.items():
@@ -1426,4 +1426,29 @@
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.
"""
@wraps(function)
@carljm
carljm / deploy.wsgi
Created January 27, 2011 19:24
A mod_wsgi deployment file for Django that handles a virtualenv, putting its paths in front
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 http://code.google.com/p/modwsgi/wiki/VirtualEnvironments
@carljm
carljm / test.py
Created March 24, 2015 01:07
playing with logging
from logging.config import dictConfig
import logging
initial = {
'version': 1,
'disable_existing_loggers': False,
'handlers': {
'console': {
'class': 'logging.StreamHandler',
},
@carljm
carljm / patch.diff
Created February 12, 2015 00:00
draft patch for --fake-initial doc updates
diff --git a/docs/topics/migrations.txt b/docs/topics/migrations.txt
index a0dc365..fae87a0 100644
--- a/docs/topics/migrations.txt
+++ b/docs/topics/migrations.txt
@@ -148,6 +148,13 @@ developers (or your production servers) check out the code, they'll
get both the changes to your models and the accompanying migration at the
same time.
+.. versionadded:: 1.8
+
$ ./tests/runtests.py migrations
Testing against Django installed in '/home/carljm/projects/django/django/django/django'
Creating test database for alias 'default'...
Creating test database for alias 'other'...
..................................................................................................................................s...............................EE.EE.E..........s.......................................
======================================================================
ERROR: test_squashmigrations_squashes (migrations.test_commands.SquashMigrationsTest)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/carljm/projects/django/django/django/django/test/utils.py", line 187, in inner