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
import language.dynamics | |
import language.experimental.macros | |
import reflect.macros.Context | |
class Fields[A] extends Dynamic { | |
import Fields._ | |
def selectDynamic(nameE: String): String = macro impl[A] | |
} | |
object Fields { |
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 models | |
import com.typesafe.config.ConfigFactory | |
import reactivemongo.api.{DefaultDB, DB, MongoDriver} | |
import akka.event.slf4j.Logger | |
import reactivemongo.api.collections.default.BSONCollection | |
import scala.util.Try | |
object MongoDb { | |
private val logger = Logger("MongoDB") |
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
trait Unbox { | |
type Box[A] | |
def apply[A](boxed: Box[A]): A = ??? | |
} | |
object Id extends Unbox { type Box[A] = A } | |
case class C[A](a:A) | |
object CU extends Unbox { type Box[A] = C[A] } |
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
import reflect.macros.Context | |
import language.experimental.macros | |
def producerImpl[A: c.WeakTypeTag](c: Context): c.Expr[Any] = { | |
c.universe.reify{ | |
() => (??? : A) | |
} | |
} | |
def producer[A] = macro producerImpl[A] |
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
import concurrent.Await | |
import concurrent.duration._ | |
import akka.util.Timeout | |
import akka.pattern.ask | |
import concurrent.Future | |
import concurrent.ExecutionContext.Implicits.global | |
def time(n:Int)(block: => Unit) = { | |
var i = 0 | |
val start = System.currentTimeMillis() |
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
val compile = { | |
import tools.reflect.ToolBox | |
val c = reflect.runtime.currentMirror | |
val tb = c.mkToolBox() | |
(src: String) => tb compile (tb parse (imports+src)) | |
} |
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
scalaVersion := "2.10.2" | |
resolvers += "edofic snapshots" at "http://repo.edofic.com/snapshots" | |
libraryDependencies += "org.reactivemongo" %% "reactivemongo-bson-macros" % "0.10-SNAPSHOT" |
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
import language.dynamics | |
class Path(path: String) extends Dynamic { | |
def selectDynamic(m: String) = new Path(s"$path$m/") | |
def applyDynamic(m: String)(args: Any*) = s"$m: $path with args $args" | |
override def toString = s"Path($path)" | |
} | |
val root = new Path("/") |
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
def unfold[A](starting: A)(f: A PartialFunction A): Iterator[A] = { | |
var state = starting | |
val tail = new Iterator[A]{ | |
def hasNext = f.isDefinedAt(state) | |
def next() = { | |
state = f(state) | |
state | |
} | |
} |
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
#!/bin/bash | |
if [ -f $1 ] ; then | |
case $1 in | |
*.tar.bz2) tar xvjf $1 ;; | |
*.tar.gz) tar xvzf $1 ;; | |
*.bz2) bunzip2 $1 ;; | |
*.rar) rar x $1 ;; | |
*.gz) gunzip $1 ;; | |
*.tar) tar xvf $1 ;; | |
*.tbz2) tar xvjf $1 ;; |