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 sys | |
import random | |
import itertools | |
from collections import Counter | |
clean = lambda s: s.replace('\'', '').lower().strip() | |
def is_word(i): | |
i = i.strip() | |
return i and (len(i) > 1 or i == 'a') |
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 redis | |
from datetime import datetime | |
import uuid | |
import time | |
import json | |
import datetime | |
KEY_TTL = 24 * 60 * 60 |
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 datetime | |
import requests | |
import json | |
class StubObject: | |
def __init__(self, **kwargs): | |
self.__dict__['data'] = {} | |
self.data.update(kwargs) | |
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 uuid | |
gen_uid = lambda: uuid.uuid4().hex | |
class RedisObject: | |
keyspace = 'object' | |
def __init__(self, store, uid=None, ttl=KEY_TTL): | |
self.__dict__['store'] = store | |
self.__dict__['uid'] = uid or gen_uid() |
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 timer(object): | |
def __init__(self, text, n=1): | |
self.text = text | |
self.n = n | |
def __enter__(self): | |
self.t1 = time.time() | |
def __exit__(self, *args): | |
delta = time.time() - self.t1 |
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
$(function() { | |
var $columns = $('.column ul'); | |
var heights = $columns.map(function() { return $(this).height(); }); | |
var tallest = Math.max.apply(null, $.makeArray(heights)); | |
$columns.height(tallest); | |
}); |
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
$(function() { | |
var $columns = $('.column ul'); | |
var heights = $columns.map(function() { return $(this).height(); }); | |
var tallest = Math.max.apply(null, $.makeArray(heights)); | |
$columns.height(tallest); | |
}); |
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 zmq | |
import logging | |
import uuid | |
MASTER_ENDPOINT = 'tcp://127.0.0.1:5000' | |
WORKER_ENDPOINT = 'tcp://127.0.0.1:5001' | |
log = logging.getLogger(__name__) | |
TASKS = {} |
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
(function() { | |
var formatters = { | |
'phone' : [/^\(?\s?(\d{3})\s?\)?\s?\-?\s?(\d{3})\s?\-?\s?(\d{4})$/, '($1) $2-$3' ], | |
'ssn' : [/^(\d{3})\s?\-?\s?(\d{2})\s?\-?\s?(\d{3})$/, '$1-$2-$3' ], | |
'creditcard' : [/^(\d{4})\s?\-?\s?(\d{4})\s?\-?\s?(\d{4})\s?\-?\s?(\d{4})$/, '$1-$2-$3-$4'] | |
}; | |
jQuery.fn.formatWith = function(regex, replacement) { | |
$(this).change(function() { | |
this.value = this.value.replace(regex, replacement); |
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 name="control_group(name, label, **kwargs)"> | |
<div class="control-group ${'required' if kwargs.get('required') else ''}"> | |
<label | |
class="control-label" | |
for="${kwargs.get('id') or name}"> | |
${label}: | |
</label> | |
<div class="controls"> |