This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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))) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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() { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
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') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Git Repo: | |
branches | |
dev | |
worker | |
production | |
master | |
dev |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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]' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[(x, getattr(settings, x)) for x in dir(settings) if x.startswith('DATABASE')] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
""" |