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 / 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
Last active August 6, 2025 01:41
Rsync over SSH - synchronize 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)
@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 / 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 / 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 / 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 / quicksort.c
Created November 5, 2023 22:58
K&R Recursive Quicksort in C
/* Pg. 87 - The C Programming Language (2nd Ed) - Recursive Quicksort */
/* qsort: sort v[left]..v[right into increasing order */
void qsort(int v[], int left, int right)
{
int i, last;
void swap(int v[], int i, int j);
if (left >= right) /* do nothing if array contains */
return; /* fewer than two elements */
@jimdiroffii
jimdiroffii / ElapsedTime.cpp
Last active November 2, 2023 00:30
Calculate elapsed time in C++ program using chrono with high resolution and precision
#include <iostream> // cout
#include <iomanip> // fixed, setprecision
#include <chrono> // time library
{
auto startTime = std::chrono::high_resolution_clock::now();
/* work */
auto endTime = std::chrono::high_resolution_clock::now();