Skip to content

Instantly share code, notes, and snippets.

View jdwyah's full-sized avatar

Jeff Dwyer jdwyah

View GitHub Profile
SemanticLogger.sync!
SemanticLogger.default_level = :trace # Prefab will take over the filtering
SemanticLogger.clear_appenders!
SemanticLogger.add_appender(
io: $stdout,
formatter: Rails.env.development? ? :color : :json,
filter: Prefab.log_filter
)
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
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
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):
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
cumulative AS (
SELECT
DAY,
experiment_test,
experiment_result,
exposures,
sum(exposures)
OVER (
PARTITION BY experiment_test, experiment_result
ORDER BY DAY
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
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'
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,
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)