Skip to content

Instantly share code, notes, and snippets.

@arush
arush / vidtogif.sh
Last active August 29, 2015 14:24 — forked from imkevinxu/vidtogif.sh
# Convert an animated video to gif
# Works best for videos with low color palettes like Dribbble shots
#
# @param $1 - video file name like `animation.mov`
# @param @optional $2 - resize parameter as widthxheight like `400x300`
#
# Example: vidtogif animation.mov 400x300
# Requirements: ffmpeg and gifsicle. Can be downloaded via homebrew
#
# http://chrismessina.me/b/13913393/mov-to-gif
@arush
arush / gist:8e4592ccba4d42522200
Last active March 9, 2016 06:48
Cohort Queries
-- invoices
SELECT
u.id AS user_id,
uuid_timestamp(i.id)::DATE AS dt,
sum(i.balance) AS inc_amt
FROM public.users u
JOIN public.invoices i ON u.id = i.user_id
WHERE
u.fraud_score != 'F'
AND uuid_timestamp(i.id) > DATE '2015-06-30'
with
dau as (
-- This part of the query can be pretty much anything.
-- The only requirement is that it have three columns:
-- dt, user_id, inc_amt
-- Where dt is a date and user_id is some unique identifier for a user.
-- Each dt-user_id pair should be unique in this table.
-- inc_amt represents the amount of value that this user created on dt.
-- The most common case is
-- inc_amt = incremental revenue from the user on dt