Skip to content

Instantly share code, notes, and snippets.

@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 / 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 / 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 / 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 / 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 / .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