Skip to content

Instantly share code, notes, and snippets.

@benkuhn
benkuhn / README.md
Last active March 21, 2024 04:43
Migration tool README

$NAME is a language-agnostic tool for managing your Postgres schema, designed to make downtime-free schema changes as easy as possible to develop and run.

High-level overview

$NAME improves database migration ergonomics in five major ways:

  1. It stores previous versions of your schema in source control and auto-generates scaffolding for new migrations by "diffing" them with the current schema. This ensures that your production schema never drifts out of sync from the schema defined by your application.

  2. It automates many recipes for doing tricky migrations like column renames "online," without requiring downtime or a synchronized application deploy. Naive methods of renaming a column require multiple application deploys and costly table rebuilds. $NAME's recipe doesn't require either.

@benkuhn
benkuhn / views.sql
Created June 10, 2020 12:24
Athena view to enrich Cloudfront logs
CREATE OR REPLACE VIEW cloudfront_logs_plus AS
SELECT *,
replace(replace(user_agent, '%25', ' '), '%20', ' ') as user_agent_decoded,
(sc_content_type='text/html' and status = 200 and uri not like '/theme/pages/%') as is_pageview,
(referrer like '%benkuhn.net%' or referrer like '%dvmskfca82zxm.cloudfront.net%') as is_internal_referrer,
(
user_agent like 'Zapier'
or user_agent like 'SimplePie%'
or user_agent like 'Feedbin%'
or user_agent like 'Fever/%'
@benkuhn
benkuhn / slack_watcher.scpt
Created October 15, 2015 05:04
Pop up a notification prompting you to close Slack if it's open
tell application "System Events"
set activeApp to name of first process whose frontmost is true
end tell
if application "Slack" is running and activeApp is not equal to "Slack" then
tell application "Notifications Scripting"
# set show event handler results to true
set event handlers script path to (path to me)
display notification "Slack is running" message "Are you waiting on an @mention?" action button "No" other button "Yes"
@benkuhn
benkuhn / keybase.md
Created June 11, 2014 05:24
Proof of identity on Keybase

Keybase proof

I hereby claim:

  • I am benkuhn on github.
  • I am benkuhn (https://keybase.io/benkuhn) on keybase.
  • I have a public key whose fingerprint is 2CB4 EC24 9AC0 8DA6 83DE 8BD8 9706 BEC4 1F2D 3723

To claim this, I am signing this object: