Skip to content

Instantly share code, notes, and snippets.

View JohnMurray's full-sized avatar

John Murray JohnMurray

View GitHub Profile
@JohnMurray
JohnMurray / .travis.yaml
Last active January 30, 2018 02:02
snippet to install and setup gometalinter
before_install:
- go get -u gopkg.in/alecthomas/gometalinter.v2
- gometalinter.v2 --install
@JohnMurray
JohnMurray / .travis.yaml
Created January 24, 2018 05:59
travis snippet to ignore a specific go version
matrix:
allow_failures:
go: master
fast_finish: true
@JohnMurray
JohnMurray / .travis.yaml
Created January 24, 2018 05:58
basic Go setup for Travis - snippet
language: go
go:
- 1.8
- 1.9
- 1.9.x
- master
@JohnMurray
JohnMurray / .travis.yaml
Last active January 25, 2018 17:32
Setup depenencies with dep and travis
install:
- dep ensure
@JohnMurray
JohnMurray / .travis.yaml
Created January 24, 2018 05:37
diable email notification snippet
notifications:
email: false
@JohnMurray
JohnMurray / .travis.yaml
Created January 24, 2018 05:37
Simple email notifications snippet
notifications:
email:
recipients:
- [email protected]
- [email protected]
on_success: change
on_failure: always
@JohnMurray
JohnMurray / .travis.yaml
Last active January 24, 2018 05:34
Simple install snippet for getting up dep
before_install:
- >-
curl -L -s https://github.com/golang/dep/releases/download/v0.3.2/dep-linux-amd64
-o $GOPATH/bin/dep
- chmod +x $GOPATH/bin/dep
@JohnMurray
JohnMurray / Makefile
Last active January 23, 2018 14:44
A simple makefile for a blog post
BUILD_OPTS=-p4 -race
BIN_NAME=my_app
default: test
.PHONY: test
test: compile
@echo
@echo "[running tests]"
@go test -v ./...
@JohnMurray
JohnMurray / build.sbt
Created January 16, 2018 19:10
Simple project to launch a REPL with a dependency on Akka
name := "console-project"
version := "1.0"
scalaVersion := "2.12.4"
libraryDependencies ++= Seq(
"com.typesafe.akka" %% "akka-actor" % "2.5.9"
)
@JohnMurray
JohnMurray / retry-with-exponential-backoff.scala
Last active January 27, 2018 21:57
Simple retries with future-based networking code in Scala (with exponential back-off)
def networkRequestWithRetries(factor: Float = 1.5f, init: Int = 1, cur: Int = 0)
(implicit as: ActorSystem): Future[String] = {
networkRequest().recoverWith {
case NetworkException =>
val next: Int =
if (cur == 0) init
else Math.ceil(cur * factor).toInt
println(s"retrying after ${next} ms")
after(next.milliseconds, as.scheduler, global, Future.successful(1)).flatMap { _ =>
networkRequestWithRetries(factor, init, next)