Skip to content

Instantly share code, notes, and snippets.

View nascimento's full-sized avatar

Vitor Nascimento nascimento

View GitHub Profile
@nascimento
nascimento / example.go
Created May 6, 2022 21:02
goavro linkedin textual parser UTF-8 ( Golang )
func textualUtf8Resolver(textual []byte) ([]byte, error) {
var t map[string]interface{}
_ = json.Unmarshal(textual, &t)
response, err := json.Marshal(t)
if err != nil {
return nil, err
}
machines=($(docker-machine ls | sed '1d' | awk '{print $1}'))
for i in "${machines[@]}"
do
:
docker-machine ssh $i sudo docker login -u XXXXXXX -p XXXXXXXXXXXXXXX [REGISTRY];
docker-machine ssh $i sudo docker pull [REGISTRY]/[IMAGE]:latest &
done
#!/bin/bash
# relaunch with sudo if we aren't root
if [[ $EUID -ne 0 ]]; then
echo "$0: relaunching as sudo $0 $1 $USER"
sudo "$0" $1 $USER
exit $?
fi
real_user=$USER
@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 '"'`
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 / 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
@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 / .zpreztorc
Created March 15, 2017 13:46
.zpreztorc
#
# Sets Prezto options.
#
# Authors:
# Sorin Ionescu <[email protected]>
#
#
# General
#
@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
### 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"