Skip to content

Instantly share code, notes, and snippets.

View notsobad's full-sized avatar

notsobad notsobad

View GitHub Profile
@notsobad
notsobad / autopdb.py
Last active August 29, 2015 14:08 — forked from rctay/sitecustomize.py
auto run pdb when there is a exception throw.
'''
original: http://code.activestate.com/recipes/65287/
Put this in python module dir, on mac: /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7
Run your script this way:
>> python -m autopdb /path/script.py
'''
import base64
from Crypto.Cipher import AES
from Crypto import Random
BS = 16
pad = lambda s: s + (BS - len(s) % BS) * chr(BS - len(s) % BS)
unpad = lambda s : s[:-ord(s[len(s)-1:])]
class AESCipher:
'''AES
@notsobad
notsobad / docker.md
Last active August 29, 2015 14:10
docker笔记

doker

install

apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 36A1D7869245C8950F966E92D8576A8BA88D21E9

sh -c "echo deb http://get.docker.com/ubuntu docker main > /etc/apt/sources.list.d/docker.list"

apt-get update

lua quick start

variable

num = 42
str = ‘hello’
is_ok = false

t = {key1 = 'value1', key2 = false}
@notsobad
notsobad / io.md
Created December 30, 2014 03:42
io

IO性能分析

iostat

$ iostat -x 1
Linux 3.5.2-x86_64-linode26 (linode)    11/08/2012      _x86_64_        (4 CPU)

avg-cpu:  %user   %nice %system %iowait  %steal   %idle
           0.84    0.00    0.08    1.22    0.07   97.80
@notsobad
notsobad / gist:860749603a8fbb33e3c4
Last active August 29, 2015 14:22
install java
cd /opt/
tar xzvf ~/jdk-7u80-linux-x64.tar.gz
sudo update-alternatives --install /usr/bin/java java /opt/jdk1.7.0_80/bin/java 1
sudo update-alternatives --install /usr/bin/javac javac /opt/jdk1.7.0_80/bin/javac 1
# vi ~/.bashrc
export JAVA_HOME=/opt/jdk1.7.0_80

先安装lua5.1, luajit v2.1, luarocks

vagrant@precise64:~$ lua -v
Lua 5.1.4  Copyright (C) 1994-2008 Lua.org, PUC-Rio
vagrant@precise64:~$ luajit -v
LuaJIT 2.1.0-alpha -- Copyright (C) 2005-2015 Mike Pall. http://luajit.org/
vagrant@precise64:~$ luarocks --version
/usr/local/bin/luarocks 2.2.2
LuaRocks main command-line interface
vagrant@precise64:~$ luarocks|grep "Lua version"
function escapeNonePrintable(_)
local fmt = string.format
return string.gsub(_, "[%z\1-\31,\127-\255]", function (x)
return fmt("\\%d",string.byte(x))
end)
end
print(escapeNonePrintable("a\tb\10c"))