Skip to content

Instantly share code, notes, and snippets.

View sergeykolbasov's full-sized avatar

Sergey Kolbasov sergeykolbasov

View GitHub Profile
@sergeykolbasov
sergeykolbasov / SomeService.scala
Last active November 16, 2015 21:37
Abstraction over service in finch
class SimpleHttpService {
override def apply(f: (RequestContext) => FutureResult[ErrorResult, Response]): Service[Request, Response] = new Service[Request, Response] {
override def apply(request: Request): Future[Response] = {
for {
context <- requestContext(request)
response <- f.andThen(errorHandler)(context)
} yield {
response
}
@sergeykolbasov
sergeykolbasov / FromParams.scala
Last active March 21, 2016 20:43
FromParams with love to Option
package io.finch.internal
import scala.reflect.ClassTag
import io.finch._
import shapeless._
import shapeless.labelled._
/**
* A type class empowering a generic derivation of [[Endpoint]]s from query string params.
import shapeless.{::, DepFn1, HList, HNil, LabelledGeneric}
import shapeless.labelled.{FieldType, field}
object deepcopy extends App {
trait DeepCopy[A] extends DepFn1[A]
object DeepCopy extends LowPriorityDeepCopy {
type Aux[A, O] = DeepCopy[A] {type Out = O}
import shapeless.{HList, HNil, LabelledGeneric}
import deepcopy._
import shapeless.ops.record.Merger
import shapeless.syntax.singleton._
object copyandmerge extends App {
implicit class MergeAndCopy[A](a: A) {
class Converter[B] {
@sergeykolbasov
sergeykolbasov / benchmark.md
Created September 28, 2018 19:52
Finch cats-effect benchmark

With cats.effect.IO:

[info] Benchmark                                                                    Mode  Cnt       Score       Error   Units
[info] JsonAndTextNegotiatedBootstrapBenchmark.foos                                thrpt   10   28449.544 ±  3887.823   ops/s
[info] JsonAndTextNegotiatedBootstrapBenchmark.foos:·gc.alloc.rate.norm            thrpt   10   79800.658 ±  1312.407    B/op
[info] JsonBootstrapBenchmark.foos                                                 thrpt   10   18630.972 ±  2404.050   ops/s
[info] JsonBootstrapBenchmark.foos:·gc.alloc.rate.norm                             thrpt   10  112024.079 ±    12.754    B/op
[info] JsonNegotiatedBootstrapBenchmark.foos                                       thrpt   10   18668.871 ±  1511.295   ops/s
[info] JsonNegotiatedBootstrapBenchmark.foos:·gc.alloc.rate.norm                   thrpt   10  110568.082 ±  2435.077    B/op
[info] TextBootstrapBenchmark.foos                                                 thrpt   10   59870.966 ±  4066.127