Skip to content

Instantly share code, notes, and snippets.

View smerritt's full-sized avatar

Sam Merritt smerritt

View GitHub Profile
@smerritt
smerritt / mimestream.py
Last active August 29, 2015 14:05
If a a MIME streams in a forest, does anyone care?
#!/usr/bin/env python
#
# An overly-strict multipart-MIME parser thingy. Works for my contrived
# examples, at least. Does things in a streaming fashion so you can deal with
# large (multi-GB) multipart MIME messages without using all your memory.
import email.parser
import pprint
import random
import sys
@smerritt
smerritt / gist:6d5c2e209376f1d1c834
Created July 11, 2014 16:24
This is a valid program in C, Perl, and sh.
#define do main() /*
# This is a valid program in C, Perl, and sh.
eval 'function sub() { echo "I like code."; exit; }';
sub echo {}
#*/
do {
printf("I like code.\n");
}
@smerritt
smerritt / gist:255ad07ee6989c0f44ae
Created July 3, 2014 00:57
chunked HTTP putter
#!/usr/bin/env python
import httplib
import time
conn = httplib.HTTPConnection('localhost', '6020')
conn.putrequest('PUT', '/sdb2/831/AUTH_test/c/o')
conn.putheader('Transfer-Encoding', 'chunked')
conn.putheader('Content-Type', 'application/octet-stream')
conn.putheader('X-Timestamp', "%016.05f" % time.time())
# NOTE: all this code is completely untested. At best, it's syntactically
# valid, but don't bet on it.
import errno
import fcntl
import os
import splicetee
F_SETPIPE_SZ = getattr(fcntl, 'F_SETPIPE_SZ', 1031)
Resque.configure do |config|
config.redis = MockRedis.new
end
diff --git a/swiftclient/client.py b/swiftclient/client.py
index ee80769..275c6b7 100644
--- a/swiftclient/client.py
+++ b/swiftclient/client.py
@@ -219,8 +219,9 @@ def http_connection(*arg, **kwarg):
return conn.parsed_url, conn
-def get_auth_1_0(url, user, key, snet):
- parsed, conn = http_connection(url)
@smerritt
smerritt / Helpful Gerrit queries
Last active August 29, 2015 13:56
Gerrit queries that I use to help me find stuff in the howling torrent of pending reviews. For best results, paste them in the Gerrit search box and bookmark the resulting page.
# Starred reviews
# I star something when I want to follow it and make sure it gets in; that way I can find it again.
# I never have more than a half-dozen things starred at a time, or else it's pointless.
is:starred
# My pending changes
status:open AND owner:torgomatic
# Everything Swift-related that's ready for review (no WIP stuff)
status:open AND -status:workinprogress AND (project:openstack/swift OR project:openstack/python-swiftclient OR project:openstack/swift-bench OR project:openstack/object-api)
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Benchmark the relative performance of stdlib's json, simplejson, and
# a wrapped simplejson that gives the same API as stdlib's json.
import benchmark
import hashlib
import json as stdjson
import simplejson
#!/usr/bin/env python
import benchmark
import heapq
class BenchHeapq(benchmark.Benchmark):
def eachSetUp(self):
self.size = 500
#!/usr/bin/env python
import os
from swift.common.utils import get_logger
NLOGGERS = 500
for _ in xrange(NLOGGERS):
get_logger({})