Skip to content

Instantly share code, notes, and snippets.

View beaufour's full-sized avatar

Allan Beaufour beaufour

View GitHub Profile
@beaufour
beaufour / elb_cloudwatch.py
Created February 15, 2012 19:24
Get CloudWatch metrics for an Amazon ELB
#!/usr/bin/python
#
# Get Cloudwatch metrics for an ELB
#
# Inspired by http://onemoredigit.com/post/3263274796/single-instance-cloudwatch-stats-with-boto
#
import datetime
import sys
@beaufour
beaufour / ebs_stats.py
Created February 16, 2012 00:56
Get CloudWatch metrics for Amazon EBS volumes
#!/usr/bin/python
#
# Get Cloudwatch metrics for the EBS volumes attached to an instance
#
import datetime
import logging
import sys
import urllib
@beaufour
beaufour / language.py
Created November 30, 2012 16:00
Django Middleware to choose language based on subdomain
import logging
from django.utils import translation
class SubdomainLanguageMiddleware(object):
"""
Set the language for the site based on the subdomain the request
is being served on. For example, serving on 'fr.domain.com' would
make the language French (fr).
@beaufour
beaufour / gzipinputstream.py
Created December 4, 2012 16:03
Python: Streaming Gzip reader
import zlib
import string
BLOCK_SIZE = 16384
"""Read block size"""
WINDOW_BUFFER_SIZE = 16 + zlib.MAX_WBITS
"""zlib window buffer size, set to gzip's format"""
[user]
name = Allan Beaufour
email = ...
[color]
ui = auto
[pack]
threads = 0
@beaufour
beaufour / todo-check.py
Created April 2, 2013 13:39
Git commit hook to check for lines with "TODO" in them
#!/usr/bin/python
import logging
import re
import sys
import envoy
def _exec_git(cmd, args=''):
cmd = 'git {0} --color=never {1}'.format(cmd, args)
@beaufour
beaufour / pre-commit-runner.bash
Created April 2, 2013 13:40
A git commit hook runner, for running multiple commit scripts
#!/bin/bash
#
# Collection of pre-commit hooks
#
set -e
# Get directory of script file
ME=$0
if [ -h ${ME} ]; then
#!/bin/bash
# Core
export HUBOT_HIPCHAT_JID="XXXXX"
export HUBOT_HIPCHAT_PASSWORD="YYYYY"
export HUBOT_AUTH_ADMIN=ZZZZZ
export HUBOT_DIR=/home/ubuntu/ponce
# Plugins
export HUBOT_DARK_SKY_API_KEY="XXXXXX"
# hubot
#
description "Hubot chat bot"
start on filesystem or runlevel [2345]
stop on runlevel [!2345]
setuid ubuntu
setgid ubuntu
# hubot
#
description "Hubot chat bot"
start on filesystem or runlevel [2345]
stop on runlevel [!2345]
setuid ubuntu
setgid ubuntu