Scala is a general-purpose programming language designed to express common programming patterns in a concise, elegant, and type-safe way. It smoothly integrates features of object-oriented and functional programming languages, enabling programmers to be more productive. Scala is an acronym for “Scalable Language”. This means that Scala grows with you.
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
package samples | |
import akka.stream.scaladsl.Flow | |
import akka.stream.{MaterializerSettings, FlowMaterializer} | |
import org.reactivestreams.api.{Consumer, Producer} | |
import org.reactivestreams.spi.{Subscription, Subscriber} | |
import akka.actor.ActorSystem | |
object OneProducerManySubscribers { |
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
package controllers; | |
import com.fasterxml.jackson.databind.ObjectMapper; | |
import models.Computer; | |
import play.mvc.*; | |
import play.data.Form; | |
import java.util.Map; | |
public class Application extends Controller { |
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
package controllers | |
import play.api.mvc._ | |
import scala.concurrent._ | |
import akka.actor.{Props, Actor} | |
import play.api.Play.current | |
import play.api.libs.concurrent.Akka | |
import scala.concurrent.ExecutionContext.Implicits._ | |
object Application extends Controller { |
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 factory = new org.jboss.netty.channel.socket.nio.NioServerSocketChannelFactory( | |
new NioServerBossPool(Executors.newCachedThreadPool(NamedThreadFactory("play-netty-boss")), 1, ThreadNameDeterminer.CURRENT), | |
new NioWorkerPool(Executors.newCachedThreadPool(NamedThreadFactory("play-netty-worker")), | |
Runtime.getRuntime.availableProcessors * 2, | |
ThreadNameDeterminer.CURRENT) | |
) |
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
//instead of using WS.url("http://www.google.com") use new CustomRequestHeader(url) | |
class CustomRequestHolder extends WSRequestHolder { | |
public CustomRequestHolder(String url) { super(url); } | |
@Override | |
public Promise<Response> execute(String method) { |
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
package controllers | |
import play.api._ | |
import play.api.mvc._ | |
import play.api.mvc.Controller | |
object Application { | |
def index = Action { | |
Results.Ok(views.html.index("Your new application is ready.")) |
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
package controllers; | |
import java.io.File; | |
import java.util.List; | |
import play.mvc.BodyParser; | |
import play.mvc.BodyParser.Of; | |
import play.mvc.Controller; | |
import play.mvc.Http.MultipartFormData; | |
import play.mvc.Http.MultipartFormData.FilePart; |
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 class Speaker(name: String, bio: String, twitterId: Option[String], id: Option[Long] = None) | |
class Speakers extends Table[Speaker]("Speaker") { | |
def id = column[Long]("id", O.PrimaryKey, O.AutoInc) | |
def name = column[String]("name") | |
def bio = column[String]("bio") | |
def twitterId = column[Option[String]]("twitterId") |