Skip to content

Instantly share code, notes, and snippets.

View nascimento's full-sized avatar

Vitor Nascimento nascimento

View GitHub Profile
@nascimento
nascimento / rbenv-howto.md
Created March 23, 2016 21:12 — forked from samukasmk/rbenv-howto.md
Setting up and installing rbenv, ruby-build, rubies, rbenv-gemset, and bundler

Setting up and installing rbenv, ruby-build, rubies, rbenv-gemset, and bundler

This guide enables you to install (ruby-build) and use (rbenv) multiple versions of ruby, isolate project gems (gemsets and/or bundler), and automatically use appropriate combinations of rubies and gems.

TL;DR Demo

# Ensure system is in ship-shape.

aptitude install git zsh libssl-dev zlib1g-dev libreadline-dev libyaml-dev

# Command
shasum -a 256 /path/to/file | cut -c-12
# Example:
> shasum -a 256 ~/Desktop/Python-3.4.0.tgz | cut -c-12 (master⚡)
d2c83ea02177
# learned in: https://coderwall.com/p/bbfjrw/calculate-checksum-for-chef-s-remote_file-resource
@nascimento
nascimento / convert_link_to_file.sh
Created April 12, 2016 01:54
Script to conver symlink to file content.
### Start Piperita Theme ###
# Theme by Jacob Tomlinson
# https://github.com/killfall/terminal-piperita
# Aliases to make ls easier to use in different modes, taken from Red Hat EL 6
alias ls='ls -GFh'
alias ll="ls -l"
alias lo="ls -o"
alias lh="ls -lh"
alias la="ls -la"
@nascimento
nascimento / humanize.rb
Created November 7, 2016 20:39
Detailed distance from seconds
def humanize secs
[[60, :seconds], [60, :minutes], [24, :hours], [1000, :days]].map{ |count, name|
if secs > 0
secs, n = secs.divmod(count)
"#{n.to_i} #{name}"
end
}.compact.reverse.join(' ')
end
p humanize 1234
@nascimento
nascimento / .zpreztorc
Created March 15, 2017 13:46
.zpreztorc
#
# Sets Prezto options.
#
# Authors:
# Sorin Ionescu <sorin.ionescu@gmail.com>
#
#
# General
#
@nascimento
nascimento / smtp.rb
Created February 12, 2018 01:22
smtp_ruby_sample.rb
#!/usr/bin/env ruby
require 'net/smtp'
unless (2..3).include? ARGV.length
puts 'Usage: mail.rb SUBJECT TO [FROM]'
exit 1
end
subject, to, from_ = ARGV
@nascimento
nascimento / worker_stress.rb
Created February 12, 2018 01:28
Mult Thread to Stress service with Ruby
require 'mechanize'
require 'open-uri'
require 'rubygems'
require 'work_queue'
wq = WorkQueue.new 1000
(1..5000).each do |number|
#beginning = Time.now
wq.enqueue_b do
git filter-branch --index-filter 'git rm --cached --ignore-unmatch blah.jar' -f --tag-name-filter cat -- --all
git filter-branch --index-filter 'git rm -r --cached --ignore-unmatch folder/' -f --tag-name-filter cat -- --all
@nascimento
nascimento / entry_point.sh
Created October 29, 2018 21:36
Get SSM parameters to ECS
#!/bin/sh
PARAMETERS=`aws ssm get-parameters-by-path --path ${1} --with-decryption`
for row in $(echo ${PARAMETERS} | jq -c '.Parameters' | jq -c '.[]'); do
KEY=$(basename $(echo ${row} | jq -c '.Name'))
VALUE=$(echo ${row} | jq -c '.Value')
KEY=`echo ${KEY} | tr -d '"'`
VALUE=`echo ${VALUE} | tr -d '"'`