Skip to content

Instantly share code, notes, and snippets.

"""
jQuery templates use constructs like:
{{if condition}} print something{{/if}}
This, of course, completely screws up Django templates,
because Django thinks {{ and }} mean something.
Wrap {% verbatim %} and {% endverbatim %} around those
blocks of jQuery templates and this will try its best
@codysoyland
codysoyland / post-checkout
Created January 18, 2011 20:19
place in .git/hooks/post-checkout to delete empty directories and pyc files
#! /bin/sh
echo "Purging pyc files and empty directories..."
# Start from the repository root.
cd ./$(git rev-parse --show-cdup)
# Delete .pyc files and empty directories.
find . -name "*.pyc" -delete 2>&1 > /dev/null &
find . -type d -empty -delete 2>&1 > /dev/null &
@rwaldron
rwaldron / style-guide.js
Created January 24, 2011 18:20
Writing Idiomatic JavaScript
1. Two space soft indents (fake tabs) OR tabs... BUT NEVER BOTH - DO NOT MIX
2. Whitespace, Parens, Braces, Linebreaks
if/else/for/while/try always have spaces, braces and multiple lines.
--------------------------------------------------------------------
@jasonrudolph
jasonrudolph / about.md
Last active May 14, 2024 16:36
Programming Achievements: How to Level Up as a Developer
@sfreytag
sfreytag / Yuml.me generator for Python class inheritance
Created November 2, 2011 14:15
Generate a http://yuml.me definition of Django's class-based views to get a nice class diagram of those views.
"""
Generate a http://yuml.me definition of Django's class-based views to get a
nice class diagram of those views.
"""
# This runs as a script, but in my Django project root, so import the settings
import settings
import inspect
import django.views.generic.list as list_views
@carljm
carljm / runner.py
Created December 9, 2011 04:07
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 ``./manage.py test``, it'll discover and run all tests
underneath the ``TEST_DISCOVERY_ROOT`` setting (a path). If you run
``./manage.py test full.dotted.path.to.test_module``, it'll run the tests in
that module (you can also pass multiple modules).
@benbarnett
benbarnett / GroupsToPNG.jsx
Created January 17, 2012 15:19
Groups to PNG Photoshop Script
#target photoshop
var sizes = {
'xlarge': [1490, 730],
'large': [1160, 568],
'medium': [890, 436],
'small': [760, 372]
};
@hrldcpr
hrldcpr / tree.md
Last active June 8, 2024 18:11
one-line tree in python

One-line Tree in Python

Using Python's built-in defaultdict we can easily define a tree data structure:

def tree(): return defaultdict(tree)

That's it!

@codeinthehole
codeinthehole / fetch_pyvideo.py
Created March 11, 2012 22:36
Fetch PyCon videos from pyvideo.org and convert them to M4V so they can be synced to your iPhone
# Hacky script for downloading videos from PyVideo and converting them to m4v
# format so they can be synced onto your apple device. Useful if you
# want to see everything that happened at PyCon while commuting.
#
# Requirements:
# * pip install requests BeautifulSoup
# * youtube-dl (from https://github.com/rg3/youtube-dl/) - add this to the
# directory where this script runs and ensure its execute bit is set.
# This was the only YouTube downloader I found that worked. It doesn't
# really have a good Python API so I call it through os.system.
document.body.addEventListener('error', function(event) {
if ( event.target.nodeName.toLowerCase() == 'img' ) {
// an image on the page failed to load
}
}, true);