Skip to content

Instantly share code, notes, and snippets.

View steinnes's full-sized avatar

Steinn Eldjárn Sigurðarson steinnes

View GitHub Profile
# 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 / 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;
@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 / 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 / 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 / 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?