Skip to content

Instantly share code, notes, and snippets.

View jancajthaml's full-sized avatar
🦈

Jan Cajthaml jancajthaml

🦈
View GitHub Profile
@skoky
skoky / gist:5044da1c34a28fde6b4a6b2d032bbc7e
Last active September 12, 2016 09:23
Split string by 2 characters in Scala - simple, functional, great :)
def spl(s:String) : List[String] = {
if (s.length>0) {
val x = s.splitAt(2)
x._1 :: spl(x._2)
} else Nil
}
val x = spl("010203")
>>>> x: List[String] = List(01, 02, 03)
@alari
alari / PersistentJson.scala
Created May 7, 2015 06:20
A simple trait to work with bson/json events in akka's persistence
import play.api.libs.json._
import play.modules.reactivemongo.json.ImplicitBSONHandlers._
import reactivemongo.bson.BSONDocument
trait PersistentJson extends akka.persistence.PersistentActor {
private[this] var classMap: Map[Manifest[_], Writes[_]] = Map.empty
private[this] var namesMap: Map[String, Reads[_]] = Map.empty
case class ClassFormat[T](cls: Class[T], format: Format[T])