Skip to content

Instantly share code, notes, and snippets.

View rtfpessoa's full-sized avatar

Rodrigo Fernandes rtfpessoa

View GitHub Profile
@rtfpessoa
rtfpessoa / cgd.py
Created March 16, 2016 22:18 — forked from brunomlopes/cgd.py
Simple api to fetch accounts, balances and transactions from Caixa Geral de Depósitos's ( CGD ) API used by their Windows 8 application.
# gist: https://gist.github.com/4397792
# Usage:
# session = cgd.CgdSession(uid, password)
# session.login()
# session.load_latest_transactions(account_key)
# 'session.known_accounts' is now populated with the initial accounts taken from the login response,
# and the data for the 'account_key' account.
# session.load_latest_transactions(account_key) loads the latest transactions and balances for a given account.
@rtfpessoa
rtfpessoa / downgrade-docker-osx.sh
Last active March 13, 2016 14:21
Docker in OS X
#!/bin/bash
#
# Downgrade docker on OS X (to version 1.8.3)
#
brew uninstall docker docker-machine boot2docker
# Download and run https://github.com/docker/toolbox/releases/download/v1.8.3/DockerToolbox-1.8.3.pkg
# Open VirtualBox app and remove all the docker VMs and files
@rtfpessoa
rtfpessoa / linux-monitor.sh
Last active March 3, 2016 11:21
Linux Monitor Tools
#!/bin/bash
#
# Linux Server Profiling tools (cpu, memory, io, etc)
#
sudo apt-get -y install htop iotop sysstat
htop
@rtfpessoa
rtfpessoa / postgresql-blockers-waiters.sql
Created February 18, 2016 23:11
Postgresql Blockers and Waiters
SELECT blocked_locks.pid AS blocked_pid,
blocked_activity.usename AS blocked_user,
blocking_locks.pid AS blocking_pid,
blocking_activity.usename AS blocking_user,
blocked_activity.query AS blocked_statement,
blocking_activity.query AS blocking_statement
FROM pg_catalog.pg_locks blocked_locks
JOIN pg_catalog.pg_stat_activity blocked_activity ON blocked_activity.pid = blocked_locks.pid
JOIN pg_catalog.pg_locks blocking_locks
ON blocking_locks.locktype = blocked_locks.locktype
@rtfpessoa
rtfpessoa / ImplicitStackOverflow.scala
Last active February 9, 2016 15:16
Scala Implicit StackOverflow
case class ModelObject(foo1: String, foo2: String, foo3: String, foo4: String, foo5: String)
case class ApiObject(bar1: String, bar3: String, bar4: String)
object ModelObject {
implicit def toApi(m: ModelObject): ApiObject = {
ApiObject(m.foo1, m.foo3, m.bar1)
}
}
ModelObject.toApi(ModelObject("1","2","3","4","5")) // bar1 ?? what ?? StackOverflow
@rtfpessoa
rtfpessoa / 1.README.md
Last active January 27, 2016 09:32 — forked from varemenos/1.README.md

Get Git log in JSON format

git log --pretty=format:'{%n  "commit": "%H",%n  "abbreviated_commit": "%h",%n  "tree": "%T",%n  "abbreviated_tree": "%t",%n  "parent": "%P",%n  "abbreviated_parent": "%p",%n  "refs": "%D",%n  "encoding": "%e",%n  "subject": "%s",%n  "sanitized_subject_line": "%f",%n  "body": "%b",%n  "commit_notes": "%N",%n  "verification_flag": "%G?",%n  "signer": "%GS",%n  "signer_key": "%GK",%n  "author": {%n    "name": "%aN",%n    "email": "%aE",%n    "date": "%aD"%n  },%n  "commiter": {%n    "name": "%cN",%n    "email": "%cE",%n    "date": "%cD"%n  }%n},'

The only information that aren't fetched are:

  • %B: raw body (unwrapped subject and body)
  • %GG: raw verification message from GPG for a signed commit
@rtfpessoa
rtfpessoa / npm-install.sh
Last active January 24, 2016 15:23
NPM install OSX
#!/bin/bash
#
# Correct way to install NPM and Node.js on OS X
# Credits: https://gist.github.com/DanHerbert/9520689
#
rm -rf /usr/local/lib/node_modules
brew uninstall node npm
brew install node --without-npm
@rtfpessoa
rtfpessoa / docker-sg-command.sh
Last active January 10, 2016 18:01
Docker group change without reload shell
#!/bin/bash
# Execute docker command without need to kill shell after changing groups
sudo userdel docker || echo "Success"
sudo groupdel docker || echo "Success"
sudo groupadd -g 2004 docker
sudo adduser --disabled-password --gecos "" --uid 2004 --gid 2004 docker
sudo gpasswd -a docker docker
sudo gpasswd -a $USER docker
sudo su -c 'sudo service docker restart' -s /bin/bash $USER
@rtfpessoa
rtfpessoa / .gitconfig
Last active December 31, 2015 00:39
git Configuration
#
# rtfpessoa git Configuration
#
# core {{{
[core]
editor = /usr/bin/nano
pager=less -x4
quotepath = false
# excludesfile = /Users/rtfpessoa/.gitignore
@rtfpessoa
rtfpessoa / partial-function-tupled.scala
Last active November 23, 2015 10:58
Partially apply function with tuple
def t(a: Int, b : Int, c : Int) = a + b + c
t(1, _: Int, _: Int)
t.tupled.apply((2, 3))