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
mysqldump -uroot --routines --no-data --quick --opt insight_card_services_development > ~/mysql.sql | |
cat ~/mysql.sql | mysql -uroot insight_card_services_test |
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
>> str = "Snakes on a plane" | |
=> "Snakes on a plane" | |
>> str["Snakes"] = "Farts" | |
=> "Farts" | |
>> puts str | |
Farts on a plane |
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
def search | |
bucket = Person | |
#Narrow our query depending on params sent | |
bucket = bucket.hair_color(params["hair_color"]) unless params["hair_color"].blank? | |
bucket = bucket.enjoys_chunky_bacon(params["chunky_bacon_preference"]) unless params["chunky_bacon_preference"].blank? | |
bucket = bucket.age_between(params["age_lower_limit"], params["age_upper_limit"]) unless params["age_lower_limit"].blank? && params["age_upper_limit"].blank? | |
#This actually does the query, if no params were sent then all people will be returned. | |
@people = bucket.all |
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
class Person < ActiveRecord::Base | |
named_scope hair_color, lambda { |hair_color| { :conditions => ["people.hair_color = ?", hair_color]}} | |
named_scope enjoys_chunky_bacon, lambda { |chunky_bacon_preference| {:conditions => ["people.chunky_bacon_preference = ?", chunky_bacon_prefence]}} | |
named_scope age_between, lambda { |lower_limit, upper_limit| {:conditions => ["people.age BETWEEN ? AND ?", lower_limit, upper_limit]}} | |
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
if transaction_feed.is_pin? && transaction_feed.card.card_account.fee_plan == "Monthly Fee" | |
pin_fee_amount = BigDecimal(transaction_feed.card.store.region.region_setting[:settings]["monthly_plan_pin_fee"]) | |
current_balance -= pin_fee_amount | |
end | |
if transaction_feed.is_pin? && transaction_feed.card.card_account.fee_plan == "Pay as you go" | |
pin_fee_amount = BigDecimal(transaction_feed.card.store.region.region_setting[:settings]["pay_as_you_go_pin_fee"]) | |
current_balance -= pin_fee_amount | |
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
insert_sql << "INSERT INTO negative_balance_reports (bank, agent, store_number, name, ssn, pan, overdraft, their_balance, our_balance, overdraft_limit, account_type) VALUES " | |
@rows.each do |row| | |
insert_sql << "('#{@bank}', '#{row[0]}', '#{row[1]}', '#{row[2].gsub("'","''")}', '#{row[3]}', '#{row[4]}', '#{row[5]}', '#{row[6]}', '#{row[7]}', '#{row[8] == "N/A" ? 0 : row[8]}', '#{row[9]}')," | |
end | |
NegativeBalanceReport.connection.execute(insert_sql.string.chop + ";") |
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
options = {"DOB"=>"2000-01-01", | |
"ValidationQuestion"=>"what is 1 + blue", | |
"PostalRegion"=>"AL", | |
"PostalCity"=>"Birmingham", | |
"IDValue"=>7013088, | |
"SSN"=>"444-44-4444", | |
"IDType"=>1, | |
:pngUser=> | |
{:UserName=>"isotope", :APIKey=>"isotope", :Status=>true, :IsLocked=>false}, | |
"LastName"=>"Gamble", |
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
module Enumerable | |
def each_with_progress(&block) | |
out = STDERR | |
self.each_with_index do |thing,i| | |
out.print sprintf("%s", makeProgress(i,self.count)) + "\r" | |
block.call thing | |
end | |
nil | |
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
module Enumerable | |
def each_with_progress(&block) | |
self.each_with_index do |thing,i| | |
puts makeProgress(i,self.count) | |
block.call thing | |
end | |
nil | |
end | |
protected |
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
def makeProgress(i, t) | |
percent = (Float(i) / Float(t)) * 100 | |
percent = (( percent / 5).round * 5).to_i | |
number_of_bars = percent / 5 | |
progress = "" | |
for g in 0..number_of_bars do | |
progress = progress + "=" | |
end | |
progress = progress + percent.to_s + "%" | |
for s in 0..(20 - number_of_bars) do |