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: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: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:1414604
Created December 1, 2011 07:21
a coroutine implementation that can work with tornado.ioloop
#!/usr/bin/env python
import tornado.ioloop
class Coroutine(object):
"""
a coroutine implementation that can work with tornado.ioloop
def generator():
print('A')
@yyuu
yyuu / msgpack-rpc.monitor.rb
Created November 7, 2011 10:51
a mon's monitor plugin to monitor msgpack-rpc services
#!/usr/bin/env ruby
require 'rubygems'
require 'msgpack/rpc'
require 'optparse'
require 'yaml'
PROGRAM_NAME = File.basename($0)
EXIT_SUCCESS = 0
EXIT_FAILURE = 1
@yyuu
yyuu / gist:1277579
Created October 11, 2011 08:33
aws-rds-benchmark.sh
#!/bin/sh -e
rds_db_instance_identifier() {
echo "$@" | sed -e 's/[^-0-9A-Za-z]/-/g'
}
rds_describe_db_instance() {
if test $# -lt 1; then
return 1
fi
@yyuu
yyuu / gist:1099104
Created July 22, 2011 08:44
tcp6? connection monitor for munin
#!/bin/sh
case $1 in
config)
cat <<EOF
graph_title Connections through firewall
graph_vlabel Connections
graph_category network
graph_args -l 0
established.label ESTABLISHED
@yyuu
yyuu / gist:1084613
Created July 15, 2011 12:46
fucking cardinal conversion in awk
function int2(str, card, rec) {
if(!card) card=10;
i = index("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ", toupper(substr(str, 1, 1)))-1;
if(length(str) < 2) {
return rec*card+i;
} else {
return int2(substr(str, 2), card, rec*card+i);
}
}
@yyuu
yyuu / irc.alert
Created July 14, 2011 10:19
irc alert script for mon
#!/usr/bin/env ruby
require 'logger'
require 'net/irc'
require 'optparse'
require 'thread'
class IRCNotifier < Net::IRC::Client
def initialize(host, port, opts={})
super
@yyuu
yyuu / resolvconf.conf
Created May 24, 2011 17:12
upstart configuration for resolvconf (LP:448095)
# upstart script for resolvconf
start on ( virtual-filesystems and starting udev )
stop on runlevel [06]
pre-start script
invoke-rc.d resolvconf start
end script
@yyuu
yyuu / gist:931210
Created April 20, 2011 12:33
Makefile to dump all Cassandra's SSTables to JSON (with LZO compression)
SRCDIR = /var/lib/cassandra/data
DSTDIR = .
SOURCES = $(wildcard $(SRCDIR)/*/*-Data.db)
ALL = $(foreach S,$(SOURCES),$(basename $(subst $(SRCDIR)/,,$(S))).json.lzo)
.SUFFIXES: .json.lzo
all: $(ALL)