This file contains hidden or 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 scala.annotation.{StaticAnnotation, compileTimeOnly} | |
import scala.language.experimental.macros | |
import scala.reflect.macros.whitebox.Context | |
@compileTimeOnly("use macro paradise") | |
class Extends[T](defaults: Any*) extends StaticAnnotation { | |
def macroTransform(annottees: Any*): Any = macro Extends.impl | |
} | |
object Extends { |
This file contains hidden or 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 java.util.NoSuchElementException | |
import io.circe._ | |
import spray.httpx.marshalling.Marshaller | |
import spray.httpx.unmarshalling.Unmarshaller | |
import spray.http._ | |
// scalastyle:off | |
// providing return types causes a stack overflow, and the throw is necessary in this case |
This file contains hidden or 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
/* | |
This is a port of Tony Morris' Haskell beginner list exercises from (http://blog.tmorris.net/posts/haskell-beginner-exercises-with-tests/index.html). | |
To run, compile with `scalac Main.scala` and then run `scala Main`. | |
*/ | |
import scala.{List => _, :: => _, Nil => _} | |
sealed trait List[+T] { | |
def head: T |
This file contains hidden or 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 org.apache.log4j.{Level, Logger} | |
import org.specs2.mutable._ | |
import Predef.{conforms => _, _} | |
class ExampleTest extends Specification { | |
Logger.getRootLogger.setLevel(Level.ERROR) | |
sequential | |
"the transformStream method" should { |
This file contains hidden or 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 org.apache.spark.streaming.dstream._ | |
import org.specs2.mutable._ | |
import org.apache.spark.streaming._ | |
import scala.collection.mutable | |
class spark[T](val seq: Seq[String])(implicit val fun: DStream[String] => DStream[T]) extends After { | |
lazy val ssc = new StreamingContext("local", "test", Seconds(1)) | |
val rdd = ssc.sparkContext.makeRDD(seq) | |
val stream = new ConstantInputDStream(ssc, rdd) |
This file contains hidden or 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 org.apache.spark.streaming.dstream.DStream | |
import org.apache.spark.streaming.dstream.DStream._ | |
import org.joda.time.DateTime | |
import org.json4s.jackson.JsonMethods._ | |
import scala.util.Try | |
case class Purchase(item_id: String, amount: BigDecimal, time: Long) | |
case class Key(item_id: String, time: DateTime) | |
case class Summary(item_id: String, time: DateTime, total: BigDecimal) |