Skip to content

Instantly share code, notes, and snippets.

View petergi's full-sized avatar
💭
Just Busy Living On The Side Of A Square

Peter Giannopoulos petergi

💭
Just Busy Living On The Side Of A Square
View GitHub Profile
@petergi
petergi / Dark Mode for the operating system Light Mode for cognition-heavy tools.md
Created January 22, 2026 15:17
Ergonomically sound and backed by actual usability research — bright reading surfaces reduce eye strain for dense text, even when the surrounding UI is dark.

All right Peter — let’s make this boringly reliable, the way infrastructure should be.

There are three sane ways to keep per-app light mode enforced on modern macOS. They differ mainly in how “enterprise” you want to get.

I’ll walk from simplest → most robust, with opinions included at no extra charge.


Option 1 — Login script (best balance of power vs simplicity)

@petergi
petergi / ebook_auditor.py
Last active January 20, 2026 19:03
Total Library Portability: We now have a searchable terminal tool, readable Markdown reports, and a raw data CSV file. Best Practice Tip for CSVs: Once you open library_data.csv in Excel: Select all data (Ctrl+A). Insert > Table. Use the Filter arrows on the "Reason" or "Ext" columns to quickly see only your largest files or only your .mobi books.
"""
EBOOK AUDIT CENTER (V9 - CSV EXPORT & PORTABILITY)
===================================================
OVERVIEW:
A professional-grade ebook auditor and cataloger.
This version adds the ability to export your data for use
in spreadsheet software like Excel or Google Sheets.
FEATURES:
@petergi
petergi / Git Bisect.md
Created January 19, 2026 14:38
git bisect is Git’s built-in “binary search” wizard for hunting down which exact commit introduced a bug.

git bisect is Git’s built-in “binary search” wizard for hunting down which exact commit introduced a bug.

Instead of you guessing and checking commits one-by-one like a caveman with a keyboard, git bisect repeatedly checks out a commit halfway between a known-good state and a known-bad state. You test that commit, tell Git “good” or “bad,” and it halves the search space again. In about log₂(N) steps, you land on the first bad commit.

When you use it • A bug exists now (bad) • You know a point in history where it didn’t exist (good) • You want the first commit that made it break

Typical workflow (manual testing)

# Try to show the contents of docs/ from the master branch.
# - git show works for files, but may fail for directories.
# - Suppress errors and limit output to 20 lines.
# - If that fails, fall back to listing files under docs/ instead.
# - Always show only the first 20 results to keep output predictable.
git show master:docs/ 2>/dev/null | head -20 \
|| git ls-tree -r master --name-only | grep '^docs/' | head -20
@petergi
petergi / Remove References in Git Branches.sh
Created December 14, 2025 05:53
Find and remove text from your branches. Just update the files you're targeting. e.g. md, txt, py, go, cs, etc... And of course the text your want to find and clean.
#!/bin/bash
# clean-branch-references.sh
# Branches to clean
BRANCHES=("master" "original" "go-version")
for branch in "${BRANCHES[@]}"; do
echo "Cleaning branch: $branch"
git checkout $branch
@petergi
petergi / Searching Through Git Branches.sh
Created December 14, 2025 05:40
Search through Git branches for particular text. In this case I am looking at reference to Anthropic or Claude.
# Search in files across all branches
git grep -i "claude\|anthropic\|generated with.*claude\|co-authored-by.*claude" $(git rev-list --all) -- ':(exclude)go.sum' ':(exclude)go.mod' | head -50
# Search in commit messages
git log --all --grep="Claude\|Generated with\|Co-Authored" --oneline
# Search for specific patterns in current branch
grep -r "Claude Code\|Co-Authored-By: Claude\|🤖 Generated" . --exclude-dir=.git --exclude-dir=build
@petergi
petergi / 90° Counter-Clockwise Image Rotation Script.py
Created December 13, 2025 23:36
This Python script walks a directory, finds images, and rotates any portrait-oriented image 90° counter-clockwise so it becomes landscape. # Landscape images are left alone. It also respects EXIF orientation, which saves you from the classic “why is this one upside down?” ritual.
from PIL import Image, ImageOps
import os
IMAGE_EXTENSIONS = (".jpg", ".jpeg", ".png", ".tiff", ".bmp")
def rotate_portrait_images(directory):
for filename in os.listdir(directory):
if not filename.lower().endswith(IMAGE_EXTENSIONS):
continue
@petergi
petergi / rename_pdfs.py
Created October 7, 2025 20:42
PDF file renaming utility based on metadata.
#!/usr/bin/env python3
"""PDF file renaming utility based on metadata."""
import os
import re
from PyPDF2 import PdfReader
def get_pdf_metadata(pdf_path):
"""
#!/usr/bin/env python3
"""
The Python script extracts metadata (title and author) from EPUB files and renames them based on the extracted information.
:param epub_path: The `epub_path` parameter in the `get_epub_metadata` function is the file path to the EPUB file from which you want to extract the title and author metadata. You should provide the full path to the EPUB file as a string when calling this function. For example, if
:return: Defines a Python script that extracts metadata (title and author) from EPUB files and renames the files based on this metadata. The `get_epub_metadata` function extracts the metadata from an EPUB file and returns a dictionary containing the title and author. The `rename_epubs` function renames EPUB files in a specified directory based on the extracted metadata.
"""
import os
import re
import xml.etree.ElementTree as ET
@petergi
petergi / RickRollQuickie
Created September 3, 2025 20:58
Never gonna give you up...
curl -sL https://raw.githubusercontent.com/keroserene/rickrollrc/master/roll.sh | bash