Skip to content

Instantly share code, notes, and snippets.

View steinnes's full-sized avatar

Steinn Eldjárn Sigurðarson steinnes

View GitHub Profile
@steinnes
steinnes / bug_report_rules.md
Last active August 6, 2019 12:04
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
steinnes / bm.py
Created March 17, 2014 13:24
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):
self.name = name
@steinnes
steinnes / redis-dump-keys-safely.py
Created April 1, 2014 16:31
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
try:
port = int(sys.argv[2])
except:
pass
r = redis.Redis(sys.argv[1], port)
@steinnes
steinnes / heartbleedcheck.sh
Last active August 29, 2015 13:58
ELB Heartbleed alerter
#!/bin/bash
# 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 https://github.com/titanous/heartbleeder/
# runs on OS X -- probably the osascript line can be replaced with a similar oneliner
# on linux
HOST=$1
@steinnes
steinnes / rateof.sh
Created June 20, 2014 17:04
rateof.sh
#!/bin/bash
CMD=$1
cmds=`bash -c "$CMD"`
while [ 0 ]; do
new_cmds=`bash -c "$CMD"`;
let cmds_per_sec="$new_cmds - $cmds";
echo $cmds_per_sec;
cmds=$new_cmds;
# 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\]"
@steinnes
steinnes / mockmethod.py
Created August 19, 2014 13:48
mockmethod.py
# 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
steinnes / simpleproxy.rb
Created September 25, 2014 02:17
Homebrew formula for simpleproxy
require "formula"
class Simpleproxy < Formula
homepage ""
url "http://downloads.sourceforge.net/project/simpleproxy/simpleproxy/3.4/simpleproxy-3.4.tar.gz"
sha1 "ec98a2e622507f5b6ecdbbe0b50d2fc82480bcc2"
def install
system "./configure", "--disable-debug",
"--disable-dependency-tracking",
@steinnes
steinnes / pgbouncer.py
Created September 27, 2014 15:33
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
steinnes / daskarabiner.md
Last active August 29, 2015 14:13
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