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 time | |
from functools import wraps | |
def timeit(comment=None): | |
""" | |
auto establish and close mongo connection | |
""" | |
def decorator(func): | |
@wraps(func) | |
def wrapper(*args, **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
def checktype(*types): | |
def typerror(expect, got): | |
raise TypeError('expecting {}, got{}'.format(expect, type(got))) | |
def checker(fn): | |
def receiver(*args, **kwargs): | |
for _type, arg in zip(types, args): | |
type(arg) is _type or typerror(_type, arg) | |
return fn(*args, **kwargs) | |
return receiver |
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
// Helper | |
function print(obj) { | |
console.log(obj) | |
} | |
// Mimic Async-Await | |
function coRunner(feedback) { | |
let iterator = this; | |
let result = iterator.next(feedback); |
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 os | |
import io | |
from prettytable import PrettyTable | |
def countLines(path, extension) : | |
pt = PrettyTable() | |
pt.field_names = ['filename', '#lines'] | |
total_line = 0 | |
total_files = 0 |
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
from __future__ import division | |
from matplotlib import pylab as plt | |
import numpy as np | |
MAX = np.inf | |
DEBUG = True | |
# DEBUG = False | |
class Arm: | |
def __init__(self, name, mean, stddev, cost): |
NewerOlder