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.avro.io.DatumReader | |
import org.apache.avro.io.DecoderFactory | |
import org.apache.avro.specific.SpecificDatumReader | |
import org.apache.flink.api.common.typeinfo.TypeInformation | |
import org.apache.flink.api.java.typeutils.TypeExtractor | |
class AvroDeserializationSchema[T <: SpecificRecordBase: ClassTag](private val baselineMessage: () ⇒ T) extends DeserializationSchema[T] { | |
override def deserialize(message: Array[Byte]): 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
object Test { | |
type Cause = String | |
type FutureXor[A] = XorT[Future, Cause, A] | |
case class ProcessContext[+A](context: List[String], data: A) //context never need to change | |
trait Processor[-A, B] extends Serializable { | |
def process: ProcessContext[A] ⇒ FutureXor[B] |
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
trait AnimalMouth | |
class Beak extends AnimalMouth | |
//================================Generic type works as in the following ======================= | |
trait Animal[Mouth <: AnimalMouth] { | |
def mouth : Mouth | |
def feedAnother(m: Mouth): Unit = () | |
} |
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
object overloaded extends Overload { | |
implicit def futureT[T] = | |
Case((t: Future[T]) => t.map(Right(_)) | |
implicit def futureOptT[T, U](implicit ev: U <:< Option[T]) = | |
Case((t: Future[U]) => t.map(Right(_.get)).getOrElse(Left(NotFoundException)) | |
} |
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
val endpoint0 = handle( | |
fromJson[PartialRequestMessage].body and from(req ⇒ 'name ->> req.headers("my_name") :: HNil), | |
process[RequestMessage] using myActor `then` expect[ResponseMessage].respondJson(Ok(_)) | |
) | |
val endPoint1 = handleParams( | |
process[RequestMessage] using myActor `then` expect[ResponseMessage].respond(Ok) `with` authentication | |
) | |
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
package com.iheart.play.akka | |
import org.specs2.mutable.Specification | |
import shapeless._ | |
import ops.hlist._ | |
import shapeless.ops.record.{Values, Keys} | |
import syntax.singleton._ | |
object Test { | |
case class RawReq(ip: String, header: Map[String, String] = Map()) |
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
def createOrUpdateCard( profileId: ProfileId, contextName: ContextName): FutureEither[CardId] = { | |
lazy val nowF = getAndValidateGoogleNowCredential(profileId) | |
lazy val contentF = getContentFromStationService(profileId, contextName) | |
lazy val contextF = ensureContextExistsOnGoogle(contextName) | |
def createCard = { | |
for { | |
now <- nowF | |
content <- contentF |
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
var Note = Backbone.Model.extend({ | |
initialize: function() {}, | |
delete: function() { | |
//do something | |
this.log('deleted'); | |
}, | |
log: function(msg) { | |
alert(msg); |
NewerOlder