Skip to content

Instantly share code, notes, and snippets.

@neilxp
neilxp / .vimrc
Created October 5, 2011 07:59
.vimrc
set ts=2 sw=2
set hlsearch
syntax on
set fileencodings=ucs-bom,utf-8,cp936
if has("gui_macvim")
set gfn=Monaco:h13
set transparency=8
colorscheme desert
set go=egmt
@neilxp
neilxp / svn_ana.sh
Created October 19, 2011 06:26
Analyze SVN committer productivity
#!/bin/sh
# This is a script that help you get your team member's productivity
# by analyzing his/her code commiting in SVN repository, for the day before
#
# You can get a rough num for comparing between team members by using it in the way below
# ./svn_ana.sh SVN_ACCOUNT_NAME | wc -l
#
uname=vr
password=reader
@neilxp
neilxp / wimax_filter.c
Created October 29, 2011 07:47
Linux Wimax filter
/*
* Wimax filter by Ricky Wen <cwen01390@cienet.com.cn>
*/
#include <linux/types.h>
#include <linux/string.h>
#include <linux/fcntl.h>
#include <linux/if.h>
#include <linux/in.h>
#include <net/ip.h>
#include <net/tcp.h>
@neilxp
neilxp / shaping.c
Created October 29, 2011 07:50
shaping
#include "shaping.h"
#ifdef LINUX
#include <sys/time.h>
#include <time.h>
#include <string.h>
#include <assert.h>
#define OCT_CYCLES_PER_SECOND (1000000ull)
@neilxp
neilxp / credit.js
Created December 13, 2011 02:55
credit card number checking
CreditCard: {
TEST_NUMBERS: $w('378282246310005 371449635398431 378734493671000 30569309025904 38520000023237 6011111111111117 6011000990139424 5555555555554444 5105105105105100 4111111111111111 4012888888881881 4222222222222'),
isValid: function(number){
if (number.blank()) return false;
if (Braintree.CreditCard.TEST_NUMBERS.include(number)) return false;
var total = ($A(number).reverse().inject(0, function(a, n, index) {
return a + $A((parseInt(n) * [1, 2][index % 2]).toString()).inject(0, function(b, o) {
return b + parseInt(o);
@neilxp
neilxp / CAPTCHA.cpp
Created May 15, 2012 12:34
CPP CAPTCHA generator
#include <memory>
#include <time.h>
#include <vector>
#include <string>
#include <iterator>
#include <fstream>
#include <boost/shared_ptr.hpp>
#include <boost/interprocess/sync/scoped_lock.hpp>
@neilxp
neilxp / dumpstack.sh
Created June 7, 2012 08:42
dumpstack
#!/bin/sh
if test $# -ne 1; then
echo "Usage: `basename $0 .sh` PROGRAM" 1>&2
exit 1
fi
GDB=${GDB:-gdb}
if $GDB -nx --quiet --batch --readnever > /dev/null 2>&1; then
@neilxp
neilxp / IOWatch.py
Created June 15, 2012 02:29
watch IO for process
#!/usr/bin/python
# Monitoring per-process disk I/O activity
# written by http://www.vpsee.com
import sys, os, time, signal, re
class DiskIO:
def __init__(self, pname=None, pid=None, reads=0, writes=0):
self.pname = pname
self.pid = pid
@neilxp
neilxp / gist:3127577
Created July 17, 2012 06:24
proxy.pac
function regExpMatch(url, pattern) {
try { return new RegExp(pattern).test(url); } catch(ex) { return false; }
}
function FindProxyForURL(url, host) {
url = url.toLowerCase();
host = host.toLowerCase();
var proxy = "PROXY 1.1.1.1:8999";
@neilxp
neilxp / JeAllocator.hpp
Created October 24, 2012 13:00
JeAllocator
#ifndef __JeAllocator__HEADER__
#define __JeAllocator__HEADER__
#define JEMALLOC_NO_DEMANGLE 1
#include "jemalloc/jemalloc.h"
template<typename T>
class JeAllocator {
public :
// typedefs