Skip to content

Instantly share code, notes, and snippets.

#!/bin/sh
# OSX friendly version by jeff donovan
#
# Grep for a pattern through a Postfix mail log, collect the message ids into a temporary
# file and then grep for all occurrences of the ID's in the maillog.
# This is a very intensive operation since it requires 1+N greps through the entire log file,
# where N is the number of unique ID's returned from the first grep.
#
# Usage sample:
# Nginx can serve FLV/MP4 files by pseudo-streaming way without any specific media-server software.
# To do the custom build we use 2 modules: --with-http_secure_link_module --with-http_flv_module
# This module "secure-link" helps you to protect links from stealing away.
#
# NOTE: see more details at coderwall: http://coderwall.com/p/3hksyg
$ cd /usr/src
$ wget http://nginx.org/download/nginx-1.2.2.tar.gz
$ tar xzvf ./nginx-1.2.2.tar.gz && rm -f ./nginx-1.2.2.tar.gz
@heartshare
heartshare / diskpart.bat
Created April 27, 2013 06:04
Esxi diskpart
今天本想打开服务器,同步下文件,但发现ESXI突然hang在“cnic_Register Loaded Sucessfully”,无法启动,什么也输入不了。Google后发现是vmware核心文件有问题,要重新安装一下,具体内容参考下面文章:
Vmware ESxi 5 hung on loading with message “cnic_Register Loaded Sucessfully”
http://www.zhaocs.info/install-esi-5-by-usb.html
在重新安装EXSI时,发现之前做U盘启动的步骤又忘记了。。。不写真是记不住,查了很多资料,终于又找到了正确的方法,下面是几点tips,防止再次遗忘:
1. 不能用UltraISO刻录vmwarexxx.iso,缺少启动文件,本身iso不带启动文件
2. 用unetbootin是正解,直接选择iso文件,安装即可,里面已经集成了syslinux的启动文件,不用单独下了
3. 部分质量次的U盘即使用上述方法也不成功
4. 用unetbootin前,最好用diskpart格式化一下U盘,下面是过程:
C:\Users\frank>diskpart
<!-- copy this to YOUR_THEME.tmTheme-->
<dict>
<key>name</key>
<string>diff: deleted</string>
<key>scope</key>
<string>markup.deleted</string>
<key>settings</key>
<dict>
<key>background</key>
<string>#EAE3CA</string>
smtpd_helo_restrictions =
        reject_non_fqdn_helo_hostname,
        reject_invalid_helo_hostname,
        reject_rhsbl_helo hostkarma.junkemailfilter.com=127.0.0.2,
        reject_rhsbl_helo zen.spamhaus.org
 
smtpd_data_restrictions =
        reject_unauth_pipelining
 
smtpd_client_restrictions =
# -*- mode:cperl;coding:utf-8-unix; -*-
# Decode base64 encoded text in mail subject.
# And operate it in Japanese.
use strict;
use warnings;
use utf8;
use Encode;
use MIME::Base64 qw(decode_base64);
types {
# other mime types...
application/json json;
}
proxy_cache_path /var/cache/nginx levels=2 keys_zone=my_diskcached:50m inactive=365d max_size=7g;
server {
listen 80;
server_name cdn.jsdelivr.net HOSTNAME.jsdelivr.net;
location / {
access_log off;
gzip on;
gzip_min_length 100;
gzip_types text/plain text/xml application/xml text/css text/javascript application/javascript application/x-javascript text/x-component application/json application/xhtml+xml application/rss+xml application/atom+xml application/vnd.ms-fontobject image/svg+xml application/x-font-ttf font/opentype;
#!/bin/sh
KEY="$HOME/.ssh/id_dsa.pub"
if [ ! -f ~/.ssh/id_dsa.pub ];then
echo "private key not found at $KEY"
echo "* please create it with "ssh-keygen -t dsa" *"
echo "* to login to the remote host without a password, don't give the key you create with ssh-keygen a password! *"
exit
fi

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