This file contains 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
class Model(object): | |
keyspace = None | |
column_family = None | |
key = None | |
data = {} | |
required = [] | |
modified = False | |
def __init__(self, **kwargs): | |
if self.key in kwargs and len(kwargs) == 1: |
This file contains 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 pstats | |
>>> p = pstats.Stats('p.1258156459.52174278XcQE.prof') | |
>>> p.strip_dirs().sort_stats(-1).print_stats(5) | |
Fri Nov 13 15:54:20 2009 p.1258156459.52174278XcQE.prof | |
124278 function calls (122386 primitive calls) in 0.589 CPU seconds | |
Ordered by: standard name | |
List reduced from 1014 to 5 due to restriction <5> |
This file contains 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
"Memcached cache backend" | |
from django.core.cache.backends import memcached | |
from django.utils.encoding import smart_unicode, smart_str | |
MIN_COMPRESS_LEN = 150000 | |
class CacheClass(memcached.CacheClass): | |
def add(self, key, value, timeout=None, min_compress_len=MIN_COMPRESS_LEN): | |
if isinstance(value, unicode): |
This file contains 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
#!/bin/bash | |
if [ $# -ne 1 ]; then | |
echo "Usage: vipy <python module>" | |
exit 1 | |
fi | |
MODULE_LOCATION=`python -c "import $1; print $1.__file__.rstrip('c')"` | |
if [ -z $MODULE_LOCATION ]; then |
This file contains 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 random | |
import time | |
from eventlet import patcher, greenpool, pools | |
patcher.monkey_patch() | |
import simplegeo | |
LAYER = 'your.layer.identifier.here' | |
OAUTH_KEY = 'YOUR OAUTH KEY HERE' |
This file contains 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
# In-memory Cassandra-ish thingy... useful for unit tests. Maybe useful for other | |
# stuff too? No support for SuperColumns, but that should be easy enough to add. | |
import bisect | |
import copy | |
from cassandra.ttypes import NotFoundException, Column, ColumnPath, ColumnOrSuperColumn | |
class SSTable(object): |
This file contains 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
1568020383607837124674242424233936224366074619938054295149435080651133347159866539515828916334423825699216287430613550119009746682495526220087196369932993220993947068398348139078036223234189886410582032934294689156382470618963836853600005504402303219553800308328245464091978334255365120288597797327665191066332303969094527875543599893710346844574971075921041496871881080512503217260769624804065596751534343662438394009356717682549849813579683807411836806956417224771432950855424795916847683629888419235012414123218681592018347300549566480645820788828884670170227348048694510744364877265930061422199605236539854481131874246370399956781377830722015722886884059955236617197194789439998472191229648923258247262131755689255146886795535534537354318015385271178803608088214700126029621133594790006436889852250107606783683417339851548995227133141803484257221095744914814397064115308252464652873341285802340753454548916615332528616057502990290828900499685424871335209817720727253000270548565157264252790009718525020443966599344478805 |
This file contains 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
# Requires apachelog from http://code.google.com/p/apachelog/source/browse/trunk/apachelog.py | |
import sys, time, re | |
from collections import defaultdict | |
from threading import Timer | |
import apachelog | |
class Parser(apachelog.parser): |
This file contains 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 django.core.paginator import ObjectPaginator | |
class QuickObjectPaginator(ObjectPaginator): | |
max_safe_pages = 0 | |
def __init__(self, object_list, per_page, orphans=0, max_safe_pages=0): | |
self.max_safe_pages = max_safe_pages | |
super(QuickObjectPaginator, self).__init__(object_list, per_page, orphans) | |
def validate_page_number(self, page_number): |
This file contains 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
# Create a root certificate and signing key. | |
$ step certificate create "Root CA" root.crt root.key --profile root-ca | |
Please enter the password to encrypt the private key: | |
Your certificate has been saved in root.crt. | |
Your private key has been saved in root.key. | |
# Create an intermediate certificate & signing key. This isn't | |
# required; we could use the root to sign directly which is | |
# probably fine for local dev and removes the need to bundle later. | |
$ step certificate create "Intermediate CA" int.crt int.key --profile intermediate-ca --ca root.crt --ca-key root.key |
NewerOlder