This file contains 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
autoCompilerPlugins := true, | |
libraryDependencies <+= scalaVersion { | |
v => compilerPlugin( | |
"org.scala-lang.plugins" % | |
"continuations" % | |
"2.10.0-RC5") | |
// Use the final Scala version once it's released | |
}, | |
scalacOptions += "-P:continuations:enable", |
This file contains 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
public Future<List<String>> crawl(final String url, final int maxDepth, final int currentDepth) { | |
if (maxDepth == currentDepth) { | |
// no need to call | |
return Future.succesful(Collections.emptyList()); | |
} else { | |
// 1. get crawl the URL and get its URLs | |
Future<List<String>> foundUrlsFuture = future(new Callable<List<String>>() { | |
public List<String> call() throws Exception { |
This file contains 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._ | |
import com.typesafe.config.ConfigFactory | |
import akka.actor.ActorSystem | |
object Global extends GlobalSettings { | |
override def onStart(app: Application) { | |
val config = ConfigFactory.parseString(""" | |
akka { | |
actor { |
This file contains 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 org.specs2.mutable.Specification | |
import org.specs2.runner.JUnitRunner | |
import org.junit.runner.RunWith | |
@RunWith(classOf[JUnitRunner]) | |
class MySpec extends Specification { | |
"The number 1" should { | |
"equal the number 2" in { | |
1 must_== 2 | |
} |
This file contains 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 system = ActorSystem("jse-system") | |
implicit val timeout = Timeout(5.seconds) | |
val engine = system.actorOf(Rhino.props(), "engine") | |
def tempResourceFile(resourceName: String): File = { | |
import org.apache.commons.io._ | |
val url = this.getClass.getResource(resourceName); | |
val file = File.createTempFile( | |
FilenameUtils.getBaseName(resourceName), |
This file contains 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 PlayBaseDirProp = Tags.Tag("PlayBaseDirProp") | |
concurrentRestrictions in Global += Tags.limit(PlayBaseDirProp, 1) | |
def withSystemProperty[T](name: String, value: String)(f: => T) = { | |
println(s"*** Setting property $name = $value") | |
System.setProperty(name, value) | |
try { | |
f | |
} finally { | |
println(s"*** Clearing property $name") |
This file contains 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
macro invert { | |
rule { { $x:ident <- $y:expr } } => { | |
$y(function($x) { return $x }) | |
} | |
rule { { $x:ident <- $y:expr $rest ... } } => { | |
$y(function($x) { | |
return invert { $rest ... } | |
}) | |
} | |
rule { { $y:expr } } => { $y } |
This file contains 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._ | |
import play.api.mvc._ | |
object Global extends GlobalSettings { | |
case class RewrittenRequestHeader(val path: String, delegate: RequestHeader) extends RequestHeader { | |
def id = delegate.id | |
def tags = delegate.tags | |
def uri = delegate.uri | |
def method = delegate.method |
This file contains 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._ | |
import play.api.mvc._ | |
import scala.concurrent.Future | |
object RewrittenRequestHeader { | |
def rewrite(header: RequestHeader): RequestHeader = { | |
if (header.path.startsWith("//")) { | |
val newPath = header.path.substring(1) | |
RewrittenRequestHeader(newPath, header) | |
} else { |
This file contains 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._ | |
import play.api.mvc._ | |
object Global extends GlobalSettings { | |
case class RewrittenRequestHeader(val path: String, delegate: RequestHeader) extends RequestHeader { | |
def id = delegate.id | |
def tags = delegate.tags | |
def uri = delegate.uri | |
def method = delegate.method |
OlderNewer