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
#!/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 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 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 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
# 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 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 random | |
import itertools | |
def find_collision(rng): | |
d = {} | |
for iteration in itertools.count(): | |
nonce = rng() | |
if nonce in d: | |
return iteration |
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
class Outer { | |
public Outer() { | |
} | |
public class Inner { | |
public Inner() { | |
} | |
public void doit() { | |
System.out.println("Sup."); |
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
1568020383607837124674242424233936224366074619938054295149435080651133347159866539515828916334423825699216287430613550119009746682495526220087196369932993220993947068398348139078036223234189886410582032934294689156382470618963836853600005504402303219553800308328245464091978334255365120288597797327665191066332303969094527875543599893710346844574971075921041496871881080512503217260769624804065596751534343662438394009356717682549849813579683807411836806956417224771432950855424795916847683629888419235012414123218681592018347300549566480645820788828884670170227348048694510744364877265930061422199605236539854481131874246370399956781377830722015722886884059955236617197194789439998472191229648923258247262131755689255146886795535534537354318015385271178803608088214700126029621133594790006436889852250107606783683417339851548995227133141803484257221095744914814397064115308252464652873341285802340753454548916615332528616057502990290828900499685424871335209817720727253000270548565157264252790009718525020443966599344478805 |
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 math | |
import random | |
class Statistic(object): | |
""" | |
Hookin' it up with the seven descriptive statistics. | |
""" | |
def __init__(self, sample): |
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
# 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 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 = 'abcdefghijklmnopqrstuvwyz1234567890' | |
>>> for i in xrange(len(x) + 1): | |
... y = (x[:i] + 'x' * len(x))[:len(x)] | |
... print timeit.Timer('x == y', 'from __main__ import x, y').timeit() | |
... | |
0.0604889392853 | |
0.0732460021973 | |
0.069344997406 | |
0.0671350955963 | |
0.0664479732513 |
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
def diskstats(): | |
file_path = '/proc/diskstats' | |
# http://lxr.osuosl.org/source/Documentation/iostats.txt | |
columns_disk = ['major_dev_num', 'minor_dev_num', 'device', 'reads', 'reads_merged', 'sectors_read', 'ms_reading', 'writes', 'writes_merged', 'sectors_written', 'ms_writing', 'current_ios', 'ms_doing_io', 'weighted_ms_doing_io'] | |
columns_partition = ['major_dev_num', 'minor_dev_num', 'device', 'reads', 'sectors_read', 'writes', 'sectors_written'] | |
result = {} | |
for line in (l for l in open(file_path, 'r').xreadlines() if l != ''): | |
parts = line.split() |