Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am mcveat on github.
  • I am mcveat (https://keybase.io/mcveat) on keybase.
  • I have a public key ASBJkE7VqvqBmo3Y-AOdKqG10e1jSNrayzivXqkJcyCSLwo

To claim this, I am signing this object:

implicit def eitherFormat[A, B](implicit af: Format[A], bf: Format[B]) = new Format[Either[A, B]] {
override def writes(o: Either[A, B]): JsValue = o match {
case Left(a) => af.writes(a)
case Right(b) => bf.writes(b)
}
override def reads(json: JsValue): JsResult[Either[A, B]] =
json.validate[B].map(Right.apply).orElse(json.validate[A].map(Left.apply))
}
@mcveat
mcveat / .gitconfig
Last active June 16, 2022 23:13
alias part of my gitconfig
[alias]
st = status
ci = commit
co = checkout
lg = log -p
lsd = log --graph --decorate --pretty=oneline --abbrev-commit --all
lld = log --graph --decorate --abbrev-commit --all
s = status --short
files = log --name-status --oneline
ri = rebase -i origin/master
@mcveat
mcveat / JsBSONHandlers.scala
Last active December 18, 2015 22:59 — forked from nevang/JsBSONHandlers.scala
Supports spray 1.1-M8 and spray-json 1.2.5
import spray.json._
import reactivemongo.bson._
import scala.util.{ Try, Success, Failure }
import org.apache.commons.codec.binary.Hex
import org.joda.time.format.ISODateTimeFormat
import org.joda.time.{DateTime, DateTimeZone}
import java.nio.ByteBuffer
/**
* From https://gist.github.com/nevang/4690568