Skip to content

Instantly share code, notes, and snippets.

🎯
Focusing

Guilherme Pejon guilpejon

🎯
Focusing
Block or report user

Report or block guilpejon

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@guilpejon
guilpejon / array_flattener.rb
Created Jun 6, 2019
Array Flattener + Tests
View array_flattener.rb
#!/usr/bin/ruby
class ArrayFlattener
def initialize(array)
@array = array
end
def call
raise unless array.is_a? Array
@guilpejon
guilpejon / setup.md
Last active Jun 1, 2019
Ubuntu Ruby on Rails Workspace Setup
View setup.md

New Linux RoR Work Setup

Installing Albert

sudo add-apt-repository ppa:nilarimogard/webupd8 && \
sudo apt-get update && \
sudo apt-get install albert
View gist:fe921a99d8bd7c77ee6badfac008994c
sudo add-apt-repository ppa:nilarimogard/webupd8
sudo apt-get update
sudo apt-get install albert
wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | sudo apt-key add -
echo 'deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main' | sudo tee /etc/apt/sources.list.d/google-chrome.list
sudo apt-get update
sudo apt-get install google-chrome-stable
sudo add-apt-repository ppa:jonathonf/vim
@guilpejon
guilpejon / validate_xml.rb
Created Jan 25, 2018
An example on how to validate XMLNS digital signature
View validate_xml.rb
require "nokogiri"
require "openssl"
require "base64"
C14N = Nokogiri::XML::XML_C14N_EXCLUSIVE_1_0
SHA_MAP = {
1 => OpenSSL::Digest::SHA1,
256 => OpenSSL::Digest::SHA256,
384 => OpenSSL::Digest::SHA384,
512 => OpenSSL::Digest::SHA512
View vimrc
"Use Vim settings, rather then Vi settings (much better!).
"This must be first, because it changes other options as a side effect.
set nocompatible
" ================ General Config ====================
"load pathogen managed plugins
call pathogen#infect()
set number "Line numbers are good
set backspace=indent,eol,start "Allow backspace in insert mode
@guilpejon
guilpejon / zip_generation.rb
Created Jul 11, 2017
Downloading files from S3, zipping them and uploading them to S3 with carrierwave
View zip_generation.rb
# METHOD 1: using output stream
def generate_kit_banco_zip(kit_banco)
s3 = Aws::S3::Resource.new
bucket = s3.bucket(ENV['FOG_DIRECTORY'])
compressed_filestream = Zip::OutputStream.write_buffer do |zos|
file = kit_banco.social_contract_file.file
file_obj = bucket.object(file.path)
zos.put_next_entry("ContratoSocial.#{file.extension}")
zos.print(file_obj.get.body.read)
@guilpejon
guilpejon / brazil-states-spree
Last active Oct 31, 2016
Create Brazil states in spree
View brazil-states-spree
brazil = Spree::Country.find_by(name: "Brasil")
Spree::State.create!(
[{name: "Acre", abbr: "AC", country: brazil},
{name: "Alagoas", abbr: "AL", country: brazil},
{name: "Amapá", abbr: "AP", country: brazil},
{name: "Amazonas", abbr: "AM", country: brazil},
{name: "Bahia", abbr: "BA", country: brazil},
{name: "Ceará", abbr: "CE", country: brazil},
{name: "Espírito Santo", abbr: "ES", country: brazil},
You can’t perform that action at this time.