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
def running_sum_generator(iterable): | |
sum = 0 | |
for i in iterable: | |
if not i: | |
continue | |
sum += i | |
yield sum | |
def running_avg(value_list): |
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 datetime import datetime | |
from math import sqrt | |
from time import sleep | |
import csv | |
import logging | |
import urlparse | |
from selenium import selenium | |
SELENIUM_BROWSERS = ['firefox'] |
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.db.models.query import QuerySet | |
class QuerySetFromIter(QuerySet): | |
def __init__(self, objects=[], model=None, query=None, *args, **kwargs): | |
if model is None: | |
if len(objects): | |
model = type(objects[0]) | |
else: | |
# TODO: find a better way to handle this |
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 | |
TASK=$1 | |
node_checksum() { | |
if [ "$1" = "$2" ]; then | |
return | |
elif [ -z $2 ]; then | |
echo 'Checksums empty' #missing in raspberry pi binary | |
return |
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
# stdout to file | |
echo test > file.txt | |
# stdout append to file | |
echo test >> file.txt | |
# stderr to file | |
cmd 2> file.txt | |
# stderr to stdout |
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
python setup.py sdist bdist_egg upload |
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 redis import Redis | |
r = Redis('host', db=1, password='pass') | |
r.keys(':1:cachekey*') |
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 string | |
rand_string = ''.join(random.choice(string.ascii_letters + string.digits) | |
for i in xrange(random.randint(6, 20))) |
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
date = now().replace(hour=0, minute=0, second=0, microsecond=0) |
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
SELECT * FROM [table name] LIMIT [row id], 1; |
OlderNewer