Skip to content

Instantly share code, notes, and snippets.

Avatar
👁️‍🗨️

federico silva fedesilva

👁️‍🗨️
View GitHub Profile
@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
@fedesilva
fedesilva / Main.hs
Created Nov 15, 2017 — forked from jkachmar/Main.hs
Just Do the Right Thing
View Main.hs
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 / README.md
Created Jul 1, 2017 — forked from polvi/README.md
HDFS of Kubernetes
View README.md

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:

View admin.json
{
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 / gist:979311b30a10de04f86678d8b2341315
Created Dec 29, 2016 — forked from juanje/gist:3797297
Mount apt cache of a Vagrant box in the host to spin up the packages installation
View gist:979311b30a10de04f86678d8b2341315

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
@fedesilva
fedesilva / elasticsearch.yml
Last active Dec 28, 2016
ES 5.1 java client fails to connect to single node cluster in localhost
View elasticsearch.yml
# ======================== Elasticsearch Configuration =========================
#
# NOTE: Elasticsearch comes with reasonable defaults for most settings.
# Before you set out to tweak and tune the configuration, make sure you
# understand what are you trying to accomplish and the consequences.
#
# The primary way of configuring a node is via this file. This template lists
# the most important settings you may want to configure for a production cluster.
#
# Please see the documentation for further information on configuration options:
View bash.generate.random.alphanumeric.string.sh
#!/bin/bash
# bash generate random alphanumeric string
#
# bash generate random 32 character alphanumeric string (upper and lowercase) and
NEW_UUID=$(cat /dev/urandom | base64 | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1)
# bash generate random 32 character alphanumeric string (lowercase only)
cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1
@fedesilva
fedesilva / play2.service
Created Aug 24, 2016 — forked from dkhenry/play2.service
Systemd script for the Play Framework
View play2.service
[Unit]
Description=Play2 Server for <site>
After=network.target
 
[Service]
Type=simple
PIDFile=<path>/RUNNING_PID
 
ExecStartPre=/bin/sh -c 'cd <path> ;/bin/rm RUNNING_PID ; sbt clean compile stage'
ExecStart=<path>/target/start
@fedesilva
fedesilva / IO.scala
Created Aug 11, 2016 — forked from jdegoes/IO.scala
A pedagogical implementation of the IO monad in Scala in 14 LOC
View IO.scala
case class IO[A](unsafePerformIO: () => A) {
def map[B](ab: A => B): IO[B] = IO(() => ab(unsafePerformIO()))
def flatMap[B](afb: A => IO[B]): IO[B] =IO(() => afb(unsafePerformIO()).unsafePerformIO())
def tryIO(ta: Throwable => A): IO[A] =
IO(() => IO.tryIO(unsafePerformIO()).unsafePerformIO() match {
case Left(t) => ta(t)
case Right(a) => a
})
}
object IO {
@fedesilva
fedesilva / gist:3b9ca0448de3fbf6c43c79e406a08d95
Created Jul 2, 2016 — forked from colestanfield/gist:fac042d3108b0c06e952
sbt-assembly merge strategy for aop.xml files
View gist:3b9ca0448de3fbf6c43c79e406a08d95
// 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)