This file contains 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 | |
import time | |
body = r"""\ | |
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Streaming response demo</title> |
This file contains 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 itertools | |
import contextlib | |
import httplib | |
import urllib2 | |
import xlrd | |
def parse(fh, sheet=0, mappings=(), start=0, stop=None, step=1): | |
sheet = xlrd.open_workbook(file_contents=fh).sheet_by_index(0) |
This file contains 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
REM>Brainfuck | |
REM by Urban Mueller | |
REM RiscOS Assembler version by Keith Gaughan | |
REM v2.01 28-Aug-1999, 03:19am | |
ON ERROR PRINT REPORT$;" at ";ERL:END | |
DIM code% 2048 | |
sp=13:link=14:pc=15 | |
file$="<Obey$Dir>.Brainfuck" | |
: |
This file contains 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
""" | |
Thread pool extensions to SocketServer. | |
""" | |
import Queue | |
import SocketServer | |
import sys | |
import threading |
This file contains 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
RewriteEngine On | |
RewriteBase / | |
RewriteRule ^view/(.*)$ component/extension/$1 [QSA,L] |
This file contains 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
# 'pkg_name' is the name of a package/module. May be dotted | |
# 'obj_name' is the name of an object within said package. | |
# Why there isn't a straightforward function in the standard library for dealing with this already boggles my mind. | |
obj = __import__(pkg_name, fromlist=[object_name.split('.', 1)[0]]) | |
for segment in object_name.split('.'): | |
obj = getattr(obj, segment) |
This file contains 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
d1 = {} | |
d1 = {} | |
# get intersection of key sets. | |
common = set(d1) & set(d2) | |
# Check if all common keys map to the same value. | |
are_same = all(d1[k] == d2[k] for k in common) | |
# Get those common keys where the values differ. | |
differences = [k for k in common if d1[k] != d2[k]] |
This file contains 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 urllib2 | |
mgr = urllib2.HTTPPasswordMgr() | |
mgr.add_password('realm', 'http://example.com/base/', 'username', 'password') | |
urllib2.install_opener(urllib2.build_opener(urllib2.HTTPBasicAuthHandler(mgr))) | |
urllib2.urlopen('http://example.com/base/something/') |
This file contains 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
#!/bin/sh | |
find . -maxdepth 1 -mindepth 1 -type d -exec rm -rf {} \; | |
for i in *.tar.bz2; do | |
tar xjf $i && ( | |
echo '==>' Attempting build of ${i%.tar.bz2} | |
cd ${i%.tar.bz2} && \ | |
./configure --prefix=/opt/python-ci && \ | |
make && \ | |
make install && echo WIN || echo FAIL | |
) |
This file contains 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
<?php | |
function check_if_in_ranges($ip, array $ranges) { | |
$chunked_ip = to_chunked_ip($ip); | |
foreach ($ranges as $range) { | |
$parts = explode('/', $range, 2); | |
$chunked_range = to_chunked_ip($parts[0]); | |
if (count($chunked_range) != count($chunked_ip)) { | |
continue; | |
} |