Skip to content

Instantly share code, notes, and snippets.

View fedesilva's full-sized avatar
👁️‍🗨️

federico silva fedesilva

👁️‍🗨️
View GitHub Profile
@fedesilva
fedesilva / gist:3b9ca0448de3fbf6c43c79e406a08d95
Created July 2, 2016 14:44 — forked from colestanfield/gist:fac042d3108b0c06e952
sbt-assembly merge strategy for aop.xml files
// Create a new MergeStrategy for aop.xml files
val aopMerge: MergeStrategy = new MergeStrategy {
val name = "aopMerge"
import scala.xml._
import scala.xml.dtd._
def apply(tempDir: File, path: String, files: Seq[File]): Either[String, Seq[(File, String)]] = {
val dt = DocType("aspectj", PublicID("-//AspectJ//DTD//EN", "http://www.eclipse.org/aspectj/dtd/aspectj.dtd"), Nil)
val file = MergeStrategy.createMergeTarget(tempDir, path)
package test.zipper
object TreeZipper extends App {
println("hello")
// exp 2 * 3 + 4 * 6
val _2 = Node("2", Nil)
val _3 = Node("3", Nil)
@fedesilva
fedesilva / 0introduction.md
Created April 5, 2016 19:48 — forked from djspiewak/0introduction.md
Scala Collections Proposal

Collections Redesign Proposal

I'm going to start off by motivating what I'm doing here. And I want to be clear that I'm not "dissing" the existing collections implementation or anything as unproductively negative as that. It was a really good experiment, it was a huge step forward given what we knew back in 2.8, but now it's time to learn from that experiment and do better. This proposal uses what I believe are the lessons we can learn about what worked, what didn't work, and what is and isn't important about collections in Scala.

This is going to start out sounding really negative and pervasively dismissive, but bear with me! There's a point to all my ranting. I want to be really clear about my motivations for the proposal being the way that it is.

Problems

Generic Interfaces

object ToFromMap {
implicit def materialize[T]: ToFromMap[T] = macro impl[T]
def impl[T: c.WeakTypeTag](c: Context): c.Expr[ToFromMap[T]] = {
import c.universe._
val wt = weakTypeOf[T]
// Gets the type parameters, eg Holder[T, J] => List(T, J)
val baseTypes = wt.baseClasses.head.asType.typeParams.map{ _.asType.toType }
// Gives a Map(T -> Int, J -> Double) if we are extracting Holder[Int, Double]
val myTypes = baseTypes zip wt.typeArgs toMap;
@fedesilva
fedesilva / keybase.md
Created February 9, 2016 22:47
keybase.md

Keybase proof

I hereby claim:

  • I am fedesilva on github.
  • I am fedesilva (https://keybase.io/fedesilva) on keybase.
  • I have a public key ASDem0Fuocr5gGIqgl7dUj-Fo-qj_7v2GQKmn9Rioj3SlQo

To claim this, I am signing this object:

@fedesilva
fedesilva / Zipper.scala
Created February 8, 2016 20:37 — forked from rcherrueau/Zipper.scala
Scala implementation of Gérard Huet's The Zipper
/** Scala implementation of Gérard Huet's The Zipper.
*
* The Zipper is a kind of Iterator for Tree. The Zipper offers
* navigation and edition primitives in constant time.
* [[http://www.dblp.org/rec/bibtex/journals/jfp/Huet97 The Zipper]]
*/
/** Tree data structure. */
sealed abstract class Tree[T]
case class Item[T] (val item: T) extends Tree[T]
@fedesilva
fedesilva / con-y-sin-println.scala
Last active January 26, 2016 15:35
Con y sin println
// The t function takes times and puts data points in an arraybuffer.
// I use that data to compute mean, stddev, variance ...
//
// The Walker just recursively walks a jsoup document feeding the elements to the parser
// or the parsers it returns and accumulating the new ast nodes.
// Lot's of work for the GC
//
// On one run there are two printlns, on the other none.
//
@fedesilva
fedesilva / multiple_ssh_setting.md
Created November 29, 2015 15:48 — forked from jexchan/multiple_ssh_setting.md
Multiple SSH keys for different github accounts

Multiple SSH Keys settings for different github account

create different public key

create different ssh key according the article Mac Set-Up Git

$ ssh-keygen -t rsa -C "your_email@youremail.com"
@fedesilva
fedesilva / anda.conf
Created October 21, 2015 14:13
nginx configs
upstream app {
server localhost:9000;
}
server {
listen 80;
server_name leases.counselytics.net;
# Application root
/*
* Copyright (C) 2009-2015 Typesafe Inc. <http://www.typesafe.com>
*/
import akka.actor.ActorSystem
import akka.http.Http
import akka.http.Http.IncomingConnection
import akka.http.model.HttpEntity
import akka.http.model.Multipart.FormData
import akka.http.server.{ Directives, Route, RoutingSetup }