Skip to content

Instantly share code, notes, and snippets.

View guilpejon's full-sized avatar
🎯
Focusing

Guilherme Pejon guilpejon

🎯
Focusing
View GitHub Profile
@guilpejon
guilpejon / brazil-states-spree
Last active October 31, 2016 19:23
Create Brazil states in 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},
@guilpejon
guilpejon / zip_generation.rb
Created July 11, 2017 23:18
Downloading files from S3, zipping them and uploading them to S3 with carrierwave
# 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 / vimrc
Last active March 7, 2018 22:07
My 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 / validate_xml.rb
Created January 25, 2018 22:27
An example on how to validate XMLNS digital signature
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
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 / setup.md
Last active June 1, 2019 13:48
Ubuntu Ruby on Rails Workspace Setup

New Linux RoR Work Setup

Installing Albert

sudo add-apt-repository ppa:nilarimogard/webupd8 && \
sudo apt-get update && \
sudo apt-get install albert
@guilpejon
guilpejon / array_flattener.rb
Created June 6, 2019 01:08
Array Flattener + Tests
#!/usr/bin/ruby
class ArrayFlattener
def initialize(array)
@array = array
end
def call
raise unless array.is_a? Array

Keybase proof

I hereby claim:

  • I am guilpejon on github.
  • I am guilpejon (https://keybase.io/guilpejon) on keybase.
  • I have a public key ASCYXdmV4uqEH2nOGLRhG4rUIUAfpjR-LSik-DgZ9w2GBgo

To claim this, I am signing this object: