I use psql
a lot when interacting with Postgres databases. I recently
took the time to glam up my ~/.pgsqlrc and the results are pretty 🔥🔥🔥.
Obviously, I have the nord theme there. Anyhoo,
| # Minimal Powerline Prompt for Zsh | |
| # Features: OS icon, directory, git branch, exit status | |
| # No external dependencies | |
| # Powerline characters | |
| local PL_ARROW=$'\uE0B0' # | |
| local PL_ARROW_LEFT=$'\uE0B2' # | |
| local PL_BRANCH=$'\uF126' # | |
| # Colors (matching original p10k rainbow theme) |
| #!/usr/bin/env zsh | |
| # | |
| # gc - Git Clone with Smart Directory Organization | |
| # | |
| # This function clones Git repositories into a well-organized directory structure | |
| # based on the repository's domain, user/org, and name. | |
| # | |
| # USAGE: | |
| # gc <git-url> | |
| # |
I use psql
a lot when interacting with Postgres databases. I recently
took the time to glam up my ~/.pgsqlrc and the results are pretty 🔥🔥🔥.
Obviously, I have the nord theme there. Anyhoo,
| #!/bin/sh | |
| # We expect a single parameter, the URL of the YouTube video | |
| if [ $# -ne 1 ]; then | |
| echo "Usage: $0 <YouTube URL>" | |
| exit 1 | |
| fi | |
| # Get a temp file name | |
| tempfile=$(mktemp) |
| /** | |
| This file shows how to do a perfect matching check in a bipartite graph using PL/pgSQL. | |
| */ | |
| -- Use the pg_temp schema to avoid conflicts with other sessions | |
| SET search_path TO pg_temp; | |
| CREATE EXTENSION IF NOT EXISTS plpgsql; | |
| CREATE TABLE IF NOT EXISTS lhs ( |
| #!/bin/sh | |
| # This shell script will search for all repos matching a | |
| # provided organization and regex. It will list those for | |
| # you and, if you confirm, DELETE YOUR REPOS. 🔥🔥🔥⚠️⚠️⚠️ | |
| # It requires 'gh', the GitHub command line interface. | |
| if [ -z "$1" ] || [ -z "$2" ]; then | |
| echo "Illegal number of parameters $*" | |
| echo "Usage: $0 USER/ORG REGEX" |
| #!/bin/sh | |
| # Create a temprary directory | |
| tmp_dir=$(mktemp -d -t pg-install-XXXXXXXXXX) | |
| printf "Using tmp directory $tmp_dir\n" | |
| # Remove that directory upon exit | |
| trap 'cd && rm -rf -- "$tmp_dir"' EXIT | |
| # Change to tmp dir |
| /* This function loops over all schemas and drops a role's | |
| privileges in those schemas and then drops the role. Call | |
| it like `SELECT drop_role('foo');` where 'foo' is the role | |
| you want to drop. Would be nice to have exception handling | |
| 😎😜 | |
| Inspiration: | |
| https://stackoverflow.com/questions/3023583/how-to-quickly-drop-a-user-with-existing-privileges | |
| */ |
python main.py data.json example.org.| #!/bin/sh | |
| # This file, or contents like below, should be in | |
| # .git/hooks/pre-commit. If you have a YAML file | |
| # with invalid formatting, the commit will be aborted. | |
| # Check formatting of all yaml files. | |
| # Uses yq v4. For v3 use 'r' instead of 'e' | |
| fd -t f --regex '.*\.yaml' -x yq e {} |