Skip to content

Instantly share code, notes, and snippets.

View jbranchaud's full-sized avatar

Josh Branchaud jbranchaud

View GitHub Profile
@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 / playwright-platforms.md
Last active June 20, 2023 17:10
Platforms that support running Playwright + Chromium
@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
@jbranchaud
jbranchaud / README.md
Created June 10, 2021 18:51
Change `work_mem` configuration for PostgreSQL Database

Change work_mem configuration for PostgreSQL Database

Let's say you are experiencing a Postgres error that reads like this: "Postgres running out of temp space".

A potential fix to this is adjusting the work_mem value for the database. This will require some tuning to optimize the database for the particular query load that it experiences. So, some trial and error.

Before getting started, you'll want to take note of the specs of your Postgres instance where these errors occur. You'll be interested in both the available RAM and the number of supported connections.

@jbranchaud
jbranchaud / summary.rb
Last active February 21, 2021 18:26
TIL Repo: Generate List of Links For Past Week's TILs
results = `git log HEAD@{'7 days ago'}..HEAD --oneline | sed 's/^\([[:alnum:]]*\) .*$/\1/'`
commit_list = results.split(/\n/).map do |item|
item.split(' ', 2)
end.filter do |sha, commit_message|
commit_message.start_with?('Add ')
end
commit_data = commit_list.map do |sha, commit_message|
diff_tree_result = `git diff-tree --no-commit-id --name-only -r #{sha}`
@jbranchaud
jbranchaud / retry.rb
Created February 8, 2021 23:10
Ruby's rescue exception and retry functionality
def sometimes_fails
puts "Beginning of sometimes_fails"
begin
retries ||= 0
puts "About to do a thing (#{retries})"
raise StandardError if rand(5) != 4
puts "Success!"