View Boot.scala
object Boot extends App with Logging with KubernetesClient {
implicit val system = ActorSystem()
implicit val ec = system.dispatcher
implicit val materializer = ActorMaterializer()
log.info(s"Starting watching services")
watchServices()
}
View searchCriteria2BingQueries.scala
implicit def searchCriteria2Queries(searchCriteria: SearchCriteria): Set[Query] = {
searchCriteria.getSearchwords.flatMap { searchWord => {
val emptyQuery = Query(searchWord, None, None)
val queriesWithSites = searchCriteria.getWebsites.toList.map(site => Query(searchWord, None, Some(site)))
val queriesWithMarkets = Markets(searchCriteria).map(market => Query(searchWord, Some(market), None))
Option(queriesWithSites.zipAll(queriesWithMarkets, emptyQuery, emptyQuery).map { case (q1, q2) =>
q1.copy(
market = q1.market.orElse(q2.market),
domain = q1.domain.orElse(q2.domain)
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