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
from collections import defaultdict | |
class ArgDefaultDict(defaultdict): | |
def __missing__(self, key): | |
self[key] = self.default_factory(key) | |
return self[key] |
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
package main | |
// Seems like this could be problematic when extending a type in a 3rd party module... | |
import ( | |
"fmt" | |
) | |
type Shredder interface { | |
Shred() |
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
#====== Decorator to use memcached for locking ======= | |
def mc_lock(namespace, on_lock_failed) : | |
''' | |
This uses memcached to provide a lock on a key before performing some operation. | |
The first argument provided to the decorated function will be the key. | |
It will be preceded by $namespace to ensure uniqueness | |
on_lock_failed is a function that will be called if we fail to acquire the lock | |
''' |
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 | |
# encoding: utf-8 | |
""" | |
untitled.py | |
Created by Daniel Frank on 2011-10-24. | |
Copyright (c) 2011 __MyCompanyName__. All rights reserved. | |
""" | |
import sys |
NewerOlder