Skip to content

Instantly share code, notes, and snippets.

View nguyenthenguyen's full-sized avatar

Nguyễn Thế Nguyên nguyenthenguyen

View GitHub Profile
@nguyenthenguyen
nguyenthenguyen / gist:597d898331d6a1addd1537134dbfa6ee
Created January 30, 2017 18:56 — forked from francolaiuppa/gist:9507d003c9694c451bee
Example HAProxy 1.5 configuration for load-balancing Redis nodes with Sentinel (including health checks!)
backend messages
mode tcp
option tcplog
option tcp-check
#tcp-check send AUTH\ foobar\r\n
#tcp-check expect +OK
tcp-check send PING\r\n
tcp-check expect +PONG
tcp-check send info\ replication\r\n
tcp-check expect string role:master
@nguyenthenguyen
nguyenthenguyen / gist:d584ef151f65ac22988a
Created January 20, 2016 15:33 — forked from booherbg/gist:f812c9145d157d8945b2
Cross compiling a simple go server for windows

How to build Golang windows/arm static binaries from linux

Alternate title: Cross compiling Windows/Darwin/Linux amd64/386/arm all from linux

After fumbling around trying to figure out the go toolchain and cross compilation configuration, I ran across the wiki page on Go's homepage. It's super helpful, and worked out of the box. I'm including the necessary scripts here in case they get changed or lost, and we can help Google find it (since it's the first real source I've found that "Just Worked"). http://code.google.com/p/go-wiki/wiki/WindowsCrossCompiling

Generated private key

openssl genrsa -out server.key 2048

To generate a certificate

openssl req -new -x509 -key server.key -out server.pem -days 3650

https

@nguyenthenguyen
nguyenthenguyen / sub.go
Created January 7, 2016 17:56 — forked from netroy/sub.go
Redis subscribe over websockets in golang
package main
import (
"github.com/chuckpreslar/emission"
"github.com/garyburd/redigo/redis"
"github.com/gorilla/websocket"
"log"
"net/http"
)
@nguyenthenguyen
nguyenthenguyen / client.go
Created January 7, 2016 16:37 — forked from spikebike/client.go
TLS server and client
package main
import (
"crypto/tls"
"crypto/x509"
"fmt"
"io"
"log"
)
@nguyenthenguyen
nguyenthenguyen / main.go
Last active August 29, 2015 14:20 — forked from nmerouze/main.go
package main
import (
"database/sql"
"encoding/json"
"errors"
"fmt"
"log"
"net/http"
"time"
@nguyenthenguyen
nguyenthenguyen / main.go
Last active August 29, 2015 14:20 — forked from nmerouze/main.go
package main
import (
"encoding/json"
"log"
"net/http"
"reflect"
"time"
"github.com/gorilla/context"
@nguyenthenguyen
nguyenthenguyen / app.go
Last active August 29, 2015 14:19 — forked from Bochenski/app.go
package main
import (
"github.com/codegangsta/negroni"
"github.com/gorilla/context"
"github.com/unrolled/render"
"labix.org/v2/mgo"
"labix.org/v2/mgo/bson"
"log"
"net/http"
type (
// BuoyCondition contains information for an individual station.
BuoyCondition struct {
WindSpeed float64 `bson:"wind_speed_milehour"`
WindDirection int `bson:"wind_direction_degnorth"`
WindGust float64 `bson:"gust_wind_speed_milehour"`
}
// BuoyLocation contains the buoy's location.
BuoyLocation struct {
type (
// BuoyCondition contains information for an individual station.
BuoyCondition struct {
WindSpeed float64 `bson:"wind_speed_milehour"`
WindDirection int `bson:"wind_direction_degnorth"`
WindGust float64 `bson:"gust_wind_speed_milehour"`
}
// BuoyLocation contains the buoy's location.
BuoyLocation struct {