Skip to content

Instantly share code, notes, and snippets.

View c4pt0r's full-sized avatar

dongxu c4pt0r

View GitHub Profile
@c4pt0r
c4pt0r / memcache.py
Created September 23, 2012 15:36
my memcached client
import os
import socket
import sys
import errno
class Memcached(object):
def __init__(self, host, port, connect_timeout = 30):
self._host = host
self._port = port
@c4pt0r
c4pt0r / sk_list.c
Created October 2, 2012 14:52
sk_list
/*
* desc: yet another simple ANSI-C skip list implement
*
* author: c4pt0r <huangdongxu@gmail.com>
* date: 2012-10-1
*
* */
#include <stdio.h>
#include <memory.h>
@c4pt0r
c4pt0r / multidict.py
Created October 16, 2012 10:24
simple work-around
#encoding=utf-8
import uuid
"""a simple work around for a multi-key dictionary"""
"""written by c4pt0r 2012-10-16 """
class MultiDict(object):
def __init__(self):
self._key_map = {}
self._data = {}
@c4pt0r
c4pt0r / redis-sharding.py
Created October 21, 2012 02:40
redis-sharding
import os
import re
import bisect
import zlib
import redis
class DHT(object):
# servers ---> [('name', 'ip:port'), ('name1', 'ip:port')]
def __init__(self, servers, replica = 128):
self._servers = servers
@c4pt0r
c4pt0r / ft.go
Created November 5, 2012 02:52
ft
package main
import (
"bufio"
"encoding/json"
"flag"
"fmt"
"io"
"io/ioutil"
"log"
@c4pt0r
c4pt0r / fuckgfw.py
Created November 11, 2012 10:13
fuckgfw.py
#encoding=utf-8
#!/usr/bin/env python
# Copyright (c) 2012 dongxu
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
@c4pt0r
c4pt0r / observer.cpp
Created December 3, 2012 10:24
thread-safe observer
// threadsafe_observer.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <memory>
#include <vector>
#include <string>
#include <Windows.h>
#include <iostream>
#include <process.h>
@c4pt0r
c4pt0r / jsonconfigparser.py
Last active December 14, 2015 14:18
simple json config parser
import os
import json
# json config parser
class JsonConfigParser(object):
def __init__(self, config_file):
self.fp = open(config_file)
self.raw_config_content = self.fp.read()
#print self.raw_config_content
self.config_value = json.loads(self.raw_config_content)
### INSTALLATION NOTES ###
# 1. Install Homebrew (https://github.com/mxcl/homebrew)
# 2. brew install zsh
# 3. Install OhMyZsh (https://github.com/robbyrussell/oh-my-zsh)
# 4. brew install reattach-to-user-namespace --wrap-pbcopy-pbpaste && brew link reattach-to-user-namespace
# 5. Install iTerm2
# 6. In iTerm2 preferences for your profile set:
# Character Encoding: Unicode (UTF-8)
# Report Terminal Type: xterm-256color
# 7. Put itunesartist and itunestrack into PATH
// MainDlg.cpp : 实现文件
//
#include "stdafx.h"
#include "float_main_window.h"
#include "manage_dlg.h"
#include "usb_connection_helper.h"
#include "miniwdj2_dlg.h"
#include "setting_dialog.h"