Skip to content

Instantly share code, notes, and snippets.

View yyuu's full-sized avatar
👽
Working from home

YAMASHITA, Yuu yyuu

👽
Working from home
View GitHub Profile
@yyuu
yyuu / gist:1436573
Created December 6, 2011 03:28
S3 request signer in python
#!/usr/bin/env python
#
# baaed on Ruby S3 client implementation in RESTful Web Services of O'Reilly.
#
import base64
import hashlib
import hmac
import os
import re
@yyuu
yyuu / gist:1569253
Created January 6, 2012 06:01
df in python on Linux
#!/usr/bin/env python
from __future__ import with_statement
import contextlib
import os
import sys
print "Filesystem\tMounted on\tUse%\tIUse%"
with contextlib.closing(open('/etc/mtab')) as fp:
for m in fp:
@yyuu
yyuu / gist:1626558
Created January 17, 2012 13:01
/etc/pbuilderrc on sid to build packages for both Debian and Ubuntu
# Codenames for Debian suites according to their alias. Update these when
# needed.
UNSTABLE_CODENAME="sid"
TESTING_CODENAME="wheezy"
STABLE_CODENAME="squeeze"
STABLE_BACKPORTS_SUITE="$STABLE_CODENAME-backports"
OLDSTABLE_CODENAME="lenny"
# List of Debian suites.
DEBIAN_SUITES=($UNSTABLE_CODENAME $TESTING_CODENAME $STABLE_CODENAME $OLDSTABLE_CODENAME
@yyuu
yyuu / gist:1675502
Created January 25, 2012 08:54
handle periodic jobs on tornado's ioloop
#!/usr/bin/env python
import os
import sys
import time
import tornado.ioloop
class PeriodicServer(object):
def __init__(self, request_callback, io_loop=None, period=1):
self.request_callback = request_callback
@yyuu
yyuu / gist:1722714
Created February 2, 2012 10:06
switching between sbt versions (sbt @${VERSION} ${SBT_OPTIONS})
#!/bin/sh -e
SBT_HOME="$HOME/usr/sbt"
if test $# -gt 0 -a -f "$SBT_HOME/${1#@}/sbt-launch.jar"; then
SBT_JAR="$SBT_HOME/${1#@}/sbt-launch.jar"
shift
fi
if ! test -f "$SBT_JAR"; then
@yyuu
yyuu / Makefile
Created February 8, 2012 04:09 — forked from anonymous/Makefile
openssl private CA management script
OPENSSL = openssl
DAYS = -days 3652
CADAYS = -days 3652
REQ = $(OPENSSL) req
CA = $(OPENSSL) ca
VERIFY = $(OPENSSL) verify
X509 = $(OPENSSL) x509
# must be absolute path
CATOP = $(PWD)/ca
@yyuu
yyuu / find-orphaned-snapshots.py
Created February 17, 2012 08:35
find snapshot which is not referenced from any AMIs
#!/usr/bin/env python
#
# find snapshots which is not referenced from any AMIs
#
import boto.ec2
import boto.ec2.image
import boto.exception
import os
import re
@yyuu
yyuu / r53dump.py
Created February 20, 2012 12:30
dump route53 zones
#!/usr/bin/env python
#
# dump route53 zones
#
import boto.route53
import boto.exception
import os
import re
import sys
@yyuu
yyuu / fluent.alert.py
Created February 29, 2012 05:48
a mon's alert plugin that sends alert to fluentd
#!/usr/bin/env python
import logging
import optparse
import os
import re
import sys
import time
import urllib
import urllib2
@yyuu
yyuu / botosh.py
Created March 6, 2012 04:13
boto REPL
#!/usr/bin/env python
import boto.ec2
import boto.ec2.autoscale
import boto.route53
import boto.s3.connection
import boto.sqs
import code
import optparse
import os