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 / 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/|[email protected]:|g' "$config_file"
}
@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
@Justintime50
Justintime50 / resetForm.gs
Created March 1, 2024 00:11
Reset a Google Form's Sheet and Responses
function resetForm() {
deleteAllFormResponses()
resetFormResponseDestination()
}
function resetFormResponseDestination() {
var form = FormApp.getActiveForm();
var formResponsesSheetId = form.getDestinationId();
var spreadsheet = SpreadsheetApp.openById(formResponsesSheetId);
@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 / random_int_of_length.py
Created November 2, 2023 16:43
Create a random integer of a specified length`
import random
n = 36
random.randint(pow(10, n - 1), pow(10, n) - 1)
@Justintime50
Justintime50 / setup-laravel-project.sh
Last active May 6, 2024 17:26
Sets up a Laravel project for the first time.
#!/bin/bash
# shellcheck disable=SC2104
# The following script will setup the project for the first time for local dev
# To run the project after setup, use `docker compose up -d`
set -e
REPO_NAME="$1"
@Justintime50
Justintime50 / lldb-debugging.md
Last active July 9, 2023 21:23
Learn how to debug a program with lldb.

Debugging with LLDB

LLDB is a debugger you can attach to a program to do things like capturing stacktraces. Here is some basic usage:

# Attach to a program (waits for future execution in another terminal)
lldb -n php -w

# continue execution
c