Skip to content

Instantly share code, notes, and snippets.

View williamsjj's full-sized avatar

Jason J. W. Williams williamsjj

View GitHub Profile
#!/usr/bin/python
import StringIO
import gzip
my_raw_string = "howdy doody!"
zbuf = StringIO.StringIO()
zf = gzip.GzipFile(mode="wb",compresslevel=6,fileobj=zbuf)
zf.write(my_raw_string)
zf.flush()
my_gzip_string= zbuf.getvalue()
↑ ↕ ↓ ⚡
def getListeningPort(self, reactor):
"""
Get a TCP port from a reactor
"""
return reactor.listenUDP(0, DatagramProtocol())
def test_connectionLostLogMsg(self):
"""
When a connection is lost, an informative log dict should be logged
(see L{getExpectedConnectionLostLogMsg}) containing: the event source,
=ERROR REPORT==== 20-Feb-2011::16:56:18 ===
connection <0.12317.0> (running), channel 1 - error:
{{{bad_return_value,
{error,
{badarg,
[{erlang,is_process_alive,[<15672.23498.0>]},
{rabbit_amqqueue,'-internal_declare/2-fun-3-',2},
{rabbit_misc,'-execute_mnesia_tx_with_tail/1-fun-0-',1},
{mnesia_tm,apply_fun,3},
{mnesia_tm,execute_transaction,5},
=INFO REPORT==== 20-Feb-2011::16:56:23 ===
accepted TCP connection on 0.0.0.0:5673 from 127.0.0.1:59588
=INFO REPORT==== 20-Feb-2011::16:56:23 ===
starting TCP connection <0.12376.0> from 127.0.0.1:59588
=WARNING REPORT==== 20-Feb-2011::16:56:23 ===
exception on TCP connection <0.12376.0> from 127.0.0.1:59588
connection_closed_abruptly
import sys, json, pika
from pika.connection import SimpleReconnectionStrategy
def msg_rcvd(channel, method, header, body):
if header.content_type != "application/json":
print "Discarding message. Not JSON."
channel.basic_ack(delivery_tag=method.delivery_tag)
return
import sys, json, asyncore, pika
from pika.reconnection_strategies import SimpleReconnectionStrategy
def msg_rcvd(channel, method, header, body):
if header.content_type != "application/json":
print "Discarding message. Not JSON."
channel.basic_ack(delivery_tag=method.delivery_tag)
return
@williamsjj
williamsjj / gist:848376
Created March 1, 2011 00:39
pika_properties_fail.py
import pika
def connected(conn):
conn.channel(build_channel)
# Establish connection to broker
creds_broker = pika.PlainCredentials("guest", "guest")
conn_params = pika.ConnectionParameters("localhost",
virtual_host = "/",
credentials = creds_broker)
@williamsjj
williamsjj / gist:850204
Created March 2, 2011 00:23
HTTP Riak Response
HTTP/1.1 200 OK
Vary: Accept-Encoding
Server: MochiWeb/1.1 WebMachine/1.7.3 (participate in the frantic)
Link: </riak/riak_perf_test/ccode_svnsm4>; riaktag="contained", </riak/riak_perf_test/ccode_a6ym7i>; riaktag="contained", </riak/riak_perf_test/ccode_woy0ru>; riaktag="contained", </riak/riak_perf_test/ccode_nfofjs>; riaktag="contained", </riak/riak_perf_test/ccode_oovfyq>; riaktag="contained", </riak/riak_perf_test/ccode_5852p9>; riaktag="contained", </riak/riak_perf_test/ccode_aowge1>; riaktag="contained", </riak/riak_perf_test/ccode_bt5psm>; riaktag="contained", </riak/riak_perf_test/ccode_36jmpr>; riaktag="contained", </riak/riak_perf_test/ccode_33ulkn>; riaktag="contained", </riak/riak_perf_test/ccode_52j45o>; riaktag="contained", </riak/riak_perf_test/ccode_j0woil>; riaktag="contained", </riak/riak_perf_test/ccode_y3rcwn>; riaktag="contained", </riak/riak_perf_test/ccode_kkrlnj>; riaktag="contained", </riak/riak_perf_test/ccode_vf3zhf>; riaktag="contained", </riak/riak_perf_test/ccode_efd91l>; riakta
=ERROR REPORT==== 2-Mar-2011::14:48:50 ===
** State machine <0.8693.13> terminating
** Last event in was inputs_done
** When State == executing
** Data == {state,1,riak_kv_reduce_phase,
{state,
{javascript,
{reduce,
{jsanon,