Skip to content

Instantly share code, notes, and snippets.

View gbpereira's full-sized avatar

Guilherme Pereira gbpereira

View GitHub Profile
@gbpereira
gbpereira / spec_helper.rb
Last active May 25, 2022 05:42
Clean up carrierwave's files for rspec. Ruby 2.0, Rails 4.0.2.
Dir["#{Rails.root}/app/uploaders/*.rb"].each { |file| require file }
if defined?(CarrierWave)
CarrierWave::Uploader::Base.descendants.each do |klass|
next if klass.anonymous?
klass.class_eval do
def cache_dir
"#{Rails.root}/spec/support/uploads/cache"
end
@gbpereira
gbpereira / diffcoper.sh
Last active September 17, 2015 16:59
Command to run rubocop on branch modified files
git diff origin/dev --name-only --diff-filter=ACMRTUXB | xargs rubocop
ou
git diff my_branch..upstream/dev --name-only --diff-filter=ACMRTUXB
@gbpereira
gbpereira / filterable.rb
Last active September 8, 2015 12:49 — forked from justinweiss/filterable.rb
Filterable
# Call scopes directly from your URL params:
#
# @products = Product.filter(params.slice(:status, :location, :starts_with))
module Filterable
extend ActiveSupport::Concern
module ClassMethods
# Call the class methods with the same name as the keys in <tt>filtering_params</tt>
# with their associated values. Most useful for calling named scopes from
# imprime uma mensagem
puts 'Ola Seccomp!'
# comentário de uma linha
puts 'seccomp' # comentário de uma linha
=begin
comentario
com
muitas
linhas
=end
# declaração de variáveis
integer = 1 # fixnum
float = 1.0
array = []
hash = {}
string = 'Olá Seccomp!'
symbol = :seccomp
range = (1..10)
regexp = /one/
#!/usr/bin/env ruby
if ARGV.any?
filename = ARGV.shift
content = File.open(filename)
sorted_filename = ARGV.shift || "sorted-#{filename}"
sorted_file = File.new(sorted_filename, 'w')
sorted_file.write(content.sort.join(''))
puts "Done. #{sorted_filename} generated."
else
#!/usr/bin/env ruby
if ARGV.length >= 2
h, m = 0, 0
ARGV.each do |e|
h += e.split(':').first.to_i
m += e.split(':').last.to_i
end
if a == 1
puts 'a = 1'
end
if a == 1
puts 'a = 1'
elsif a <= 0
puts 'a <= 0'
else
puts 'a > 1'
class OperatorOverload
def initialize(value = nil)
@value = value || 0
end
def +(n)
puts 'método sobrescrito'
@value + n
end