Skip to content

Instantly share code, notes, and snippets.

View wudi's full-sized avatar
🎯
Focusing

Di Wu wudi

🎯
Focusing
View GitHub Profile
@wudi
wudi / benchmark+go+nginx.md
Created August 29, 2016 14:51 — forked from hgfischer/benchmark+go+nginx.md
Benchmarking Nginx with Go

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
@wudi
wudi / search_big_tree.php
Last active June 27, 2017 09:02
Search Big tree
<?php
/**
# 建葨
CREATE TABLE `rel` (
`id` bigint(11) NOT NULL AUTO_INCREMENT,
`pid` bigint(11) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8
@wudi
wudi / concurrent_download.go
Last active July 8, 2016 13:23
concurrent_download
package main
import (
"fmt"
"io"
"io/ioutil"
"net/http"
"os"
"time"
)
@wudi
wudi / QingCloudDoc2ThriftIDL.js
Last active June 14, 2016 07:22
QingCloudDoc2ThriftIDL
var typeConvert = function(t){
switch(t) {
case "String":
case "TimeStamp":
return "string";
case "Integer":
return "i32";
case "Array":
return "list<string>";
default:
@wudi
wudi / Makefile.golang
Created June 13, 2016 03:29 — forked from dnishimura/Makefile.golang
Makefile for Golang projects
# Makefile for a go project
#
# Author: Jon Eisen
# site: joneisen.me
#
# Targets:
# all: Builds the code
# build: Builds the code
# fmt: Formats the source files
# clean: cleans the code
.
β”œβ”€β”€ README.md
β”œβ”€β”€ bin
β”œβ”€β”€ composer.json
β”œβ”€β”€ composer.lock
β”œβ”€β”€ shell
β”‚Β Β  β”œβ”€β”€ README.md
β”‚Β Β  β”œβ”€β”€ access.log
β”‚Β Β  β”œβ”€β”€ build_sql.php
β”‚Β Β  β”œβ”€β”€ com_center
@wudi
wudi / tieba_list_pics.js
Last active January 27, 2016 07:49
Show 贴吧图片
javascript:!function() { document.getElementsByTagName('body')[0].scrollTop = 0; $('.search_bright').remove(); $('#com_userbar').remove(); $('#tbui_aside_float_bar').remove(); var posts_urls = []; var posts_title = []; var nodes = $('.j_thread_list .threadlist_title .j_th_tit'); $(nodes).each(function(e){ posts_urls.push($(nodes[e]).attr('href')); posts_title.push($(nodes[e]).text()); }); console.log(posts_urls); $('#pending').remove(); $('html>body').prepend('<center id="pending"><h1 style="color:red;">倄理中...</h1></center>'); function loadCss(css_url) { var link = document.createElement('link'); link.type = 'text/css'; link.rel = 'stylesheet'; link.href = css_url; document.getElementsByTagName("head")[0].appendChild(link); } loadCss('//apps.bdimg.com/libs/jqueryui/1.10.4/css/jquery-ui.min.css'); loadCss('//blueimp.github.io/Gallery/css/blueimp-gallery.min.css'); $.getScript('//apps.bdimg.com/libs/jqueryui/1.10.4/jquery-ui.js'); $.getScript('//7xiam0.com1.z0.glb.clouddn.com/jquery.blueimp-gallery.min.js'); va
@wudi
wudi / compare.c
Created January 13, 2016 03:13
nagative or positive
//ref: http://stackoverflow.com/questions/33882676/why-intunsigned-intintv
int compare(int x)
{
return -(int)(
(unsigned int)( (int) x ) >> ( sizeof(int) * CHAR_BIT - 1 )
);
}
//equal to
int compare(int x)
@wudi
wudi / eagle-lambda-mod.itermcolors
Created January 11, 2016 15:26
eagle-lambda-mod.itermcolors
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Ansi 0 Color</key>
<dict>
<key>Blue Component</key>
<real>0.0</real>
<key>Green Component</key>
<real>0.0</real>
@wudi
wudi / html-include-replace.php
Last active December 24, 2015 03:18
html-include-replace.php
#!/usr/bin/env php
<?php
/**
* Auth: Eagle.Wu
* Usage:
* 1、 /bin/sh file.php /dir
* 2、 cd /dir && /bin/sh file.php
* 3、 cp file.php /usr/local/bin/file && chmod +x /usr/local/bin/file && && file /dir