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
| // We define a logical rule Augmentable that transform Int -> Long and Float -> Double | |
| // at the type level with a dependent type. | |
| // Then we want to abstract over arity and ensure that an "augment" transformation | |
| // is defined for every type of a HList. | |
| import shapeless._ | |
| // Dependent type T -> S (S depends on T) | |
| trait Augmentable[T] { | |
| type S |
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
| // Enum type based on Sum types (OR) | |
| trait ADTEnum[A] { | |
| import play.api.data.mapping.json.Writes._ | |
| import play.api.data.mapping.json.Rules._ | |
| val list: Seq[A] | |
| def withName(name: String): Option[A] = { | |
| list.find(_.toString.toLowerCase == name.toLowerCase) | |
| } |
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
| sealed trait IOToolResponse[+A] { | |
| def flatMap[B](f: A => IOToolResponse[B]): IOToolResponse[B] = this match { | |
| case Authenticated(a) => f(a) | |
| case na: NotAuthenticated => na | |
| } | |
| def map[B](f: A => B): IOToolResponse[B] = this.flatMap(a => IOToolResponse.unit(f(a))) | |
| } | |
| object IOToolResponse { | |
| def unit[A](a: A): IOToolResponse[A] = Authenticated(a) |
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 uploadStream(bucket: String, key: String, enum: Enumerator[Array[Byte]]) | |
| (implicit ec: ExecutionContext): Future[CompleteMultipartUploadResult] = { | |
| import scala.collection.JavaConversions._ | |
| val initRequest = new InitiateMultipartUploadRequest(bucket, key) | |
| val initResponse = s3.initiateMultipartUpload(initRequest) | |
| val uploadId = initResponse.getUploadId | |
| val rechunker: Enumeratee[Array[Byte], Array[Byte]] = Enumeratee.grouped { | |
| Traversable.takeUpTo[Array[Byte]](5 * 1024 * 1024) &>> Iteratee.consume() |
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
| implicit val app = new play.core.StaticApplication(new java.io.File(".")) |
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
| #!/bin/bash | |
| REMOTE=play@SERVER_IP | |
| REMOTE_APP=/home/play/PROJECT_NAME/ | |
| sbt stage || exit 1; | |
| rsync -va target/ $REMOTE:$REMOTE_APP/target; | |
| ssh $REMOTE "cd $REMOTE_APP; ./stop.sh"; | |
| ssh $REMOTE "cd $REMOTE_APP; ./start.sh"; |
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
| \begin{figure}[h] | |
| \begin{center} | |
| \makebox[\textwidth]{\includegraphics[width=1.0\textwidth]{img/archi_actor_dataintegration.png}} | |
| \caption{Puller actor system} | |
| \label{fig:archi_actor_dataintegration} | |
| \end{center} | |
| \end{figure} |
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 play.api.libs.iteratee._ | |
| import play.api.libs.iteratee.Enumerator._ | |
| import concurrent.ExecutionContext.Implicits.global | |
| import scala.concurrent._ | |
| import scala.concurrent.duration._ | |
| implicit val t = 100 seconds | |
| def startStream(): Future[Iteratee[Event, Unit]] = { | |
| Thread.sleep(1000) |
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 play.api.libs.iteratee._ | |
| import play.api.libs.iteratee.Enumerator._ | |
| import concurrent.ExecutionContext.Implicits.global | |
| import scala.concurrent._ | |
| import scala.concurrent.duration._ | |
| implicit val t = 100 seconds | |
| trait TreatCont2[E, S] { | |
| def apply[A](loop: (Iteratee[E, A], S) => Future[Iteratee[E, A]], s: S, it: Iteratee[E, A]): Future[Iteratee[E, A]] |
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
| /** | |
| * Created by atamborrino on 11/03/2014. | |
| */ | |
| import play.api.libs.iteratee.Enumeratee._ | |
| import play.api.libs.iteratee._ | |
| import scala.concurrent._ | |
| import scala.concurrent.duration._ | |
| def mapWithCounter[From, To](f: (From, Int) => To): Enumeratee[From, To] = new CheckDone[From, To] { |