Skip to content

Instantly share code, notes, and snippets.

🎪

federico silva fedesilva

🎪
Block or report user

Report or block fedesilva

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@fedesilva
fedesilva / .scalafmt.conf
Created Jun 12, 2019
My scalafmt config
View .scalafmt.conf
version = "2.0.0-RC4"
align = most
maxColumn = 100
docstrings = ScalaDoc
assumeStandardLibraryStripMargin = true
continuationIndent.callSite = 2
continuationIndent.defnSite = 2
align.openParenCallSite = false
align.openParenDefnSite = false
@fedesilva
fedesilva / circe-inmemory-ttfi-di.sc
Created May 8, 2019 — forked from MateuszKubuszok/circe-inmemory-ttfi-di.sc
Showoff code that I probably wouldn't use on production, but looks smarter than whatever stuff is actually required in our everyday coding :P
View circe-inmemory-ttfi-di.sc
//
// @author: Mateusz Kubuszok
//
// requirements: ammonite 1.1.0
// usage: run `amm` and copy paste into REPL
import $ivy.`org.typelevel::cats-core:1.3.1`, cats._, cats.syntax.all._
import $ivy.`org.typelevel::cats-effect:1.0.0`, cats.effect._, cats.effect.syntax._
import $ivy.`io.circe::circe-core:0.9.3`, io.circe._, io.circe.syntax._
import $ivy.`io.circe::circe-generic:0.9.3`, io.circe.generic.auto._
@fedesilva
fedesilva / ConsoleJsonWriter.java
Created Dec 20, 2018 — forked from jonnywray/ConsoleJsonWriter.java
Generic JSON reporter for Dropwizard metrics (https://dropwizard.github.io/metrics/3.1.0/) for sending JSON representation to arbitrary HTTP endpoint
View ConsoleJsonWriter.java
import com.codahale.metrics.MetricFilter;
import com.codahale.metrics.MetricRegistry;
import com.fasterxml.jackson.databind.SerializationFeature;
import java.io.PrintStream;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.TimeUnit;
@fedesilva
fedesilva / SangriaReproExample.scala
Created Aug 13, 2018 — forked from OlegIlyenko/SangriaReproExample.scala
An example of minimal self-contained snippet that reproduces specific issue
View SangriaReproExample.scala
// Imports that you are using
import sangria.schema._
import sangria.execution._
import sangria.macros._
import sangria.marshalling.circe._
import scala.concurrent.ExecutionContext.Implicits.global
// The schema definition
@fedesilva
fedesilva / OneOf.scala
Created Jul 31, 2018 — forked from wheaties/OneOf.scala
Type Level OneOf
View OneOf.scala
trait OneOf[Obj, Items]
object OneOf extends LowPriorityOneOf{
implicit def apply[Obj, Items](implicit oneOf: OneOf[Obj, Items]) = oneOf
implicit def left[L, R, Obj <: L] = new OneOf[Obj, L | R]{}
}
protected trait LowPriorityOneOf extends LowPriorityOneOf1{
implicit def right[L, R, Obj <: R] = new OneOf[Obj, L | R]{}
@fedesilva
fedesilva / SimplePartitionSample.scala
Created Jul 6, 2018 — forked from johanandren/SimplePartitionSample.scala
Sample of using partition to split up incoming elements over multiple outgoing streams
View SimplePartitionSample.scala
import akka.actor.ActorSystem
import akka.stream._
import akka.stream.scaladsl._
import scala.io.StdIn
import scala.util.Random
object SimplePartitionSample extends App {
implicit val system = ActorSystem()
View disable-xdebug.sh
#!/bin/sh
sed -i.default "s/^zend_extension=/;zend_extension=/" /usr/local/etc/php/7.1/conf.d/ext-xdebug.ini
launchctl unload ~/Library/LaunchAgents/homebrew.mxcl.php71.plist
launchctl load ~/Library/LaunchAgents/homebrew.mxcl.php71.plist
sudo brew services restart php71
echo "xdebug disabled"
@fedesilva
fedesilva / refinedMonoid.scala
Last active Apr 13, 2018
A `Monoid` for `Refined` refinement types.
View refinedMonoid.scala
package we.sg.data
import cats.kernel.Monoid
import eu.timepit.refined.{W, refineMV, refineV}
import eu.timepit.refined.api.Refined
import eu.timepit.refined.boolean.Not
import eu.timepit.refined.string.MatchesRegex
object RefinementTypes {
@fedesilva
fedesilva / a-very-simple-typeclass-example.scala
Last active Jan 30, 2018
Very basic type class example.
View a-very-simple-typeclass-example.scala
//
// While testing the Elasticsearch 6.x http client works for me, using circe for json,
// I added a silly `Entity` type class which describes how to get an ID from an entity.
//
import java.util.UUID
import org.apache.http.HttpHost
import org.elasticsearch.action.index.IndexRequest
@fedesilva
fedesilva / pre-commit-hook-install.sh
Created Jan 7, 2018 — forked from cvogt/pre-commit-hook-install.sh
git pre-commit hook for Scala compile and format checking (put both in your git project root, needs to be installed in each clone)
View pre-commit-hook-install.sh
#!/bin/sh
cd "$(dirname "$0")"
touch .git/hooks/pre-commit
rm .git/hooks/pre-commit
ln -s ../../pre-commit-hook.sh .git/hooks/pre-commit
You can’t perform that action at this time.