Skip to content

Instantly share code, notes, and snippets.

@errorgem
errorgem / gist:2371387
Created April 12, 2012 22:11 — forked from mikeyk/gist:1329319
Testing storage of millions of keys in Redis
#! /usr/bin/env python
import redis
import random
import pylibmc
import sys
r = redis.Redis(host = 'localhost', port = 6389)
mc = pylibmc.Client(['localhost:11222'])
@errorgem
errorgem / jetty
Created April 12, 2012 14:04 — forked from thesmith/jetty
shell script to start jetty
#! /bin/sh
cd `dirname "$0"`
USER=`whoami`
if [ $USER != 'jetty' ]
then
sudo -u jetty $0 $@
exit $?
@errorgem
errorgem / fabfile.py
Created April 11, 2012 17:11 — forked from yuvadm/fabfile.py
Fabric example for SSH keyfile connection
from fabric.api import *
env.hosts = ['host.name.com']
env.user = 'user'
env.key_filename = '/path/to/keyfile.pem'
def local_uname():
local('uname -a')
def remote_uname():
@errorgem
errorgem / fab_ec2.py
Created April 11, 2012 17:05 — forked from joet3ch/fab_ec2.py
Use fabric with dynamic auto scaling
def web_cluster():
env.user = 'ubuntu'
env.key_filename = ['mykey.pem']
env.conftype = 'prod'
env.project = 'sample'
ec2conn = ec2.connection.EC2Connection(AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY)
web_group = ec2conn.get_all_security_groups(groupnames=['web'])
for i in web_group[0].instances():
hostname = i.__dict__['public_dns_name']
@errorgem
errorgem / aws_usage.py
Created April 11, 2012 16:28 — forked from rcoup/aws_usage.py
A script to query the Amazon Web Services (S3/EC2/etc) usage reports programmatically.
#!/usr/bin/env python
"""
A script to query the Amazon Web Services usage reports programmatically.
Ideally this wouldn't exist, and Amazon would provide an API we can use
instead, but hey - that's life.
Basically takes your AWS account username and password, logs into the
website as you, and grabs the data out. Always gets the 'All Usage Types'