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
import functools
class memoize(object):
def __init__(self, func):
self.func = func
self.cache = {}
def __call__(self, *args):
return self.cache_get(args, lambda: self.func(*args))
def __get__(self, obj, objtype):
return self.cache_get(id(obj), lambda: self.__class__(functools.partial(self.func, obj)))
// Attempt to make a drop-and-forget bunch of scripts that mimick some missing html5 goodies automatically
// Example:
// $(document).ready(function() {
// ProvideHtml5.autofocus()
// ProvideHtml5.datepicker()
// ProvideHtml5.forcenumber()
// })
var ProvideHtml5 = {
autofocus = function() {
@jefftriplett
jefftriplett / convert_hg_to_git.sh
Created January 12, 2010 05:13
convert a mercurial (HG) repo to Git
# Converting an HG repo to Git with commit history (via: http://tinyurl.com/yajlk9x)
$ git clone git://repo.or.cz/fast-export.git
$ mkdir new_git_repo
$ cd new_git_repo
$ git init
$ /path/to/hg-fast-export.sh -r /path/to/hg_repo
$ git checkout HEAD
Patchwork commands
Available commands:
apache_activate Set Apache to start on boot
apache_available_modules List available Apache modules
apache_available_sites List available Apache sites
apache_create_website Create a new website
apache_deactivate Set Apache to not start on boot
apache_delete_website Delete a website (! delete all file and fol...
"""
A quick and dirty adaptation of Daniel's pubsubittyhub that supports mongodb to demo and scratch an itch.
A tiny implementation of pubsubhubbub with webhooks.
Not recommended at scale, but maybe fun for little projects.
Based off ``watercoolr`` (http://github.com/jcapote/watercoolr).
"""
__author__ = 'Daniel Lindsley'
__version__ = ('0', '1', '0')
"""
Git Repo:
branches
dev
worker
production
master
dev
#!/usr/bin/env python
from __future__ import with_statement # needed for python 2.5
from fabric.api import *
from fabric.contrib.console import confirm
# ================================================================
# NOTE:
# using this fabfile expects that you have the python utility
# fabric installed locally, ssh access to reamea.com, and your
# ssh public key associated with the account '[email protected]'
#!/usr/bin/env python
# -*- coding: iso-8859-1 -*-
"""
SUNRISET.C - computes Sun rise/set times, start/end of twilight, and
the length of the day at any date and latitude
Written as DAYLEN.C, 1989-08-16
Modified to SUNRISET.C, 1992-12-01
[(x, getattr(settings, x)) for x in dir(settings) if x.startswith('DATABASE')]
try:
from ipdb import Pdb
except ImportError:
from pdb import Pdb
import sys
class PdbTraceback(object):
"""
Drops into pdb or ipdb if a view raises an exception. Should be the last
thing in MIDDLEWARE_CLASSES
"""