requirements
- SQLAlchemy==0.9.1
python initialdb.py python demo.py
class ErrorDict(object): | |
def __init__(self, errordict): | |
self.errordict = errordict | |
def __getitem__(self, item): | |
return self.errordict[item] | |
def __setitem__(self, key, value): | |
self.errordict[key] = value |
#! /usr/bin/env python | |
""" | |
Get a LGHT picture from LGTM.in ramdomly. | |
Usage | |
===== | |
:: | |
$ ./lgtm.py |
import argparse | |
def parse(args): | |
parser = argparse.ArgumentParser() | |
parser.add_argument('--send', choices=['zlib', 'bz2', 'none'], dest='send') | |
parsed = parser.parse_args(args) | |
if parsed.send: | |
return parsed.send | |
else: | |
return 'zlib' |
#!/bin/bash | |
# This bash script is to get the IPA dictionary for igo, | |
# allow to morpholigical analysis of Japanese for your project. | |
# You won't install anything. this script is for just downloading and compiling the dic. | |
# Actual process for MA is provided by igo-python. | |
# | |
# This will do: | |
# * create 'ipadic' directory here | |
# * download mecab-ipadic | |
# * download jar of igo |
#! /usr/bin/env python | |
""" | |
=== | |
xrt | |
=== | |
Replace inputed contents with spaces on each line like C-x r t of emacs. | |
4 white-spaces will be inserted by default. | |
But you can change this stirng by specifying '-i' option'. |
from hashlib import sha1 | |
def default_key_generator(func, *args, **kwargs): | |
""" モジュール名、関数名 + 文字列化した引数から生成したsha1をキーとするキャッシュ用キー生成関数 | |
""" | |
func_identifier = '{func.__module__}:{func.__name__}'.format(func=func) | |
arg_identifier = 'args:{args}kwargs:{kwargs}'.format(args=args, kwargs=kwargs) | |
return sha1(func_identifier + '::' + arg_identifier).hexdigest() |
requirements
python initialdb.py python demo.py
import sys | |
from itertools import product | |
def build_truth_table(inputs): | |
""" | |
>>> print(build_truth_table(['P', 'Q', 'S'])) | |
P | Q | S | | |
-------+-------+-------+ | |
True | True | True | |
def removable_decorators(*decorators): | |
def wrapper(func): | |
wrapped = reduce(lambda a, b: b(a), reversed(decorators + (func,))) | |
wrapped.original_func = func | |
return wrapped | |
return wrapper |
from wsgiref.simple_server import make_server; make_server('', 8888, lambda e, s: [s('200 Ok', []), 'hello'][1]).serve_forever() |