This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package foo | |
import java.util.concurrent.TimeUnit | |
import akka.actor.{ActorSystem, Props} | |
import akka.pattern.ask | |
import akka.persistence.{PersistentActor, RecoveryCompleted} | |
import akka.util.Timeout | |
import com.typesafe.config.ConfigFactory | |
import org.scalatest.{FunSuite, Matchers} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package foo | |
import java.util.concurrent.TimeUnit | |
import akka.actor.{ActorSystem, Props} | |
import akka.pattern.ask | |
import akka.persistence.{PersistentActor, RecoveryCompleted} | |
import akka.util.Timeout | |
import com.typesafe.config.ConfigFactory | |
import org.scalatest.{FunSuite, Matchers} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package foo | |
import java.lang.ref.WeakReference | |
class Listeners[T] { | |
private var buffer = List[WeakReference[T => Unit]]() | |
def fire(e: T): Unit = { | |
buffer.map(_.get()).filter(_ ne null).foreach(_.apply(e)) | |
buffer = buffer.filter(_.get() ne null) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
classOf[String].getDeclaredMethods.map(_.getName).toSet[String].map(x => (x, math.abs(x.hashCode) % 256)).groupBy(_._2).toList.sortBy(_._1).map(x => s"${x._1}(${x._2.size}}): ${x._2.map(_._1).mkString(", ")}").foreach(println) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package foo | |
class Entity extends DelayedInit { | |
def delayedInit(x: => Unit) {x} | |
class Field | |
protected def EntityField[T <: Entity: Manifest] = new Field |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.mahpella.snake.core | |
import collection.mutable | |
import scala.collection.mutable.{ListBuffer, ArrayBuffer} | |
import scala.util.control.Exception._ | |
class Field(map: GameMap) extends Object with ClockDriven { | |
val width = map.width | |
val height = map.height |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// any to json | |
Extraction.decompose(a: Any)(implicit formats: Formats): JValue | |
// json to case class | |
Extraction.extractOpt[A](json: JValue)(implicit formats: Formats, mf: Manifest[A]): Option[A] | |
// json to string | |
Printer.compact(d: Document): String | |
Printer.pretty(d: Document): String | |
JsonAST.render(value: JValue): Document |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
implicit def toEqualable[T](obj: T) = new { | |
def === (other: T): Boolean = { | |
obj == other | |
} | |
} |