Skip to content

Instantly share code, notes, and snippets.

View afsalthaj's full-sized avatar
💭
Every day is learning. Every day is the pursuit to perfectness.

Afsal Thaj afsalthaj

💭
Every day is learning. Every day is the pursuit to perfectness.
View GitHub Profile
@kdrakon
kdrakon / Avro4s.scala
Last active December 16, 2022 15:29
Using Avro4s with Confluent Kafka Avro Serializer + Schema Registry
import java.util
import com.sksamuel.avro4s.RecordFormat
import org.apache.avro.generic.GenericRecord
import org.apache.kafka.common.serialization.{Deserializer, Serde, Serializer}
object Avro4s {
implicit class CaseClassSerde(inner: Serde[GenericRecord]) {
def forCaseClass[T](implicit recordFormat: RecordFormat[T]): Serde[T] = {
val caseClassSerializer: Serializer[T] = new Serializer[T] {
import scalaz.{-\/, Applicative, Coproduct, Free, FreeAp, Inject, Monad, NaturalTransformation, Nondeterminism, \/-, ~>}
import scala.language.{higherKinds, reflectiveCalls}
import scalaz.concurrent.Task
import Task._
import scala.util.Random
case class User(name: String, age: Int)
sealed trait UserOperation[T]
case class CreateUser(name: String, age: Int) extends UserOperation[User]
--==============================
-- Send Keynote Text to Desktop Markdown File
-- Writted By: Richard Dooling https://github.com/RichardDooling/
-- Based on
-- Send Keynote Presenter Notes to Evernote
-- Version 1.0.1
-- Written By: Ben Waldie <ben@automatedworkflows.com>
-- http://www.automatedworkflows.com
-- Version 1.0.0 - Initial release