Skip to content

Instantly share code, notes, and snippets.

View chaozh's full-sized avatar
🎯
Focusing

chaozh chaozh

🎯
Focusing
View GitHub Profile
@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 / 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'
];
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):
#!/bin/sh
usage()
{
local name=${0##*/}
cat >&2 <<-END
Rewrite history to squash all commits wiht message starts with 'fixup!' to
its first parent. By drdr.xp@gmail.com
@chaozh
chaozh / CommandOptions.java
Created September 30, 2015 01:53
A storage class for both command line options and shell commands. <code from ZK>
/**
* A storage class for both command line options and shell commands.
*
*/
static class CommandOptions {
private Map<String,String> options = new HashMap<String,String>();
private List<String> cmdArgs = null;
private String command = null;
@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>
@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 / varnish.py
Created March 29, 2016 00:42
varnish缓存清理
#!/usr/bin/env python
import sys,os
varnish_adm='varnishadm'
try:
var=sys.argv[1:][0]
if 'http://' in var or 'HTTP://' in var:
domain=var.split('/')[2]
url=var.split(domain)[1]
if url == "":
url=sys.argv[1:][1]
@chaozh
chaozh / pom.xml
Created May 4, 2016 05:46
For Jmeter with maven bug fixed
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.apache.curator</groupId>
<artifactId>apache-curator</artifactId>
<version>2.8.1-SNAPSHOT</version>
<packaging>pom</packaging>
<dependencies>
<dependency>