Skip to content

Instantly share code, notes, and snippets.

@zhasm
zhasm / md2_github_mailer.py
Created January 7, 2013 01:52
markdown -> github css -> html -> email
#place holder
@zhasm
zhasm / ccc.sh
Last active December 10, 2015 06:28
像脚本语言一样运行 c 程序文件。放在 .bashrc / .bash_profile 环境中。
ccc ()
{
if [[ "$#" -lt 1 ]]; then
echo "Usage: $FUNCNAME <script.c> [optional_args]";
return;
else
file=$1;
shift;
args=$*;
out=`mktemp`;
@zhasm
zhasm / xml2json.py
Created December 18, 2012 14:57 — forked from anonymous/xml2json.py
#!/usr/bin/env python
# -*- encoding: utf-8 -*-
"""xml2json.py Convert XML to JSON
Relies on ElementTree for the XML parsing. This is based on
pesterfish.py but uses a different XML->JSON mapping.
The XML->JSON mapping is described at
http://www.xml.com/pub/a/2006/05/31/converting-between-xml-and-json.html
$.fn.vectorMap('addMap', 'cn_merc_en',{"insets": [{"width": 560, "top": 0, "height": 470, "bbox": [{"y": -7092705.234177706, "x": 8197509.958779432}, {"y": -2058430.530198134, "x": 15010424.448806616}], "left": 0}],
"paths": {
aomen:{
name : "澳门特区",
path: "M413.032,414.183l-0.96,1.752c0,0,0.889,0.883,1.98,1.086s1.995-0.493,1.995-0.493L413.032,414.183z"},
hongkong:{
name : "香港特区",
path: "M417.745,409.005l3.394,0.773l3.453-2.558l1.666,4.582c0,0-5.521,2.673-3.691,1.785c1.828-0.884-4.641-0.355-4.641-0.355l-0.834-3.454L417.745,409.005z"},
taiwan:{
name : "台湾省",
@zhasm
zhasm / init_db_env.py
Created November 21, 2012 04:48
fix 'can not find libmysqlclient.so.18' error of python mysql
def init_db_env():
import sys, os
os.environ["PYTHON_EGG_CACHE"] = "/tmp"
os.environ['PYTHONPATH']= '/home/rex/local/lib/python2.6/site-packages'
os.environ["LD_LIBRARY_PATH"] = '/home/rex/local/lib:/usr/lib/'
sys.path.append('/home/rex/local/lib/python2.6/site-packages')
sys.path.append('/home/rex/local/lib')
sys.path.append('/usr/lib/')
from ctypes import cdll
cdll.LoadLibrary("/usr/lib/libmysqlclient.so.18")
@zhasm
zhasm / ncdc.sh
Created November 16, 2012 12:28
get ncdc data
for i in {1900..2012};
do
wget -r ftp://ftp3.ncdc.noaa.gov/pub/data/noaa/$i/;
done
@zhasm
zhasm / dumper.py
Created November 13, 2012 02:51
django data dumper (the default `python manage.py datadumper` is not working for no reason)
#!/usr/bin/env python
# -*- encoding: utf-8 -*-
#
# Author: Rex Zhang
# Create Time: 2012-11-13 10:14
# File name: datadumper.py
import sys, os
import re
import imp
@zhasm
zhasm / gist:4038348
Created November 8, 2012 11:46
Emacs Command Summary

Emacs Command Summary

Emacs command summary, Thu Jul 25. link

Key
Key Cmd
@zhasm
zhasm / p.sh
Created November 1, 2012 07:00
代码快照打包
#!/usr/bin/env bash
##代码打包:
p='cloudweb'
d=`date +"%Y-%m-%d"`
v=`git log -n 1 |pcregrep -io '(?<=commit )\w{8}'`
git archive master --prefix="$p/" | gzip > "$p"."$d"."$v".tar.gz
@zhasm
zhasm / .tmux.conf
Created October 22, 2012 13:50
tmux config
#ctrl a
set -g prefix ^a
unbind ^b
bind a send-prefix
#此类配置可以在命令行模式中输入show-options -g查询
#set-option -g base-index 1 #窗口的初始序号;默认为0,这里设置为1
set-option -g display-time 5000 #提示信息的持续时间;设置足够的时间以避免看不清提示,单位为毫秒
set-option -g repeat-time 1000 #控制台激活后的持续时间;设置合适的时间以避免每次操作都要先激活控制台,单位为毫秒
set-option -g status-keys emacs #操作状态栏时的默认键盘布局;可以设置为vi或emacs
set-option -g status-right "#(date +%H:%M' ')" #状态栏右方的内容;这里的设置将得到类似23:59的显示