Skip to content

Instantly share code, notes, and snippets.

View jbranchaud's full-sized avatar

Josh Branchaud jbranchaud

View GitHub Profile
@jbranchaud
jbranchaud / explain_analyze_query_plan.json
Created December 6, 2024 02:37
Explain analyze for complex query plan in TEXT, JSON, YAML, and XML formats
[
{
"Plan": {
"Node Type": "Sort",
"Parallel Aware": false,
"Async Capable": false,
"Startup Cost": 25.77,
"Total Cost": 25.78,
"Plan Rows": 1,
"Plan Width": 164,
@jbranchaud
jbranchaud / qtil.go
Created December 5, 2024 00:14
quick TIL file creator
package main
import (
"flag"
"fmt"
"os"
"path/filepath"
"regexp"
"strings"
"time"
@jbranchaud
jbranchaud / send_more_money.rb
Created November 21, 2024 03:47
Send More Money solved with Ruby (brute-force)
# Send More Money
#
# Verbal Arithmetic https://en.wikipedia.org/wiki/Verbal_arithmetic
letters = %i[s e n d m o r y]
check = ->(vals) do
# leading zeros are not allowed
return false if vals[:s] == 0 || vals[:m] == 0
@jbranchaud
jbranchaud / get-email-for-newsletter-signup.js
Created November 20, 2024 17:59
Get email (w/ current site interpolated) for newsletter signup
/** @type {import("@johnlindquist/kit")} */
// Name: Get Email for Newsletter
// Description: Create email address with current domain interpolated
const createEmailWithDomain = (baseEmail, { url }) => {
const [emailUser, emailDomain] = baseEmail.split("@");
const urlObj = new URL(url);
let domain = urlObj.host.split(".");
@jbranchaud
jbranchaud / stored-array.sql
Created March 11, 2024 15:32
User-Defined Ordering in PostgreSQL using Stored Array
-- from the People, Postgres, Data Discord https://discord.com/channels/710918545906597938/710918545906597941/1214677867431206932
CREATE TABLE todo_list (
id INT NOT NULL PRIMARY KEY GENERATED ALWAYS AS IDENTITY,
list_name TEXT NOT NULL,
item_order INT[] NULL
);
CREATE TABLE todo_list_item (
id INT NOT NULL PRIMARY KEY GENERATED ALWAYS AS IDENTITY,
@jbranchaud
jbranchaud / postgres-migrating-from-int-to-bigint.md
Created July 5, 2023 22:49
PostgreSQL: Migrating from INT to BIGINT
@jbranchaud
jbranchaud / markdown-link-active-tab-jxa.js
Created November 18, 2022 01:25
A ScriptKit script for putting a markdown link on your clipboard for the active Chrome tab
@jbranchaud
jbranchaud / close-active-taco-bell-tab.js
Created November 6, 2022 01:51
ScriptKit script to close the active Chrome tab if it is open to Taco Bell
let jxa = await npm("@jxa/run")
let result = await jxa.run(() => {
let app = Application("com.google.Chrome")
let windows = app.windows()
let frontWindow = windows[0]
let tab = frontWindow.activeTab()
let closedTabData = {
id: tab.id(),
@jbranchaud
jbranchaud / markdown-link-active-tab.js
Created November 5, 2022 20:58
A ScriptKit script for putting a markdown link on your clipboard for the active Chrome tab