Skip to content
View FooTest.scala
import org.specs2.mutable.Specification
/**
* Created by jero on 3-12-15.
*/
class FooTest extends Specification {
"FooTest" should {
"doSomethingAwesome" >> todo
View ConvertJsonToHList.scala
import play.api.libs.json._
import play.api.libs.functional.syntax._
import HListUtils._
import JsonFormats._
implicit val specReads = (
(__ \ "id").read[String] and
(__ \ "specs").read((
(__ \ "specA").read[SpecA] and
View DynamicConverter.scala
package util
import org.specs2.mutable.Specification
/**
* Created by jero on 26-10-15.
*/
class FooTest extends Specification{
trait Spec
trait Data
View AkkaHttpApiFollowingJsonApiSpec.scala
import akka.actor.ActorSystem
import akka.event.LoggingAdapter
import akka.http.scaladsl.marshallers.sprayjson.SprayJsonSupport._
import akka.http.scaladsl.marshalling.{ToEntityMarshaller, Marshaller}
import akka.http.scaladsl.model._
import akka.http.scaladsl.server.Directives._
import akka.stream.Materializer
import com.oxyme.monitoring.HealthChecker
import com.oxyme.monitoring.model.{Unhealthy, Healthy}
import com.typesafe.config.{ConfigFactory, Config}
View AkkaHttpMicroService.scala
import akka.actor.ActorSystem
import akka.http.scaladsl.Http
import akka.stream.ActorMaterializer
object Boot extends App with Service with CorsSupport {
override implicit val system = ActorSystem()
override implicit val executor = system.dispatcher
override implicit val materializer = ActorMaterializer()
Http().bindAndHandle(corsHandler(routes), "0.0.0.0", 1337)
View NgramExtractor.scala
object Boot extends App {
val extractor = new SentenceAnalyzer
with NGramExtraction
with Unigrams
with Bigrams
with Trigrams
val sentences = Source.fromInputStream(getClass.getResourceAsStream("/input.txt")).getLines().toIterable
println(extractor.analyze(sentences))
}
View CombinerBase.scala
def ~>[Out](junction: UniformFanInShape[T, Out])(implicit b: Builder[_]): PortOps[Out, Unit] = {
def bind(n: Int): Unit = {
if (n == junction.inSeq.length)
throw new IllegalArgumentException(s"no more inlets free on $junction")
else if (b.module.upstreams.contains(junction.in(n))) bind(n + 1) // it's already part of the graph
else b.addEdge(importAndGetPort(b), junction.in(n)) // b.add(), add it to the graph
}
bind(0)
junction.out
}
View ProposalOfImplicitAddToGraph.scala
val src = Source.actorRef[ByteString](1000, OverflowStrategy.dropHead)
FlowGraph.closed(src) { implicit builder =>
byteStringSource =>
import FlowGraph.Implicits._
// for junctions / fan-in / fan-out shapes we need to builder.add explicitly
// val broadcaster = builder.add(Broadcast[String](2))
val broadcaster: UniformFanOutShape[String,String] = Broadcast[String](2) // builder.add is done implicitly
View Flows.scala
val src = Source.actorRef[ByteString](1000, OverflowStrategy.dropHead)
FlowGraph.closed(src) { implicit builder =>
byteStringSource =>
import FlowGraph.Implicits._
// for junctions / fan-in / fan-out shapes we need to builder.add explicitly
val broadcaster = builder.add(Broadcast[String](2))
// for Flows builder.add is implicit, if I'm not mistaking
View Build.scala
object ApplicationBuild extends Build {
val appName = "my-app"
val appVersion = "1-SNAPSHOT"
val appDependencies = Seq(
jdbc,
cache
)
val main = play.Project(appName, appVersion, appDependencies)
Something went wrong with that request. Please try again.