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
Arrays | |
# http://stackoverflow.com/questions/7857019/rails-remove-element-from-array-of-hashes | |
filtered_array = array.reject { |h| blacklist.include? h['email'] } | |
filtered_array = array.select { |h| !blacklist.include? h['email'] } | |
# Hstore Tips and Tricks | |
# Sort based on the Hstore data: | |
2.1.1 :022 > Post.order("data->'hello' DESC") |
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
[ | |
{ | |
"hierarchy1": "Bank Fees", | |
"hierarchy2": "", | |
"hierarchy3": "", | |
"plaid_transaction_category_id": 10000000, | |
"Inflows": "operating_expenses", | |
"Outflows": "operating_expenses", | |
"": 0 | |
}, |
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
attachments: parent_id, asset_id | |
domain_names: organisation_id | |
event_memberships: user_id, event_id | |
events: editor_id | |
group_actions: user_id, group_id | |
groups: user_id | |
icons: parent_id | |
invitations: sender_id | |
legacy_actions: item_upon_id | |
news_items: author_id |
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
#from http://brettu.com/category/rails/page/2/ | |
@photos = Photo.all | |
count = @photos.count | |
@photos.each_with_index do |photo, idx| | |
# ... do a bunch of processing | |
puts "#{(100.0 * idx / count).round(2)}%" | |
end | |
# When the script is run we will get a percentage complete counter like: | |
#=> 0.1% |
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
puts "Populate Nickname table" | |
# Processes file in CSV format from http://code.google.com/p/nickname-and-diminutive-names-lookup/ | |
puts "Truncating nicknames table" | |
Nickname.delete_all | |
puts "Downloading nicknames CSV file from http://code.google.com/p/nickname-and-diminutive-names-lookup/" | |
file = Net::HTTP.get 'nickname-and-diminutive-names-lookup.googlecode.com', '/files/names1.2.csv' | |
puts "Done" | |
puts "Parsing file" |
NewerOlder