Skip to content

Instantly share code, notes, and snippets.

View hSATAC's full-sized avatar
🐈
Cataholic

Ash Wu hSATAC

🐈
Cataholic
View GitHub Profile

What

A lot of times you are developing a web application on your own laptop or home computer and would like to demo it to the public. Most of those times you are behind a router/firewall and you don't have a public IP address. Instead of configuring routers (often not possible), this solution gives you a public URL that's reverse tunnelled via ssh to your laptop.

Because of the relaxation of the sshd setup, it's best used on a dedicated virtual machine just for this (an Amazon micro instance for example).

Requirements

@hSATAC
hSATAC / gist:2de7df67e4dc9a7052a7
Last active August 29, 2015 14:04
Install fluentd on debian
## Run as root
cat << 'EOF' > /etc/init.d/fluentd
#! /bin/sh
### BEGIN INIT INFO
# Provides: fluentd
# Required-Start: $network $local_fs
# Required-Stop:
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
sub vcl_recv {
# .....
# cookie sanitization
if (req.http.Cookie) {
set req.http.Cookie = ";"+req.http.Cookie;
set req.http.Cookie = regsuball(req.http.Cookie, "; +", ";");
set req.http.Cookie = regsuball(req.http.Cookie, ";(locale)=", "; \1=");
set req.http.Cookie = regsuball(req.http.Cookie, ";[^ ][^;]*", "");
set req.http.Cookie = regsuball(req.http.Cookie, "^[; ]+|[; ]+$", "");
if (req.http.Cookie == "") {
@hSATAC
hSATAC / piping.go
Last active August 29, 2015 14:06 — forked from kylelemons/piping.go
package main
import (
"bytes"
"exec"
"log"
"os"
)
// Pipeline strings together the given exec.Cmd commands in a similar fashion
@hSATAC
hSATAC / unicorn
Created September 26, 2014 03:39
/etc/init.d/unicorn Unicorn init script for multiple apps
#!/bin/bash
### BEGIN INIT INFO
# Provides: unicorn
# Required-Start: $all
# Required-Stop: $network $local_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start the unicorns at boot
# Description: Enable at boot time.
### END INIT INFO
#! /usr/bin/ruby
require "rubygems"
require "net/http"
require "socket"
SOCKET_PATH = '/Users/cat/kkbox/kktix/unicorn.sock'
def unicorn_ready
return false unless File.exist? SOCKET_PATH
return true if unicorn_return.to_i == 200
@hSATAC
hSATAC / main.go
Last active August 29, 2015 14:07
package main
import (
"fmt"
"sync"
)
type Callback func() int
func doSomething() {}
#!/bin/bash
# Usage: slackpost <username> <channel> <message>
# Enter the name of your slack host here - the thing that appears in your URL:
# https://slackhost.slack.com/
slackhost=HOST_HERE
token=TOKEN_HERE
userName=$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
@hSATAC
hSATAC / new_gist_file_0
Created December 2, 2014 17:30
Install OSX vm in OSX
記錄一下步驟
1. 從 appstore 下載 OSX 安裝檔,不需要安裝
2. gem install iesd
3. iesd -i /Applications/Install\ OS\ X\ Mavericks.app -o Mavericks.dmg -t BaseSystem 做完會在家目錄多一個 Mavericks.dmg
4. 開一個 VirtualBox 虛擬機器,選 OSX Mavericks 建立好以後先不要開機,進入設定 > 系統 > 晶片組選 PIIX3 然後確定 EFI 有打勾