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
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
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
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
@(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
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
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
// prime number generator | |
for (i <- 2 to 1000) | |
if((2 to i).find( j=> (i % j == 0 && i != j) ) == None) | |
println(i) | |
// function currying example | |
def matcher(haystack: List[Char])(needle: String) = { | |
haystack contains needle.charAt(0) | |
} |
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 scrapbook; | |
import java.lang.reflect.InvocationTargetException; | |
public class Test { | |
public static void main(String[] args) { | |
// Standard function | |
Function<String,String> toUpperCase = new Function<String,String>() {{ b = a.toUpperCase(); }}; |
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
~/Desktop/scrapbook/coco $ play dependencies | |
~ _ _ | |
~ _ __ | | __ _ _ _| | | |
~ | '_ \| |/ _' | || |_| | |
~ | __/|_|\____|\__ (_) | |
~ |_| |__/ | |
~ | |
~ play! 1.1-localbuild, http://www.playframework.org | |
~ framework ID is gbo | |
~ |