Skip to content

Instantly share code, notes, and snippets.

View sadache's full-sized avatar

Sadek Drobi sadache

View GitHub Profile
package controllers
import scala.concurrent._
import ExecutionContext.Implicits.global
import play.api.libs.iteratee._
import play.api._
import play.api.mvc._
import play.api.libs._
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()
})
@sadache
sadache / gist:8804038
Last active August 29, 2015 13:56
A naive, potentially buggy and largely improvable implementation of Enumerator[Array[Byte]] to InputStream
import java.io.InputStream
import play.api.libs.iteratee.{ Enumerator, Iteratee }
import scala.concurrent.Promise
import scala.concurrent.ExecutionContext.Implicits.global
import scala.util.{ Success, Failure }
import java.util.concurrent.ArrayBlockingQueue
import java.util.concurrent.atomic.AtomicInteger
def toInputStream(chunks: Enumerator[Array[Byte]], bufferSize: Int): InputStream = new InputStream {
@sadache
sadache / gist:d357ced8f6c942bca81a
Last active August 29, 2015 14:02
Faster with much less memory consumption JSON object reader
def objectReader[T1,T2,T3,T4,R](t1: String, t2: String, t3: String, t4: String)(f: (T1,T2,T3,T4) => R)(implicit readsT1:Reads[T1], readsT2:Reads[T2], readsT3:Reads[T3], readsT4:Reads[T4]): Reads[R] = {
def orElse[A](a:A, default: =>A) = if(a!=null) a else default
Reads[R]{
case JsObject(fields) =>
var t1V:JsResult[T1] = null.asInstanceOf[JsResult[T1]]
var t2V:JsResult[T2] = null.asInstanceOf[JsResult[T2]]
{
"Header" : {
"title" : {
"type" : "StructuredText",
"config" : {
"single" : "heading1"
}
},
"subtitle" : {
"type" : "StructuredText",

At last an article that analyses the situation beyond the hype, this is how we can grow better solutions for the future, by constructive critic.

Headless CMS can’t be the goal on its own. There are plenty of problems to be solved in content management to increase flexibility and agility. Being API-based is, however, a solid corner stone, a foundation for the future that allows unlimited extensibility.

Pretty much like when the IPhone was announced, critics have targeted its simplicity and lack of features (premature virtual keyboard and lack of a physical one, its battery consumption, its fragility). Look at the market now, completely transformed and big actors like Nokia are now unheard of!

We’re going into the same transformation in the CMS world. Back when we announced our product, we’ve said that there are plenty of challenges to be addressed, I am glad this article mentioned quite a few!

None of these shortcomings are actually inherent to the API-based foundation. They just didn’t get enough attentio