Skip to content

Instantly share code, notes, and snippets.

View humphriesjm's full-sized avatar

Jason Humphries humphriesjm

View GitHub Profile
Traceback (most recent call last):
File "/tmp/runscript.py", line 207, in <module>
download_and_install(args.extra_py_files, timeout=time_out)
File "/tmp/runscript.py", line 137, in download_and_install
download_from_s3(s3_file_path, local_file_path)
File "/tmp/runscript.py", line 165, in download_from_s3
retry(_download_from_s3, s3, bucket_name, s3_key, new_file_path, exceptions=TimeoutError, message="downloading {} from s3".format(s3_script_location))
File "/tmp/runscript.py", line 35, in retry
return func(*func_args)
File "/tmp/runscript.py", line 164, in _download_from_s3
@humphriesjm
humphriesjm / listing_proof_for_agent.rb
Last active May 23, 2019 19:22
Show listings that happened for a given agent
# ----------------------------------------------
# SHOW LISTINGS THAT HAPPENED FOR A GIVEN AGENT
# ----------------------------------------------
# 1. given an agent, how many listings did they have since the beginning of the year?
# 2. for each listing, show the contact's name, address, star rating, and date the listing was first detected
def show_listings_proof(user_id, since_date=Time.now.beginning_of_year)
puts "agent_name,contact_name,address,city,state,max_star_rating_in_12_months_prior_to_listing,max_star_rating_date,date_of_listing"
if user_id.nil?
# no user_id -> show for ALL USERS
@humphriesjm
humphriesjm / campaign_recipients_send_push.rb
Created May 22, 2019 14:53
Send pushes to all who received a campaign tile and didn't dismiss it
# -------------------------------------------------------------
# SEND PUSHES TO ALL WHO RECEIVED A TILE AND DIDN'T DISMISS IT
# -------------------------------------------------------------
# `days_threshold` should be just more than 1 cycle of the campaign's delivery time. example: if a campaign is sent each tuesday, and it's the following tuesday, set `days_threshold` to 8
def send_pushes_to_recipients_of_campaign(campaign_id, days_threshold=8)
message = "📈 Rising Seller Scores 📈 Set a Next Step for 1 of these high priority contacts and you're sure to stay on top of your follow up."
push_name = "increasing_sscores_1wk_nudge"
date_name = "05_22_2019"
@humphriesjm
humphriesjm / listings_proof.rb
Last active May 22, 2019 17:15
Listings in agents' networks & Predicted (starred) contacts who listed
# 1. given a brokerage (or all users), how many listings did each agent have?
# 2. from those listings, how many did First "predict"?
# 3 star over the last 12 months = predicted
def show_listings_proof(brokerage_name=nil, since_date=Time.now.beginning_of_year)
show_listings_counts_per_agent_for_brokerage(brokerage_name, since_date)
end
def show_listings_counts_per_agent_for_brokerage(brokerage_name, since_date)
if brokerage_name.nil?
@humphriesjm
humphriesjm / recommended_starred_contacts.rb
Created May 13, 2019 20:10
Number of starred contacts presented in recommendations
@humphriesjm
humphriesjm / complete_contacts.rb
Created May 13, 2019 20:07
Complete Contacts by Agent
SUPPORTED_ASSOCIATIONS = [:email_addresses, :names, :phone_numbers, :properties]
def ids_of_complete_contacts_for(user, without: [])
without = Array(without)
with = SUPPORTED_ASSOCIATIONS - without
# all contacts
q = user.contacts
# for associations we want to verify, add a WHERE EXISTS query for it
with.each do |assoc|
q = add_subquery(q, assoc, user, exists: true, user_sourced: false)
Verifying my identity on Peepeth.com 0x1c2c3150e1c5eac41e8aad7039ecb51b669d7331
@humphriesjm
humphriesjm / eleven.swift
Last active November 2, 2017 17:02
Number of times digits add up to eleven
import Foundation
func sumOfDigits(_ n: Int) -> Int {
guard n > 0 else { return 0 }
let nString = String(n)
let nArray = Array(nString)
var sumOfInts = 0
for item in nArray {
if let itemInt = Int(String(item)) as? Int {
sumOfInts += itemInt
Verifying that "humphriesjm.id" is my Blockstack ID. https://onename.com/humphriesjm
0x6108D91F9d90647e1Bd7A415a2AEB9A694FE8Bfe