Skip to content

Instantly share code, notes, and snippets.

View rtfpessoa's full-sized avatar

Rodrigo Fernandes rtfpessoa

View GitHub Profile
@rtfpessoa
rtfpessoa / LittleTree.scala
Created November 14, 2015 21:01
LittleTree Implementation
package com.rtfpessoa.scala
import scala.language.postfixOps
import scala.util.Properties
case class LittleTree(height: Int) {
implicit class IntOps(int: Int) {
def isOdd = int % 2 > 0
}
@rtfpessoa
rtfpessoa / remove-running-pid.sh
Created October 28, 2015 11:57
Remove RUNNIG_PID
#!/bin/bash
#
# Remove RUNNING_PID on PlayFramework applications
#
for DOCKER in $(docker ps -a -q --filter "name=codacy_"); do
docker stop $DOCKER
docker start $DOCKER
docker exec -it $DOCKER rm RUNNING_PID
@rtfpessoa
rtfpessoa / name-redefenition.scala
Last active October 6, 2015 13:24
Scala can be weirdly dangerous
object NameReDef {
def withWrapper(foo: String => String) = {
println("Wrapping ...")
foo("My pretty string")
}
def bar = {
withWrapper { str =>
// Does not compile if we use the str above before the re-definition
// println("Defined:")
@rtfpessoa
rtfpessoa / count-lines.sh
Last active September 29, 2015 14:28
Line counter dummy script
#!/bin/bash
EXTENSION=$1
FILE_COUNT=0
LINE_SUM=0
for FILE in $(find . -type f -iname "*.$EXTENSION")
do
NUM_LINES=$(cat $FILE | wc -l)
NUM_LINES=${NUM_LINES%% }
@rtfpessoa
rtfpessoa / ZipUtils.scala
Last active September 25, 2015 15:44
Zip Utils Scala Wrapper
import java.util.zip.{ZipEntry, ZipFile, ZipOutputStream}
import better.files._
import scala.collection.JavaConversions.enumerationAsScalaIterator
import scala.language.existentials
import scala.util.{Properties, Try}
object ZipUtils {
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>ANSIBlackColor</key>
<data>
YnBsaXN0MDDUAQIDBAUGFRZYJHZlcnNpb25YJG9iamVjdHNZJGFyY2hpdmVyVCR0b3AS
AAGGoKMHCA9VJG51bGzTCQoLDA0OVU5TUkdCXE5TQ29sb3JTcGFjZVYkY2xhc3NPEB8w
LjAzMTM3MjU0OTAyIDAuMTYwNzg0MzEzNyAwLjIAEAGAAtIQERITWiRjbGFzc25hbWVY
JGNsYXNzZXNXTlNDb2xvcqISFFhOU09iamVjdF8QD05TS2V5ZWRBcmNoaXZlctEXGFRy
@rtfpessoa
rtfpessoa / docker-run-timeout.sh
Last active September 7, 2015 17:20
Docker run timeout
#!/bin/bash
DOCKER_TIMEOUT=$1
shift
CONTAINER=$(docker run -d "$@")
docker stop --time=900 $CONTAINER
EXIT_CODE=$(docker wait $CONTAINER)
@rtfpessoa
rtfpessoa / gist:f3767a7cb2b7d6d62783
Last active September 6, 2015 22:16 — forked from gcatlin/gist:1847248
Install specific version of Homebrew formula
brew update
brew versions FORMULA
cd `brew --prefix`
git checkout HASH Library/Formula/FORMULA.rb # use output of "brew versions"
brew install FORMULA
brew switch FORMULA VERSION
git checkout -- Library/Formula/FORMULA.rb # reset formula
## Example: Using Subversion 1.6.17
#
@rtfpessoa
rtfpessoa / uninstall_mactex.sh
Last active September 6, 2015 21:38 — forked from uchida/uninstall_mactex.sh
MacTeX uninstaller script based on pkgutil command
#!/bin/bash
# MacTeX uninstaller script based on pkgutil command
# by Akihiro Uchida, CC0 dedicated to the public domain
# see http://creativecommons.org/publicdomain/zero/1.0/
IFS=$(echo -en "\n")
for pkg in $(pkgutil --pkgs|grep org.tug.mactex); do
volume="$(pkgutil --pkg-info "$pkg"|grep volume|cut -d' ' -f2-)"
location="$(pkgutil --pkg-info "$pkg"|grep location|cut -d' ' -f2-)"
echo "remove all of the files installed under the $pkg"
for file in $(pkgutil --files "$pkg"); do
@rtfpessoa
rtfpessoa / .zpreztorc
Last active August 29, 2015 14:26
Prezto Configuration
#
# Sets Prezto options.
#
# Authors:
# Sorin Ionescu <sorin.ionescu@gmail.com>
#
#
# General
#