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 / printv.cpp
Created November 18, 2023 20:13
C++ :: Templated vector print function
// Credit: @bweinman | C++ Templates and the STL
// printv() iterates a vector, printing space separated elements
template<type T>
void printv(vector<T> &v) {
if(v.empty()) return;
for(T &i : v) cout << i << " ";
cout << endl;
}
@jimdiroffii
jimdiroffii / nmap.sh
Last active July 10, 2024 19:25
inline bash cli command for running nmap, just update host IP
host=10.10.11.224 && ports=$(sudo nmap -p- --min-rate=1000 -T4 $host -Pn | grep ^[0-9] | cut -d '/' -f 1 | tr '\n' ',' | sed s/,$//) && sudo nmap -p $ports -sV -sC $host -Pn -oN 'nmap_tcp.txt'
@jimdiroffii
jimdiroffii / gitclone.ps1
Created June 10, 2024 05:02
Fix "Fatal: early EOF" clone issue with large git repository
# Credit: ingyhere | https://stackoverflow.com/a/22317479/8077665
# Fixes this error during `git clone`
#
# fetch-pack: unexpected disconnect while reading sideband packet
# fatal: early EOF
# fatal: fetch-pack: invalid index-pack output
#
# First, turn off compression:
git config --global core.compression 0
# Next, let's do a partial clone to truncate the amount of info coming down:
@jimdiroffii
jimdiroffii / remove-empty.sh
Created July 1, 2024 19:46
Recursively delete all empty files and directories in a path. Starts as deeply as possible, removes all files first, then the parent directory if empty.
#!/bin/bash
# Recursive Delete - All empty files and directories
# Check if a directory is provided
if [ -z "$1" ]; then
echo "Usage: $0 [directory]"
exit 1
fi
@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)
@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 / 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 / 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 / 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 / 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" }