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
import org.parboiled2._ | |
case class Person(name: String, age: Seq[Int]) | |
//parses "dustin 35 36" | |
class PersonNumEvaluator(val input: ParserInput) extends Parser { | |
def InputLine = rule{ Both ~ EOI } | |
def Both = rule { Name ~ Number ~> Person } | |
def Name = rule { capture(oneOrMore(CharPredicate.Alpha)) } | |
def WS = rule { oneOrMore(" ") } | |
def Number = rule { zeroOrMore(WS ~ capture(oneOrMore(CharPredicate.Digit)) ~> (_.toInt)) } | |
} |
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
import sangria.schema._ | |
import sangria.execution.Executor | |
import sangria.introspection.introspectionQuery | |
import sangria.integration.PlayJsonSupport._ | |
import sangria.parser.{SyntaxError, QueryParser} | |
import sangria.renderer.SchemaRenderer | |
import scala.util.{Success,Failure} | |
trait NamedEntity{ val name: String } |
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
import sangria.schema._ | |
import sangria.execution.Executor | |
import sangria.introspection.introspectionQuery | |
import sangria.integration.PlayJsonSupport._ | |
import sangria.parser.{SyntaxError, QueryParser} | |
import sangria.renderer.SchemaRenderer | |
import scala.util.{Success,Failure} | |
trait NamedEntity{ val name: String } |
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
//this works | |
val route = | |
path("hello"){ | |
get{ | |
respondWithHeader(ETag("asdf")){ | |
complete{ | |
"{}" | |
} | |
} |
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
//this works | |
val route = | |
path("hello"){ | |
get{ | |
respondWithHeader(ETag("asdf")){ | |
complete{ | |
"{}" | |
} | |
} |
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.api._ | |
import play.api.mvc._ | |
import scala.concurrent._ | |
import scala.concurrent.Future._ | |
//import play.api.libs.concurrent.Execution.Implicits._ |
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
var http = require('http'); | |
var Q = require('q'); | |
var IntensiveFunctions = (function(){ | |
var self = {}; | |
self.randomWalk = function(i){ | |
return Q.fcall(function(){ | |
var total = 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
val server = Http(DefaultContext.port).context("/public") { | |
ctx: ContextBuilder => | |
ctx.resources(new java.net.URL("file:///path/to/my/files)) | |
} |
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
atomic{ implicit t => | |
var accounts = accountsRef() | |
var (from, to) = (accounts(fromNo), accounts(toNo)) | |
if(from.balance > amount){ | |
to = to.credit(amount)) | |
accounts = accounts + (to.accountNo -> to) | |
accounts = accounts + (from.accountNo -> from.debit(amount)) | |
val time = System.currentTimeMillis | |
if(time % 1234 == 0) accounts = accounts + (to.accountNo -> to.credit(1) | |
accountsRef() = accounts |
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 time = System.currentTimeMillis | |
atomic{ implicit t => | |
var accounts = accountsRef() | |
var (from, to) = (accounts(fromNo), accounts(toNo)) | |
if(from.balance > amount){ | |
to = to.credit(amount)) | |
accounts = accounts + (to.accountNo -> to) | |
accounts = accounts + (from.accountNo -> from.debit(amount)) | |
if(time % 1234 == 0) accounts = accounts + (to.accountNo -> to.credit(1) |