Skip to content

Instantly share code, notes, and snippets.

import os
import datetime
import pdb
from struct import unpack
from collections import OrderedDict
from cStringIO import StringIO
path = "/data/project/py/github/android/demo/testok.stacks"
data = open(path, "r").read()
@maliubiao
maliubiao / prefix-replace.py
Created October 21, 2013 13:02
remove the prefix of a c++ global symbol .
if __name__ == "__main__":
import sys
if len(sys.argv) < 1:
print "error"
exit()
f = open(sys.argv[1], "r")
src = f.readlines()
dst = []
for line in src:
dst.append(line.replace("_GLOBAL__sub_I_", ""))
@maliubiao
maliubiao / baseutils.c
Last active December 26, 2015 04:39
baseutils
#include <Python.h>
PyDoc_STRVAR(baseutils_string_to_signed_doc, "string to signed int");
static PyObject *
baseutils_string_to_signed(PyObject *object, PyObject *args)
{
PyObject *str;
int strlen;
int extra;
@maliubiao
maliubiao / home.html
Last active December 27, 2015 08:49
tornado-trace.py
<html>
<head>
<title>
trace enabled
</title>
</head>
<body>
<p> trace enabled </p>
</body>
</html>
@maliubiao
maliubiao / enable-routing.py
Last active December 27, 2015 17:59
enable-routing.py
import subprocess
import os
if __name__ != "__main__":
exit(0)
#local socks proxy address
_SOCKS_SERVER = "127.0.0.1:###"
#remote server address
_SERVER = "106.###.###.###"
@maliubiao
maliubiao / del_method.py
Last active December 29, 2015 01:49
obj&instance
#__del__ will be called when a instance object being dealloced.
#__init__ will be called by PyInstance_New
#use function instance(class, [dict]) to create an instance
# without calling its __init__ method
#use function classobj(name, bases, dict) to create a class object manually.
#the tp_dealloc member of a instance object is function instance_dealloc
#Object/classobject.c:621 in CPython2.7.3
from types import ClassType as classobj
from types import InstanceType as instance
#for more? see types.py
@maliubiao
maliubiao / build.py
Created November 24, 2013 07:48
build a c project
#! /usr/bin/env python
import os
import subprocess
import cStringIO
TYPEC = 1 << 1
TYPECXX = 1 <<2
project = {
@maliubiao
maliubiao / uwsgi-request-time.py
Last active December 29, 2015 09:49
uwsgi-request-time
#! /usr/bin/env python
import os
import sys
import signal
stap_script = """
global counter
global start = 0
global end = 0
probe process("/usr/bin/uwsgi").function("uwsgi_request_wsgi")
@maliubiao
maliubiao / nginx.conf
Last active December 29, 2015 09:58
uwsgi-problem
#user nobody;
worker_processes 1;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
@maliubiao
maliubiao / simple_pack.py
Last active December 29, 2015 15:08
simple_pack
import os.path
import io
import re
from cStringIO import StringIO
from struct import pack
from struct import unpack
#internal
_fileobject = None
_index = "index.db"