Skip to content

Instantly share code, notes, and snippets.

@xieran1988
xieran1988 / c_call_python.c
Created October 13, 2012 02:23
Python Common
// Python: 从 C 调用 Python
//
#include <Python.h>
// 有长度的字符串
PyObject *r = PyObject_CallFunction(func, "s#", "str", 3);
// 以0结尾的字符串
PyObject *r = PyObject_CallFunction(func, "s", "str with NUL terminate");
// 无符号整形 unsigned long
PyObject *r = PyObject_CallFunction(func, "k", 1988UL);
// 有符号整形 int
@xieran1988
xieran1988 / mysql.sh
Created October 13, 2012 02:20
Mysql Common
# 备份表
mysqldump -h 192.168.1.1 -u username -ppassword dbname table
@xieran1988
xieran1988 / mount-encrypted-loop.sh
Created June 5, 2012 06:24
mount encrypted loop filesystems
# Implementing Encrypted Home Directories
# http://www.linuxjournal.com/article/6481?page=0,1
# sudo apt-get install loop-aes-utils
# modprobe aes cryptoloop
dd if=/dev/urandom bs=1 count=32 > key
dd if=/dev/zero of=a.img
losetup -e aes -p0 /dev/loop0 a.img < key
mkfs.ext2 /dev/loop0
@xieran1988
xieran1988 / ws_httpbody_dissector.lua
Created April 19, 2012 03:17
wireshark lua dissector http body
-- Decode param=value from query string of http request uri (http.request.uri)
-- Author: Huang Qiangxiong (qiangxiong.huang@gmail.com)
-- change log:
-- 2010-07-01
-- Just can play.
------------------------------------------------------------------------------------------------
do
local querystring_decoder_proto = Proto("my_http_querystring_decoder",
"Decoded HTTP URI Query String [HQX's plugins]")