Skip to content

Instantly share code, notes, and snippets.

View dlsniper's full-sized avatar

Florin Pățan dlsniper

View GitHub Profile
@dlsniper
dlsniper / explicit.go
Created September 18, 2016 20:58
Dependency injection in Go by explicitly passing the dependency
package main
import "log"
type printerFunc func(message string, args ...interface{})
func hello(p printerFunc) {
p("hello %s", "world")
}
@dlsniper
dlsniper / keybase.md
Last active October 9, 2016 08:55
keybase.md

Keybase proof

I hereby claim:

  • I am dlsniper on github.
  • I am dlsniper (https://keybase.io/dlsniper) on keybase.
  • I have a public key whose fingerprint is E59D 94AB 2C05 69B3 C63A 56B5 0AA5 CCB6 8EE3 4BE5

To claim this, I am signing this object:

@dlsniper
dlsniper / bench
Last active February 8, 2017 23:10
Go 1.8RC3 BashOnWindows vs Pure Windows
Bash Windows
benchmark old ns/op new ns/op delta
BenchmarkBinaryTree17-8 2740384400 3162642000 +15.41%
BenchmarkFannkuch11-8 3323651700 3213270000 -3.32%
BenchmarkFmtFprintfEmpty-8 58.7 53.1 -9.54%
BenchmarkFmtFprintfString-8 174 129 -25.86%
BenchmarkFmtFprintfInt-8 160 128 -20.00%
BenchmarkFmtFprintfIntInt-8 175 188 +7.43%
@dlsniper
dlsniper / loaderror.txt
Created March 1, 2017 19:25
Slack load error
2017/3/1 19:23:29.162 rtm.start failed; retry_after = NaN
rollup-core_required_ts.js:1 2017/3/1 19:23:29.162 Tried to finalize incremental boot, but rtm.start failed. Will recover when we reconnect.
_console @ rollup-core_required_ts.js:1
error @ rollup-core_required_ts.js:1
error @ rollup-core_required_ts.js:1
(anonymous) @ rollup-core_required_ts.js:1
tryCatcher @ rollup-core_required_libs.js:26
Promise._settlePromiseFromHandler @ rollup-core_required_libs.js:25
Promise._settlePromise @ rollup-core_required_libs.js:25
Promise._settlePromise0 @ rollup-core_required_libs.js:25
@dlsniper
dlsniper / webinar.go
Created June 18, 2017 11:08
webinar code
package main
import (
"fmt"
"log"
"net/http"
"github.com/gorilla/mux"
)
@dlsniper
dlsniper / Dockerfile
Last active June 18, 2017 12:11
Dockerfile to build the webinar example
# build stage
FROM golang:1.8.3 AS build-env
ADD . /go/src/github.com/dlsniper/webinar
RUN go build -o /webinar github.com/dlsniper/webinar
# final stage
FROM ubuntu:16.04
WORKDIR /
COPY --from=build-env /webinar /
@dlsniper
dlsniper / Dockerfile
Created June 18, 2017 16:40
Debug Dockerfile for Go applications
# build stage
FROM golang:1.8.3 AS build-env
ADD . /go/src/github.com/dlsniper/webinar
RUN go build -gcflags="-N -l" -o /webinar github.com/dlsniper/webinar
# final stage
FROM ubuntu:16.04
WORKDIR /
COPY --from=build-env /webinar /
ADD dlv /
@dlsniper
dlsniper / container-settings.json
Created June 18, 2017 16:51
Gogland container settings
{
"_comment": "FOR DETAILED FORMAT LOOK AT https://docs.docker.com/engine/api/v1.22/#create-a-container",
"AttachStdin": true,
"OpenStdin": true,
"HostConfig": {
"PortBindings":{
"8000/tcp": [{ "HostIp": "0.0.0.0", "HostPort": "8000" }],
"40000/tcp": [{ "HostIp": "0.0.0.0", "HostPort": "40000" }]
},
"SecurityOpt": ["apparmor=unconfined"],
#!/usr/bin/env bash
echo "Creating GOPATH for issue 3960..."
echo "This will create a folder named gopath3960"
read -p "Are you sure? " -n 1 -r
echo
if [[ ! $REPLY =~ ^[Yy]$ ]]
then
[[ "$0" = "$BASH_SOURCE" ]] && exit 1 || return 1
0x0000 00000 (/home/florin/go/src/github.com/dlsniper/u/tmp/asd/de.go:16) TEXT "".cl(SB), $120-8
0x0000 00000 (/home/florin/go/src/github.com/dlsniper/u/tmp/asd/de.go:16) MOVQ (TLS), CX
0x0009 00009 (/home/florin/go/src/github.com/dlsniper/u/tmp/asd/de.go:16) CMPQ SP, 16(CX)
0x000d 00013 (/home/florin/go/src/github.com/dlsniper/u/tmp/asd/de.go:16) JLS 359
0x0013 00019 (/home/florin/go/src/github.com/dlsniper/u/tmp/asd/de.go:16) SUBQ $120, SP
0x0017 00023 (/home/florin/go/src/github.com/dlsniper/u/tmp/asd/de.go:16) MOVQ BP, 112(SP)
0x001c 00028 (/home/florin/go/src/github.com/dlsniper/u/tmp/asd/de.go:16) LEAQ 112(SP), BP
0x0021 00033 (/home/florin/go/src/github.com/dlsniper/u/tmp/asd/de.go:16) FUNCDATA $0, gclocals·5f7ae22b544db82d5d4c812af83655e9(SB)
0x0021 00033 (/home/florin/go/src/github.com/dlsniper/u/tmp/asd/de.go:16) FUNCDATA $1, gclocals·bdf35