Skip to content

Instantly share code, notes, and snippets.

View basperheim's full-sized avatar

Benji Asperheim basperheim

View GitHub Profile
@basperheim
basperheim / create_gifs_macos_screen_record.py
Created November 28, 2025 18:51
Turn macOS Screen Recordings into GIFs and Screenshots
#!/usr/bin/env python3
"""
Batch-convert .mov/.MOV QuickTime videos in the current directory:
1. Find all .mov/.MOV files.
2. For each:
- Convert to MP4 (H.264, no audio, slightly reduced quality).
- Generate a high-quality GIF from the MP4.
- Extract JPEG screenshots from the GIF every 1 second.
- If everything succeeds, delete the original .mov/.MOV file.
@basperheim
basperheim / python-venv-tutorial.md
Last active December 7, 2025 15:24
Ultimate Python Venv Tutorial and Guide

Ultimate Python Venv Tutorial and Guide

This is a practical, opinionated guide to Python virtual environments on POSIX/macOS/Linux with a few Windows notes. It shows the cleanest workflows that don't bite you later: create/activate, install via pip and requirements.txt, run scripts with reliable logging/printing, deactivate/uninstall/remove, common gotchas, when to upgrade pip/setuptools/wheel, and a Zsh prompt that shows the active venv in red. It also explains what a venv does and doesn't do (spoiler: you can still build Go, run Docker, etc.).


Why venvs (in one paragraph)

Python versions and packages vary per project. A venv creates an isolated interpreter + site-packages so each project can pin its own dependencies without polluting system or Homebrew installs. On macOS/Homebrew you usually only have python3 globally; once you activate a venv, you get a project-local python.

@basperheim
basperheim / ollama-reference-guide.md
Last active November 11, 2025 12:43
Ollama: Practical Reference (macOS · Linux · Windows)

Ollama: Practical Reference (macOS · Linux · Windows)

Local LLMs with a Docker-like CLI. This doc shows how to install, run, manage RAM/disk usage, and clean up.

TL;DR (cheat-sheet)

# install (mac)
brew install --cask ollama-app   # or: brew install ollama
@basperheim
basperheim / README.md
Last active October 13, 2025 14:44
Use Python/Vosk to Create Transcripts from Audio Files

Vosk Transcriber (MP3/WAV → Text)

A small Python CLI that transcribes audio using Vosk. If you pass an .mp3, it automatically converts to a 16 kHz mono WAV via ffmpeg and then transcribes. If you pass a .wav, it transcribes directly.


@basperheim
basperheim / README.md
Last active November 4, 2025 13:45
Focused Git diffs for humans and LLMs: prints only meaningful changed files (skips assets/vendor dirs), groups by file with headers, and supports path filtering—perfect for pasting compact context into prompts.

git_diff_filtered — focused diffs for humans and LLMs

A small Bash function that prints only the meaningful parts of your Git diff, skipping asset/vendor directories and binary-ish files. Output is grouped by file with a clear header, making it ideal for quickly reviewing changes or pasting compact, high-signal code context into LLM prompts.

Why

  • Less noise, more signal. Excludes node_modules/, .yarn, .astro, and common binary/extensions by default.
  • LLM-friendly. Keeps diffs tight to save tokens and reduce hallucinations; per-file headers help models understand boundaries.
  • Convenient. One call prints all filtered diffs, or you can narrow to a path.
@basperheim
basperheim / tetris.py
Created August 12, 2025 14:14
Tetris clone written in Python using the Pygame high-level SDL wrapper.
#!/usr/bin/env python3
# Tetris clone in Python + Pygame
# No assets needed. Run: python tetris.py
# Controls:
# Left/Right: move
# Down: soft drop
# Up / X: rotate CW
# Z: rotate CCW
# Space: hard drop
# P: pause
@basperheim
basperheim / README.md
Last active August 5, 2025 21:05
Fast, Flexible Directory Tree & File Preview Tool for Sharing Context with LLMs

detailed_tree.sh

A robust, cross-platform shell function for quickly sharing a directory’s structure and previewing file contents.
Ideal for collaborating with others, sharing context with ChatGPT or other LLMs, or just auditing a codebase without manually sifting through files.


Features

  • Smart Exclusions
@basperheim
basperheim / replace_special_char_markdown.py
Last active November 4, 2025 13:44
Removes special LLM-injected characters from markdown files in order to "normalize" the markdown content.
#!/usr/bin/env python3
import argparse
import os
import sys
import re
# directories to skip entirely
EXCLUDE_DIRS = {'node_modules', 'target', 'bin', '__pycache__', 'build', 'dist'}
MARKDOWN_LINK = re.compile(r'(!?\[.*?\])\((.*?)\)') # matches [text](url) and ![alt](url)
@basperheim
basperheim / search_angular_components.py
Last active July 17, 2025 13:05
Python script that prints Angular custom component methods declared in a component TS file, and also prints how they are used.
import os
import re
import argparse
from collections import defaultdict
# ---------------------------------------------------------
# Step 0: Utility Functions
# ---------------------------------------------------------
def find_parent_method(lines, call_line_num):
"""
@basperheim
basperheim / top-seo-keywords.csv
Created June 30, 2025 15:35
Some Popular SEO Keywords of 2024-25
We can't make this file beautiful and searchable because it's too large.
keyword,searches,visits
Chatgpt,24900000,8092500
chaat gbt,24900000,8092500
chaat gpt,24900000,8092500
chact gpt,24900000,8092500
chadgbt,24900000,8092500
chag gpt,24900000,8092500
chap gpt,24900000,8092500
chast gpt,24900000,8092500
chatb gpt,24900000,8092500