Skip to content

Instantly share code, notes, and snippets.

@gtopper
gtopper / LeanHttpRequest.scala
Last active August 29, 2015 14:23
Attempt at serializing HttpRequest to JSON, leaving out the URI.
package com.supersonicads.utils.spray
import com.supersonicads.utils.OptionUtil._
import play.api.libs.json.Json
import spray.http.HttpHeaders.RawHeader
import spray.http.{HttpMethods, HttpProtocols, HttpRequest}
case class LeanHttpRequest(entity: String,
headers: List[RawHeader],
protocol: String,
import com.typesafe.config.ConfigFactory
import org.joda.time.DateTime
import com.datastax.spark.connector._
implicit val config = ConfigFactory.load()
//val rdd = RawEventsReader2.getDataFromRange(sc)(new DateTime(2015, 5, 15, 4, 0), new DateTime(2015, 5, 15, 4, 0))
val keySpace = "offlinedb"
val tableName = "raw_events_2015_20"
val keys = "201505150400001976"
consulData <- Try(ConsulData(base64Value, modifyIndex)) match {
case Success(cd) => JsSuccess(cd)
case Failure(throwable) => JsError(throwable.toString)
}
@gtopper
gtopper / ReversePolishNotation.scala
Last active August 29, 2015 14:01
Functional solution for ReversePolishNotation
object ReversePolishNotation {
type Operand = Double
type BinaryOp = (Operand, Operand) => Operand
val parseOp: String => Double = _.toDouble
val opMap: Map[String, BinaryOp] = Map(
"+" -> (_ + _),
"-" -> (_ - _),
"*" -> (_ * _),