This file contains hidden or 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
fn = "filename" | |
compressed_file_name = "#{fn}.gz" | |
Zlib::GzipWriter.open(compressed_file_name) do |gz| | |
gz.mtime = File.mtime(fn) | |
gz.orig_name = fn | |
gz.write IO.binread(fn) | |
end |
This file contains hidden or 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
# Ao invés de fazer: | |
# dentro de uma iteração | |
h = {} | |
h[:somekey] = {} if h[:somekey].nil? | |
h[:somekey][:otherkey] = [] if h[:somekey][:otherkey].nil? | |
h[:somekey][:otherkey] << item_da_teracao | |
# Teremos um hash: { somekey: { :otherkey => [1, 2, 3, 4] } } |
This file contains hidden or 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
# | |
# ~/app/helpers/combo_helper.rb | |
# | |
# Association => { { id: 1, association: "Coolest" } , { id: 2, association: "Hardest" } } | |
# | |
# Model Class << ActiveRecord::Base | |
# has_many :associations | |
# end | |
# | |
# Use: |
NewerOlder