Skip to content

Instantly share code, notes, and snippets.

Wesley Childs mrchilds

  • Hampshire
Block or report user

Report or block mrchilds

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@mrchilds
mrchilds / gist:9230933
Created Feb 26, 2014
Vagrant - Build on base box
View gist:9230933
# Package up new box
vagrant package --base /Users/<USER>/VirtualBox VMs/<VM-NAME> --output mybox.box
vagrant box add foobar mybox.box
@mrchilds
mrchilds / gist:9178139
Created Feb 23, 2014
Machine Setup...
View gist:9178139
#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:9132599
Created Feb 21, 2014
Custom fabric decorators
View gist:9132599
# 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:9099373
Last active Aug 29, 2015
Who has a crontab...
View gist:9099373
cat /etc/passwd | awk -F: '{print "crontab -u "$1" -l"}' |s
@mrchilds
mrchilds / gist:8733191
Last active Aug 29, 2015
Unit Test Helpers - Mock logging
View gist:8733191
# 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:8315307
Created Jan 8, 2014
Update Route53 script
View gist:8315307
# Adapted from: http://blog.domenech.org/2012/11/automatically-manage-your-aws-ec2.html
# External IPs are not useful internally in AWS. Change to CNAME with public DNS. This ensures you don't pay for extra bandwidth as if will resolve to an internal IP when inside AWS and an external IP when outside in the real world
#!/bin/bash
logger start-up-name.sh Started
#More environment variables than we need but... we always do that
export AWS_CREDENTIAL_FILE=/opt/aws/apitools/mon/credential-file-path.template
export AWS_CLOUDWATCH_HOME=/opt/aws/apitools/mon
View gist:7871446
def pre_staging_restart_services():
"""
Restart celery and gunicorn services
Used by newer staging environments
"""
# Install requirements
with virtualenv():
run('pip install -r /srv/CustomMade/requirements.txt')
@mrchilds
mrchilds / S3 Size
Created Nov 21, 2013
S3 Bucket Size
View S3 Size
# Crude but does the job
from boto.s3.connection import S3Connection
conn = XXX
rs = conn.get_all_buckets()
# Get bucket
bucket_name = 'XXX'
View gist:6611165
def setUp(self):
if 'remote_saucelabs' in os.environ:
desired_capabilities = []
##--tc=name:Dev-run --tc=browser:firefox
browser = copy.copy(webdriver.DesiredCapabilities.FIREFOX)
browser['name'] = config['name']
desired_capabilities += [browser]
self.driver = webdriver.Remote(
desired_capabilities=desired_capabilities,
View gist:6611158
import argparse
import multiprocessing
import os
import sys
import unittest
class RunTests():
"""
Test wrapper to allow for local or remote (via saucelabs) tests to be run in
parallel.
You can’t perform that action at this time.