Skip to content

Instantly share code, notes, and snippets.

@qxj
qxj / .screenrc
Created December 14, 2011 15:56
My screen settings
# skip the startup message
startup_message off
# encoding
defutf8 on
# go to home dir
# chdir
# Automatically detach on hangup
@qxj
qxj / tumblr-style.css
Created December 14, 2011 16:05
My tumblr style setting
#Posts h1 {
font-size: 180%;
font-weight: bold;
color: #000;
/* border-bottom: 5px solid #000; */
margin-bottom: 10px;
text-align: center;
}
#Posts h2 {
@qxj
qxj / auto_bcc.vbs
Created December 14, 2011 16:34
Auto bcc to yourself in MS Outlook
Private Sub Application_ItemSend(ByVal Item As Object, _
Cancel As Boolean)
Dim objRecip As Recipient
Dim strMsg As String
Dim res As Integer
Dim strBcc As String
On Error Resume Next
' #### USER OPTIONS ####
' address for Bcc -- must be SMTP address or resolvable
@qxj
qxj / hash_func.c
Created December 26, 2011 02:28
Collection of some frequently used hash functions
// RS Hash Function
unsigned int
RSHash (char *str)
{
unsigned int b = 378551;
unsigned int a = 63689;
unsigned int hash = 0;
while (*str)
{
hash = hash * a + (*str++);
@qxj
qxj / RedisEnvGenerator.cpp
Created January 24, 2012 14:14
Consistent Hash Implementation for Redis cache servers
// @(#)RedisEnvGenerator.cpp
// Time-stamp: <Qian Julian 2012-01-26 21:25:50>
// Copyright 2011
// Version: $Id: RedisEnvGenerator.cpp,v 0.0 2011/12/26 09:44:44 jqian Exp $
#include <zlib.h>
#include <assert.h>
#include "RedisEnvGenerator.h"
@qxj
qxj / chnroutes_openwrt.py
Created May 23, 2012 14:41
Generate route files for openvpn in openwrt
#!/usr/bin/env python
"""
hacked for openwrt, from http://chnroutes.googlecode.com/files/chnroutes.py
"""
import re
import urllib2
import sys
import argparse
@qxj
qxj / test_crc32.c
Created August 6, 2012 11:48
crc32 in zlib
/* @(#)test_crc32.cpp
* Time-stamp: < 2011-12-26 11:30:17>
* Copyright 2011
* Version: $Id: test_crc32.c,v 0.0 2011/12/26 03:25:28 jqian Exp $
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <zlib.h>
@qxj
qxj / test_secondary_db.cpp
Created March 24, 2013 03:31
test multiple secondary index of berkeley db g++ -o test_secondary_db test_secondary_db.cpp -g -O2 -Wall -Wextra -ldb
// -*- mode: c++ -*-
// @(#) test_secondary_db.cpp Time-stamp: <Julian Qian 2013-03-23 22:16:12>
// Copyright 2013 Julian Qian
// Author: Julian Qian <junist@gmail.com>
// Version: $Id: test_secondary_db.cpp,v 0.1 2013-03-23 21:31:19 jqian Exp $
//
// test multiple secondary index of berkeley db
// g++ -o test_secondary_db test_secondary_db.cpp -g -O2 -Wall -Wextra -ldb
@qxj
qxj / test_bdb.cpp
Last active December 16, 2015 22:49
compare performance between CDS and TDS when multiple-read and one-write
// -*- mode: c++ -*-
// @(#) test_bdb.cpp Time-stamp: <Julian Qian 2013-05-07 11:37:26>
// Copyright 2013 Julian Qian
// Author: Julian Qian <junist@gmail.com>
// Version: $Id: test_bdb.cpp,v 0.1 2013-05-02 20:58:38 jqian Exp $
//
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
@qxj
qxj / multiple_timers.cpp
Created May 21, 2013 03:41
boost samples
#include <iostream>
#include <map>
#include <boost/asio.hpp>
#include <boost/date_time/posix_time/posix_time.hpp>
#include <boost/shared_ptr.hpp>
#include <boost/bind.hpp>
enum { N = 10 };