Skip to content

Instantly share code, notes, and snippets.

View Justintime50's full-sized avatar

Justin Hammond Justintime50

View GitHub Profile
@Justintime50
Justintime50 / check-db-size.sql
Created November 27, 2024 22:34
Check the size of your database
SELECT
table_name AS `Table`,
table_rows AS `Records`,
ROUND((data_length + index_length) / 1024 / 1024, 2) AS `Size (MB)`
FROM
information_schema.tables
WHERE
table_schema = 'your_db_table'
ORDER BY
`Size (MB)` DESC;
@Justintime50
Justintime50 / colors.scss
Last active November 14, 2024 19:31
Bootstrap 5 Color Palette
// Bootstrap 5 Color Palette
// Docs: https://getbootstrap.com/docs/5.3/customize/color
// Theme colors
$primary: #0d6efd;
$secondary: #6c757d;
$success: #198754;
$info: #0dcaf0;
$warning: #ffc107;
$danger: #dc3545;
@Justintime50
Justintime50 / mass-git-push.sh
Last active October 24, 2024 04:09
Push any changes from each repo in the current directory - great for mass updating repos at once.
#!/bin/bash
# Copy a set of files to each repo in a dir, create a branch, and push to origin
# Requires GitHub CLI: `brew install gh` and must be logged in with `gh auth login`
# GitHub CLI Docs: https://cli.github.com/manual/
MAIN_BRANCH="master"
BRANCH_NAME="ignore_cassette_diffs"
COMMIT_MESSAGE="chore: ignore cassette diffs via gitattributes"
PR_TITLE="$COMMIT_MESSAGE"
@Justintime50
Justintime50 / https-to-ssh-git.sh
Created October 7, 2024 23:07
Replace HTTPS URLs with SSH URLs for your Git repos recursively
#!/bin/bash
# Start from the current directory or specify the root directory as an argument
start_dir="${1:-.}"
process_config() {
local config_file="$1"
echo "Processing $config_file"
sed -i.bak 's|https://github.com/|git@github.com:|g' "$config_file"
}
@Justintime50
Justintime50 / ssh-agent-in-crontab.md
Last active October 4, 2024 05:31
Use Your SSH Agent in a Crontab

Use Your SSH Agent in a Crontab

Getting access to SSH inside a Crontab is often a problem for many as the environment in which your cron runs is not the same as your normal shell. Simply running ssh-add will not allow you to use your SSH Agent inside your crontab. Follow the below guide to setup your crontab to use your ssh-agent:

Usage

  1. Install Keychain.
  2. Add the following to your ~/.zlogin file which will be invoked on each login. This will allow your crontab (and normal shell) to use your ssh keys and bypass needing to punch in your password each time you need SSH. This will also span across multiple sessions and shells.
@Justintime50
Justintime50 / reset-xcode-install.md
Last active September 16, 2024 15:55
Reset Your Xcode Installation on macOS

Reset your Xcode Install on macOS

Having troubles with Xcode or their Command Line Tools? Follow this guide to reset your Xcode instance on macOS and resolve issues such as "No Xcode or CLT version detected!"

1) Check if Xcode is installed

xcode-select -print-path
@Justintime50
Justintime50 / standard-user-owned-brew.md
Last active September 1, 2024 16:11
Use the following commands to setup Hombrew as a standard user getting around needing sudo access for most packages.

Standard User Owned Brew

Use the following commands to setup Hombrew as a standard user getting around needing sudo access for most packages.

NOTE: This still requires an admin to install Homebrew initially. After the ownership change, the standard user can use Homebrew moving forward.

Setup Homebrew for a Standard User

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
@Justintime50
Justintime50 / diagnose-docker-macos.md
Last active August 22, 2024 21:09
Diagnose Docker on macOS

Diagnose Docker on macOS

/Applications/Docker.app/Contents/MacOS/com.docker.diagnose check
@Justintime50
Justintime50 / print-zpl-macos.md
Created August 19, 2024 17:43
Print a ZPL from the CLI on macOS

Print a ZPL from the CLI on macOS

  1. Install the ZPL printer
# 2. Get the list of printers
lpstat -p -d

# 3. Print to the ZPL
lpr -P NAME_OF_PRINTER -o raw path/to/file.zpl
@Justintime50
Justintime50 / clean-docker-container-logs-macos.md
Last active August 8, 2024 06:14
Learn how to clean Docker container logs on macOS

Clean Docker Container Logs on macOS

I searched high and low for a command that worked in 2024 to clean all the Docker container logs on macOS and finally found one that worked:

docker run -it --rm --privileged --pid=host justincormack/nsenter1
truncate -s 0 /var/lib/docker/containers/*/*-json.log