This file contains hidden or 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 Conf extends ScallopConf(args){ | |
| class BadArgsException(msg: String) extends Exception(msg) {} | |
| val properties = props[String]('D') andThen | |
| (_.map(_.toLowerCase)) andThen | |
| (s => s.map { case s if(List("true","t","y","yes").contains(s)) => true | |
| case s if(List("false","f","n","no").contains(s)) => false | |
| case s => throw new BadArgsException(s + " is not a boolean value") | |
| } |
This file contains hidden or 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 dispatch._ ,Defaults._ | |
| import com.ning.http.client.Request.EntityWriter | |
| import org.apache.commons.compress.utils.IOUtils | |
| import java.io.{InputStream, OutputStream} | |
| implicit def InputStream2EntityWriter(in: InputStream): EntityWriter = new EntityWriter { | |
| override def writeEntity(out: OutputStream): Unit = { | |
| IOUtils.copy(in,out) | |
| in.close | |
| out.close |
This file contains hidden or 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
| name := s"my-artifact_lib${System.getProperty("cross.build.lib.version")}" | |
| libraryDependencies += "com.some.group" % "some-artifact" % System.getProperty("cross.build.lib.version") | |
| val changeVer = inputKey[Unit]("change system property cross.build.lib.version") | |
| val buildAndPublish = taskKey[Unit]("your custom build task...") | |
| changeVer := { | |
| import complete.DefaultParsers._ |
This file contains hidden or 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 solve(board: Seq[Seq[Seq[Int]]]): String = { | |
| require(board.size == 7 && board.forall(row => row.size == 8 && row.forall(_.size == 3)),"Must have exact dimensions") | |
| //initialization | |
| val mat = new Array[Array[(Int,Char)]](8) | |
| for(i ← 0 to 7){ | |
| mat(i) = new Array[(Int,Char)](8) | |
| for(j ← 0 to 7) { | |
| if(i == 0) mat(0)(j) = 0 → '✓' | |
| else mat(i)(j) = Int.MaxValue → '✓' |
This file contains hidden or 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 akka.actor._ | |
| import akka.stream.actor.ActorPublisher | |
| import akka.stream.actor.ActorPublisherMessage.{Cancel, Request} | |
| import akka.stream.scaladsl.Source | |
| import scala.concurrent.{ExecutionContext, Future} | |
| import scala.util.{Failure, Success, Try} | |
| def unfold[S,E](s: S) | |
| (f: S => Option[(S,E)]): Source[E,ActorRef] = |
This file contains hidden or 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 akka.stream.stage.{OutHandler, GraphStageLogic, GraphStage} | |
| import akka.stream.actor.ActorPublisherMessage.{Cancel, Request} | |
| import akka.stream.scaladsl._ | |
| import akka.stream._ | |
| import scala.concurrent.{ExecutionContext, Future} | |
| import scala.util.{Failure, Success, Try} | |
| class Unfold[S, E](s: S,f: S => Option[(S, E)]) extends GraphStage[SourceShape[E]] { |
This file contains hidden or 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 Aggregate { | |
| private[this] val inc: Any ⇒ Long = _⇒1L | |
| def apply[In,Out](max: Long, seed: In ⇒ Out)(aggregate: (Out, In) ⇒ Out) = | |
| AggregateWeighted[In,Out](max, inc, seed)(aggregate) | |
| } | |
| object AggregateWeighted { |
This file contains hidden or 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 hochgi.util.http | |
| import java.io.InputStream | |
| import akka.actor.ActorSystem | |
| import akka.http.scaladsl._ | |
| import akka.http.scaladsl.model.HttpHeader.ParsingResult | |
| import akka.http.scaladsl.model._ | |
| import akka.http.scaladsl.model.ws._ | |
| import akka.stream.stage.{OutHandler, InHandler, GraphStageLogic, GraphStage} |
This file contains hidden or 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 hochgi.util | |
| package object collections { | |
| /** | |
| * `partition` and `map` combined. | |
| * for a given collection, and a function from the collection elements to `Either[A,B]`, | |
| * generates a tuple of 2 collections of types `A` and `B` | |
| * | |
| * @param xs the collection of elements | |
| * @param f a function that convert an element to an `Either[A,B]` |
This file contains hidden or 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 akka.actor.ActorSystem | |
| import akka.stream._ | |
| import akka.stream.scaladsl._ | |
| import akka.stream.stage._ | |
| import com.typesafe.config.ConfigFactory | |
| import org.scalameter._ | |
| import scala.concurrent._ ,duration._ | |
| import scala.concurrent.ExecutionContext.Implicits.global | |
| object PartitionWithMeter { |
OlderNewer