Skip to content

Instantly share code, notes, and snippets.


Pengfei Xue pengfei-xue

View GitHub Profile
pengfei-xue /
Last active November 3, 2017 17:36 — forked from iserko/
A simple script to migrate all keys from one Redis to another
#!/usr/bin/env python
import argparse
import redis
def connect_redis(conn_dict):
conn = redis.StrictRedis(host=conn_dict['host'],
return conn
pengfei-xue / applescript_notes_to_evernote.scpt
Created December 18, 2016 15:59
apple script to migrate from notes to evernote
View applescript_notes_to_evernote.scpt
tell application "Notes"
set theMessages to every note
repeat with thisMessage in theMessages
set myTitle to the name of thisMessage
set myText to the body of thisMessage
View clean_merged_branches
for i in `git branch --merged master -r | while read; do br=${REPLY#*origin/}; if [[ $br == *"/"* ]]; then echo $br; fi; done;`;do
if [ $i == "origin/master" -o $i == "->" -o $i == "HEAD" ];then
echo "ignore $i"
printf "Delete branch * \e[0;32m $i \e[0m * ? [Y|n]: "
read answer
pengfei-xue /
Created June 10, 2015 06:34
aes encryption
import base64
import hashlib
from Crypto import Random
from Crypto.Cipher import AES
class AESCipher(object):
def __init__(self, key): = 32
self.key = hashlib.sha256(key.encode()).digest()
pengfei-xue / ubuntu-support-chinese
Created May 7, 2015 14:54
ubuntu Chinese character garbled
View ubuntu-support-chinese
vim /var/lib/locales/supported.d/local
zh_CN.UTF-8 UTF-8
en_US.UTF-8 UTF-8
zh_CN GB2312
sudo dpkg-reconfigure locales
pengfei-xue / pre-commit
Created February 4, 2015 14:01
pre-commit hook run pep8 against py files
View pre-commit
#!/usr/bin/env bash
git diff --cached -- '*.py' | `which pep8` --max-line-length=119 --show-source --diff
if [ $? -gt 0 ]; then
echo '--------'
echo 'Lint check failed.'
exit 1
pengfei-xue /
Created January 24, 2015 10:40
fabric auto complete script
# auto complete for fab
function _fab_complete() {
local cur
if [[ -f "" || -d "fabfile" ]]; then
COMPREPLY=($(compgen -W "$(fab -F short -l)" -- ${cur}))
return 0
        # no found. Don't do anything.
return 1

Benchmarking Nginx with Go

There are a lot of ways to serve a Go HTTP application. The best choices depend on each use case. Currently nginx looks to be the standard web server for every new project even though there are other great web servers as well. However, how much is the overhead of serving a Go application behind an nginx server? Do we need some nginx features (vhosts, load balancing, cache, etc) or can you serve directly from Go? If you need nginx, what is the fastest connection mechanism? This are the kind of questions I'm intended to answer here. The purpose of this benchmark is not to tell that Go is faster or slower than nginx. That would be stupid.

So, these are the different settings we are going to compare:

  • Go HTTP standalone (as the control group)
  • Nginx proxy to Go HTTP
  • Nginx fastcgi to Go TCP FastCGI
  • Nginx fastcgi to Go Unix Socket FastCGI
pengfei-xue /
Last active December 28, 2015 07:19
install taobao file system in centos5 box
rpm -Uvh
yum install mysql.`uname -i` yum-plugin-replace
yum replace mysql --replace-with mysql55
yum remove mysql mysql-devel
yum install mysql55 mysql55-server mysql55-devel
yum install svn -y
yum install -y libtool.x86_64 libtool-ltdl-devel.x86_64 libtool-ltdl.x86_64
yum install -y zlib-devel mysql-devel
yum install -y readline.x86_64 readline-devel.x86_64
pengfei-xue /
Created June 6, 2013 10:20
get ip percentage from nginx log
use NetAddr::IP;
unless (@ARGV) {
print "usage: $0 file1 file2 file3\n";