Skip to content

Instantly share code, notes, and snippets.

View VledicFranco's full-sized avatar

Vledic | Franco | faramburo VledicFranco

View GitHub Profile
@VledicFranco
VledicFranco / SerializedComputations.scala
Last active January 22, 2019 12:31
Serialize arbitrary computations and run them on a different machine while keeping type safety
import shapeless._
import shapeless.record._
import shapeless.ops.record._
import syntax.singleton._
object Main extends App {
// === Your normal code base =========================================================================================
@VledicFranco
VledicFranco / AdventOfCodeSeven.scala
Created January 4, 2019 22:25
Advent of Code 2018 Day 7
import cats._
import cats.data.State
import cats.effect.{ExitCode, IO, IOApp}
import cats.implicits._
import scala.io.Source
// Tweet: https://twitter.com/francoaramburo/status/1081303164660473857
object Main extends IOApp {
@VledicFranco
VledicFranco / TaglessFinal.scala
Created August 5, 2018 13:04
Tagless final is a flexible and powerful design pattern in functional programming, this gist tries to give a brief explanation of it.
import scala.concurrent.{ExecutionContext, Future}
import Monad.syntax._
import scalaz.reactive.tmp.lambda_tickets.{HttpImplementation, Id, MockedImplementation}
object tickets {
import scala.concurrent.ExecutionContext.Implicits.global
// Q: How many implementations does this have? A: mathematically infinite
// Q: How many implementations differ from the one you intended? A: mathematically infinite
@VledicFranco
VledicFranco / Heroes.scala
Created March 31, 2017 14:56
Typeclasses Workshop
/* See: http://underscore.io/blog/posts/2015/06/04/more-on-sealed.html */
sealed trait FrostSpell extends Product with Serializable
case object Blizzard extends FrostSpell
case object Icebolt extends FrostSpell
object FrostSpell {
implicit val ordering: Ordering[FrostSpell] = new Ordering[FrostSpell] {
override def compare(x: FrostSpell, y: FrostSpell): Int = (x,y) match {
@VledicFranco
VledicFranco / ImageRequester.java
Created May 2, 2012 02:20
Android class, downloads an image from an url and sets it in the an ImageView.
/*
* Instantiate this class and use the method "execute", just give the image url and the ImageView where you want to set it.
* Notice that you may only use the method once, you need to have one object per image request.
* You don't have to worry about threads or blocking your app, this is handled with the AsyncTask class.
*/
import java.io.IOException;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
@VledicFranco
VledicFranco / bin\app
Created April 24, 2012 00:27
Handles commands, options and parameters to call a nodejs app
#!/usr/bin/env node
// This file has to have execution permission.
// You can do it with 'sudo chmod 777 thisfile', will give write, read and execute permissions to everyone.
// To execute it from terminal be sure that your $PATH is updated, adding the path of this file to it.
var delegate = require('../lib/delegate') // Replace delegate with the module which will handle the commands functionality.
var args = new ArgumentsCollection();
// # Declaration of your app arguments