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 os | |
import re | |
import pyuv | |
LINESEP = os.linesep.encode() | |
PATTERN = re.compile(r'^(?P<file_name>([A-Za-z]:)?[^:]+):' | |
'(?P<line_number>\d+):((?P<position>\d+):)?' | |
'\s+((?P<code>\w{4,4})\s+)?(?P<reason>.*)$') |
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
. |
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
curl -L -o requests.tar.gz https://github.com/schlamar/requests/archive/new-urllib3-api.tar.gz | |
tar -xzvf requests.tar.gz | |
curl -L -o test_proxy.py https://gist.github.com/schlamar/5080598/raw/test_proxy.py | |
python test_proxy.py |
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
class VLCFileSystem(object): | |
_cur_path = None | |
_cur_dir = None | |
@classmethod | |
def listdir(cls, path): | |
url = 'http://127.0.0.1:8080/requests/browse.json?dir=%s' % path | |
resp = requests.get(url) | |
data = resp.json()['element'] |
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 | |
def _packages_path(): | |
t = os.path.join(os.path.dirname(__file__), '..') | |
return os.path.abspath(t) | |
SITE_PACKAGES = os.path.join(_packages_path(), 'Lib', 'site-packages') | |
_PACKAGING_MODS = os.path.join(_packages_path(), 'Lib', 'packaging') |
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 operator import lt | |
def insertion_sort(data, cmp_func=lt): | |
for i in xrange(1, len(data)): | |
if cmp_func(data[i], data[i - 1]): | |
el = data.pop(i) | |
j = i - 1 | |
while j > 0 and cmp_func(el, data[j - 1]): |
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
""" | |
remconsole.py | |
A Python console you can embed in a program and attach to remotely. | |
To spawn a Python console in a script do the following in any scope | |
of any module: | |
import remconsole | |
remconsole.spawn_server() |
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 cPickle | |
import json | |
import ujson | |
import msgpack | |
d = { | |
'words': """ | |
Lorem ipsum dolor sit amet, consectetur adipiscing | |
elit. Mauris adipiscing adipiscing placerat. | |
Vestibulum augue augue, |
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 _lookup(pos): | |
def composition(*args): | |
return args[pos] | |
return composition | |
def _apply(func, *funcs): | |
def composition(*args): | |
return func(*(f(*args) for f in funcs)) | |
return composition |
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 link(f, other): | |
'''Resolve other with the current Future.''' | |
def on_done(f): | |
e = f.exception() | |
if e: | |
other.set_exception(e) | |
else: | |
other.set_result(f.result()) |