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 / 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 / postgres-migrating-from-int-to-bigint.md
Created July 5, 2023 22:49
PostgreSQL: Migrating from INT to BIGINT
@jbranchaud
jbranchaud / gist:bccead47f0e75e145db8
Last active January 25, 2024 21:28
Working With Buffers

Working With Buffers

Me

  • I'm Josh Branchaud
  • I work at Hashrocket
  • Twitter: @jbrancha
  • Github: @jbranchaud

Why talk about buffers?

@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 / switch_pg_server_client_versions.bash
Last active July 6, 2022 17:37
Bash function for switching asdf postgres versions and stopping/starting servers
function switch_pg {
local version_to_run=$1
local currently_running_version=$(psql --no-psqlrc -t -c 'show server_version;' postgres | xargs)
# check if you're erroneously switching to the same version
if [ "$version_to_run" = "$currently_running_version" ]; then
echo "Postgres $version_to_run is already running."
return 1
fi
@jbranchaud
jbranchaud / TestableJavaScript.md
Last active July 15, 2021 12:36
Resources on writing testable JavaScript

Testable JavaScript Resources

Testing JavaScript isn't just a thing you can read about in children's fairy tales.

This is just a scratch pad of everything I find. As the really good resources start to float to the top, I'll transition them to a more permanent GitHub repo.

General