Skip to content

Instantly share code, notes, and snippets.

Dino Fancellu fancellu

Block or report user

Report or block fancellu

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
View index.html
<!-- Do you need Material Icons? -->
<link href=",300,400,500,700,900|Material+Icons" rel="stylesheet" type="text/css">
<link href="" rel="stylesheet" type="text/css">
fancellu / RowParser.scala
Last active Mar 4, 2019
Little Typeclass example
View RowParser.scala
case class Row(rowstring: String)
trait RowParse[A]{
def parse(row:Row):A
case class TwoPart(v1: String, v2: String)
case class ThreePart(v1: String, v2: String, v3: String)
fancellu / Censor.scala
Created Dec 4, 2018
Scala uJson code to censor certain field names
View Censor.scala
import ujson.{ Obj, Value }
object Censor{
def updateAll(root: Value, target: (String => Boolean), newValue: Value): Value = {
def update(value: Value, parent: Value = null, valueName: String = null): Unit = {
value match {
case Obj(values) => { case (name, v) => update(v, value, name) }
fancellu / FoldingValidationExamples.scala
Created Nov 13, 2018
Simple chaining validation example with pure Scala
View FoldingValidationExamples.scala
import scala.util.{Failure, Try}
val li=List(1,2,3,4)
type Transform[F[_],A]=F[A] => F[A]
def filterSmall: Transform[Try,Int] ={ ti=>
ti.flatMap(i=>if (i>1) Try(i) else new Failure(new Exception(s"$i is too small")))

Keybase proof

I hereby claim:

  • I am fancellu on github.
  • I am fancellu ( on keybase.
  • I have a public key ASAIwD1-6lC-FAdHSUyefT5Xul7zEulj3OlQnMZ7uGYBtAo

To claim this, I am signing this object:

fancellu / TryFlatten.scala
Created Apr 11, 2017
A few ways to flatten down a Seq[Try] to only Success values
View TryFlatten.scala
import scala.util.{Success, Failure}
val seq=Seq(Success(1), Failure(new Exception("bang")), Success(2))
// all emit List(1, 2)
seq.collect{case Success(x) => x}
fancellu / .block
Last active Mar 30, 2019
Force directed graph for D3.js v4 with labelled edges and arrows
View .block
license: gpl-3.0
height: 600
fancellu / InfiniteStreamReceiver.scala
Created Jan 23, 2017
Spark streaming custom receiver example, consumes scala Streams
View InfiniteStreamReceiver.scala
* Allows you to receive scala.collection.immutable.Stream
import org.apache.spark.streaming.receiver.Receiver
class InfiniteStreamReceiver[T](stream: Stream[T], delay:Int=0, storageLevel: StorageLevel) extends Receiver[T](storageLevel) {
fancellu / ES.scala
Last active Nov 24, 2016
ElasticSearch 5.x Java client REST example with Play JSON (to get around Netty issue)
View ES.scala
// Play 2.5 is not compatible with ES 5.x Java TCP, as ES demands Netty 4.1 vs Play's 4.0
import org.apache.http.HttpHost
import org.apache.http.entity.ContentType
import org.apache.http.nio.entity.NStringEntity
import org.apache.http.util.EntityUtils
import org.elasticsearch.client.RestClient
import play.api.libs.json.{Format, Json, Writes}
fancellu / Module.scala
Created Nov 18, 2016
Using bindActor: Play 2.5/Akka/Guice, starting an actor before anything else,
View Module.scala
import actors.ActorBrowserActor
import play.api.libs.concurrent.AkkaGuiceSupport
class Module extends AbstractModule with AkkaGuiceSupport{
def configure(): Unit = {
bindActor[ActorBrowserActor](ActorBrowserActor.NAME, _=>ActorBrowserActor.props)
You can’t perform that action at this time.