Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am akheron on github.
  • I am akheron (https://keybase.io/akheron) on keybase.
  • I have a public key whose fingerprint is B5D6 953E 6D50 59ED 7ADA 0F2F D365 7D24 D058 434C

To claim this, I am signing this object:

@akheron
akheron / gist:9502209
Created March 12, 2014 07:09
du -h sorted by size
# From http://derblub.com/human-readable-and-by-size-sorted-disk-usage-in-bash
function duf {
du -sk "$@" | sort -n | while read size fname; do for unit in k M G T P E Z Y; do if [ $size -lt 1024 ]; then echo -e "${size}${unit}\t${fname}"; break; fi; size=$((size/1024)); done; done
}
@akheron
akheron / setup.py
Created March 5, 2014 14:00
Minimal Django logging setup that works with Gunicorn
LOGGING = {
'version': 1,
'disable_existing_loggers': False,
}
@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 / ec2-connect.sh
Created October 19, 2012 11:20
Connect to Amazon EC2 instances
#!/bin/sh
#
# Look up the public IP address of an Amazon EC2 instance via
# the Amazon API, and connect to it using ssh.
# Defaults
region=eu-west-1
identity_file=~/amazon/identity.pem
username=ubuntu
@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