Skip to content

Instantly share code, notes, and snippets.

View Justintime50's full-sized avatar

Justin Hammond Justintime50

View GitHub Profile
@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
@Justintime50
Justintime50 / justmakefiles.py
Last active March 4, 2024 22:46
Make Justfiles out of Makefiles
import os
def main():
makefile_path = os.path.join(os.getcwd(), "Makefile")
with open(makefile_path, "r") as makefile:
content = makefile.readlines()
new_content = ""
@Justintime50
Justintime50 / event_handler_example.py
Last active June 14, 2023 22:03
An example of how to setup event handlers in Python
import requests
class Event:
"""An Event that gets triggered when an HTTP event occurs."""
def __init__(self):
self._event_handlers = []
def __iadd__(self, handler):
@Justintime50
Justintime50 / working-with-branches.md
Last active October 3, 2022 16:58
Learn about various operations of a Git branch

Working with Git Branches

This document contains various operations you can use when working with Git branches such as moving commits, updating branch names, creating branches from a tag, etc.

Move a Commit to Another Branch

New Branch

git branch newbranch