Skip to content

Instantly share code, notes, and snippets.

@manfre
manfre / log_settings.py
Created October 5, 2011 13:32
Django logging filter to throttle repeated messages
# Example logging configuration that will restrict console logging to
# at most 2 repeated messages per 30 seconds.
LOGGING = {
'version': 1,
'disable_existing_loggers': True,
'formatters': {
'simple': {
'format': '%(asctime)s - %(name)s - %(levelname)s - %(filename)s:%(lineno)d - %(message)s'
},
},
@jonasvp
jonasvp / pre-commit
Created March 7, 2011 08:29
My .git/hooks/pre-commit - save yourself from embarassment using pyflakes
#!/bin/bash
TMPDIR=`mktemp -d`
TMPFILE=`mktemp`
git diff --cached --name-only --diff-filter=ACMR | xargs git checkout-index --prefix=$TMPDIR/ --
pyflakes $TMPDIR >$TMPFILE 2>&1
grep -v "unable to detect undefined names" $TMPFILE >$TMPFILE.2
egrep -v "migrations.*'(datetime|models)' imported but unused" $TMPFILE.2 >$TMPFILE
grep -rn "pdb.set_trace" $TMPDIR >>$TMPFILE
sed "s/^${TMPDIR//\//.}.//" $TMPFILE >$TMPFILE.2