Skip to content

Instantly share code, notes, and snippets.

View AlphaWong's full-sized avatar
🇭🇰
I go to work by MTR

Alpha AlphaWong

🇭🇰
I go to work by MTR
View GitHub Profile
@AlphaWong
AlphaWong / howto.md
Created October 1, 2018 16:13 — forked from petrkohut/howto.md
How to have redis-cli and psql installed on machine using Docker

How to install redis-cli and psql client on your machine with Docker

Preparing docker images

We will use minimalistic Linux distribution called Alpine (5MB)

Dockerfile of redis-cli

FROM alpine:latest
RUN apk --update add redis
@AlphaWong
AlphaWong / HaversinFormula.go
Created August 2, 2018 09:05 — forked from cdipaolo/HaversinFormula.go
Golang functions to calculate the distance in meters between long,lat points on Earth.
// haversin(θ) function
func hsin(theta float64) float64 {
return math.Pow(math.Sin(theta/2), 2)
}
// Distance function returns the distance (in meters) between two points of
// a given longitude and latitude relatively accurately (using a spherical
// approximation of the Earth) through the Haversin Distance Formula for
// great arc distance on a sphere with accuracy for small distances
//
@AlphaWong
AlphaWong / StringTrap.go
Last active July 17, 2018 14:14
"text/template" issue for embed string struct
package main
import (
"log"
"os"
"strings"
"text/template"
)
type myStr string
@AlphaWong
AlphaWong / History|-224c4945|entries.json
Last active August 13, 2022 14:59
Visual Studio Code Settings Sync Gist
{"version":1,"resource":"file:///Users/alphawong/works/src/github.com/hanksmak/ibrilli/package.json","entries":[{"id":"iBrt.json","timestamp":1659415552224}]}
@AlphaWong
AlphaWong / README.md
Created March 24, 2018 10:28 — forked from rjeczalik/README.md
Go, multiple packages and coveralls.io

Go, multiple packages and coveralls.io

Single profile for single Go package

For Go projects that consist of only one package, the following Travis configuration is enough to get started with coveralls.io. You may want to encrypt your $COVERALLS_TOKEN via Travis encryption keys though.

language: go
go:
 - 1.3.1
package main
import (
"fmt"
"github.com/julienschmidt/httprouter"
"log"
"net/http"
)
// The type of our middleware consists of the original handler we want to wrap and a message
@AlphaWong
AlphaWong / result.txt
Created March 14, 2018 03:10 — forked from knsh14/result.txt
golang 1.10 strings builder test
$ go test -bench . -benchmem
goos: linux
goarch: amd64
pkg: github.com/knsh14/sample
BenchmarkBytesBuffer-2 10 103512777 ns/op 438779214 B/op 23 allocs/op
BenchmarkStringBuilder-2 10 138950789 ns/op 661977072 B/op 54 allocs/op
BenchmarkBytesBufferString-2 5000000 353 ns/op 1280 B/op 1 allocs/op
BenchmarkStringBuilderString-2 2000000000 0.33 ns/op 0 B/op 0 allocs/op
PASS
ok github.com/knsh14/sample 5.699s
@AlphaWong
AlphaWong / index.html
Created January 3, 2018 15:47 — forked from tmichel/index.html
simple websocket example with golang
<html>
<head>
<title>WebSocket demo</title>
</head>
<body>
<div>
<form>
<label for="numberfield">Number</label>
<input type="text" id="numberfield" placeholder="12"/><br />
package main
import (
"fmt"
"net/http"
"github.com/gorilla/websocket"
)
func echo(w http.ResponseWriter, r *http.Request) {
@AlphaWong
AlphaWong / gist:30b5bed1370e49518e541729037e8e00
Created December 22, 2017 03:46 — forked from digitaljhelms/gist:3099010
Squash the first two commits in a git repository's history

The scenario

Your repository has two commits:

$ git log --oneline
957fbfb No, I am your father.
9bb71ff A long time ago in a galaxy far, far away....