Skip to content

Instantly share code, notes, and snippets.

View brew --config && brew doctor
$ brew --config
HEAD: d0a2ed907ddb750c519bb9f56d7055490f968edf
HOMEBREW_PREFIX: /usr/local/homebrew
HOMEBREW_CELLAR: /usr/local/homebrew/Cellar
CPU: 8-core 64-bit ivybridge
OS X: 10.8.3-x86_64
Xcode: 4.6.1
razamatan /
Created March 10, 2011 01:26
simple conversion from etree parsed xml to objects
''' xml utilities '''
__author__ = ''
from itertools import groupby
from operator import attrgetter
def split_ns(txt):
''' returns [ns, tag] for '{ns}tag'
>>> split_ns('{}nil')
razamatan /
Created February 8, 2011 22:43
fix for ZSI 2.0 and python 2.6's ssl handling
# in class TimeoutHTTPS:
def connect(self):
sock = TimeoutSocket(self.timeout)
sock.connect((, self.port))
self.sock = ssl.wrap_socket(sock, self.key_file, self.cert_file)
razamatan / randomize iterator in python
Created December 10, 2010 10:10
randomize python iterator
View randomize iterator in python
from random import shuffle, randrange
def randomize(iterable, bufsize=1000):
''' generator that randomizes an iterable. space: O(bufsize). time: O(n). '''
buf = list()
for x in iterable:
if len(buf) == bufsize:
i = randrange(bufsize)
yield buf[i]
buf[i] = x