Skip to content

Instantly share code, notes, and snippets.

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] = {
// 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 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[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)
@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))
)))))
@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:

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","