Get some high-level data on our sends table.
select
min(sent_on) as first_date,
max(sent_on) as latest_date,
count(*) as total_records,
count(distinct template) as unique_templates,
count(distinct sent_on) as unique_dates
from
-- let's check what our table looks like | |
-- without bringing in everything | |
select * from email.sends limit 10; | |
select * from email.opens limit 10; | |
-- how many records are in the table? | |
select count(*) | |
from email.sends | |
limit 10; |
Get some high-level data on our sends table.
select
min(sent_on) as first_date,
max(sent_on) as latest_date,
count(*) as total_records,
count(distinct template) as unique_templates,
count(distinct sent_on) as unique_dates
from
with | |
email_data as ( | |
select | |
s.id as send_id, | |
s.template, | |
s.sent_on, | |
o.opened_on, | |
case | |
when opened_on is null then false |
# install: | |
# pip3 install python-gnupg | |
# note - gpg needs to be installed first: | |
# brew install gpg | |
# apt install gpg | |
# you may need to also: | |
# export GPG_TTY=$(tty) |
drop table if exists seq_test; | |
create table seq_test as | |
with | |
dates as ( | |
select | |
0 as id, | |
generate_series( | |
'2017-01-01'::date, |
processing split transactions | |
who | total | each | what | |
tuck | 130 | 14.44 | Groceries | |
tuck | 11 | 1.22 | Uber back from groceries | |
sara | 47 | 7.83 | Dommy doms | |
tuck | 18 | 3.6 | Lyft to smellrose | |
sara | 7 | 2.33 | Uber | |
tuck | 18 | 3.6 | Lyft from santas | |
tuck | 70 | 10.0 | Lunch |
import logging | |
log = logging.getLogger('my-app.aux') | |
def log_this(msg): | |
if isinstance(msg, int): | |
log.debug('{} is an int!'.format(msg)) | |
return None |
from __future__ import division | |
from collections import Counter | |
import itertools | |
import six | |
n_dice = 6 | |
n_sides_per_die = 6 | |
options = range(1, n_sides_per_die+1) |
# How many coin flips does it take to randomly shuffle a list of length N? | |
# My guess is to start with a list of all possible permutations, e.g. | |
# ABC | |
# ACB | |
# BAC | |
# BCA | |
# CAB | |
# CBA |