Skip to content

Instantly share code, notes, and snippets.

View jonhilgart22's full-sized avatar

Jonathan Hilgart jonhilgart22

  • San Francisco
View GitHub Profile
python -m ipykernel install --user --name=jupyter2
replace jupyter2 with the pyenv name
ack -l '(#{Analytics::Snippets::SANITIZED_AGENT_ROOM_LOGS})' | xargs perl -pi -E 's/(#{Analytics::Snippets::SANITIZED_AGENT_ROOM_LOGS})/#{Analytics::Snippets::SANITIZED_AGENT_ROOM_LOGS_REDSHIFT}/g'
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath("sentiment_bootstrap_data.py"))))
# 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
}
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))
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)
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
--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 (
with summary as (
select
identity_email,
identity_name,
company_industry,
company_domain,
company_name,
known_by_user_count,
identity_created_at,
identity_imported_from,
-- 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