http://wiki.eclipse.org/Jetty/Howto/Deal_with_Locked_Windows_Files
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
case class Uri( | |
scheme: String, user: Option[String], host: String, port: Option[Int], | |
path: List[String], query: List[String]) | |
object Uri { | |
def unapply(uri: String): Option[Uri] = { | |
scala.util.Try(new java.net.URI(uri)).map{ v => | |
Some(new Uri(v.getScheme, Option(v.getUserInfo), v.getHost, Option(v.getPort), | |
v.getRawPath.split("/").to[List], v.getRawQuery.split("&").to[List])) | |
}.getOrElse(None) |
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
/*** | |
scalaVersion := "2.11.2" | |
resolvers ++= Seq( | |
"Sonatype" at "https://oss.sonatype.org/content/repositories/releases", | |
"spray repo" at "http://repo.spray.io" | |
) | |
libraryDependencies ++= Seq( | |
"io.spray" %% "spray-client" % "1.3.2-20140909", |
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
sealed trait Node[T] | |
case class Leaf[T](v: T) extends Node[T] | |
case class Branch[T](l: Node[T], r: Node[T]) extends Node[T] | |
implicit def nodeOrdering[W, C](implicit num: Numeric[W]): Ordering[Node[(W, C)]] = { | |
def weight(a: Node[(W, C)]): Tuple2[W, C] = a match { | |
case Leaf((w, c)) => (w, c) | |
case Branch(l, r) => { | |
val (wl, cl) = weight(l) | |
val (wr, _) = weight(r) |
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
libraryDependencies += "org.scala-lang" % "scala-reflect" % scalaVersion.value |
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 scala.util.Try | |
val nl = System.lineSeparator | |
def gliff(xs: String) = { | |
xs.stripMargin.split(nl).to[List] | |
} | |
val gliffs = | |
Map( |
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
object TC { | |
trait Ser[In, Out] { | |
def ser(in: In): Out | |
} | |
implicit object StringString extends Ser[String, String] { | |
def ser(a: String) = a | |
} | |
} |
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
// props: https://github.com/soloman1124/atom-solo-dark-ui | |
::-webkit-scrollbar { | |
width: 8px; | |
height: 8px; | |
} | |
::-webkit-scrollbar-track, | |
::-webkit-scrollbar-corner { | |
background: rgba(42, 42, 42, 0.5); | |
} |
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 code = """def html[X, Y](xs: List[(X, Y)]) = xs.toString | |
val a = List((1,1)) | |
a | |
val b = List((1,1)) | |
b""" | |
val tree = tb.parse(code) | |
val identifiers = tree.children.collect{ case i @ Ident(_) => i } | |
val instrumentation = identifiers.map{ i => | |
Apply(Select(Ident("scala"), TermName("Tuple2")), |
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
implicit class ReceiveAllOf[T]( probe: TestProbe ) { | |
def expectMsgAllPF[T]( handlers: List[PartialFunction[Any, T]] ): List[T] = { | |
val messages = probe.receiveN( handlers.size ) | |
// Accumulate result, Every handler must map to one Message | |
messages.foldRight( ( handlers, List.empty[T] ) ){ case ( message, ( accHandlers, res ) ) => { | |
val handler = accHandlers.find( _.isDefinedAt( message ) ) | |
val newAcc = accHandlers.filterNot( _ == handler.get ) | |
val result = handler.map( _.apply( message ) ).getOrElse( fail(s"got unexpected message $message") ) |