Skip to content

Instantly share code, notes, and snippets.

View sadache's full-sized avatar

Sadek Drobi sadache

View GitHub Profile
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)
type 'a SimpleType= F of (int ->'a-> 'a)
let get a = F(fun req -> id)
[<GeneralizableValue>]
let oops2<'T> : SimpleType<'T> = get ""
@sadache
sadache / demo.scala
Created October 18, 2011 14:23 — forked from nicmarti/demo.scala
Yes I am proud to be able to write this kind of Code
@(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>
@sadache
sadache / code.scala
Created December 12, 2011 09:27 — forked from gre/code.scala
Play20 Promise sequence function
// 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.
@sadache
sadache / ServerEventsComparison.scala
Created April 29, 2012 17:22 — forked from fcroiseaux/ServerEventsComparison.scala
Comparison of Comet, SSE and WebSocket server to client communication with Playframework 2.0 in Scala
/**
* 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
@sadache
sadache / funky.scala
Created May 16, 2012 19:47 — forked from jto/funky.scala
Funky enumerator usage
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 {
@sadache
sadache / gist:3382059
Created August 17, 2012 19:58 — forked from mandubian/gist:3377514
Play2 new plugin: File NonBlocking/Async API - Copying a file
"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
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()
})