View cancellable ruby server streamer.rb
This file contains 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 EzConfig | |
class CallInterceptor < GRPC::ClientInterceptor | |
def cancel! | |
@call.instance_variable_get("@wrapped").instance_variable_get("@call").cancel | |
end | |
def server_streamer(request:, call:, method:, metadata:, &block) | |
@call = call | |
yield | |
end |
View service.yaml
This file contains 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
name: landings | |
image: ezcater-landings | |
slack: j-growth | |
deployables: | |
web: | |
type: web | |
port: 3000 | |
command: "bundle exec rails server -p 3000 -b 0.0.0.0" | |
replicas: 2 |
View significance.sql
This file contains 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
create or replace function | |
public.significance(control_size integer, | |
control_conversion integer, | |
experiment_size integer, | |
experiment_conversion integer) | |
returns float | |
stable as $$ | |
from scipy.stats import norm | |
def standard_error(sample_size, successes): |
View rollup.sql
This file contains 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
daily AS ( | |
SELECT | |
experiment_arm.day, | |
experiment_arm.experiment_test, | |
experiment_arm.cumulative_exposures :: INT experiment_cumulative_exposures, | |
experiment_arm.cumulative_order_placed_1 :: INT experiment_cumulative_conversions, | |
control_arm.cumulative_exposures :: INT control_cumulative_exposures, | |
control_arm.cumulative_order_placed_1 :: INT control_cumulative_conversions |
View cumulative results.sql
This file contains 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
cumulative AS ( | |
SELECT | |
DAY, | |
experiment_test, | |
experiment_result, | |
exposures, | |
sum(exposures) | |
OVER ( | |
PARTITION BY experiment_test, experiment_result | |
ORDER BY DAY |
View daily results.sql
This file contains 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
results AS ( | |
SELECT | |
event, | |
experiment_test, | |
experiment_result, | |
day, | |
count(DISTINCT first_exposures.tracking_id) exposures, | |
count(DISTINCT conversions_order_placed_1.tracking_id) order_placed_1, | |
count(DISTINCT conversions_order_placed_1.tracking_id) / | |
count(DISTINCT first_exposures.tracking_id) :: FLOAT conversion_rate |
View exposure and conversion.sql
This file contains 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
WITH first_exposures AS ( | |
SELECT | |
tracking_id, | |
created_at, | |
event, | |
experiment_test, | |
experiment_result, | |
date_trunc('day', created_at) AS day | |
FROM warehouse.events | |
WHERE category = 'experiment' |
View example_event_schema.sql
This file contains 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
CREATE TABLE events ( | |
event_guid CHARACTER VARYING(128), | |
tracking_id CHARACTER VARYING(128), | |
category CHARACTER VARYING(128) encode TEXT255, | |
sub_category CHARACTER VARYING(128), | |
event CHARACTER VARYING(128) encode TEXT255, | |
event_name CHARACTER VARYING(128) encode TEXT255, | |
value_decimal NUMERIC(38, 6), | |
value_string CHARACTER VARYING(255), | |
created_at TIMESTAMP WITHOUT TIME ZONE, |
View churn.sql
This file contains 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
WITH monthly_usage AS ( | |
SELECT | |
user_id, | |
date_part('month', age(created_at, '1970-01-01')) + | |
12 * date_part('year', age(created_at, '1970-01-01')) AS time_period | |
FROM orders | |
WHERE order_state = 'completed' | |
GROUP BY 1, 2 | |
ORDER BY 1, 2) |
View activation funnel.sql
This file contains 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
SELECT | |
date_trunc('day', page.timestamp) | |
count(distinct page.anonymous_id), | |
count(distinct conversions.user_id) | |
FROM pages page | |
JOIN identifies ids | |
LEFT JOIN conversions ON conversions.user_id = identifies.user_id | |
WHERE | |
ids.anonymous_id = page.anonymous_id | |
AND completes.user_id = ids.user_id |
NewerOlder