Skip to content

Instantly share code, notes, and snippets.

View deankarn's full-sized avatar
Coffee In -> Code Out

Dean Karn deankarn

Coffee In -> Code Out
  • Hubspot
  • /dev/tty0
View GitHub Profile
@deankarn
deankarn / Go Cross Compile
Last active August 29, 2015 14:15
Go Cross compile setup + build
Step #1 setup cross compiler(s) you want/need to use
cd $(go env GOROOT)/src
GOOS=linux GOARCH=amd64 ./make.bash <- GOOS=operating system - linux, darwin, windows etc... GOARCH=architechture - amd64, x86_64 386...
Step #2 navigate to go project
cd /path/of/go/project
env GOOS=linux GOARCH=amd64 go build
@deankarn
deankarn / gorilla sessions random key
Created April 23, 2015 19:57
Generates a random key and encodes into base64
key := securecookie.GenerateRandomKey(64)
encoded := base64.StdEncoding.EncodeToString(key)
decoded, _ := base64.StdEncoding.DecodeString(encoded)
log.Println(key)
log.Println(encoded)
log.Println(decoded)
@deankarn
deankarn / response_writer.go
Created April 30, 2015 15:50
Wrapping/implementing golang's http.ResponseWriter example
// LogResponseWritter wraps the standard http.ResponseWritter allowing for more
// verbose logging
type LogResponseWritter struct {
status int
size int
http.ResponseWriter
}
// func NewMyResponseWriter(res http.ResponseWriter) *MyResponseWriter {
// // Default the status code to 200
@deankarn
deankarn / gist:796e2dff57e5d210cb2d
Created June 8, 2015 12:09
Long lived, concurrent safe pools made with buffered channels
// Pool holds Clients.
type Pool struct {
pool chan *Client
}
// NewPool creates a new pool of Clients.
func NewPool(max int) *Pool {
return &Pool{
pool: make(chan *Client, max),
}
{
"auto_complete_commit_on_tab": true,
"color_scheme": "Packages/Monokai Extended/Monokai Extended.tmTheme",
"font_size": 12,
"ignored_packages":
[
"Vintage"
]
}
{
"env": { "GOPATH":"$GOPATH"},
"fmt_cmd": ["goimports"],
"on_save": [{
"cmd": "gs9o_open", "args": {
"run": ["sh",
"gofmt -s -w . && go build . errors && go test -i && go test && go vet && golint ."],
"focus_view": false
}}],
"autocomplete_closures": true,
#!/bin/bash
CD_CMD="cd "\\\"$(pwd)\\\"" && clear"
if echo "$SHELL" | grep -E "/fish$" &> /dev/null; then
CD_CMD="cd "\\\"$(pwd)\\\""; and clear"
fi
VERSION=$(sw_vers -productVersion)
OPEN_IN_TAB=0
while [ "$1" != "" ]; do
@deankarn
deankarn / iris-test
Created March 14, 2016 12:38
iris bench test no cache
package iris
import (
"io"
"net/http"
_ "runtime"
"testing"
"github.com/gin-gonic/gin"
"github.com/go-playground/lars"
@deankarn
deankarn / rpc_pool.go
Created May 10, 2016 21:16
rpc ppol example
package client
import (
"net/rpc"
"github.com/go-playground/log"
)
// NewFunc is the type of function that is called to create a new Go rpc Client
type NewFunc func() *rpc.Client
@deankarn
deankarn / main.go
Last active April 24, 2017 18:47
Release WebHook & Tweet
package main
import (
"fmt"
"log"
twitter "github.com/ChimeraCoder/anaconda"
"gopkg.in/go-playground/webhooks.v3"
"gopkg.in/go-playground/webhooks.v3/github"