Skip to content

Instantly share code, notes, and snippets.

Krzysiek Ciesielski kciesielski

  • SoftwareMill
  • Lublin, Poland
Block or report user

Report or block kciesielski

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View Semiauto.scala
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]
View AroundDirectives.scala
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 =>
View KafkaPlayground.scala
package akka.kafka.scaladsl
import java.util.concurrent.TimeUnit
import java.util.{Properties, UUID}
import akka.kafka.{ConsumerSettings, ProducerSettings}
import akka.testkit.TestKit
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;
kciesielski / freemonads.scala
Last active Apr 12, 2019
Free Monads example
View freemonads.scala
package com.softwaremill.freemonads
import cats.~>
import cats._, cats.std.all._
import scala.concurrent.Future
sealed trait External[A]
case class Tickets(count: Int) extends AnyVal
kciesielski / aggregate2.scala
Created Sep 25, 2015
Functional aggregate example with Kleislis replaced by simple monads + flatMaps
View aggregate2.scala
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)
View gist:5347375
package com.mtgox.api;
import java.util.HashMap;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.crypto.Mac;
View FunctionalDecorator.scala
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)
kciesielski /
Created Nov 22, 2012
Decorator Pattern example
public abstract class RebateDecorator implements RebatePolicy {
protected RebatePolicy decorated;
protected RebateDecorator(RebatePolicy decorated){
this.decorated = decorated;
You can’t perform that action at this time.