Skip to content

Instantly share code, notes, and snippets.

View chaozh's full-sized avatar
🎯
Focusing

chaozh chaozh

🎯
Focusing
View GitHub Profile
import sys
class Node(object):
def __repr__(self):
n = self.__class__.__name__
fields = ['%s=%r' % (f, self.__dict__[f]) for f in self.fields]
return '<%s(%s)>' % (n, ', '.join(fields))
def add(self, ls, level, s):
@chaozh
chaozh / base.js
Created June 10, 2014 06:24
a simple base js toolkit handle event
// Avoid `console` errors in browsers that lack a console.
(function() {
var method;
var noop = function () {};
var methods = [
'assert', 'clear', 'count', 'debug', 'dir', 'dirxml', 'error',
'exception', 'group', 'groupCollapsed', 'groupEnd', 'info', 'log',
'markTimeline', 'profile', 'profileEnd', 'table', 'time', 'timeEnd',
'timeStamp', 'trace', 'warn'
];
@chaozh
chaozh / base.js
Created June 9, 2014 10:04
for jquery learn
(function(exports, undefined){
//redefine document
var document = exports.document;
//namse space
var BASE = (function(){
// base obj
var BASE = function(selector, context){
return new BASE.fn.init();
@chaozh
chaozh / ibd-analyzer.py
Created July 19, 2013 02:19
a script to analyze innodb's table file, some problems about rec size
#! /usr/bin/env python
#encoding=utf-8
import os
import sys
import getopt
import struct
def printf(format, *args):
print format % args
@chaozh
chaozh / daemonlize.c
Created January 8, 2013 12:15
From book Advanced programming in the Unix Environment Charpter 13.4
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
#include <pthread.h>
#include <syslog.h>
#include <fcntl.h>
#include <sys/stat.h>