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 StringIO | |
| import urlparse | |
| import cgi | |
| from docutils import io, readers | |
| from docutils.core import publish_doctree, Publisher | |
| from docutils.transforms import TransformError | |
| ALLOWED_SCHEMES = '''file ftp gopher hdl http https imap mailto mms news nntp |
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
| # Pyramid 1.5 and lower | |
| Name Pattern View | |
| ---- ------- ---- | |
| debugtoolbar /_debug_toolbar/*subpath <function decorator at 0x349a398> | |
| __static/ /static/*subpath <function <pyramid.static.static_view object at 0x3421890> at 0x349a758> | |
| __static2/ /static2/*subpath <function <pyramid.static.static_view object at 0x3421950> at 0x349a9b0> | |
| __pdt_images/ /pdt_images/*subpath <function <pyramid.static.static_view object at 0x3421a50> at 0x349ab90> | |
| a / None | |
| no_view_attached / None | |
| route_and_view_attached / <function route_and_view_attached at 0x349f050> |
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 wsgiref.simple_server import make_server | |
| from wsgiref.util import application_uri | |
| import sys | |
| import json | |
| def home(): | |
| return 'hello world' | |
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
| #!/usr/bin/env python | |
| """This is a demonstration of sharing file descriptors across processes. | |
| It uses Tornado (need a recent post-2.0 version from github) and the | |
| multiprocessing module (from python 2.6+). To run it, start one copy | |
| of fdserver.py and one or more copies of testserver.py (in different | |
| terminals, or backgrounded, etc). Fetch http://localhost:8000 and | |
| you'll see the requests getting answered by different processes (it's | |
| normal for several requests to go to the same process under light | |
| load, but under heavier load it tends to even out). |
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
| _complete_hosts () { | |
| COMPREPLY=() | |
| cur="${COMP_WORDS[COMP_CWORD]}" | |
| host_list=`{ | |
| for c in /etc/ssh_config /etc/ssh/ssh_config ~/.ssh/config | |
| do [ -r $c ] && sed -n -e 's/^Host[[:space:]]//p' -e 's/^[[:space:]]*HostName[[:space:]]//p' $c | |
| done | |
| for k in /etc/ssh_known_hosts /etc/ssh/ssh_known_hosts ~/.ssh/known_hosts | |
| do [ -r $k ] && egrep -v '^[#\[]' $k|cut -f 1 -d ' '|sed -e 's/[,:].*//g' | |
| done |
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 threading | |
| import requests | |
| import logging | |
| logging.basicConfig() | |
| logging.getLogger().setLevel(logging.DEBUG) | |
| requests_log = logging.getLogger("requests.packages.urllib3") | |
| requests_log.setLevel(logging.DEBUG) |
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 threading | |
| import requests | |
| import logging | |
| from threadpool import ThreadPool | |
| from threadpool import makeRequests | |
| pool = ThreadPool(4) | |
| logging.basicConfig() | |
| logging.getLogger().setLevel(logging.DEBUG) | |
| requests_log = logging.getLogger("requests.packages.urllib3") |
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 wsgiref.simple_server import make_server | |
| from pyramid.config import Configurator | |
| from pyramid.response import Response | |
| from pyramid.compat import text_type | |
| from sqlalchemy.orm import scoped_session | |
| from sqlalchemy.orm import sessionmaker | |
| from sqlalchemy import create_engine | |
| from sqlalchemy.ext.declarative import declarative_base |
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
| Things with $ at the beginning are commands you run | |
| $ sudo yum install python-virtualenv openssl-devel zeromq-devel gcc | |
| $ mkvirtualenv datanommer | |
| $ cdvirtualenv | |
| $ mkdir src |
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 ctypes | |
| import os | |
| import sys | |
| here = os.path.dirname(__file__) | |
| cpath = os.path.abspath(os.path.join(here, "fib.so")) | |
| fiblib = ctypes.CDLL(cpath) | |
| def fib(n): | |
| if n == 0: |