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 cats.data.State | |
| import cats.data.State._ | |
| def factorialWithState(x: Int): Int = { | |
| def stateFactorial: State[Int, Int] = | |
| get.flatMap(x => | |
| if (x <= 1) | |
| State.pure(1) | |
| else { | |
| set[Int](x - 1).flatMap(_ => stateFactorial.map(z => x * z)) |
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
| //Problem : https://www.hackerrank.com/challenges/angry-children | |
| // Algorithm : | |
| // Read input into 2D lists => List(List(x)) | |
| // Sort every row of the matrix | |
| // Then iterate over every column, check for unsorted first column | |
| // break if we find unsorted column | |
| object Test extends App { |
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 Solution { | |
| def main(args: Array[String]) { | |
| val sc = new java.util.Scanner (System.in); | |
| var n = sc.nextInt(); | |
| var a = Array.ofDim[Int](n,n); | |
| for(a_i <- 0 to n-1) { | |
| for(a_j <- 0 to n-1){ | |
| a(a_i)(a_j) = sc.nextInt(); | |
| } |
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 java.util.concurrent.ThreadLocalRandom | |
| import akka.actor.ActorSystem | |
| import akka.stream.{ClosedShape, ActorMaterializer} | |
| import akka.stream.scaladsl.{Sink, Flow, Source, FileIO, GraphDSL, Broadcast, RunnableGraph} | |
| import java.io.File | |
| import akka.util.ByteString | |
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.{ActorRef, ActorSystem} | |
| import akka.stream.scaladsl._ | |
| import akka.stream.{OverflowStrategy, ActorFlowMaterializer} | |
| import org.reactivestreams.Publisher | |
| import twitter4j.{StallWarning, StatusDeletionNotice, TwitterStreamFactory, FilterQuery} | |
| import twitter4j.{Status => TwitterStatus} | |
| import com.typesafe.config.ConfigFactory | |
| import twitter4j._ | |
| import twitter4j.conf.ConfigurationBuilder |
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.{RootActorPath, Actor, Props, ActorSystem} | |
| import akka.cluster.{Member, MemberStatus, Cluster} | |
| import akka.cluster.ClusterEvent.{CurrentClusterState, MemberUp} | |
| import com.typesafe.config.ConfigFactory | |
| /** | |
| * Created by rajeevprasanna on 5/13/16. | |
| */ | |
| object TransformationBackend { | |
| def main(args: Array[String]): Unit = { |
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.http.Http | |
| import akka.http.model.{StatusCodes, Uri, HttpResponse, HttpRequest} | |
| import akka.stream.FlowMaterializer | |
| import akka.stream.scaladsl.Flow | |
| import akka.http.model.HttpMethods._ | |
| import play.api.libs.json.Json | |
| import play.modules.reactivemongo.json.BSONFormats | |
| import reactivemongo.bson.BSONDocument |
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.http.scaladsl.Http | |
| import akka.http.scaladsl.model.ws.{TextMessage, Message} | |
| import akka.http.scaladsl.server.Directives._ | |
| import akka.stream.ActorMaterializer | |
| import akka.stream.scaladsl.Flow | |
| import scala.concurrent.ExecutionContext.Implicits.global | |
| object WebsocketExample extends App { |
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.SupervisorStrategy.{Escalate, Restart} | |
| import akka.actor._ | |
| import scala.concurrent.duration._ | |
| object Main extends App { | |
| val system = ActorSystem("supervisorStrategy") | |
| implicit val context = system.dispatcher | |
| import scala.concurrent.ExecutionContext.Implicits.global |
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.{Props, ActorSystem} | |
| import akka.event.Logging | |
| import akka.http.scaladsl.Http | |
| import akka.http.scaladsl.client.RequestBuilding | |
| import akka.http.scaladsl.marshallers.sprayjson.SprayJsonSupport | |
| import akka.http.scaladsl.marshalling.ToResponseMarshallable | |
| import akka.http.scaladsl.marshalling.ToResponseMarshaller | |
| import akka.http.scaladsl.model.{HttpResponse, HttpRequest} | |
| import akka.http.scaladsl.server.RouteResult.Complete | |
| import akka.http.scaladsl.unmarshalling.Unmarshal |