Skip to content

Instantly share code, notes, and snippets.

@simerplaha
simerplaha / C3js.scala
Last active May 16, 2018 13:40
A simple Scala-js C3.js Charts facade ... Something I wrote quickly to integrate C3.js charts. Hopefully it will be good enough for anyone to get started with C3.js charts in Scala.js. I will try to make the parameters more type safe objects soon and implement the APIs properly.
import scala.scalajs.js
import scala.scalajs.js.JSConverters._
import scala.scalajs.js.annotation.JSName
trait C3ChartObject extends js.Object {
def load(data: C3JSChartDataset): js.Dynamic = js.native
def unload() = js.native
}
@cvogt
cvogt / gist:9193220
Last active February 13, 2022 13:50 — forked from ruescasd/gist:7911033
Slick: Dynamic query conditions using the **MaybeFilter** (Updated to support nullable columns)
import scala.slick.lifted.CanBeQueryCondition
// optionally filter on a column with a supplied predicate
case class MaybeFilter[X, Y](val query: scala.slick.lifted.Query[X, Y]) {
def filter[T,R:CanBeQueryCondition](data: Option[T])(f: T => X => R) = {
data.map(v => MaybeFilter(query.filter(f(v)))).getOrElse(this)
}
}
// example use case
import java.sql.Date