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
// 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 { |
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
// 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._ |
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
// Expression problem in Scala | |
object OOP { | |
trait Expr { | |
def eval: Int | |
def show: String | |
} | |
case class Add(a: Expr, b: Expr) extends Expr { |
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 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._ |