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" |
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
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
[ | |
{ | |
"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
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
window.findAddressFromZip = function(zipcode) { | |
var city, state, zip; | |
zip = zipcode.value; | |
city = ''; | |
state = ''; | |
if (zip.length === 5) { | |
$.ajax({ | |
type: 'POST', | |
url: "http://maps.googleapis.com/maps/api/geocode/json?address=" + zip + "?key=XXXXXXXXXXXXXXXXXXXX", | |
success: (function(_this) { |
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
# Delete many branches with one command | |
git branch | grep 'NXT-7' | xargs git branch -d |
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
require 'fileutils' | |
namespace :spec do | |
def progress name, x, y | |
print "\r #{name}: #{x}/#{y} %6.2f%%" % [x.to_f/y * 100] | |
end | |
def generate_files name | |
kind = name.to_s.singularize | |
collection = Dir.glob Rails.root.join('app',name.to_s,'**','*').to_s |
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
require "net/http" | |
def start_server | |
# Remove the X to enable the parameters for tuning. | |
# These are the default values as of Ruby 2.2.0. | |
@child = spawn(<<-EOC.split.join(" ")) | |
XRUBY_GC_HEAP_FREE_SLOTS=4096 | |
XRUBY_GC_HEAP_INIT_SLOTS=10000 | |
XRUBY_GC_HEAP_GROWTH_FACTOR=1.8 | |
XRUBY_GC_HEAP_GROWTH_MAX_SLOTS=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
select percentage(uniquecount(session), where userAgentName = 'Chrome') as 'Chrome', percentage(uniquecount(session), where userAgentName = 'Firefox') as 'FireFox', percentage(uniquecount(session), WHERE userAgentName='IE') as 'IE' , percentage(uniquecount(session), WHERE userAgentName ='Safari') as 'Safari' from PageView SINCE 600 minutes ago |
OlderNewer