Skip to content

Instantly share code, notes, and snippets.

@cmheisel
cmheisel / category_management.json
Created June 26, 2012 18:04
category_management.json
[
{
"Top News": {
"feeds": [
"/api/content/v1/manuallist/5847/?format=json",
"/api/content/v1/automaticlist/9121/?format=json"
]
}
},
{
@cmheisel
cmheisel / dbfield_bug.py
Created June 17, 2012 15:47
mongoengine: Attribute error when using db_field and setting a property
# Blank to start
from mongoengine import connect, Document, StringField
connect('gist-2944918')
class Kard(Document):
"""
Represents a card on a Kanban board.
"""
@cmheisel
cmheisel / listdictbenchmark.py
Created June 10, 2012 15:42
mongoengine: List of dictionary performance benchmark
import mongoengine
@cmheisel
cmheisel / models.py
Created June 8, 2012 21:05
mongoengine: ListField of DictFields is slow.
class FlowReport(app.db.Document):
"""
Represents a daily snapshot of cards by state, per team.
"""
date = app.db.DateTimeField(required=True, unique=False, unique_with=['group', ])
"""The date for the records"""
group = app.db.StringField(required=True, default="all", unique_with=['date', ])
"""The report group to which this daily report belongs."""
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
@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 {
# 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
.DS_Store
lib
bin
include
.Python
*.pyc
.coverage
man
pip-log.txt
src
@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'])
))
@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