Skip to content

Instantly share code, notes, and snippets.

View jonhilgart22's full-sized avatar

Jonathan Hilgart jonhilgart22

  • San Francisco
View GitHub Profile
with most_recent_subscription as (
select
user_id,
max(created_at) as created_at
from subscriptions s
group by 1
),
weekly_minutes as (
select
date_trunc('month', subscription_started_at) as sub_start_month,
select
a.subscription_created_at::date,
b.cleaned_source,
b.utm_campaign,
count(distinct b.browser_hash) as n_visits,
count(distinct case when w.first_user_created_event_at is not null then b.user_id else null end) as accounts_created,
count(distinct a.user_id) as credit_cards_added
from analytics.browser_hash_hits b
join analytics.acquisition_waterfall_by_browser_hash w
on w.browser_hash = b.browser_hash
select
a.subscription_invitee_credit_minutes,
mm.messager_campaign_category,
mm.messager_campaign_name,
count(distinct a.user_id) as n_users
from analytics.acquisition_credit_card_source_tracking a
join analytics.messager_message_results mm
on mm.user_id = a.user_id
-- email sent before card added
and mm.messager_message_created_at < a.credit_card_added_user_event_at
-- TRAINING ---
with messager_message_and_webpage as (
select
mm.identity_id,
s.created_at as sub_start_date,
-- If the identity has subscribed, what emails did we send to them beforehand?
count(distinct case when mm.messager_message_created_at <= coalesce(s.created_at - '1 day'::interval, getdate() - '3 months'::interval) then mm.messager_message_id else null end) as number_of_emails_sent,
sum(case when mm.messager_message_created_at <= coalesce(s.created_at - '1 day'::interval, getdate() - '3 months'::interval) and mm.email_outbound_link_opened_at is not null then 1 else null end) as number_of_emails_clicked,
sum(case when mm.messager_message_created_at <= coalesce(s.created_at - '1 day'::interval, getdate() - '3 months'::interval) and mm.email_outbound_sendgrid_first_open_at is not null then 1 else null end) as number_of_emails_opened,
sum(case when mm.messager_message_created_at <= coalesce(s.created_at - '1 day'::interval, getdate() - '3 months'::interval) and mm.user_replied_to_m
with summary as (
select
identity_email,
identity_name,
company_industry,
company_domain,
company_name,
known_by_user_count,
identity_created_at,
identity_imported_from,
--ltv for users to call
with most_recent_subscription as (
select
user_id,
max(created_at) as created_at
from subscriptions s
group by 1
),
weekly_minutes as (
I just found a great line to resize images from terminal in mac
`sips -Z 640 *.jpg` The -Z is to maintain aspect ratio 640 is the max width/height
for i in range(1,13):
sample_0_color = cv2.imread('./images/source/online/{}.tif'.format(i))
channels_0 = blue, green, red = np.rollaxis(sample_0_color, 2)
sample_0_color = np.dstack((red, green, blue))
small = cv2.resize(sample_0_color, (0,0), fx=0.15, fy=0.15)
plt.imsave('./images/source/online/{}.jpg'.format(i), small)
from pyspark.sql.types import StringType
from pyspark.sql.functions import udf
maturity_udf = udf(lambda age: "adult" if age >=18 else "child", StringType())
df = sqlContext.createDataFrame([{'name': 'Alice', 'age': 1}])
df.withColumn("maturity", maturity_udf(df.age))
# Delete branches that have been merged
function cleanup-branches {
git checkout master;comm -12 <(git branch | sed "s/ *//g") <(git remote prune origin --dry-run | sed "s/^.*origin\///g") |xargs git branch -D
}