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
<?xml version="1.0"?> | |
<!DOCTYPE lolz [ | |
<!ENTITY lol "lol"> | |
<!ENTITY lol2 "&lol;&lol;&lol;&lol;&lol;&lol;&lol;&lol;&lol;&lol;"> | |
<!ENTITY lol3 "&lol2;&lol2;&lol2;&lol2;&lol2;&lol2;&lol2;&lol2;&lol2;&lol2;"> | |
<!ENTITY lol4 "&lol3;&lol3;&lol3;&lol3;&lol3;&lol3;&lol3;&lol3;&lol3;&lol3;"> | |
<!ENTITY lol5 "&lol4;&lol4;&lol4;&lol4;&lol4;&lol4;&lol4;&lol4;&lol4;&lol4;"> | |
<!ENTITY lol6 "&lol5;&lol5;&lol5;&lol5;&lol5;&lol5;&lol5;&lol5;&lol5;&lol5;"> | |
<!ENTITY lol7 "&lol6;&lol6;&lol6;&lol6;&lol6;&lol6;&lol6;&lol6;&lol6;&lol6;"> | |
<!ENTITY lol8 "&lol7;&lol7;&lol7;&lol7;&lol7;&lol7;&lol7;&lol7;&lol7;&lol7;"> |
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
trait DbConnection { | |
def readOnly(): Connection | |
def readWrite(): Connection | |
} | |
class PostgresDbConnection extends DbConnection { | |
def readOnly() = PostgresDbHandler.getReadOnlyConnection() | |
def readWrite() = PostgresDbHandler.getReadWriteConnection() | |
} |
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
package common.modules | |
import com.tzavellas.sse.guice.ScalaModule | |
import common.translation._ | |
class ProdModule extends ScalaModule { | |
def configure() { | |
bind[Translator].to[FrenchTranslatorImpl] | |
} | |
} |
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
object Global extends GlobalSettings { | |
private lazy val injector = { | |
Play.isProd match { | |
case true => Guice.createInjector(new ProdModule) | |
case false => Guice.createInjector(new DevModule) | |
} | |
} | |
override def getControllerInstance[A](clazz: Class[A]) = { | |
injector.getInstance(clazz) |
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
package controllers | |
import play.api._ | |
import play.api.mvc._ | |
import common.translation.Translator | |
import com.google.inject._ | |
@Singleton | |
class Translate @Inject()(translator: Translator) extends Controller { | |
def greet(name: String) = Action { |
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
class TranslateSpec extends Specification { | |
"Translate" should { | |
// The normal Play! way | |
"accept a name, and return a proper greeting" in { | |
running(FakeApplication()) { | |
val translated = route(FakeRequest(GET, "/greet/Barney")).get | |
status(translated) must equalTo(OK) | |
contentType(translated) must beSome.which(_ == "text/html") |
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
def timer(f: => Any): Long = { | |
val startTime = System.nanoTime | |
val ret = f | |
val endTime = System.nanoTime | |
endTime - startTime | |
} | |
def iterTest(f: => Any): Double = { | |
(for(i <- 0 to 10000) yield timer(f)).sorted.apply(5000) |
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
trait Translator { | |
def translate(input: String): String | |
} | |
class FakeTranslator extends Translator { | |
def translate(input: String): String = input | |
} | |
class FrenchTranslatorImpl extends Translator { | |
val wordReplacements = Map( |
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
trait Translator { | |
def translate(input: String): String | |
} | |
class FrenchTranslatorImpl extends Translator { | |
val wordReplacements = Map( | |
"hello" -> "bonjour", | |
"hi" -> "salut", | |
"greetings" -> "salutations" | |
) |
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
$ curl -i http://www.42go.com/ | grep Server | |
% Total % Received % Xferd Average Speed Time Time Time Current | |
Dload Upload Total Spent Left Speed | |
100 4425 100 4425 0 0 79467 0 --:--:-- --:--:-- --:--:-- 149k | |
Server: Don't Panic! |
OlderNewer