Skip to content

Instantly share code, notes, and snippets.

View jaymcgavren's full-sized avatar

Jay McGavren jaymcgavren

View GitHub Profile
@jaymcgavren
jaymcgavren / video_join.rb
Last active September 8, 2026 22:30
A Ruby script that uses ffmpeg to concatenate multiple videos into one
#!/usr/bin/env ruby
# Joins videos end to end into one video, in the order they are given. The new
# video is as long as all of them added together. Nothing is cut.
#
# video_join.rb -i intro.mp4 -i gameplay.mp4 -i outro.mp4 whole.mp4
#
# The videos do not have to match. Each one is made the size, shape and frame
# rate of the first, and a video of a different shape gets black bars rather
# than being stretched. A video with no sound is joined with silence, so the
# sound of the others stays lined up with the picture.
@jaymcgavren
jaymcgavren / video_images.rb
Created September 8, 2026 05:56
A Ruby script that uses ffmpeg to overlay images on a video
#!/usr/bin/env ruby
# Lays one or more images over a video. Each image has its own timing, opacity,
# size and position.
#
# Every --image starts a new overlay. Options before the first --image set the
# defaults for all overlays; options after one apply to that overlay only.
#
# video_images.rb --duration 5 \
# -i logo.png -s 0 -x 1 -y 0 --width 200 \
# -i arrow.png -s 3 -d 2 -o 0.5 -x 0.5 -y 0.75 \
@jaymcgavren
jaymcgavren / video_audio_mix.rb
Created September 8, 2026 05:55
A Ruby script that uses ffmpeg to mix an audio track into a video
#!/usr/bin/env ruby
# Mixes a sound file into the sound of a video. Both are heard at once, and the
# video keeps its own length. The sound file must not be longer than the video.
#
# video_audio_mix.rb -a music.m4a gameplay.mp4
# video_audio_mix.rb -a voice.wav --volume 30 gameplay.mp4 narrated.mp4
#
# Both sounds play at their own volume unless --volume lowers the video's sound
# to make room. If the video has no sound of its own, the file becomes its sound.
#
@jaymcgavren
jaymcgavren / video_text.rb
Last active September 8, 2026 05:53
A Ruby script that uses ffmpeg to add one or more text overlays to a video.
#!/usr/bin/env ruby
# Draws one or more text overlays on a video. Each overlay has its own text,
# timing, font, size, alignment and position. Text is white with a black
# outline, and can sit on an optional semi-transparent box.
#
# Every --text starts a new overlay. Options before the first --text set the
# defaults for all overlays; options after one apply to that overlay only.
#
# video_text.rb --font "Pixelify Sans" \
# -t 'New\nGame\nGenie\nCodes' -s 0 -d 2 --box \
@jaymcgavren
jaymcgavren / video_crop.rb
Created September 8, 2026 01:13
A Ruby script that uses ffmpeg to crop a source video
#!/usr/bin/env ruby
# Cuts a rectangle out of a video and writes it as a new video of that size.
# The rest of the picture is thrown away; nothing is scaled or stretched.
#
# video_crop.rb --width 1080 --height 1920 wide-recording.mp4
# video_crop.rb -x 100 -y 40 --width 800 --height 600 clip.mp4 corner.mp4
#
# Sizes and positions are in pixels of the source video. x and y are the top
# left corner of the rectangle; leave either one out and the rectangle is
# centred on that axis. Leave a width or a height out and the whole width or
@jaymcgavren
jaymcgavren / roaming_watermark.rb
Last active September 7, 2026 23:29
A Ruby script that uses ffmpeg to apply a text watermark at random positions on a video
#!/usr/bin/env ruby
# Adds a roaming watermark to a video: the text appears for a few seconds at a
# random spot, disappears, then comes back somewhere else. A mark that moves is
# harder to crop out than one fixed in a corner.
#
# The video is re-encoded at near-lossless quality; the audio is copied untouched.
require "json"
require "optparse"
require "shellwords"
@jaymcgavren
jaymcgavren / nes_game_genie_english.txt
Last active August 8, 2026 00:35
8-letter English words that can be spelled on a NES Game Genie
ALIENATE
ALKALINE
ALLUSION
ANALYSES
ANALYSIS
ANNOYING
ANNUALLY
ANTELOPE
ANTENNAE
APOPLEXY
@jaymcgavren
jaymcgavren / zanac_claude_log.txt
Created July 18, 2026 05:39
Describing Zanac (NES) map "scripting" using Claude Code
❯ You seem to have discovered a lot about the map "scripting" in Zanac. E.g. @tools/decode_mapscript.py . Can you summarize what the
script for the first area does for me?
⏺ Here's the area‑1 script (bank5 $A411, decoded with tools/decode_mapscript.py; commands documented at src/bank7.asm:4617
MapScriptExecCmd).
How to read it
The script is paced by map distance $A2/$A3 — one unit per generated map row, not per frame. At the default 2.0 px/frame scroll, ~4
frames per row. Each command fires when distance reaches its trigger, so everything below is at a fixed position in the level, never
@jaymcgavren
jaymcgavren / perplexity_perplexed_mario.md
Created June 8, 2026 00:46
In which Perplexity.ai repeatedly contradicts itself

Q:

in super mario bros for the nes, are walking, running, and jumping speeds identical for both small mario and super mario?

A:

No, the speeds are not identical — small Mario and Super Mario have the same walking, running, and jumping speeds in the original NES Super Mario Bros., but there is one critical difference: small Mario dies on any enemy touch, while Super Mario shrinks to small Mario first.

Let me verify this more specifically about the actual speed mechanics:

@jaymcgavren
jaymcgavren / claude_log.txt
Last active May 31, 2026 07:39
Make it harder for Claude Code to mark private GitHub repos as public.
❯ make the `foobar` repo public
⏺ Let me check the current state of the foobar repo before changing its visibility.
⏺ Bash(gh repo view foobar --json visibility,name,owner)
⎿  {
"name": "foobar",
"owner": {
… +5 lines (ctrl+o to expand)