Skip to content

Instantly share code, notes, and snippets.

View ochrons's full-sized avatar

Otto Chrons ochrons

View GitHub Profile
class ZipModelR[M, S, SS](root: ModelR[M, M], get1: M => S, get2: M => SS)(implicit cts: ClassTag[S], ctss: ClassTag[SS]) extends ModelR[M, (S, SS)] {
private var zipped = Tuple2[S, SS](null.asInstanceOf[S], null.asInstanceOf[SS])
// ZipModel uses optimized `get` functions to compare if the contents of the tuple has changed or not
// Different comparison functions are used for boxed values and real references
private def getXX(compS: (S, S) => Boolean, compSS: (SS, SS) => Boolean)(model: M) = {
// check if inner references have changed
val v1 = get1(root.value)
val v2 = get2(root.value)
if (compS(zipped._1, v1) || compSS(zipped._2, v2)) {
@ochrons
ochrons / browserChrome.txt
Created October 29, 2015 20:44
Scala/ScalaJS serialization lib performance comparison
1/18 : Encode single Seq[Int]
=============================
Library ops/s % size % size.gz %
BooPickle 146324 8.4% 2 100% 32 100%
Prickle 231064 13.2% 27 1350% 58 181%
uPickle 245188 14.1% 3 150% 35 109%
Circe 962996 55.2% 3 150% 35 109%
Pushka 1744486 100.0% 3 150% 35 109%
2/18 : Decode single Seq[Int]
@ochrons
ochrons / gist:10681050
Last active March 26, 2018 15:21
Super thin Scala wrapper for common DataStax Cassandra Java driver functionality.
object CassandraWrapper {
import scala.language.implicitConversions
import scala.language.postfixOps
/**
* Converts a `ResultSetFuture` into a Scala `Future[ResultSet]`
* @param f ResultSetFuture to convert
* @return Converted Future
*/
implicit def resultSetFutureToScala(f: ResultSetFuture): Future[ResultSet] = {
val p = Promise[ResultSet]()