Skip to content

Instantly share code, notes, and snippets.

View jeremywadsack's full-sized avatar

Jeremy Wadsack jeremywadsack

View GitHub Profile
@jeremywadsack
jeremywadsack / pg_mem.sh
Last active July 5, 2018 17:57
Metrics of postgres temporary file size and memory use
#!/usr/bin/env bash
# Records a line with the following space-separated fields
# date-time k-pg-tmp-work-mem k-pg-uss k-pg-pss k-pg-rss
cat <(du -sk /data/pgsql/9.5/data/base/pgsql_tmp/) <(/usr/local/bin/smem -u | grep postgres) | paste -s | awk '{print strftime("%FT%TZ") " " $1 " " $6 " " $7 " " $8}'
@jeremywadsack
jeremywadsack / retry_stripe_webhook.rb
Created May 29, 2019 17:37
Retry failed Stripe Webhook events
# frozen_string_literal: true
# Stripe will retry failed webhooks seven times with exponential backoff. If that has been exceeded
# then the webhook event is marked "failed" and won't be retried. We can resend the event by [retrieving
# the event data and posting it to the
# webhook](https://groups.google.com/a/lists.stripe.com/forum/#!topic/api-discuss/N33ZXqp3NzI).
#
# To use this, configure your endpoint URL below, then run this in providing event IDs on the command line.
WEB_HOOK = "YOUR ENDPOINT HERE"
@jeremywadsack
jeremywadsack / duplicate-cross-company.sql
Last active December 14, 2022 05:03
Employees with duplicate phone numbers that are cross-company
select
e.phone_number,
e.name,
e.public_id as employee_public_id,
c.name as company_name,
c.public_id as company_public_id,
d.name as division_name,
d.public_id as division_public_id
from customers_employee e
left join customers_company c on e.company_id = c.id