Skip to content

Instantly share code, notes, and snippets.

View mrchilds's full-sized avatar

Wesley Childs mrchilds

View GitHub Profile
@mrchilds
mrchilds / gist:8733191
Last active August 29, 2015 13:55
Unit Test Helpers - Mock logging
# Mock logging
# File - someclass.py
class SomeClass(object):
def method_man(self):
logging.basicConfig(filename='/tmp/somelog.log',
level=logging.INFO,
format='%(asctime)s | %(message)s',
datefmt='%m/%d/%Y %I:%M:%S')
@mrchilds
mrchilds / gist:9099373
Last active August 29, 2015 13:56
Who has a crontab...
cat /etc/passwd | awk -F: '{print "crontab -u "$1" -l"}' |s
@mrchilds
mrchilds / gist:9132599
Created February 21, 2014 11:14
Custom fabric decorators
# To use a custom decoractor with fabric
# the decorator needs @wraps(func) otherwise
from functools import wraps
def lock_hubot_aws_changes_when_running(func):
@wraps(func)
def wrapper(*args, **kwargs):
print 'do something'
result = func(*args, **kwargs)
print 'do something'
@mrchilds
mrchilds / gist:9178139
Created February 23, 2014 22:15
Machine Setup...
#Bash
alias pwgen='env LC_CTYPE=C tr -dc "a-zA-Z0-9-_" < /dev/urandom | head -c 15'
parse_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/'
}
export PS1="\[$(tput bold)\]\[$(tput setaf 5)\]⌘ \[$(tput setaf 6)\]\w\[$(tput setaf 3)\]\$(parse_git_branch) \[$(tput sgr0)\]"
# Git config...
@mrchilds
mrchilds / gist:9230933
Created February 26, 2014 14:57
Vagrant - Build on base box
# Package up new box
vagrant package --base /Users/<USER>/VirtualBox VMs/<VM-NAME> --output mybox.box
vagrant box add foobar mybox.box