This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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\]" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import redis | |
import sys | |
port = None | |
try: | |
port = int(sys.argv[2]) | |
except: | |
pass | |
r = redis.Redis(sys.argv[1], port) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import json | |
import simplejson | |
import ujson | |
import msgpack | |
import time | |
class Timer(object): | |
def __init__(self, name): | |
self.name = name |
NewerOlder