This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# Linux Server Profiling tools (cpu, memory, io, etc) | |
# | |
sudo apt-get -y install htop iotop sysstat | |
htop |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var updateTimer = function(period, updateTokenCallback) { | |
// Get current time seconds | |
var epocSecs = Math.floor((+new Date()) / 1000); | |
var sec = epocSecs % period; | |
var secsToNext = 0; | |
// Fire if clock has struck 0 or 'period' | |
if (sec == 0 || sec == period) { | |
updateTokenCallback(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def t(a: Int, b : Int, c : Int) = a + b + c | |
t(1, _: Int, _: Int) | |
t.tupled.apply((2, 3)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |