Skip to content

Instantly share code, notes, and snippets.


Leandro Guida lcguida

View GitHub Profile
lcguida / gsearch.rb
Created Jul 14, 2020
Search my commits given a period
View gsearch.rb
#!/usr/bin/env ruby
require 'date'
def print_usage
puts "USAGE: gsearch <from> [<to>]"
exit 1
print_usage if ARGV.size < 1 || ARGV.size > 2
lcguida / to_csv.rb
Last active Jun 20, 2020
Ruby script to trasnform my father accounting excel in a formated CSV to later be trasnformed in OFX
View to_csv.rb
#!/usr/bin/env ruby
require 'rubyXL'
require 'rubyXL/convenience_methods'
require 'csv'
# Do not show gem warnings. See:
module RubyXL
@@suppress_warnings = true
lcguida /
Created Jun 2, 2019
Debug when environment variables is set
set -e
if [[ -n "${DEBUG}" ]]; then
set -x
lcguida /
Last active Nov 28, 2018
Ubuntu new install setup
set -xe
# Update the system
sudo apt -y update && sudo apt -y upgrade
# Make GRUB remeber the last chosen entry
function grub_set_remeber_last_option () {
lcguida / currency.1h.rb
Created Sep 7, 2018
BitBar script to show BRL currency
View currency.1h.rb
#!/usr/bin/env ruby
require 'net/http'
require 'json'
url = "${ENV['FIXER_API_KEY']}&symbols=BRL"
response = Net::HTTP.get(URI(url))
body = JSON.parse(response)
rate = body['rates'] && body['rates']['BRL'] # sometimes I work with ruby 2.2 which doesnt have dig =(
lcguida / export.rb
Last active Aug 30, 2018
Exemplo de batch action ActiveAdmin (Grupo Rails - Facebook)
View export.rb
ActiveAdmin.register MyModel do
# ..
# Configura essa página do active admin para utilizar batch actions
config.batch_actions = true
# Remove a action destory em batch (Você pode controlar outras coisas por aqui)
batch_action :destroy, false
# Cria a action export
lcguida /
Last active Jun 4, 2018
Creating a postgresql docker image from production database
# Fail script if a command fails
set -x
# Grab the latest postgresql:9.4-alpine image
docker pull postgres:9.4-alpine
# We will name our container as `pg_tmp`, so we will
# make sure that no container with this name is running
lcguida / must_call.rb
Created Nov 17, 2017
Minitest `must_call`
View must_call.rb
# Wrapper to mock.verify procedure when asserting
# a method is called in minitest
class Object
def must_call(method_name, returns: nil, arguments: [])
mock =
mock.expect(:call, returns, arguments)
self.stub(method_name, mock) do
lcguida /
Created Aug 18, 2017
Jenkins update script
echo -n "Removing old jenkins.war backcups ... "
rm -rf $JENKINS_PATH/jenkins.war.*.bkp
echo "Done"
echo -n "Backing up the current jenkins.war file ... "
cp $JENKINS_PATH/jenkins.war $JENKINS_PATH/jenkins.war.$(date +"%Y%m%d").bkp
lcguida / pre-push
Last active Aug 4, 2017 — forked from calebhaye/pre-push
Run tests before git push (within specified branches)
View pre-push
branches_to_test=('master' 'staging' 'develop')
branch=`git rev-parse --abbrev-ref HEAD`
test_branch () {
local e
for e in "${branches_to_test[@]}"
You can’t perform that action at this time.