Web Frameworks
- Django — Flask
- Rails — Sinatra
- Hapi — Express
- Pecan — Falcon
Libraries
raise MyError, e.args, sys.exc_info()[2] |
N = 5 | |
V = 0.001 | |
for i in range(N): | |
print V * (2 ** i) |
# solom/__init__.py | |
THREAD_LOCAL = threading.local() | |
# In some pecan helper module... | |
def before_hook(self): | |
# Use thread-local storage so we don't have to | |
# add two extra params to virtuall every single | |
# function in our app! | |
solum.THREAD_LOCAL.ctx = context.RequestContext(...) |
from __future__ import division | |
import multiprocessing as mp | |
import argparse | |
import random | |
import time | |
from gevent import monkey as curious_george | |
curious_george.patch_all(thread=False, select=False) |
Helps scale writes:
Caveats:
░░░░░░░░░▄░░░░░░░░░░░░░░▄░░░░ | |
░░░░░░░░▌▒█░░░░░░░░░░░▄▀▒▌░░░ | |
░░░░░░░░▌▒▒█░░░░░░░░▄▀▒▒▒▐░░░ | |
░░░░░░░▐▄▀▒▒▀▀▀▀▄▄▄▀▒▒▒▒▒▐░░░ | |
░░░░░▄▄▀▒░▒▒▒▒▒▒▒▒▒█▒▒▄█▒▐░░░ | |
░░░▄▀▒▒▒░░░▒▒▒░░░▒▒▒▀██▀▒▌░░░ | |
░░▐▒▒▒▄▄▒▒▒▒░░░▒▒▒▒▒▒▒▀▄▒▒▌░░ | |
░░▌░░▌█▀▒▒▒▒▒▄▀█▄▒▒▒▒▒▒▒█▒▐░░ | |
░▐░░░▒▒▒▒▒▒▒▒▌██▀▒▒░░░▒▒▒▀▄▌░ | |
░▌░▒▄██▄▒▒▒▒▒▒▒▒▒░░░░░░▒▒▒▒▌░ |
$ pbpaste | python -m json.tool | pbcopy |
def parse_host(host, default_port=None): | |
# NOTE(kgriff): The value from the Host header may | |
# contain a port, so check that and strip it if | |
# necessary. This is complicated by the fact that | |
# a hostname may be specified either as an IP address | |
# or as a domain name, and in the case of IPv6 there | |
# may be multiple colons in the string. | |
if host.startswith('['): | |
# IPv6 address with a port |