Skip to content

Instantly share code, notes, and snippets.

View btfak's full-sized avatar

btfak

View GitHub Profile
View profilingtool.go
package main
import (
"fmt"
"log"
"os"
"runtime"
"runtime/debug"
"runtime/pprof"
"strconv"
View ngrok-selfhosting-setup.md

Intro

The plan is to create a pair of executables (ngrok and ngrokd) that are connected with a self-signed SSL cert. Since the client and server executables are paired, you won't be able to use any other ngrok to connect to this ngrokd, and vice versa.

DNS

Add two DNS records: one for the base domain and one for the wildcard domain. For example, if your base domain is domain.com, you'll need a record for that and for *.domain.com.

Different Operating Systems

@btfak
btfak / doubangroupapi
Last active August 29, 2015 14:22 — forked from iamsk/doubangroupapi
View doubangroupapi
import requests
from db import db
"""
The Douban Group API which not display on http://developers.douban.com/wiki/?title=api_v2
Base url: https://api.douban.com/v2
Group info: /group/:id
@btfak
btfak / doubangroupapi
Last active August 29, 2015 14:22 — forked from iamsk/doubangroupapi
View doubangroupapi
import requests
from db import db
"""
The Douban Group API which not display on http://developers.douban.com/wiki/?title=api_v2
Base url: https://api.douban.com/v2
Group info: /group/:id
View shortener.go
package main
import (
"fmt"
"log"
"math/rand"
"net/http"
"time"
"github.com/garyburd/redigo/redis"
View go-urlencode
func urlencode(s string) (result string){
for _, c := range(s) {
if c <= 0x7f { // single byte
result += fmt.Sprintf("%%%X", c)
} else if c > 0x1fffff {// quaternary byte
result += fmt.Sprintf("%%%X%%%X%%%X%%%X",
0xf0 + ((c & 0x1c0000) >> 18),
0x80 + ((c & 0x3f000) >> 12),
0x80 + ((c & 0xfc0) >> 6),
0x80 + (c & 0x3f),
@btfak
btfak / main.go
Created September 26, 2013 01:09
View main.go
package main
import (
"net/http"
"encoding/xml"
"ieee1888"
"os"
"fmt"
"bytes"
"io/ioutil"
@btfak
btfak / httpserver.go
Created November 18, 2013 14:19
负载工具性能测试,http server端
View httpserver.go
package main
import (
"fmt"
"log"
"net/http"
"os"
"strconv"
)
@btfak
btfak / client.go
Created November 20, 2013 03:52
递归没有GC
View client.go
package main
import (
"fmt"
"io"
"net"
"os"
"runtime"
"time"
)
@btfak
btfak / server.go
Created November 20, 2013 03:53
递归GC测试server
View server.go
package main
import (
"fmt"
"net"
"os"
)
var data []byte
var length = 1024 * 100