Skip to content

Instantly share code, notes, and snippets.

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

federico silva fedesilva

👁️‍🗨️
View GitHub Profile
@fedesilva
fedesilva / refinedMonoid.scala
Last active April 13, 2018 20:46
A `Monoid` for `Refined` refinement types.
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 January 30, 2018 22:14
Very basic type class example.
//
// 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 January 7, 2018 03:30 — 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)
#!/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
@fedesilva
fedesilva / repl.scala
Created May 10, 2012 21:57
Voldemort types in scala
f@omoikane:~$ scala
Welcome to Scala version 2.9.1.final (Java HotSpot(TM) 64-Bit Server VM, Java 1.6.0_31).
Type in expressions to have them evaluated.
Type :help for more information.
scala> :load Workshop/mine/scala-misc/voldemort.scala
Loading Workshop/mine/scala-misc/voldemort.scala...
defined module Dungeon
scala> val nemesis = Dungeon curse "fedesilva"
@fedesilva
fedesilva / Main.hs
Created November 15, 2017 11:06 — forked from jkachmar/Main.hs
Just Do the Right Thing
module Main where
--------------------------------------------------------------------------------
-- | This is the `Maybe` data type:
-- |
-- | > data Maybe a
-- | > = Nothing
-- | > | Just a
-- |
-- | `Maybe` is a sum type that can be parameterized over a given `a` type, such
@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

@fedesilva
fedesilva / README.md
Created July 1, 2017 01:32 — forked from polvi/README.md
HDFS of Kubernetes

Easiest HDFS cluster in the world with kubernetes.

Inspiration from kimoonkim/kubernetes-HDFS

kubectl create -f namenode.yaml
kubectl create -f datanode.yaml

Setup a port-forward to so you can see it is alive:

@fedesilva
fedesilva / admin.json
Created June 21, 2017 15:30
kong cosomojo
{
timers: {
running: 0,
pending: 4
},
configuration: {
admin_error_log: "logs/error.log",
cassandra_lb_policy: "RoundRobin",
admin_access_log: "logs/admin_access.log",
cassandra_port: 9042,
@fedesilva
fedesilva / artifactory.conf
Created September 4, 2012 00:28
Artifactory behind nginx
upstream artifacts {
server 127.0.0.1:8081 fail_timeout=0;
}
server {
listen 80;
root /var/www;
server_name artifacts.inconcert artifacts;
@fedesilva
fedesilva / gist:979311b30a10de04f86678d8b2341315
Created December 29, 2016 20:47 — forked from juanje/gist:3797297
Mount apt cache of a Vagrant box in the host to spin up the packages installation

This is a little trick I use to spin up the packages instalation on Debian/Ubuntu boxes in Vagrant.

I add a simple function that checks if a directory named something similar to ~/.vagrant.d/cache/apt/opscode-ubuntu-12.04/partial (it may have another path in Windows or MacOS) and create the directory if it doesn't already exist.

def local_cache(basebox_name)
  cache_dir = Vagrant::Environment.new.home_path.join('cache', 'apt', basebox_name)
  partial_dir = cache_dir.join('partial')
  partial_dir.mkdir unless partial_dir.exist?
 cache_dir