Skip to content

Instantly share code, notes, and snippets.


Filippo De Luca filosganga

View GitHub Profile
filosganga / JsonTagger.scala
Last active Oct 27, 2021
The JSON tagger allows to decode an ADT encoded in JSON avoiding the focus to switch to a different branch
View JsonTagger.scala
import io.circe._
import io.circe.generic.semiauto._
import cats.syntax.all._
object JsonTagger {
private implicit class Tagger[A](d: Decoder[A]) {
def tag(accessor: String): Decoder[Decoder[A]] =
filosganga / Memoize.scala
Last active Mar 5, 2020
Computational memoization
View Memoize.scala
import cats._
import cats.implicits._
import cats.effect._
import cats.effect.concurrent._
import cats.effect.implicits._
trait Memoize[F[_], Key, A] {
def get(id: Key): F[A]
filosganga / Queue.scala
Created Feb 25, 2020
Several effectful Queue implementation using cats-effect
View Queue.scala
import cats.implicits._
import cats.effect._
import cats.effect.concurrent._
trait Queue[F[_], A] {
def enqueue(a: A): F[Unit]
def dequeue: F[A]
filosganga / GuavaFutures.scala
Created Sep 16, 2017
How to convert a Guava ListeanbelFuture to Cats Async
View GuavaFutures.scala
import cats.effect.Async
import{FutureCallback, Futures, ListenableFuture}
import scala.concurrent.ExecutionContext
object GuavaFutures {
implicit class RichListenableFuture[T](lf: ListenableFuture[T]) {
def toAsync[F[_]: Async](implicit ec: ExecutionContext): F[T] = {
View time-avro-example.avsc
"type" : "record",
"name" : "TimeExamples",
"namespace": "com.example",
"fields" : [
"name": "aDate",
"type": "int"
"logicalType": "date"
filosganga / ResourceMapStage.scala
Last active Mar 23, 2017
A map stage that control a resource lifecycle.
View ResourceMapStage.scala
import{GraphStage, GraphStageLogic, InHandler, OutHandler}
import scala.util.control.NonFatal
class ResourceMapStage[In, Out, R](opener: () => R, closer: R => Unit, f: R => In Out) extends GraphStage[FlowShape[In, Out]] {
val in = Inlet[In]("")
val out = Outlet[Out]("ResourceMap.out")

Keybase proof

I hereby claim:

  • I am filosganga on github.
  • I am filippodeluca ( on keybase.
  • I have a public key ASC15nUa_a2CLHbteLCqNLcJOdILRNSHq5YRpdaV2xplzAo

To claim this, I am signing this object:

View blockchainID
Verifying that +filosganga is my blockchain ID.
filosganga / .gitignore
Last active Aug 29, 2015 — forked from mpilquist/.gitignore
Simulacrum Example
View CssParser.scala
import util.parsing.combinator.JavaTokenParsers
case class Rule(val selectors : List[String], val properties : List[Property])
case class Property(name: String, value: String)
object CssParser extends JavaTokenParsers {
def rules = rule+