Skip to content

Instantly share code, notes, and snippets.

View clarkbw's full-sized avatar
Hiring Product Managers!

Bryan Clark clarkbw

Hiring Product Managers!
View GitHub Profile
clarkbw / preview.yml
Last active May 15, 2024 06:19
Ideal GitHub Action for Fly preview w/ Neon database
name: PR Review
# Run this workflow on every PR event. Existing review apps will be updated when the PR is updated.
# Neon branches are created and removed according to PR updates
types: [opened, reopened, synchronize, closed]
runs-on: ubuntu-latest
clarkbw / replace-index.sql
Last active April 12, 2022 22:59
quick postgres SQL for replacing an index
-- get existing index names and SQL definitions
SELECT indexname, indexdef
FROM pg_indexes
WHERE schemaname = 'public' AND tablename = 'table'
ORDER BY indexname;
-- create new tmp index (example)
CREATE INDEX tmp_name_of_the_index ON public.table USING btree (time ASC);
-- drop existing index
DROP INDEX name_of_the_index;
clarkbw / all-up-with-vars.sql
Last active March 8, 2022 20:32
linear regression (trend line) analysis of time series data in postgres SQL (demo)
-- bring all examples together and clean up with some top level variables
WITH vars AS (
SELECT INTERVAL '1 day' AS bucket,
(now() - INTERVAL '3 months') as time_from,
(now() + INTERVAL '1 month') as time_to
-- generate timeline into the past and future
timeline AS (
clarkbw / create_hypertable_migration.rb
Last active February 10, 2022 17:19
A rails migration for creating and reverting a hypertable
class ActionsHypertable < ActiveRecord::Migration[7.0]
def change
@table_name = 'actions'
@time_column = 'created_at'
reversible do |dir|
dir.up do
execute <<-SQL
SELECT create_hypertable('#{@table_name}', '#{@time_column}', if_not_exists => TRUE, migrate_data => TRUE);
SELECT s.schemaname,
s.relname AS tablename,
s.indexrelname AS indexname,
pg_size_pretty(pg_relation_size(s.indexrelid)) AS index_size
FROM pg_catalog.pg_stat_user_indexes s
JOIN pg_catalog.pg_index i ON s.indexrelid = i.indexrelid
WHERE s.idx_scan = 0 -- has never been scanned
AND 0 <>ALL (i.indkey) -- no index column is an expression
AND NOT i.indisunique -- is not a UNIQUE index
AND NOT EXISTS -- does not enforce a constraint
let a = "foo";
let b = 42; // set breakpoint here: debugger shows b == "foo"!
clarkbw / redux-performance-mark.js
Last active February 8, 2024 05:03
A User Timing middleware for redux to create performance markers for dispatched actions
const timing = store => next => action => {
let result = next(action);
return result;
clarkbw /
Last active September 19, 2016 20:54
Instructions for the debugger.html to debug Safari running in the iOS simulator


These are the instructions for getting the debugger.html project to connect to and debug Safari on various platforms.

iOS Simulator (Mac only)


  • Xcode
  • Download and install Xcode from Apple
clarkbw / re-dash-csv.js
Last active December 21, 2016 05:56
re:dash snippet for getting the latest CSV data results from your query
// edit these values
const API_KEY_ID = "9352fd37f2f4ce923932c9c6328829a5be7093ea3d";
const QUERY_ID = 1002;
const YOUR_REDASH = "";
// leave this
const API_KEY = `?api_key=${API_KEY_ID}`;
const RESULT_URL = `${YOUR_REDASH}${QUERY_ID}/results.csv${API_KEY}`;
d3.csv(RESULT_URL, function(data) {
clarkbw / addLineWidget.patch
Created August 26, 2016 21:14
Uses addLineWidget in the debugger.html CodeMirror editor
diff --git a/public/js/components/Editor.css b/public/js/components/Editor.css
index ff6160c..3986f92 100644
--- a/public/js/components/Editor.css
+++ b/public/js/components/Editor.css
@@ -52,6 +52,10 @@
z-index: 0;
} .CodeMirror-linewidget .helpful-message {
+ background-color: yellow;