Skip to content

Instantly share code, notes, and snippets.

View jefftriplett's full-sized avatar
Living the dream

Jeff Triplett jefftriplett

Living the dream
View GitHub Profile
FROM MODEL
class Item(models.Model):
title = models.CharField(max_length=128)
photo = models.ImageField(upload_to="photos/",null=True, blank=True,)
description = models.TextField(null=True, blank=True,)
section = models.ForeignKey(Section)
order = models.IntegerField(null=True, blank=True,)
creation_date = models.DateTimeField(auto_now_add=True)
last_modified = models.DateTimeField(auto_now=True)
@jefftriplett
jefftriplett / bitlbee.ini
Created July 11, 2011 21:59
Bitlbee under Supervisord
; this annoyed me because it should have been simple but I fiddled with settings
; for quite some time. The -n is the important part though which causes bitlbee
; to not fork into the background. I tried several supervisord settings including
; pidproxy without any luck.
[program:bitlbee]
command=/usr/sbin/bitlbee -nv -c /etc/bitlbee/bitlbee.conf
user=bitlbee
@jefftriplett
jefftriplett / znc.ini
Created July 11, 2011 22:00
ZNC under supervisord
[program:znc]
command=/usr/bin/znc -f --datadir=/home/znc/.znc
user=znc
@jefftriplett
jefftriplett / ghetto_jenkins.sh
Created August 8, 2011 01:14
watchmedo demo for running CI without a buildbot or jenkins
#!/bin/bash
# this simply runs "django-admin.py test" every time it detects that a *.py
# file has changed.
watchmedo shell-command --patterns="*.py" --ignore-directories --recursive --command="django-admin.py test --noinput" project_name/
"""
Author: Jeff Triplett
Based off: https://code.djangoproject.com/wiki/PaginatorTag
Thanks to Brent O'Connor for pointing it out.
"""
from django import template
register = template.Library()
import datetime
import pymongo
import simplejson
from pymongo.objectid import ObjectId
class DateTimeMongoEncoder(simplejson.JSONEncoder):
def default(self, obj):
if isinstance(obj, (datetime.date, datetime.datetime)):
return obj.strftime('%Y-%m-%dT%H:%M:%S')
@jefftriplett
jefftriplett / redis_sets_tags.py
Created September 5, 2011 23:57
python sets and tags in redis
# Adapted from: http://rediscookbook.org/implement_tags_and_search_them.html
import redis
pool = redis.ConnectionPool(host='localhost', port=6379, db=0)
red = redis.Redis(connection_pool=pool)
red.set('book:1', {'title': 'Diving into Python', 'author': 'Mark Pilgrim'})
red.set('book:2', {'title': 'Programing Erlang', 'author': 'Joe Armstrong'})
red.set('book:3', {'title': 'Programing in Haskell', 'author': 'Graham Hutton'})
(work-armstrong-plz)Jeff-Tripletts-MacBook-Pro:work-armstrong-plz jefftriplett$ pip install armstrong
Downloading/unpacking armstrong
Using download cache from /Users/jefftriplett/.pip/download_cache/http%3A%2F%2Fpypi.python.org%2Fpackages%2Fsource%2Fa%2Farmstrong%2Farmstrong-11.09.0.alpha.2.tar.gz
Running setup.py egg_info for package armstrong
Downloading/unpacking armstrong.cli>=0.6.0 (from armstrong)
Using download cache from /Users/jefftriplett/.pip/download_cache/http%3A%2F%2Fpypi.python.org%2Fpackages%2Fsource%2Fa%2Farmstrong.cli%2Farmstrong.cli-0.6.0.tar.gz
Running setup.py egg_info for package armstrong.cli
Downloading/unpacking armstrong.core.arm-access>=0.1.1 (from armstrong)
Using download cache from /Users/jefftriplett/.pip/download_cache/http%3A%2F%2Fpypi.python.org%2Fpackages%2Fsource%2Fa%2Farmstrong.core.arm_access%2Farmstrong.core.arm_access-0.1.1.tar.gz
Running setup.py egg_info for package armstrong.core.arm-access
@jefftriplett
jefftriplett / pyhowl.py
Created September 20, 2011 05:36
Post to Howl (http://howlapp.com) from Python
"""
pyhowl - Post to Howl (http://howlapp.com)
Copyright (c) 2011, Jeff Triplett
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,
@jefftriplett
jefftriplett / filter_through_command.py
Created September 29, 2011 19:39
Sublime Text 2: "Filter Through Command" plugin
# saved from: http://pastie.org/private/bclbdgxzbkb1gs2jfqzehg
import sublime
import sublimeplugin
import subprocess
class RunExternalCommand(sublimeplugin.TextCommand):
"""
Runs an external command with the selected text,
which will then be replaced by the command output.