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
| (Source.single(request -> 42) via Http().superPool() map { | |
| case (Success(res), flag) => res.entity.toStrict(1 seconds).map(x => new String(x.data.toArray)) | |
| case (Failure(err), flag) => Future.failed(err) | |
| }).mapAsyncUnordered(2)(???) |
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
| val f = scala.io.Source.fromFile("jm.log") | |
| def trunk(value: Double): Double = BigDecimal(value).setScale(2, BigDecimal.RoundingMode.HALF_UP).toDouble | |
| def percentile(ms: Map[Long, Long], amount: Long, lvls: List[Int]): List[Long] = { | |
| val ls = ms.toList.sortBy(x => x._1) | |
| val lvlValues = lvls map (lvl => Math.ceil(amount*lvl/100f).toLong) | |
| def search(a: Long, xs: List[(Long, Long)], lvlValue: Long): Long = xs match { | |
| case v::xs if a+v._2 < lvlValue => search(a+v._2, xs, lvlValue) | |
| case v::xs => v._1 |
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
| val f = scala.io.Source.fromFile("jm.log") | |
| def trunk(value: Double): Double = BigDecimal(value).setScale(2, BigDecimal.RoundingMode.HALF_UP).toDouble | |
| def percentile(ms: Map[Long, Long], amount: Long, lvls: List[Int]): List[Long] = { | |
| val ls = ms.toList.sortBy(x => x._1) | |
| val lvlValues = lvls map (lvl => Math.ceil(amount*lvl/100f).toLong) | |
| def search(a: Long, xs: List[(Long, Long)], lvlValue: Long): Long = xs match { | |
| case v::xs if a+v._2 < lvlValue => search(a+v._2, xs, lvlValue) | |
| case v::xs => v._1 |
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
| case Event(newConnection: ActorRef, FSMData.Datum(challengeRef, channels, state)) => | |
| context.watch(newConnection) | |
| newConnection ! CurrentState(stateName).json | |
| stay() using FSMData.Datum(challengeRef, channels + newConnection, state) |
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
| class WebSocketActor(out: ActorRef) extends Actor { | |
| def receive = { | |
| case msg: JsValue => distributeCommands(msg) | |
| } | |
| def distributeCommands(req: JsValue): Unit = { | |
| (req \ "command").asOpt[String] match { | |
| case Some("get all accounts") => mock.getAllAccounts pipeTo out | |
| case Some("add account") => mock.addAccount pipeTo out |
NewerOlder