Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am trane on github.
  • I am andrewk (https://keybase.io/andrewk) on keybase.
  • I have a public key whose fingerprint is 5E11 0F44 6589 F667 F13E 55F1 270D 87D8 21BB DDF3

To claim this, I am signing this object:

@trane
trane / pre-commit.sh
Last active October 31, 2018 21:52
Does some simple go/ruby linting to add to your .git/hooks/pre-commit file
#!/bin/bash
function go_golangci_lint() {
echo "Running golangci-lint..."
local -r files="${1}"
# shellcheck disable=SC2086
golangci-lint run \
--no-config \
--presets bugs,format,style,unused \
--out-format=tab \
#!/usr/bin/env bash
declare -ir brew_installed=$(command -v brew 2>&1 > /dev/null)
if [ "${brew_installed}" -ne 0 ]; then
echo "Installing homebrew"
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
else
echo "Homebrew already installed"
fi
@trane
trane / REPL.md
Created August 19, 2017 15:20
A quick-start REPL intro

Scala REPL (Read Eval Print Loop)

You can get into a REPL on (OS X or Linux) from your terminal, from two different commands.

If you have scala installed, you can type:

$ scala

Or, more likely, you have sbt installed:

package domino.server.sync
import java.io.InputStream
import java.nio.ByteBuffer
import domino.replicator.functional.{Id, Monad}
import domino.replicator.functional.Syntax._
import scala.concurrent.{ExecutionContext, Future}
import scala.language.higherKinds
trait OrElseAble[F[_]] {
def getOrElse[A, B >: A](fa: F[A])(orElse: => B): B
}
object OrElseAble {
implicit val OptionElsable: OrElseAble[Option] = new OrElseAble[Option] {
override def getOrElse[A, B >: A](fa: Option[A])(orElse: => B) = fa.getOrElse(b)
}
implicit val TryElsable: OrElseAble[Try] = new OrElseAble[Try] {
override def getOrElse[A, B >: A](fa: Try[A])(orElse: => B) = fa.getOrElse(b)
object OptionUtils {
def fromOption[A](opt: Option[A])(onNone: => Throwable): Future[A] =
Future.successful(opt).map(_.getOrElse(throw onNone))
def fromOption[A](opt: Option[A])(onNone: => A): Future[A] =
Future.successful(opt).map(_.getOrElse(onNone))
}
class OptionOps[A](val self: Option[A]) {
def toFuture(onNone: => Throwable): Future[A] = OptionUtils.fromOption(self)(onNone)
def toFuture(onNone: => A): Future[A] = OptionUtils.fromOption(self)(onNone)
trait Prepare {
val id: PrepareId
}
case class Preparing(id: PrepareId) extends Prepare
case class Prepared(id: PrepareId, paths: Seq[Path]) extends Prepare
object Prepare {
def pathStrings(prepare: Prepare): Seq[String] = prepare match {
case Preparing(_) => Seq.empty[String]
case Prepared(_, paths) => paths.map(_.toAbsolutePath.toString)
import scala.util.Try
object ImplementedClient {
def getStuff[A](url: String): Try[A] =
Try(url.asInstanceOf[A])
}
trait Client[F[_], G[_]] {
def transform[A](f: F[A]): G[A]
def get[A](url: String): G[A]
}

Data container Dockerfile (using debian just because I want git with https support, this could be something much smaller)

FROM debian:jessie

ENV DOMINO_ECR_NAMESPACE /ecr-data

# this would be part of a git-type ECR prep-script
RUN apt-get update &&\
	apt-get install -y git