Skip to content

Instantly share code, notes, and snippets.

View schlamar's full-sized avatar

Marc Schlaich schlamar

View GitHub Profile
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']
@schlamar
schlamar / start_test.sh
Last active December 14, 2015 11:38
Test urllib3 and requests for HTTPS proxy CONNECT support (https://github.com/shazow/urllib3/pull/170).
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
@schlamar
schlamar / gist:5003934
Last active December 14, 2015 01:09
Sublime Text 3 asynchronous linting with libuv event loop
.
@schlamar
schlamar / gist:5003484
Last active December 14, 2015 01:08
Asynchronous child IO with pyuv
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>.*)$')
@schlamar
schlamar / gist:4345304
Created December 20, 2012 13:21
Safe pickle implementations
In [1]: %paste
import hmac
import hashlib
import cPickle
import cStringIO
key = '\xa7\x9ePS\xf5\x84\xce\xc8\xad\xcdfEb\x94\x10K\x9b\x12\xed'
dig_size = hashlib.sha1().digest_size
import sys
import gevent
from gevent.coros import RLock
from gevent.server import StreamServer
from gevent.socket import create_connection
lock = RLock()
@schlamar
schlamar / gist:4149031
Created November 26, 2012 16:11
pygtk + pyglet
#!/usr/bin/python
import sys
import time
import math
import gtk
import gobject
import pyglet
import pyglet.gl as gl
@schlamar
schlamar / win32i18n.py
Last active October 13, 2015 03:08
I18N with Python on win32
#!/usr/bin/env python
# -*- coding: utf-8 -*-
'''
This is the modified module `libi18n.locale` from
https://www.mail-archive.com/python-list@python.org/msg188668.html.
It is fixed to distinguish internationalization and
localization. Reference: http://tinyurl.com/gnulocale
@schlamar
schlamar / !Python serialization
Created July 18, 2012 05:32
Python serializer benchmark: json, simplejson, cPickle, messagepack, simpleubjson, marshal, literal_eval
System
======
Windows 7
Python 2.7.2 (default, Jun 12 2011, 15:08:59) [MSC v.1500 32 bit (Intel)]
Small data
==========
@schlamar
schlamar / gist:2993700
Last active September 23, 2016 20:55
urllib2 HTTPS connection with proxy and cert verification
import httplib
import urllib2
import ssl
import certifi
from backports.ssl_match_hostname import match_hostname
class CertValidatingHTTPSConnection(httplib.HTTPConnection):
default_port = httplib.HTTPS_PORT