Skip to content

Instantly share code, notes, and snippets.

@psiborg
psiborg / distro_checker.sh
Last active February 15, 2025 06:01
Linux Distro Checker
#!/bin/bash
# Log and data files
LOG_FILE="distro_checker.log"
DATA_FILE="distro_versions.txt"
# Source the external distro configuration file
source "./distro_checker_config.sh"
# Function to fetch and extract version information
@psiborg
psiborg / README.md
Last active January 7, 2025 02:59
Huffman compression

Huffman Coding (Variable-Length Encoding)

Huffman coding is a lossless data compression algorithm that assigns shorter binary codes to more frequent characters and longer codes to less frequent characters. This minimizes the overall size of encoded data while ensuring perfect decompression.

How Huffman Coding Works

  1. Analyze Character Frequencies
    • Count how often each character appears in the text.
  2. Build a Huffman Tree
  • Create a binary tree where characters with lower frequency are placed deeper.
@psiborg
psiborg / ren_booklists.ps1
Created January 7, 2025 02:13
Rename all booklist to _booklist_
# Define the target directory
$targetDirectory = "C:\Path\To\Your\Directory"
# Initialize counters for each file type
$counterPDF = 0
$counterTXT = 0
# Process both "booklist.pdf" and "booklist.txt"
foreach ($fileType in @("booklist.pdf", "booklist.txt")) {
Get-ChildItem -Path $targetDirectory -Recurse -Filter $fileType | ForEach-Object {
@psiborg
psiborg / rename_photos.bat
Created December 28, 2024 22:02
Drag-and-drop files from Windows Explorer on to this batch script to rename photos using EXIF data
@echo off
C:\Users\jing\anaconda3\python.exe "C:\Users\jing\AppData\Local\Microsoft\WindowsApps\rename_photos.py" %*
pause
@psiborg
psiborg / rename_file.bat
Last active December 18, 2024 18:06
Drag-and-drop files from Windows Explorer on to this batch script to rename them
@echo off
:: Script to rename files: lowercase and replace spaces with underscores
setlocal enabledelayedexpansion
:: Check if any files were passed
if "%~1"=="" (
echo Usage: Drag and drop files onto this script to rename them.
echo The script will rename files to lowercase and replace spaces with underscores.
pause
exit /b
@psiborg
psiborg / jumpstart.md
Last active November 19, 2024 21:23
Flowchart to jump start a car battery
flowchart TD
    A[Locate Both Cars] --> B[Position Cars Close]
    B --> C[Turn Off Both Cars]
    C --> D[Connect Red Jumper Cable to Dead Battery's Positive Terminal]
    D --> E[Connect Red Jumper Cable to Good Battery's Positive Terminal]
    E --> F[Connect Black Jumper Cable to Good Battery's Negative Terminal]
    F --> G[Connect Black Jumper Cable to Metal Surface on Dead Car]
 G --> H[Start Good Car]
@psiborg
psiborg / clean-tags.sh
Last active November 21, 2024 03:50
Clean FLAC and MP3 tags
#!/usr/bin/env bash
# ============================================================================
# clean-tags.sh
#
# Author: Jim Ing
# Date: 2024-11-19
#
# Description: This script processes audio files (.mp3 and .flac) to remove
# specified metadata tags, displays metadata before and after
# cleaning, and saves the cleaned files in a designated output
@psiborg
psiborg / BGInfo.md
Last active January 22, 2025 01:08
Custom settings and scripts for Sysinternal's BGInfo

BGInfo

%USERPROFILE%\Portable\Sysinternals\BGInfo\Bginfo64.exe .\Configs\BGInfo.bgi /timer:60

%USERPROFILE%\Portable\Sysinternals\BGInfo\Bginfo64.exe .\Configs\BGInfo.bgi /popup /taskbar
@psiborg
psiborg / blockchain.py
Last active October 14, 2024 03:41
Basic blockchain implementation in Python
#!/usr/bin/env python3
# Setup for Raspberry Pi
# pip3 install matplotlib
# Setup for Ubuntu
# sudo apt install python3-pip3
# sudo apt install python3-matplotlib
import hashlib
@psiborg
psiborg / pi_calc.py
Last active October 14, 2024 03:56
Calculate Pi in parallel using Gauss-Legendre, Chudnovsky, and Bailey-Borwein-Plouffe (BBP) algorithms
#!/usr/bin/env python3
# ./pi_calc.py --digits 5000
import decimal
from decimal import Decimal
from math import factorial
import multiprocessing
import time
import argparse