Skip to content

Instantly share code, notes, and snippets.

def create_customer_leads(posted_data)
customer_leads = []
Array(posted_data).each do |lead_params|
customer_leads << extract_customer_lead(lead_params)
end
customer_leads
end
def extract_customer_lead(lead_params)
AcquisitionClient::CustomerLead.extract_customer_lead(posted_data)
def create_customer_leads(posted_data)
customer_leads = []
if posted_data.is_an? Array
posted_data.each do |lead_params|
customer_leads << extract_customer_lead(lead_params)
end
else
customer_leads << extract_customer_lead(posted_data)
end
customer_leads
def create_customer_leads(posted_data)
customer_leads = []
if posted_data.is_an? Array
posted_data.each do |lead_params|
customer_leads << AcquisitionClient::CustomerLead.extract_customer_lead(lead_params)
end
else
customer_leads << AcquisitionClient::CustomerLead.extract_customer_lead(posted_data)
end
customer_leads
def auth_by_token(email, auth_token)
user = User.find(email: email)
session[:current_user] = user if user && Devise.secure_compare(user.auth_token, auth_token)
end
def show_account_label(account)
c = account.client_list
p = "clients".pluralize
t = c.last.connected_at
d = "#{c.length} #{p}, last connection: #{t.strftime("%H:%M:%S")}"
puts d
end
def show_account_label(account)
clients = account.client_list
description = "#{clients.length} #{"client".pluralize}, " +
"last connection: #{clients.last.connected_at.strftime("%H:%M:%S")}"
puts description
end
def show_account_label(account)
clients = account.client_list
description = "#{clients.length} #{"client".pluralize}, last connection: #{clients.last.connected_at.strftime("%H:%M:%S")}"
puts description
end
def secret_santas(names)
groups = names.map(&:split).group_by(&:last).values.sort_by(&:length).reverse
santas = groups.flatten # list of names, most prolific first
santees = santas.clone.shuffle # random for increased fun
santas.map do |santa|
santee = santees.find { |a| a.last != santa.last }
raise "ran out of matches for #{name}" if santee.nil?
santees.delete santee
@jmmastey
jmmastey / keybase.md
Created December 10, 2014 20:15
keybase.md

Keybase proof

I hereby claim:

  • I am jmmastey on github.
  • I am jmmastey (https://keybase.io/jmmastey) on keybase.
  • I have a public key whose fingerprint is 0252 C9D9 572E 9373 1F4F 7136 3829 BBFE FF20 9056

To claim this, I am signing this object:

@jmmastey
jmmastey / trip_optimizer.rb
Created December 2, 2014 16:28
refactor attempt
class TripOptimizer
attr_accessor :from, :to, :meeting_start, :meeting_end, :meeting_length
def initialize(options = {})
@from = options[:from]
@to = options[:to]
@meeting_start = options[:meeting_start]
@meeting_length = options[:meeting_length]
@meeting_end = meeting_start + meeting_length.hours
end