Skip to content

Instantly share code, notes, and snippets.

Avatar

Paweł Kołodziejczyk lewapek

View GitHub Profile
@lewapek
lewapek / RefinedInconsistency.scala
Created Jun 30, 2021
Inconsistency between 0.9.25 and 0.9.26 refined versions
View RefinedInconsistency.scala
import eu.timepit.refined.W
import eu.timepit.refined.api.Refined
import eu.timepit.refined.boolean.And
import eu.timepit.refined.char.LetterOrDigit
import eu.timepit.refined.collection.{Forall, Size}
import eu.timepit.refined.generic.Equal
import eu.timepit.refined.string.StartsWith
object Runner {
import eu.timepit.refined.auto._
@lewapek
lewapek / ExpressionProblem.scala
Last active Feb 2, 2021
Expression problem in Scala
View ExpressionProblem.scala
// Expression problem in Scala
object OOP {
trait Expr {
def eval: Int
def show: String
}
case class Add(a: Expr, b: Expr) extends Expr {
@lewapek
lewapek / arbitrage.scala
Last active Aug 30, 2021
Arbitrage solution (Ammonite)
View arbitrage.scala
// Tested on ammonite with Scala 2.13.1
// import $ivy.`io.estatico::newtype:0.4.4`
import $ivy.`io.monix::monix:3.3.0`
import $ivy.`io.circe::circe-parser:0.13.0`
import cats.Show
import cats.instances.double._
import cats.instances.int._
import cats.syntax.either._
import cats.syntax.option._
@lewapek
lewapek / AsyncFunSuiteExample.scala
Last active Sep 21, 2018
Scalatest AsyncFunSuite vs FunSuite
View AsyncFunSuiteExample.scala
// async suite
test("listen for one message when subscribed to topics regex") {
val producer = KafkaProducer[String,String](producerCfg, io)
val consumer = KafkaConsumerObservable[String,String](consumerCfg, topicsRegex).executeOn(io)
// Publishing one message
val flow = for {
_ <- producer.send(topicMatchingRegex, "test-message")
first <- consumer.take(1).map(_.value()).firstL
} yield {