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
object Orientations { | |
type Orientation = Char | |
val N = 'N' | |
val E = 'E' | |
val W = 'W' | |
val S = 'S' | |
val clockWise = List(N,E,S,W) | |
def next[A](elements:List[A],e:A):Option[A]= elements.drop(elements.indexOf(e)+1).firstOption |
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._ | |
import play.mvc._ | |
object Scalate { | |
import java.io._ | |
import org.fusesource.scalate._ |
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
@(user:models.User, accounts:java.util.List[models.Account]) | |
<h1>User @user.name has @accounts.size @("account".pluralize(accounts))</h1> | |
@for(account <- accounts) { | |
<h2>Account @accounts.number</h2> | |
@if(account.messages.isEmpty) { | |
<p>No messages for this account.</p> |
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 ScalaTemplates = (sourceDirectory:File, generatedDir:File, templateTypes:Function1[String,(String,String)], additionalImports:String) => { | |
import play.templates._ | |
(generatedDir ** "*.template.scala").get.map(GeneratedSource(_)).foreach(_.sync()) | |
try { | |
(sourceDirectory ** "*.scala.html").get.foreach { template => | |
ScalaTemplateCompiler.compile(template, sourceDirectory, generatedDir, templateTypes("html")._1, templateTypes("html")._2, additionalImports) | |
} | |
} catch { | |
case TemplateCompilationError(source, message, line, column) => { |
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 models; | |
import java.util.*; | |
import javax.persistence.*; | |
import play.db.ebean.*; | |
import play.data.format.*; | |
import play.data.validation.*; | |
@Entity |
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
public static class ManagedDatasource { | |
final BoneCPDataSource ds; | |
final String url; | |
public ManagedDatasource(BoneCPDataSource ds, String url) { | |
this.ds = ds; | |
this.url = url; | |
} |
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
{ scopeName = 'text.html.scala'; | |
fileTypes = ( 'scala.html' ); | |
foldingStartMarker = '(?x) | |
(<(?i:head|body|table|thead|tbody|tfoot|tr|div|select|fieldset|style|script|ul|ol|form|dl)\b.*?> | |
|<!--(?!.*-->) | |
|\{\s*($|\?>\s*$|//|/\*(.*\*/\s*$|(?!.*?\*/))) | |
)'; | |
foldingStopMarker = '(?x) | |
(</(?i:head|body|table|thead|tbody|tfoot|tr|div|select|fieldset|style|script|ul|ol|form|dl)> | |
|^\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
val main = PlayProject(appName, appVersion, appDependencies, mainLang = SCALA).settings( | |
compile in Compile <<= (compile in Compile, sourceDirectory in Compile, classDirectory in Compile, dependencyClasspath in Compile) map { (analysis, src, classes, classpath) => | |
val allKotlinSources: Seq[java.io.File] = (src ** ".kotlin").get | |
// call the kotlin compiler using `classpath` and output classes to `classes` | |
analysis | |
} |
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 Secured[A](username: String, password: String)(action: Action[A]) = Action(action.parser) { request => | |
request.headers.get("Authorization").flatMap { authorization => | |
authorization.split(" ").drop(1).headOption.filter { encoded => | |
new String(org.apache.commons.codec.binary.Base64.decodeBase64(encoded.getBytes)).split(":").toList match { | |
case u :: p :: Nil if u == username && password == p => true | |
case _ => false | |
} | |
}.map(_ => action(request)) | |
}.getOrElse { | |
Unauthorized.withHeaders("WWW-Authenticate" -> """Basic realm="Secured"""") |
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.*; | |
import play.mvc.*; | |
import play.libs.F.*; | |
import views.html.*; | |
public class Application extends Controller { | |