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,
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 {} | 
| #!/usr/bin/env zsh | |
| # This is a zsh shell script for uploading files to s3 in order to share | |
| # them via email, sms, or similar. The uploaded files are purged from your | |
| # s3 bucket after 30 days so that you don't incur storage costs. After upload | |
| # the public URLs for your files are copied to the clipboard (if you're using | |
| # a mac and have `pbcopy`). The only zsh-specific part of the code is the | |
| # array append/join (I think). You can likely port this to a different shell | |
| # with relative ease. This requires the AWS CLI, AWS credentials (`aws configure`), | |
| # and an existing bucket (see `$BUCKET` below). | 
| #!/bin/sh | |
| dig TXT +short _spf.google.com | \ | |
| tr ' ' '\n'| \ | |
| grep 'include:' | \ | |
| sed 's/include://' | \ | |
| xargs -Ixxx dig TXT +short xxx | \ | |
| tr ' ' '\n' | \ | |
| grep '^ip[46]:' | \ | |
| cut -c5- | |
| # Outputs something like |