Skip to content

Instantly share code, notes, and snippets.

View elprup's full-sized avatar

elprup elprup

View GitHub Profile
@elprup
elprup / s3lzocp.py
Created October 12, 2012 09:34
sync scribe file from local to amazon s3 (with lzo compress)
#!/usr/bin/python
'''
s3lzocp
Version 0.2 2012-10-22
sync log from local to s3 and lzo it.
make sure lzop and s3cmd is installed.
usage:
s3lzocp.py /path/to/dir s3://bucket-name/path/to/dir
'''
import re
@elprup
elprup / syncuser.py
Created September 13, 2012 02:23
syncuser command from svn to reviewboard
#!/usr/bin/python
'''
sync user from svn to review board
sample usage:
syncuser.py -c root:password@localhost:rbdatabase --update /var/svn/passwd
'''
import datetime
import getopt
import MySQLdb as mdb
import re
@elprup
elprup / loganalyze.py
Created August 27, 2012 05:19
hadoop log viewer in Python
import re
mode = r'([A-Z_]*)="([^"]+)"'
vmode = r'\(([^)]+)\)\(([^)]+)\)\(([^)]+)\)'
filename = 's3.txt'
f = open(filename,'r')
lines = f.readlines()
jobinfo = lines[-1]
info = []
for k,v in re.findall(mode, jobinfo):
for kk1, kk2, vv in re.findall(vmode, v):
@elprup
elprup / sendemail.py
Created July 30, 2012 09:56
send email with attachments in Python
'''
email send service library. Using SMTP.
author: yaowei
last modify: 2012-07-30
'''
import datetime
import logging
import os
@elprup
elprup / channel.py
Created April 5, 2012 06:43
Simple async callback using tornado and redis
'''
Simple async callback using tornado and redis
example:
from channel import *
import tornado.ioloop
import functools
def callback(x, prefix=''):
print prefix+str(x)