Skip to content

Instantly share code, notes, and snippets.

View ericliang's full-sized avatar

Eric Liang ericliang

View GitHub Profile
@ericliang
ericliang / subset_sum_problem_poly_time.erl
Created March 8, 2011 09:37
Illustrate the dynamic programming in subset_sum_problem
#!/usr/bin/env escript
%% -*- erlang -*-
%%! -smp enable -sname subset_sum_problem
%%
%% Illustrate the dynamic programming in subset_sum_problem:
%% http://en.wikipedia.org/wiki/Subset_sum_problem#Pseudo-polynomial_time_dynamic_programming_solution
%%
main(_) ->
@ericliang
ericliang / subset_sum_problem_exp_time.erl
Created March 8, 2011 09:38
Illustrate the dynamic programming in subset_sum_problem
#!/usr/bin/env escript
%% -*- erlang -*-
%%! -smp enable -sname subset_sum_problem
%%
%% Illustrate the dynamic programming in subset_sum_problem:
%% http://en.wikipedia.org/wiki/Subset_sum_problem#Exponential_time_algorithm
%%
main(_) ->
@ericliang
ericliang / gist:1048827
Created June 27, 2011 13:12
jgroups-config-file-tcp-with-gossip-router
<config>
<TCP
loopback="true"
recv_buf_size="30000000"
send_buf_size="6400000"
discard_incompatible_packets="true"
max_bundle_size="64000"
max_bundle_timeout="30"
enable_bundling="true"
use_send_queues="false"
@ericliang
ericliang / gist:1061482
Created July 2, 2011 18:12
Template config file when using maven with ant
<?xml version="1.0" encoding="UTF-8"?>
<project name="communicate" default="all" basedir=".." xmlns:artifact="antlib:org.apache.maven.artifact.ant">
<property name="src.dir" value="${basedir}/src"/>
<property name="compile.dir" value="${basedir}/work"/>
<property name="lib.dir" value="${basedir}/lib"/>
<property name="conf.dir" value="${basedir}/conf"/>
<property file="${conf.dir}/build.properties"/>
<typedef resource="org/apache/maven/artifact/ant/antlib.xml"
@ericliang
ericliang / gist:1226505
Created September 19, 2011 13:33
codec patch on MS1252 according to bestfit version for JDK
# HG changeset patch
# User Eric Liang <eric.l.2046@gmail.com>
# Date 1316438901 -28800
# Node ID 117c5987b5b2f7d49646f86939c040ff11b70e04
# Parent 95ac2f7ddad0b8350d5ea3aed7d7d028c44396ba
fix improper codec dictionary in MS1252 according to the bestfit version:
http://www.unicode.org/Public/MAPPINGS/VENDORS/MICSFT/WindowsBestFit/bestfit1252.txt
diff -r 95ac2f7ddad0 -r 117c5987b5b2 src/share/classes/sun/nio/cs/MS1252.java
--- a/src/share/classes/sun/nio/cs/MS1252.java Wed Aug 24 15:11:00 2011 +0100
@ericliang
ericliang / qemu_custom
Created December 4, 2011 11:06
An umbrella script for start up qemu with bridge network support
#!/bin/bash
ifconfig wlan0 down
# set up a tap interface for qemu
# USERID - uid qemu is being run under.
USERID=`whoami`
iface=`tunctl -b -u $USERID`
# generate a random mac address for the qemu nic
@ericliang
ericliang / 0001-memsql-would-not-satisfy-the-engine-test-so-skip-the.patch
Created June 21, 2012 09:57
SysBench patch for MemSQL benchmark, which skips the storage engine detection.
From 81ac1ad630b4d466bdeec58fe367dbf2de595fc2 Mon Sep 17 00:00:00 2001
From: Eric Liang <eric.l.2046@gmail.com>
Date: Thu, 21 Jun 2012 17:44:20 +0800
Subject: [PATCH] memsql would not satisfy the engine test, so skip the detection and use innodb as default
---
sysbench/drivers/mysql/drv_mysql.c | 29 ++++++++++++++++++-----------
1 files changed, 18 insertions(+), 11 deletions(-)
diff --git a/sysbench/drivers/mysql/drv_mysql.c b/sysbench/drivers/mysql/drv_mysql.c
@ericliang
ericliang / gist:5281730
Last active December 15, 2015 15:28
微博未来特性(Weibo Future Feature)

微博未来特性(Weibo Future Feature)

  1. 时间旅行模式 TimeTravelMode

    微博即将为用户提供时间旅行模式,每个用户将可以把自己的微博随意切换到任意时间的状态,包括评论、微博、关系以及好友状态在内的所有信息都会重建。高级用户甚至可以邀请自己的好友一同回到过去,重新开始自己的微博生活。

  2. 应用子网支持 AppSubnetSupport

    作为微博助力初创开发者的重要举措之一,为App提供单独子网数据传输通道,子网内数据传输仅限定在本应用内部。一个典型的游戏开发者,可以1)只定义自己的业务逻辑,所有与用户的通讯通过接入微博通道而实现;2)或者仅将SDK绑定在应用后台,通过AB面翻转即可完成微博关系通讯与当前应用的切换。

@ericliang
ericliang / gist:5281835
Last active December 15, 2015 15:29
微博开源计划(Weibo Open Source Program)

#微博开源计划(Weibo Open Source Program)

微博工程师法则(Laws of Engineer in Weibo):

1. 工程师必须牛逼
2. 除非抵触法则1,否则不能吹牛逼
3. 除非抵触法则1和2,否则开源才牛逼

详情已更新至微博开源计划(Weibo Open Source Program)

@ericliang
ericliang / gist:6105284
Created July 29, 2013 15:43
Illustrate processor cache effects
#include <iostream>
#include <sys/time.h>
using namespace std;
//http://igoro.com/archive/gallery-of-processor-cache-effects/
int print_interval(timeval t1, timeval t2){
double elapsed;
elapsed = (t2.tv_sec - t1.tv_sec) * 1000.0; // sec to ms
elapsed += (t2.tv_usec - t1.tv_usec) / 1000.0; // us to ms