Instantly share code, notes, and snippets.

View GuavaFutures.scala
import cats.effect.Async
import com.google.common.util.concurrent.{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"
},
View ResourceMapStage.scala
import akka.stream.ActorAttributes.SupervisionStrategy
import akka.stream._
import akka.stream.stage.{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]("ResourceMap.in")
val out = Outlet[Out]("ResourceMap.out")
View keybase.md

Keybase proof

I hereby claim:

  • I am filosganga on github.
  • I am filippodeluca (https://keybase.io/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. https://onename.com/filosganga
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+
View CycleIterator.scala
class CycleIterator[B <: A, +A](elements: Iterable[B]) extends Iterator[A] {
var iterator: Iterator[B] = Iterator.empty
def hasNext: Boolean = {
if (!iterator.hasNext) {
iterator = elements.iterator
}
iterator.hasNext
}
View RoundRobinIterable.java
import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.collect.Iterables.filter;
import static com.google.common.collect.Iterators.cycle;
import static java.util.Arrays.asList;
import java.util.Iterator;
import com.google.common.base.Function;
import com.google.common.base.Predicate;
import com.google.common.collect.FluentIterable;
View FizzBuzz.scala
class FizzBuzz(divisors = Map(3->"Fizz", 5->"Buzz")) {
def fizzBuzz(n: Int): String = {
divisors.foldLeft(""){(res, d)=>
n % d._1 match {
case 0 => res + d._2
case _ => res
}
} match {
case "" => n.toString