This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Set prefix key to Ctrl-a | |
unbind C-b | |
set-option -g prefix C-a | |
bind-key C-a send-prefix | |
# reload settings | |
unbind r | |
bind r source-file ~/.tmux.conf \; display-message "Config reloaded..." | |
# Ctrl-j/k cycles thru windows (no prefix) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#/usr/bin/env bash | |
main() { | |
local ip=$1; shift; | |
local maxGapMinutes=$1; shift; | |
local epochLastSuccess=`date +%s` | |
while true; do | |
# check if network is good to avoid false alarming |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Collection; | |
import java.util.SortedMap; | |
import java.util.TreeMap; | |
public class ConsistentHash<T> { | |
private final HashFunction hashFunction; | |
private final int numberOfReplicas; | |
private final SortedMap<Integer, T> circle = new TreeMap<Integer, T>(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env python | |
import random | |
from optparse import OptionParser | |
DEBUG = False | |
def dprint(str): | |
if DEBUG: | |
print str |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from collections import defaultdict | |
from collections import deque | |
# adjacency list for the graph | |
graph = defaultdict(list) | |
# queue for bfs | |
q = deque() | |
# distances of nodes |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from collections import defaultdict | |
graph = defaultdict(list) | |
visited = [] | |
for edge in [[1,2], [1,7], [1,8], [2,3], [2,6], [3,4], [3,5], [8,9], [8,12], [9,10], [9,11]]: | |
graph[edge[0]].append(edge[1]) | |
graph[edge[1]].append(edge[0]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import SocketServer | |
import BaseHTTPServer | |
import urllib | |
PORT = 5678 | |
class Proxy(BaseHTTPServer.BaseHTTPRequestHandler): | |
def do_GET(self): | |
self.send_response(200) | |
self.send_header("Content-type", "text/html") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[user] | |
name = Xing, Wang | |
email = zenja.wang@gmail.com | |
[core] | |
editor = /usr/bin/vim | |
excludesfile = /Users/wangxing/.gitignore_global | |
[alias] | |
co = checkout | |
ci = commit | |
st = status |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
while : | |
do | |
clear | |
git --no-pager log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%ci) %C(bold blue)<%an>%Creset' --abbrev-commit --date=relative --all | |
sleep 1 | |
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.regex.Matcher; | |
import java.util.regex.Pattern; | |
public class UsernameValidator{ | |
private Pattern pattern; | |
private Matcher matcher; | |
private static final String USERNAME_PATTERN = "^[a-z0-9_-]{3,15}$"; | |