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 api = Api.get("https://lesbonneschoses.prismic.io/api") | |
// Find all macarons | |
var products = api.then(function(api) { | |
return api.forms['products'] | |
.query('[[:d = at(document.tags, "Macaron")]]') | |
.ref(api.master) | |
.submit() | |
}) |
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
"copy file" in { | |
val fileGenerator = Enumerator.repeat(new java.util.Date.getTime.toString + "\n").through(Enumeratee.take(1000)) | |
//val fileGenerator = Enumerator.repeat(new java.util.Date.getTime.toString + "\n") &>> Enumeratee.take(1000) | |
val f = FileChannel("/tmp/testwrite.txt").delete.writing.create | |
val f2 = FileChannel("/tmp/testwrite2.txt").delete.writing.create | |
fileGenerator // generates data | |
.through(RichEnumeratee.binarize()) // binarizes data to write into File |
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 play.api.libs.ws._ | |
import play.api.libs.iteratee._ | |
import play.api.libs.concurrent._ | |
object Application extends Controller { | |
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
/** | |
* Handles the comet event stream. | |
*/ | |
def cometStream = Action { | |
AsyncResult { | |
implicit val timeout = Timeout(5.seconds) | |
val actor=Akka.system.actorOf(Props[EventListener]) | |
// Actor is listening for event on the eventStream | |
Akka.system.eventStream.subscribe(actor,classOf[ChangeEvent]) | |
// For each event, stream the data to client |
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
// What is a Promise sequence function ? | |
// A function which transform a List[Promise[A]] into a Promise[List[A]] | |
// First naive implementation. It's a synchronous implementation (blocking). | |
def sequencePromises[A](list: List[Promise[A]]): Promise[List[A]] = | |
list.foldLeft(Promise.pure(Promise[List[A]]()))((s,p) => s.flatMap( s => p.map(a => s :+ a))) | |
//should be in the lines of this, didn't try to typecheck it though. |
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
@(contacts:List[(Long,String,String)]) | |
<html> | |
<head> | |
<title>ZenContact - Play! 2 Sample application</title> | |
<link rel="shortcut icon" type="image/png" href="http://www.playframework.org/public/images/favicon.png"> | |
<link rel="stylesheet" type="text/css" media="screen" href="@routes.Assets.at("stylesheets/main.css")"> | |
<link rel="stylesheet" type="text/css" href="http://fonts.googleapis.com/css?family=Varela+Round|Droid+Sans"> | |
</head> | |
<body> |
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
type 'a SimpleType= F of (int ->'a-> 'a) | |
let get a = F(fun req -> id) | |
[<GeneralizableValue>] | |
let oops2<'T> : SimpleType<'T> = get "" |
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
Sandwiches: | |
* Jay's Cheesesteaks (many seitan flavors) | |
* Ike's Place (tons of amazing veggie sandwiches) | |
* Toaster Oven (Potbelly's clone) | |
Mexican: | |
* Papalote (their house salsa is the best IN THE WORLD) | |
* El Buen Sabor (my favorite super veggie burrito) | |
* Taqueria Cancún (classic mission burrito; open till 2am on fri/sat, 1am other days, I think) |