- slick: http://slick.typesafe.com
- activate: http://activate-framework.org
- ReactiveMongo: http://reactivemongo.org
- json4s: https://github.com/json4s/json4s
- spray-json: https://github.com/spray/spray-json
| heroku config:add BUILDPACK_URL=http://github.com/heroku/heroku-buildpack-scala.git |
| var STATE_CASE_1 = 0, | |
| STATE_CASE_2 = 1, | |
| STATE_CASE_3 = 2, | |
| DEFAULT_CASE = 99999; | |
| var dict = { | |
| STATE_CASE_1: function (s) { /**/ }, // The key is not its Number value! It's String "STATE_CASE_1"! | |
| STATE_CASE_2: function (s) { /**/ }, | |
| STATE_CASE_3: function (s) { /**/ }, | |
| DEFAULT_CASE: function (s) { /**/ } |
| def reformat(json: String) = { | |
| val tab = " " | |
| var inString = false | |
| var indentLevel = 0 | |
| var index = 0; | |
| val stringLength = json.length | |
| val formatted = new StringBuilder | |
| while (index < stringLength) { |
| location xxxx { | |
| proxy_pass http://localhost:9000; | |
| proxy_buffering off; | |
| proxy_cache off; | |
| proxy_redirect off; | |
| proxy_set_header Connection ''; | |
| proxy_http_version 1.1; | |
| chunked_transfer_encoding off; | |
| proxy_set_header Host $host; | |
| proxy_set_header X-Real-IP $remote_addr; |
| // import java.io._ | |
| // import java.security._ | |
| // import play.api.libs.iteratee._ | |
| def sha1FileParser(to: File): BodyParser[(String, File)] = BodyParser((header: RequestHeader) ⇒ { | |
| Iteratee.fold[Array[Byte], (MessageDigest, FileOutputStream)](MessageDigest.getInstance("SHA-1"), new FileOutputStream(to)) { case ((md, os), data) ⇒ | |
| md.update(data) | |
| os.write(data) | |
| (md, os) | |
| } mapDone { case (md, os) ⇒ |
| // Rewrite http://tour.golang.org/#63 to scala using Channel | |
| import scala.concurrent._ | |
| import scala.concurrent.ExecutionContext.Implicits.global | |
| object GO63Channel extends App { | |
| def sum(a: List[Int], c: Channel[Int]) = future { | |
| c write a.sum | |
| } | |
| val c = new Channel[Int]() |
| scalaVersion := "2.10.1" | |
| resolvers ++= Seq( | |
| "Typesafe Snapshots" at "http://repo.typesafe.com/typesafe/snapshots/", | |
| "OSS" at "https://oss.sonatype.org/content/repositories/snapshots/") | |
| libraryDependencies ++= Seq( | |
| "org.scalaz" %% "scalaz-core" % "7.0-SNAPSHOT" | |
| ) | |
| /* render a tweet using entities: for example | |
| * val e = Entity(10, 21, """<a href="https://twitter.com/search/?q=%23ScalaIntro">#ScalaIntro</a>""") | |
| * val entities = Seq(e) | |
| * render("I love my #ScalaIntro exercises!", entities) | |
| * should result in | |
| * """I love my <a href="https://twitter.com/search/?q=%23ScalaIntro">#ScalaIntro</a> exercises!""" | |
| * The "start" and "end" fields of an Entity refer to the indices in the | |
| * original string to be substituted with the html field; you may assume | |
| * that these indices are all non-overlapping. | |
| */ |
| sealed abstract class L[A] { | |
| def append(l: L[A]): L[A] | |
| } | |
| case class LNil[A]() extends L[A] { | |
| def append(l: L[A]) = l | |
| override def toString = "Nil" | |
| } | |
| case class LCons[A](head: A, tail: L[A]) extends L[A] { |