Skip to content

Instantly share code, notes, and snippets.

View xmzhao's full-sized avatar

Xuemin Zhao xmzhao

  • Tencent
  • Chengdu, China
View GitHub Profile
@xmzhao
xmzhao / merge_git_repo_as_subdir
Last active September 16, 2019 08:14 — forked from smdabdoub/merge_git_repo_as_subdir
Merge one git repository into another repository as a sub-directory
# based on the following:
# http://saintgimp.org/2013/01/22/merging-two-git-repositories-into-one-repository-without-losing-file-history/
# http://blog.caplin.com/2013/09/18/merging-two-git-repositories/
git clone Task (保证在master)
git clone DopNluServer (保证在master)
cd Task
git remote add DopNluServer ../DopNluServer
git fetch DopNluServer
@xmzhao
xmzhao / connection_pool
Created December 2, 2016 07:16 — forked from opensourcegeek/connection_pool
A quick and easy way to reconnect to mysql when connection is lost, it uses gevent queues but still the idea should work whichever way the connections are pooled.
from gevent import monkey
monkey.patch_socket()
import logging
import gevent
from gevent.queue import Queue
import pymysql as db
logging.basicConfig(level=logging.DEBUG)
LOGGER = logging.getLogger("connection_pool")
import bisect
class NFA(object):
EPSILON = object()
ANY = object()
def __init__(self, start_state):
self.transitions = {}
self.final_states = set()
self._start_state = start_state
@xmzhao
xmzhao / gist:4211426
Created December 5, 2012 02:00
go pprof
http://blog.golang.org/2011/06/profiling-go-programs.html
go tool pprof http://10.168.152.18:12345/debug/pprof/profile
@xmzhao
xmzhao / gist:4144079
Created November 25, 2012 15:40
[hadoop] Passing parameters to Mappers and Reducer
http://www.thecloudavenue.com/2011/11/passing-parameters-to-mappers-and.html
There might be a requirement to pass additional parameters to the mapper and reducers, besides the the inputs which they process. Lets say we are interested in Matrix multiplication and there are multiple ways/algorithms of doing it. We could send an input parameter to the mapper and reducers, based on which the appropriate way/algorithm is picked. There are multiple ways of doing this
Setting the parameter:
1. Use the -D command line option to set the parameter while running the job.
2. Before launching the job using the old MR API
@xmzhao
xmzhao / gist:4142180
Created November 25, 2012 02:40
hadoop
http://coderplay.iteye.com/blog
@xmzhao
xmzhao / gist:4110074
Created November 19, 2012 10:49
hadoop + peacock
[编译libhdfs]
https://github.com/forward/node-hdfs
[编译github.com/zyxar/hdfs]
因为zyxar/hdfs是根据hadoop 1.0.3编写, 需要修改:
1. cgo部分
删除github.com/zyxar/hdfs/hdfs.h, 修改import "C"为:
/*
@xmzhao
xmzhao / gist:4078538
Created November 15, 2012 13:01
gccgo + peacock
[gccgo]
http://gcc.gnu.org/install/
安装gmp|mpfr|mpc后(./configure --prefix=/data1/home/xueminzhao/gcc4.7.1/install/gmp|mpfr|mpc, make install)
export gmp|mpfr|mpc的lib到LD_LIBRARY_PATH
然后运行
./configure \
--prefix=/data1/home/xueminzhao/gcc4.7.1/install/gcc \
--with-local-prefix=/data1/home/xueminzhao/gcc4.7.1/install/gcc \
@xmzhao
xmzhao / build_gcc4.7.1.sh
Created November 15, 2012 06:36 — forked from Mistobaan/build_gcc4.7.1.sh
Build GCC 4.7.1 on Mac OS X Lion with Go support
#!/bin/sh
# GCC
## Prerequisites for GCC
## http://gcc.gnu.org/install/prerequisites.html
## Installing GCC: Configuration
## http://gcc.gnu.org/install/configure.html
GCC_VER=4.7.1
WORK_DIR=$HOME/Builds/GCC