This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// C+P from https://github.com/nafg/slick-additions/blob/63de5af9c7791c5523865d362c27380e3d031b19/bintray.sbt | |
publishMavenStyle := true | |
publishTo := Some("Slick-additions Bintray" at "https://api.bintray.com/maven/naftoligug/maven/slick-additions") | |
sys.env.get("BINTRAYKEY").toSeq map (key => | |
credentials += Credentials( | |
"Bintray API Realm", | |
"api.bintray.com", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import scalaz.\/ | |
import scalaz.concurrent.Task | |
import scala.concurrent.{ ExecutionContext, Future, Promise } | |
import scala.util.Try | |
class TaskCompat(private val T: Task.type) extends AnyVal { | |
def fromScala[A](future: Future[A])(implicit ec: ExecutionContext): Task[A] = | |
Task async (handlerConversion andThen future.onComplete) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Quasiquoted excerpt | |
def cdef = q""" | |
class $ClassName[..$classTypeParams](..$primaryParams) extends ..$classParents { | |
..$primaryAccessors | |
def get = this | |
def isEmpty = ${quasi.isEmpty} | |
def copy(..$primaryWithDefaults) = $ObjectName(..$primaryNames) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// sbt.version = 0.13.9 | |
lazy val dynver = taskKey[String]("Determine the dynamic version") | |
dynver := { | |
// Inspired by Mercurial's own self-versioning: | |
// http://www.selenic.com/hg/file/61b333b982ea/setup.py#l184 | |
// Outputs either: | |
// * v1.0.0 (if building on v1.0.0 tag, w/o local changes) | |
// * v1.0.0+20140707 (if building on v1.0.0 tag with local changes) | |
// * v1.0.0+3-1234abcd (if building on commit 1234abcd: 3 commits after v1.0.0 tag, w/o local changes) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
final case class MapWithTabularLite[K, V](private val xs: TraversableOnce[(K, V)]) extends AnyVal { | |
def showkv() = if (xs.nonEmpty) { | |
val len = xs.toIterator.map(_._1.toString.length).max | |
val fmt = s"%${len}s %s" | |
xs foreach (kv => println(fmt format (kv._1, kv._2))) | |
} | |
} | |
final case class MultimapWithTabularLite[K, V](private val xs: TraversableOnce[(K, TraversableOnce[V])]) extends AnyVal { | |
def showkvs() = if (xs.nonEmpty) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Thingy(val unThingy: String) extends AnyVal | |
class Rocket(val unRocket: Thingy) extends AnyVal |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package p | |
/** Decodes strings into Ts */ | |
trait Decoder[T] { | |
def decode(s: String): Either[String, T] | |
} | |
object Decoder { | |
def apply[T](f: String => Either[String, T]): Decoder[T] = | |
new Decoder[T] { def decode(s: String) = f(s) } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def nowIso8601() = { | |
val df = new java.text.SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'") | |
df setTimeZone (java.util.TimeZone getTimeZone "UTC") | |
df format new java.util.Date() | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# In order for gpg to find gpg-agent, gpg-agent must be running, and there must be an env | |
# variable pointing GPG to the gpg-agent socket. This little script, which must be sourced | |
# in your shell's init script (ie, .bash_profile, .zshrc, whatever), will either start | |
# gpg-agent or set up the GPG_AGENT_INFO variable if it's already running. | |
# Add the following to your shell init to set up gpg-agent automatically for every shell | |
if [ -f ~/.gnupg/.gpg-agent-info ] && [ -n "$(pgrep gpg-agent)" ]; then | |
source ~/.gnupg/.gpg-agent-info | |
export GPG_AGENT_INFO | |
else |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
val dependencyList = taskKey[File]("") | |
val dependencyListDef = Def.task { | |
val f = baseDirectory.value / "deps.sbt.txt" | |
streams.value.log.info(s"Writing to $f") | |
IO.write(f, "\n") | |
IO.append(f, "The following files have been resolved:\n") | |
val cp = (managedClasspath in Test).value | |
val lines = cp map { att => | |
val md = att.metadata |