Skip to content

Instantly share code, notes, and snippets.

@cmheisel
cmheisel / Basecamp Test Object.py
Created February 8, 2009 23:14
Allows for easier and faster unit testing when using the Basecamp API. For details see: http://heisel.org/blog/2009/02/07/adventures-in-unit-testing-the-basecamp-api/
class TestBasecamp(Basecamp):
"""Subclass of Basecamp which records network transactions.
Transactions are serialized to JSON on disk and used in lieu
of network usage on second and subsequent requests.
Basecamp class found here: http://pypi.python.org/pypi/BasecampWrapper/0.1
"""
def __init__(self, baseURL, username, password):
self.__test_responses = { 'GET': {}, 'POST': {} }
super(TestBasecamp, self).__init__(baseURL, username, password)
@cmheisel
cmheisel / cmhflopsy.py
Created June 8, 2009 14:40 — forked from nathanborror/flopsy.py
Fork of nathanb's flopsy but doesn't require Django SETTINGS
"""
Copyright (c) 2008-2009, Nathan Borror
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
Redistributions of source code must retain the above copyright notice, this list
of conditions and the following disclaimer.
Redistributions in binary form must reproduce the above copyright notice, this
@cmheisel
cmheisel / test-settings.py
Created November 21, 2009 21:44
Sample Django test settings
from yourapp.settings.common import *
ROOT_URLCONF = 'yourapp.settings.test.urls'
DATABASE_ENGINE = 'sqlite3'
DATABASE_NAME = ':memory:'
INSTALLED_APPS += ('django_nose', )
TEST_RUNNER = 'django_nose.run_tests'
@cmheisel
cmheisel / test-requirements.pip
Created November 21, 2009 21:48
PIP requirements file for tests
coverage==3.2b3
nose
git+git://github.com/cmheisel/nose-xcover.git#egg=nosexcover
git+git://github.com/jbalogh/django-nose.git#egg=django-nose
pylint
@cmheisel
cmheisel / django-hudson.sh
Created November 21, 2009 21:53
Hudson built script for Django projects
cd $WORKSPACE
virtualenv -q ve
source ./ve/bin/activate
pip install -q -E ./ve -r requirements.pip
pip install -q -E ./ve -r requirements-test.pip
python setup.py --quiet develop
django-admin.py test --settings=yourapp.settings.test --with-coverage --cover-package=yourapp --with-xunit --with-xcoverage
@cmheisel
cmheisel / natread.py
Created December 7, 2009 21:35 — forked from simonw/natread.py
A cow that can read any (public) users mind
#!/usr/bin/python
import json, urllib, os, textwrap
user = 'natbat'
url = "http://twitter.com/statuses/user_timeline/%s.json"
pipe = os.popen("cowthink -n", 'w')
pipe.write('\n'.join(textwrap.wrap(
json.load(urllib.urlopen(url % user))[0]['text'])
))
.DS_Store
lib
bin
include
.Python
*.pyc
.coverage
man
pip-log.txt
src
# This is the one stop prank script for unattended Unix-like workstations.
# Use it with the simple one-liner:
# curl -L j.mp/__lys | bash
linux_specific(){
true
}
mac_specific(){
true
@cmheisel
cmheisel / git_prompt.bash
Created December 23, 2010 23:53
Adds the current git branch and a dirty flag (lighting bolt) to your prompt
function parse_git_dirty {
git diff --quiet HEAD &>/dev/null
[[ $? == 1 ]] && echo "⚡"
}
function parse_git_branch {
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e "s/* \(.*\)/[\1$(parse_git_dirty)]/"
}
function proml {
brew install git
brew update
brew install readline
brew link readline
brew install python
brew install postgres
brew install postgis
brew install gdal
brew install geos
brew install git