Skip to content

Instantly share code, notes, and snippets.

I [INFO:CONSOLE(58687)] "phone confirmation successful:{"confirmed":true,"inv
itee_code":"BETA","countdown":5}", source: file:///android_asset/www/assets
/vendor/hozana/main.js (58687)
I [INFO:CONSOLE(56340)] "Registering GCM Id", source: file:///android_asset/w
ww/assets/vendor/hozana/main.js (56340)
I [INFO:CONSOLE(56440)] "POST /api.php?action=update_gcm_id << {"gcm_id":"ABC
DE","phone":"+33621034332"}", source: file:///android_asset/www/assets/vend
or/hozana/main.js (56440)
I [INFO:CONSOLE(56442)] "POST /api.php?action=update_gcm_id >> {"statusCode":
400,"headers":{"pragma":"no-cache","date":"Sat, 15 Oct 2016 14:26:36 GMT","
@behaghel
behaghel / keybase.md
Last active August 18, 2016 13:29
behaghel's keybase verified GitHub identity

Keybase proof

I hereby claim:

  • I am behaghel on github.
  • I am behaghel (https://keybase.io/behaghel) on keybase.
  • I have a public key ASCTzj_Om18Li3srz51njBsOiTnc0d_EhTBgxejoTClbLAo

To claim this, I am signing this object:

@behaghel
behaghel / .dir-locals.el
Last active February 20, 2017 12:46
This is to use the specific version of eslint for the current project.
((js2-mode . ((eval . (let ((project-root (locate-dominating-file default-directory ".dir-locals.el"))
(rel-path (mapconcat 'file-name-as-directory '("node-modules" ".bin" ) "")))
(setq flycheck-javascript-eslint-executable (expand-file-name "eslint" (concat project-root rel-path)))
(setq flycheck-disabled-checkers '(javascript-jshint))
)))))
type WithOID = { def id: ObjectId }
// trait WithOID { def id: ObjectId }
sealed trait QueryParams[WithOID]
case class All[WithOID]() extends QueryParams[WithOID]
case class Paginated[WithOID](pageSize: Int, pageOffset: Int,
from: Option[{def id: ObjectId}] = None) extends QueryParams[WithOID] {
def enrich(criteria: MongoDBObject): MongoDBObject =
from.map { x: {def id: ObjectId } =>
criteria ++ {
if (pageOffset >= 0)
// type WithOID = { def id: ObjectId }
trait WithOID { def id: ObjectId }
sealed trait QueryParams[WithOID]
case class All[WithOID]() extends QueryParams[WithOID]
case class Paginated[WithOID](pageSize: Int, pageOffset: Int,
from: Option[WithOID] = None) extends QueryParams[WithOID] {
def enrich(criteria: MongoDBObject) =
from map { a =>
criteria ++ {
if (pageOffset >= 0)
// type WithOID = { def id: ObjectId }
trait WithOID { def id: ObjectId }
sealed trait QueryParams[WithOID]
case class All[WithOID]() extends QueryParams[WithOID]
case class Paginated[Song](pageSize: Int, pageOffset: Int,
from: Option[Song] = None) extends QueryParams[WithOID] {
def enrich(criteria: MongoDBObject) =
from map { a =>
criteria ++ {
if (pageOffset >= 0)
type Divisor = Int
type Replacement = String
// generalization of the FizzBuzz solution.
// standard FizzBuzz works like that
// metaFizzBuzz(1 to 100, Seq((3, "Fizz"), (5, "Buzz"))).take(20).foreach(println)
def metaFizzBuzz(xs: Seq[Int], translations: Seq[(Divisor, Replacement)]): Seq[String] = {
/**
* How to convert a distributed fleet from what type of hardware to
* another without degrading (too much) your service.
*
*/
import collection.{mutable, immutable}
case class Machine(name: String, ECU: Double, mem: Int, disk: Int, TCO: Float)
object Machine {
val m1Large = Machine("m1.large", ECU = 1, mem = 7, disk = 700, TCO = 600)
/**
* How to convert a distributed fleet from what type of hardware to
* another without degrading (too much) your service.
*
*/
case class Machine(name: String, ECU: Double, mem: Int, disk: Int, TCO: Float)
object Machine {
val m1Xlarge = Machine("m1.xlarge", ECU = 1, mem = 7, disk = 700, TCO = 600)
val m2Xlarge = Machine("m2.xlarge", ECU = 2.6, mem = 14, disk = 1400, TCO = 400)
/**
* The water pouring problem is a classic one:
* 1. you have a limited set of containers, each of which has its specific
* capacity
* 2. you want to pour a precise volume of water in a jar, volume
* which is not obtained straight from one of the containers at
* hand
* 3. you then want to find the minimal set of operations to achieve
* your goal if at all possible.
*/