requirements
- SQLAlchemy==0.9.1
python initialdb.py python demo.py
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="utf-8"><html> | |
<style type="text/css"> | |
<!-- | |
div.monolith { | |
position: relative; | |
width: 300px; | |
height: 400px; |
def pocamono(wrappers, original_name=None): | |
def _dec(function): | |
if not original_name: | |
globals()['_' + function.__name__] = function | |
else: | |
globals()[original_name] = function | |
if isinstance(wrappers, list): | |
# TODO: Accept tuple, iterable too. | |
return reduce(lambda a, b: b(a), [function] + wrappers) | |
else: |
# -*- coding:utf-8 -*- | |
from __future__ import print_function | |
(lambda zero, one, succ, is_zero, pred, AND, IF, Y, undefined: | |
(lambda add, mul, sub: | |
(lambda GT, EQ: | |
(lambda rem, REP: | |
(lambda three, five, num_from_church: | |
(lambda fifteen, one_hundred: | |
(lambda fizzbuzz: |
class AssertInstanceUpdatedMixin(object): | |
""" Mixin class for TestCase to add method checking instance.utime updated or not. | |
""" | |
class AssertInstanceUpdatedContext(object): | |
def __init__(self, instance, test_case, model_class=None): | |
self.instance = instance | |
self.test_case = test_case | |
self.model_class = model_class or instance.__class__ | |
def __enter__(self): |
import re | |
eval_matcher = re.compile(r'<%([\s\S]+?)%>') | |
def render_template(template): | |
matched = eval_matcher.match(template) | |
assert matched is not None | |
repl_string = str(eval(matched.group(1))) | |
return eval_matcher.sub(template, repl_string) |
from time import sleep | |
from wsgiref.simple_server import make_server | |
def never_response_app(environ, start_response): | |
sleep(2**10) # Forever sleeping | |
if __name__ == '__main__': | |
httpd = make_server('', 5000, never_response_app) |
from wsgiref.simple_server import make_server; make_server('', 8888, lambda e, s: [s('200 Ok', []), 'hello'][1]).serve_forever() |
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 |
import sys | |
from itertools import product | |
def build_truth_table(inputs): | |
""" | |
>>> print(build_truth_table(['P', 'Q', 'S'])) | |
P | Q | S | | |
-------+-------+-------+ | |
True | True | True | |
requirements
python initialdb.py python demo.py