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
public abstract class RebateDecorator implements RebatePolicy { | |
protected RebatePolicy decorated; | |
protected RebateDecorator(RebatePolicy decorated){ | |
this.decorated = decorated; | |
} | |
} |
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
object Rebates { | |
type RebatePolicy = (Product, Int, Money) => Money | |
} | |
object standardRebate extends ((Double, Int) => RebatePolicy) { | |
def apply(rebate: Double, minimalQuantity: Int) = { | |
(product, quantity, regularCost) => { | |
val rebateRatio = BigDecimal(rebate / 100) | |
if (quantity >= minimalQuantity) |
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.mtgox.api; | |
import java.net.HttpURLConnection; | |
import java.net.URL; | |
import java.net.URLEncoder; | |
import java.util.HashMap; | |
import java.util.logging.Level; | |
import java.util.logging.Logger; | |
import javax.crypto.Mac; |
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
object aggregate { | |
type ValidationStatus[S] = \/[String, S] | |
type ProcessingStatus[S] = \/[String, S] | |
type ReaderTStatus[A, S] = ReaderT[ValidationStatus, A, S] | |
object ReaderTStatus extends KleisliInstances with KleisliFunctions { | |
def apply[A, S](f: A => ValidationStatus[S]): ReaderTStatus[A, S] = kleisli(f) | |
} |
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.softwaremill.freemonads | |
import cats.free.Free | |
import cats.~> | |
import cats._, cats.std.all._ | |
import scala.concurrent.ExecutionContext.Implicits.global | |
import scala.concurrent.Future | |
sealed trait External[A] | |
case class Tickets(count: Int) extends AnyVal |
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.softwaremill.react.kafka; | |
import org.apache.kafka.clients.consumer.ConsumerRecords; | |
import org.apache.kafka.clients.consumer.KafkaConsumer; | |
import org.apache.kafka.clients.producer.KafkaProducer; | |
import org.apache.kafka.clients.producer.ProducerRecord; | |
import java.util.Arrays; | |
import java.util.Properties; | |
import java.util.UUID; |
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 akka.kafka.scaladsl | |
import java.util.concurrent.TimeUnit | |
import java.util.{Properties, UUID} | |
import akka.actor.ActorSystem | |
import akka.kafka.{ConsumerSettings, ProducerSettings} | |
import akka.stream.ActorMaterializer | |
import akka.stream.scaladsl.Sink | |
import akka.testkit.TestKit |
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
object AroundDirectives { | |
val timeoutResponse = HttpResponse(StatusCodes.NetworkReadTimeout, entity = "Unable to serve response within time limit.") | |
def aroundRequest(onRequest: HttpRequest => Try[RouteResult] => Unit)(implicit ec: ExecutionContext): Directive0 = { | |
extractRequestContext.flatMap { ctx => | |
{ | |
val onDone = onRequest(ctx.request) | |
mapInnerRoute { inner => | |
withRequestTimeoutResponse( |
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 io.circe.semiauto._ | |
import io.circe.syntax._ | |
final case class Address(street: String, zipCode: String, city: String) | |
object Address { | |
implicit val addressEcncoder: Encoder[Address] = deriveEncoder[Address] | |
implicit val addressDecoder: Decoder[Address] = deriveDecoder[Address] | |
} |
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
case class MsgMetadata(offset: query.Offset, persistenceId: String, seqNum: Long) | |
trait EventsJournalOffsetDao { | |
def offsetFor(projection: ProjectionId): Future[Option[query.Offset]] | |
def saveOffset(projection: ProjectionId, currentOffset: query.Offset): Future[Unit] | |
} | |
class EventsStreamFactory( | |
config: EventsStreamConfig, | |
val projectionId: ProjectionId, |
OlderNewer