Skip to content

Instantly share code, notes, and snippets.

#! /bin/sh
##
## /sbin/iptables-save -c > /etc/iptables.rules
##
trusthost='10.0.3.101'
internal_ip='10.0.3.0/24'
my_internet_ip='xxx.xxx.xxx.xxx'
@masahif
masahif / snappy-java.py
Created April 30, 2013 07:52
snappy-java decoder for python
#!/usr/bin/env python
import os
import snappy
import struct
import snappy
import binascii
SNAPPY_JAVA_MAGIC = '\x82SNAPPY\x00\x00\x00\x00\x01'
@masahif
masahif / memcache_bench_2010.py
Created December 3, 2012 02:37
memcache bench
#!/usr/bin/env python
import threading
import memcache
import Queue
import inspect
import uuid
import time
@masahif
masahif / gist:4167308
Created November 29, 2012 07:07
2012 ツール・ド・おきなわ140km
@masahif
masahif / gist:4160061
Created November 28, 2012 09:10
How to build GoldenCheetah
- v3
sudo apt-get install \
bison flex \
libboost-dev \
libqt4-dev \
libical-dev \
libvlc-dev \
libclucene-dev
@masahif
masahif / gist:3038446
Created July 3, 2012 08:21
Decode methods are different between simplejson and json
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import simplejson
import json
t1 = unichr(12345)
t2 = u"a"
print type(simplejson.loads(simplejson.dumps(t1)))
@masahif
masahif / gist:1252223
Created September 29, 2011 23:29
Tornado template
>>> import tornado.template
>>> t = tornado.template.Template("<html>{{myvalue}}</html>")
>>> d['myvalue']='hoge'
>>> t.generate(**d)
'<html>hoge</html>'
>>> t.generate(myvalue='ika')
'<html>ika</html>'
# usage: . `var.py config1 config2.py ....`
import re
import sys
if __name__ == "__main__":
re_shellvar = re.compile('^[a-z][a-z0-9_]*$', re.IGNORECASE)
for v in sys.argv[1:]:
if v.endswith('.py'):
@masahif
masahif / gist:982652
Created May 20, 2011 09:52
conifg.py
#!/bin/env python
"""
--
#/bin/sh
. `./config.py`
....