Skip to content

Instantly share code, notes, and snippets.

Montana Flynn montanaflynn

Block or report user

Report or block montanaflynn

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View pointers.go
package main
import (
"fmt"
)
func CopyChange(a int) {
a = 10
}
@montanaflynn
montanaflynn / main.go
Created Apr 7, 2019
Golang graceful restart with gin framework but pattern works for any http.Server
View main.go
package main
import (
"context"
"log"
"net/http"
"os"
"os/signal"
"time"
@montanaflynn
montanaflynn / main.go
Last active Nov 3, 2019
Gin request timeout middleware and handler
View main.go
package main
import (
"context"
"log"
"net/http"
"time"
"github.com/gin-gonic/gin"
)
@montanaflynn
montanaflynn / timer.go
Created Apr 5, 2019
A simple timer to use for logging time between actions
View timer.go
package timer
import (
"log"
"os"
"time"
)
type TimeLogger interface {
Printf(format string, v ...interface{})
@montanaflynn
montanaflynn / ml.go
Created Jan 16, 2019
Simple neural net with one hidden layer consisting of one neuron
View ml.go
// Found at https://play.golang.org/p/sR0vNRAQD1
// Inspired by https://medium.com/technology-invention-and-more/how-to-build-a-simple-neural-network-in-9-lines-of-python-code-cc8f23647ca1
package main
import (
"fmt"
"math/rand"
"math"
)
@montanaflynn
montanaflynn / GOMOD.md
Created Dec 11, 2018
JUST TELL ME HOW TO USE GO MODULES
View GOMOD.md
go mod init <modulename>

go get -u ./...

go mod vendor

go get -u <repo url>

go mod vendor
@montanaflynn
montanaflynn / clean.go
Created Sep 17, 2018
ZB exchange pair cleaner
View clean.go
package main
import (
"bufio"
"encoding/json"
"fmt"
"log"
"os"
"strings"
)
@montanaflynn
montanaflynn / wildcat.go
Created Aug 12, 2018
Simple wildcard concatenation program
View wildcat.go
package main
import (
"bytes"
"io/ioutil"
"log"
"os"
"path/filepath"
)
View Makefile
include .env
PROJECTNAME=$(shell basename "$(PWD)")
# Go related variables.
GOBASE=$(shell pwd)
GOPATH=$(GOBASE)/vendor:$(GOBASE):/home/azer/code/golang # You can remove or change the path after last colon.
GOBIN=$(GOBASE)/bin
GOFILES=$(wildcard *.go)
@montanaflynn
montanaflynn / terminal.go
Last active Mar 19, 2019
Watch for signals in terminal
View terminal.go
package main
import (
"fmt"
"os"
"os/signal"
"syscall"
"golang.org/x/crypto/ssh/terminal"
)
You can’t perform that action at this time.