Skip to content

Instantly share code, notes, and snippets.

import logging, logging.config
TOPIC_NAME = 'TOPIC-NAME'
GROUP_NAME = 'GROUP-NAME'
BOOTSTRAP_SERVERS = ['BROKER-HOST']
def setup_logging():
logging.config.dictConfig({
'version': 1,
@akheron
akheron / kafka-python.log
Created March 10, 2016 12:48
kafka-python heartbeat issue
[2016-03-10 14:34:50,186] DEBUG base 14747 139872076707584 Received successful heartbeat
[2016-03-10 14:34:50,186] DEBUG fetcher 14747 139872076707584 Adding fetch request for partition TopicPartition(topic='TOPIC-NAME', partition=0) at offset 143454
[2016-03-10 14:34:50,186] DEBUG fetcher 14747 139872076707584 Sending FetchRequest to node 1
[2016-03-10 14:34:50,187] DEBUG conn 14747 139872076707584 <BrokerConnection host=SERVER-HOSTNAME port=9092> Request 975: FetchRequest(replica_id=-1, max_wait_time=500, min_bytes=1, topics=[(topic='TOPIC-NAME', partitions=[(partition=0, offset=143454, max_bytes=1048576)])])
[2016-03-10 14:34:50,683] DEBUG consumer 14747 139872076707584 Sending offset-commit request with {TopicPartition(topic='TOPIC-NAME', partition=0): OffsetAndMetadata(offset=143454, metadata='')} to 1
[2016-03-10 14:34:50,684] DEBUG conn 14747 139872076707584 <BrokerConnection host=SERVER-HOSTNAME port=9092> Request 976: OffsetCommitRequest_v2(consumer_group='GROUP-NAME', consumer_grou
@akheron
akheron / pytest_mock.py
Created January 15, 2013 11:34
mock plugin for pytest
import pytest
import mock as mock_
class Mock(object):
def __init__(self):
self._patchers = []
def _stop(self):
for patcher in self._patchers:
@akheron
akheron / venv_cd.bash
Created November 14, 2012 09:39
Change to virtualenv when cd'ing to a directory
# If a directory contains a file named .venv, read its contents and activate
# the corresponding virtualenv.
venv_cd() {
local venv
if builtin cd "$@"; then
if [ -e .venv ]; then
venv=$(cat .venv)
if [ -z "$VIRTUAL_ENV" ]; then
workon "$venv" || true
@akheron
akheron / xorg-valgrind.log
Created August 6, 2012 04:52
Valgrind log with patched xserver-xorg, running with -core, crashes with segfault
==14106== Memcheck, a memory error detector
==14106== Copyright (C) 2002-2011, and GNU GPL'd, by Julian Seward et al.
==14106== Using Valgrind-3.7.0 and LibVEX; rerun with -h for copyright info
==14106== Command: /usr/bin/Xorg :4 -auth /var/run/lightdm/root/:4 -nolisten tcp vt7 -novtswitch -core -verbose 10
==14106==
X.Org X Server 1.11.3
Release Date: 2011-12-16
X Protocol Version 11, Revision 0
Build Operating System: Linux 3.2.0-27-generic x86_64 Ubuntu
@akheron
akheron / xorg-valgrind.log
Created August 1, 2012 05:06
Valgrind log with patched xserver-xorg, crashes with segfault
==27246== Memcheck, a memory error detector
==27246== Copyright (C) 2002-2011, and GNU GPL'd, by Julian Seward et al.
==27246== Using Valgrind-3.7.0 and LibVEX; rerun with -h for copyright info
==27246== Command: /usr/bin/Xorg :3 -auth /var/run/lightdm/root/:3 -nolisten tcp vt7 -novtswitch -verbose 10
==27246==
X.Org X Server 1.11.3
Release Date: 2011-12-16
X Protocol Version 11, Revision 0
Build Operating System: Linux 3.2.0-27-generic x86_64 Ubuntu
@akheron
akheron / xorg-valgrind.log
Created July 30, 2012 13:26
Valgrind log with patched xserver-xorg
==20591== Memcheck, a memory error detector
==20591== Copyright (C) 2002-2011, and GNU GPL'd, by Julian Seward et al.
==20591== Using Valgrind-3.7.0 and LibVEX; rerun with -h for copyright info
==20591== Command: /usr/bin/Xorg :1 -auth /var/run/lightdm/root/:1 -nolisten tcp vt7 -novtswitch -verbose 10
==20591==
X.Org X Server 1.11.3
Release Date: 2011-12-16
X Protocol Version 11, Revision 0
Build Operating System: Linux 3.2.0-27-generic x86_64 Ubuntu
@akheron
akheron / xorg-valgrind.log
Created July 30, 2012 11:58
Valgrind log for xorg serve crash
==7657== Memcheck, a memory error detector
==7657== Copyright (C) 2002-2011, and GNU GPL'd, by Julian Seward et al.
==7657== Using Valgrind-3.7.0 and LibVEX; rerun with -h for copyright info
==7657== Command: /usr/bin/Xorg :0 -auth /var/run/lightdm/root/:0 -nolisten tcp vt7 -novtswitch -verbose 10
==7657==
X.Org X Server 1.11.3
Release Date: 2011-12-16
X Protocol Version 11, Revision 0
Build Operating System: Linux 2.6.42-26-generic x86_64 Ubuntu
@akheron
akheron / postactivate
Created May 29, 2012 05:31
virtualenvwrapper hooks for sala
#!/bin/bash
# This hook is run after this virtualenv is activated.
export SALADIR=/path/to/passwords
. /path/to/sala/contrib/sala-completion.bash
@akheron
akheron / mailcap
Created May 24, 2012 10:44
mailcap for text/html alternatives in mutt
# Open in browser when viewing interactively
text/html; /usr/bin/sensible-browser '%s'; description=HTML Text; nametemplate=%s.html
# Dump with w3cm and the correct encoding when viewing non-interactively
text/html; /usr/bin/w3m -dump -T text/html -I %{charset} -O utf-8 %s; copiousoutput; description=HTML Text; nametemplate=%s.html
# Support non-standard image/jpg, too
image/jpg; display 'jpeg:'%s''; test=test -n "$DISPLAY"