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 requests | |
import urllib | |
import json | |
def get(url, params): | |
print url, params | |
return json.loads(requests.get(url, params=params).text) | |
def iter_flatten(data): |
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 string | |
letters = frozenset("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" | |
+ "0123456789_") | |
def clean(seq): return filter(lambda x: x in letters, seq) | |
if __name__ == '__main__': | |
print clean("test!!!!") | |
print clean("1__^^^***test!!!!") |
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 time | |
def get_universal_time(): | |
return time.time() | |
def plural(n, word): | |
return word if n == 1 else word + "s" | |
age_units = [("year", 365.25 * 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
(def rand-string (n) | |
(let c "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" | |
(with (nc 62 s (newstring n) i 0) | |
(w/infile str "/dev/urandom" | |
(while (< i n) | |
(let x (readb str) | |
(unless (> x 247) | |
(= (s i) (c (mod x nc))) | |
(++ i))))) | |
s))) |