Skip to content

Instantly share code, notes, and snippets.

View jimdiroffii's full-sized avatar
🏠
Working from home

Jim Diroff II jimdiroffii

🏠
Working from home
View GitHub Profile
@jimdiroffii
jimdiroffii / MercuryViewingScript-Miami.ssc
Created April 18, 2025 01:57
A Stellarium script for finding the best date and time for viewing Mercury. The script tries to find when Mercury will be at least 5 degrees above the horizon, at least 0.0 magnitude, and within an hour of sunset or sunrise. The script is centered on Miami, Florida, and set to check for specific dates. Most variables need adjustment to work.
//////////////////////////////////////////////////////////////////////////////
// Stellarium Script: Mercury Twilight Search
// Date Range: Feb 10, 2025 – Apr 30, 2025
// Time Step: 5 minutes
// Location: Miami (lat: 25.7617, lon: -80.1918), ignoring DST complexities.
//////////////////////////////////////////////////////////////////////////////
// ------------------------ USER CONFIGURATION ------------------------
// Observing location
@jimdiroffii
jimdiroffii / wheelhouse.sh
Last active April 18, 2025 04:53
Maintain a Python wheelhouse across different machines. I'm using this for VM data disks, where the VM is only used on one host at a time, and the data disk is transferred between hosts.
#!/bin/bash
set -euo pipefail
IFS=$'\n\t'
# Path to the data disk
DATA_DISK="/mnt/data"
WHEELHOUSE_PATH="$DATA_DISK/wheelhouse"
PIP_CONF_PATH="$DATA_DISK/pip/pip.conf"
mountpoint -q "$DATA_DISK" || { echo "Error: $DATA_DISK not mounted"; exit 1; }
@jimdiroffii
jimdiroffii / update-links.sh
Created April 17, 2025 17:29
Find all symlinks and change their link path
@jimdiroffii
jimdiroffii / lowercase-rename.sh
Created April 16, 2025 17:21
Rename all files in a directory to its lowercase equivalent, skip if a duplicate filename already exists
#!/usr/bin/env bash
# Just comment this out to run the script within the target directory.
cd /mnt/example || exit 1
for f in *; do
lower="$(echo "$f" | tr '[:upper:]' '[:lower:]')"
if [[ "$f" != "$lower" ]]; then
if [[ -e "$lower" ]]; then
@jimdiroffii
jimdiroffii / CreateHTTPStatusFolders.ps1
Created March 19, 2025 18:48
Create a full list of HTTP Status Codes as folders using Powershell
$httpStatusCodes = @(
@{ Code = "100"; Description = "Continue" }
@{ Code = "101"; Description = "Switching Protocols" }
@{ Code = "102"; Description = "Processing" }
@{ Code = "103"; Description = "Early Hints" }
@{ Code = "200"; Description = "OK" }
@{ Code = "201"; Description = "Created" }
@{ Code = "202"; Description = "Accepted" }
@{ Code = "203"; Description = "Non-Authoritative Information" }
@{ Code = "204"; Description = "No Content" }
@jimdiroffii
jimdiroffii / countdown.js
Created March 15, 2025 22:02
Use javascript to countdown to a specific date, produce a message, and reset to the following year after the date. Replace `<tag>`s.
// Replace:
// <event> for the event name, no spaces (FirstLetterCapitalized)
// <month> for month number (January is 0)
// <day> for day number
function updateCountdown() {
const now = new Date();
const currentYear = now.getFullYear();
// Check if today is <month>.<day>
if (now.getMonth() === <month> && now.getDate() === <day>) {
@jimdiroffii
jimdiroffii / MakePowerShellRememberSSHPassphrase.md
Created September 27, 2024 16:52 — forked from danieldogeanu/MakePowerShellRememberSSHPassphrase.md
How to make Powershell remember the SSH key passphrase.

You should not use the Open SSH client that comes with Git for Windows. Instead, Windows 10 has its own implementation of Open SSH that is integrated with the system. To achieve this:

  1. Start the ssh-agent from Windows Services:
  • Type Services in the Start Menu or Win+R and then type services.msc to launch the Services window;
  • Find the OpenSSH Authentication Agent in the list and double click on it;
  • In the OpenSSH Authentication Agent Properties window that appears, choose Automatic from the Startup type: dropdown and click Start from Service status:. Make sure it now says Service status: Running.
  1. Configure Git to use the Windows 10 implementation of OpenSSH by issuing the following command in Powershell:
git config --global core.sshCommand C:/Windows/System32/OpenSSH/ssh.exe
@jimdiroffii
jimdiroffii / rsyncssh.sh
Created August 25, 2024 03:55
Rsync over SSH - syncronize folders with delete option and perform a dry run
# Dry Run (-n)
rsync -avzn --delete -e ssh user@remote_host:/path/to/remote/folder/ /path/to/local/folder/
# Sync
rsync -avz --delete -e ssh user@remote_host:/path/to/remote/folder/ /path/to/local/folder/
@jimdiroffii
jimdiroffii / copy.ps1
Created July 9, 2024 04:45
PowerShell script to copy picture files, works for any file type, good for archiving stuff from a backup or drive dump
# PowerShell script to copy picture files
# Source and destination directories
$sourceDir = "C:\tmp\drivedump"
$destDir = "C:\tmp\picbackup"
# Check if destination directory exists, if not, create it
if (!(Test-Path -Path $destDir)) {
New-Item -ItemType Directory -Path $destDir
}
@jimdiroffii
jimdiroffii / pig.py
Created July 3, 2024 23:45
Python Image Generator - Useful for generating text into images, testing template injection attacks
from PIL import Image, ImageDraw, ImageFont
def main():
# Define image size (x,y) in pixels
img = Image.new('RGB', (2000,100))
draw = ImageDraw.Draw(img)
# Choose an easily readable font for OCR
myFont = ImageFont.truetype('LiberationMono-Regular.ttf', 15)