Skip to content

Instantly share code, notes, and snippets.


Steinn Eldjárn Sigurðarson steinnes

View GitHub Profile
steinnes /
Last active Aug 6, 2019
Three golden rules for bug reports

"3" Golden Rules for Bug Reports

A common problem with bug reports, according to developers, is that they are often too vague to be helpful. This can frustrate both reporters and developers, and damage an otherwise productive and positive scenario.

If a report is vague, it becomes extremely hard to fix. Why? Because the developer may not be able understand what was going on (from the vague description) and is very unlikely to be able to duplicate the behavior.

Thankfully it is extremely easy to prevent this from happening -- we just need to make your sure our bug reports answer three simple questions:

  1. What did I do?
steinnes /
Created Mar 17, 2014
Small benchmark script to time different serialization methods as we were evaluating json vs. simplejson vs. ujson vs. msgpack.
import json
import simplejson
import ujson
import msgpack
import time
class Timer(object):
def __init__(self, name): = name
steinnes /
Created Apr 1, 2014
Because "keys *" can block for several seconds (or longer) on large redis instances, this script scans through keys and dumps them safely. Suffers from the standard SCAN limitations, so it actually may never finish.
import redis
import sys
port = None
port = int(sys.argv[2])
r = redis.Redis(sys.argv[1], port)
steinnes /
Last active Aug 29, 2015
ELB Heartbleed alerter
# quick little script to make an alert window popup when AWS have updated the SSL on
# a host -- can be used to monitor something else, but the best use case is obviously
# when waiting for a third party to fix something.
# uses
# runs on OS X -- probably the osascript line can be replaced with a similar oneliner
# on linux
cmds=`bash -c "$CMD"`
while [ 0 ]; do
new_cmds=`bash -c "$CMD"`;
let cmds_per_sec="$new_cmds - $cmds";
echo $cmds_per_sec;
# I found this somewhere on the internet and modified just slightly.
# Sorry whoever I got it from, I don't remember where so no credit for you :-(
function color_my_prompt {
local __user_and_host="\[\033[01;32m\]\u:"
local __cur_location="\[\033[01;34m\]\w"
local __git_branch_color="\[\033[31m\]"
local __git_branch='`git branch 2> /dev/null | grep -e ^* | sed -E s/^\\\\\*\ \(.+\)$/\(\\\\\1\)\ /`'
local __prompt_tail="\[\033[3m\]$"
local __last_color="\[\033[00m\]"
# I couldn't figure out how to do this with Mock or MagicMock
class MockMethod(object):
def __init__(self, *return_values):
self.return_values = return_values
self.called = 0
self.call_args = []
def __call__(self, *args, **kwargs):
self.called += 1
steinnes / simpleproxy.rb
Created Sep 25, 2014
Homebrew formula for simpleproxy
View simpleproxy.rb
require "formula"
class Simpleproxy < Formula
homepage ""
url ""
sha1 "ec98a2e622507f5b6ecdbbe0b50d2fc82480bcc2"
def install
system "./configure", "--disable-debug",
steinnes /
Created Sep 27, 2014
pgbouncer datadog agent check
from checks import AgentCheck, CheckException
class pgBouncer(AgentCheck):
"""Collects pgbouncer statistics
RATE = AgentCheck.rate
GAUGE = AgentCheck.gauge
def __init__(self, name, init_config, agentConfig):
steinnes /
Last active Aug 29, 2015
Karabiner XML for MBP + Das Keyboard with Icelandic

I recently got a new mechanical keyboard named "Das Keyboard". I decided to go for the Brown Cherry MX keys which provide excellent tactile feedback while not being the absolute loudest there are.

I am using the keyboard with my 13" MacBook Pro Retina, which is connected to a Thunderbolt display, and it works .. mostly. I guess if it worked I wouldn't need to remap keys? ¯\_(ツ)_/¯

The Problem