Skip to content

Instantly share code, notes, and snippets.

View sushidub's full-sized avatar

jgraston sushidub

View GitHub Profile
@sushidub
sushidub / MakeVSCodeWorkspace.sh
Last active August 19, 2021 23:04
Convert a directory into a VSCode workspace from the macOS command line
#!/usr/bin/env bash
# Convert a directory into a VSCode workspace from the macOS command line
# Usage
# 1. `cd` into a directory containing all the files you'd like to capture within a VSCode workspace
# 2. run `$ MakeVSCodeWorkspace`
# 3. the command will print the following json snippet in a new .code-workspace file
# using the name of the current directory for both the name of the newly created workspace file
# and the 'path' value within
@sushidub
sushidub / bash_strict_mode.md
Created December 12, 2021 15:03 — forked from maxisam/bash_strict_mode.md
set -e, -u, -o, -x pipefail explanation

set -e, -u, -o, -x pipefail

The set lines

  • These lines deliberately cause your script to fail. Wait, what? Believe me, this is a good thing.
  • With these settings, certain common errors will cause the script to immediately fail, explicitly and loudly. Otherwise, you can get hidden bugs that are discovered only when they blow up in production.
  • set -euxo pipefail is short for:
set -e
set -u
@sushidub
sushidub / sqlite_query.sh
Last active July 19, 2022 19:21
Quickly query, update, insert, or delete items within a locally owned sqlite database. Simple, fast, and user friendly. Avoids the sqlite cli. Zero syntax.
#!/bin/bash
#
# @note: WIP!!
# @desc: Quickly perform a series of simple CRUD type actions i.e., query, update, insert, delete
# against a locally owned sqlite database. Assumes one standard integer based 'id' column.
# Optional SQLITE_DB, SQLITE_TBL, SQLITE_INDEX env variables replace the -db, -t, and -c flags
# @why: Because I use several sqlite db's and frequently query and/or update them. I finally got sick of
# invoking the sqlite cli, typing sensitive slq syntax, and wanted to build or use something super
# simple without relying on but Bash functionality.
#