Skip to content

Instantly share code, notes, and snippets.

View Pwuts's full-sized avatar

Reinier van der Leer Pwuts

View GitHub Profile
@Pwuts
Pwuts / clone_schema.sql
Last active April 8, 2025 15:38
SQL script to fully clone a schema and all of its contents in a Postgres DB
-- Drop the schema if it currently exists
DROP SCHEMA IF EXISTS "platform-tmp" CASCADE;
-- Create the new schema
CREATE SCHEMA "platform-tmp";
-- Copy all objects from platform schema to platform-tmp schema
CREATE OR REPLACE FUNCTION clone_schema(source_schema text, dest_schema text) RETURNS void AS
$$
DECLARE
@Pwuts
Pwuts / list-prs-for-path.sh
Last active April 27, 2023 12:52
List pull requests that touch/change a specified file or path
#!/bin/bash
# dependencies: jq, gh
if [ -z "$1" ]; then
echo "Usage: list-prs-for-path PATH [branch]";
echo "Lists all PRs touching files starting with PATH";
exit 1;
fi
@Pwuts
Pwuts / recursive-readonly.ts
Created February 2, 2021 12:26
Typescript RecursiveReadonly utility
export type RecursiveReadonly<T extends object> = Readonly<{
readonly [key in keyof T]:
T[key] extends object
? T[key] extends BigInt | Date | Number | Symbol ? T[key] : RecursiveReadonly<T[key]>
: T[key]
}>