Skip to content

Instantly share code, notes, and snippets.

View smallnest's full-sized avatar

smallnest smallnest

View GitHub Profile
@smallnest
smallnest / fanout_test.go
Created January 29, 2019 03:57 — forked from crast/fanout_test.go
Benchmarking Reflect Channel Ops
// This is a test where I was trying to isolate how much we lost to `reflect`
// with channel operations in a tight loop.
//
// PREAMBLE
// We do a lot of processing of stream data where ordering with respect to a
// shard indicator like user ID matters. We've done this a few times where we
// implement fanout based on hashing into an slice/array of channels, and it's
// lightning fast but it ends up leaving a lot of boilerplate in your code.
//
// So I started writing a library that would do the non-critical boilerplate
package main
import (
"flag"
"log"
"net/http"
"strings"
)
func main() {
@smallnest
smallnest / Dockerfile
Created November 7, 2018 04:09 — forked from elasticjava/Dockerfile
tried to run Rocksdb under alpine linux inside Docker
FROM gliderlabs/alpine
RUN apk add --update git build-base linux-headers wget tar perl zlib zlib-dev bzip2 bzip2-dev && \
cd /tmp && \
wget https://gflags.googlecode.com/files/gflags-2.0-no-svn-files.tar.gz && \
tar -xzvf gflags-2.0-no-svn-files.tar.gz && \
cd gflags-2.0 && \
./configure && make && make install && \
cd /tmp && \
wget https://snappy.googlecode.com/files/snappy-1.1.1.tar.gz && \
@smallnest
smallnest / diskinfo.go
Created November 2, 2018 02:48 — forked from lunny/diskinfo.go
Disk Info for Golang
package main
import (
"fmt"
"syscall"
)
type DiskStatus struct {
All uint64 `json:"all"`
Used uint64 `json:"used"`
@smallnest
smallnest / sse.go
Created October 15, 2018 00:49 — forked from schmohlio/sse.go
Example SSE server in Golang
// v2 of the great example of SSE in go by @ismasan.
// includes fixes:
// * infinite loop ending in panic
// * closing a client twice
// * potentially blocked listen() from closing a connection during multiplex step.
package main
import (
"fmt"
"log"
@smallnest
smallnest / sse.go
Created October 15, 2018 00:49 — forked from rugwirobaker/sse.go
Example SSE server in Golang
// v2 of the great example of SSE in go by @ismasan.
// includes fixes:
// * infinite loop ending in panic
// * closing a client twice
// * potentially blocked listen() from closing a connection during multiplex step.
package main
import (
"fmt"
"log"
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
upstream myappget {
server 127.0.0.1:3000;
@smallnest
smallnest / nginx-location
Created August 30, 2018 11:38 — forked from luxixing/nginx-location
nginx location 匹配规则
1 普通匹配,遵循最长匹配规则,假设一个请求匹配到了两个普通规则,则选择匹配长度大的那个
例如:
location /{
[matches]
}
location /test{
[matches]
}
2 精确匹配
location = /{
@smallnest
smallnest / cgo.md
Created August 28, 2018 11:55 — forked from zchee/cgo.md
cgo convert list

See also, http://libraryofalexandria.io/cgo/

Using Go cgo

cgo has a lot of trap.
but Not "C" pkg also directory in $GOROOT/src. IDE's(vim) Goto command not works.

So, Here collect materials.

@smallnest
smallnest / main.go
Created August 9, 2018 10:49 — forked from wolfeidau/main.go
Epoll example in golang starting point
package main
//
// Starting point is from http://gcmurphy.wordpress.com/2012/11/30/using-epoll-in-go/
//
import (
"fmt"
"os"
"syscall"