This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
git diff origin/dev --name-only --diff-filter=ACMRTUXB | xargs rubocop | |
ou | |
git diff my_branch..upstream/dev --name-only --diff-filter=ACMRTUXB |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# imprime uma mensagem | |
puts 'Ola Seccomp!' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# comentário de uma linha | |
puts 'seccomp' # comentário de uma linha | |
=begin | |
comentario | |
com | |
muitas | |
linhas | |
=end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# declaração de variáveis | |
integer = 1 # fixnum | |
float = 1.0 | |
array = [] | |
hash = {} | |
string = 'Olá Seccomp!' | |
symbol = :seccomp | |
range = (1..10) | |
regexp = /one/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if a == 1 | |
puts 'a = 1' | |
end | |
if a == 1 | |
puts 'a = 1' | |
elsif a <= 0 | |
puts 'a <= 0' | |
else | |
puts 'a > 1' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class OperatorOverload | |
def initialize(value = nil) | |
@value = value || 0 | |
end | |
def +(n) | |
puts 'método sobrescrito' | |
@value + n | |
end | |
OlderNewer