Skip to content

Instantly share code, notes, and snippets.

View ryanfb's full-sized avatar

Ryan Baumann ryanfb

View GitHub Profile
@ryanfb
ryanfb / truth-social.patch
Created April 16, 2024 15:39
Diff of current Truth Social code release against previous 2022 code release
This file has been truncated, but you can view the full file.
diff -ru truth-old/opensource/.buildpacks truth-new/opensource/.buildpacks
--- truth-old/opensource/.buildpacks 2022-06-08 09:15:38
+++ truth-new/opensource/.buildpacks 2024-04-01 14:59:13
@@ -1,3 +1,3 @@
https://github.com/heroku/heroku-buildpack-apt
https://github.com/Scalingo/ffmpeg-buildpack
-https://github.com/Scalingo/ruby-buildpack
+https://github.com/heroku/heroku-buildpack-ruby
Only in truth-new/opensource: .bundle
Only in truth-new/opensource: .circleci
@ryanfb
ryanfb / transcribe-and-burn.sh
Created March 28, 2024 18:13
Auto-transcribe and burn subtitles for all videos without existing subtitles
for ext in avi mp4 mpg mkv; do
for i in *.${ext}; do
if [ ! -e "$(basename "$i" ".${ext}").srt" ]; then
echo "Transcribing: $i"
time whisperx "$i" --model large-v3 --language en --task transcribe --hf_token $HUGGINGFACE_TOKEN --compute_type int8 --chunk_size 5
echo "Burning subtitles: $i"
ffmpeg -i "$i" -vf subtitles="$(basename "$i" ".${ext}").srt" "$(basename "$i" ".${ext}")-burned.${ext}"
else
echo "Skipping: $i"
fi
@ryanfb
ryanfb / blender_compress_mesh.py
Created May 21, 2020 12:48
Blender Python script for converting a mesh to GLB with Draco compression
# Blender Python script for converting a mesh to GLB with Draco compression.
# Tested on Blender 2.82
# Usage:
# blender --background --factory-startup --addons io_scene_gltf2 --python blender_compress_mesh.py -- -i #{source_path} -o #{out_path}
from os import path
from contextlib import redirect_stdout
from sys import argv
import argparse
import io
import bpy
@ryanfb
ryanfb / .gitignore
Last active November 18, 2023 15:21
Geographic distribution of texts/collections in Trismegistos
.DS_Store
build
node_modules
@ryanfb
ryanfb / georgeblood.m3u
Last active October 16, 2023 12:11
An M3U playlist of items in the Internet Archive 78rpm collection: https://archive.org/details/georgeblood
This file has been truncated, but you can view the full file.
https://archive.org/download/78_.-tam-za-vahom-2.-horicka-zelena_andrej-gellert_gbia0001742a/!.%20Tam%20Za%20Vahom;%202.%20Horicka%20Zelena%20-%20Andrej%20Gellert.mp3
https://archive.org/download/78_1-a-dew-drop-2-rain-song_elizabeth-wheeler-sherman-gilchrist-smith_gbia0013545a/(1)%20A%20Dew%20Drop;%20(2)%20Rain%20Song%20-%20Elizabeth%20Wheeler.mp3
https://archive.org/download/78_...must-suffer-for-the-one-mistake-i-made_peppermint-harris_gbia0001396b/...Must%20Suffer%20(For%20The%20One%20Mistake%20I%20Made)%20-%20Peppermint%20Harris.mp3
https://archive.org/download/78_-and-mimi_art-lund-kennedy-simon-johnny-thompson_gbia0012786b/-And%20Mimi%20-%20Art%20Lund%20-%20Kennedy%20-%20Simon%20-%20Johnny%20Thompson.mp3
https://archive.org/download/78_-tramp-along-the-highway_nelson-eddy-nathaniel-shilkret-and-orchestra-rida-johnson_gbia0011035b/…%20Tramp%20Along%20the%20Highway%20-%20Nelson%20Eddy%20-%20Nathaniel%20Shilkret%20and%20Orchestra.mp3
https://archive.org/download/78_--and-mimi_frankie-carle-and-his-orchest
@ryanfb
ryanfb / checkzip.sh
Created October 3, 2023 16:37
Verify that all files in a given zip file exist (i.e. have been extracted). NB: no checksum verification, just existence.
#!/bin/bash
7z l -slt -ba "$1" | grep '^Path' | sed -e 's/^Path = //' | while read i; do if [ ! -e "$i" ]; then echo "$i"; fi; done
@ryanfb
ryanfb / ffmpegconcat.sh
Last active July 17, 2023 10:41
Short shell script for concatenating video files with ffmpeg's "concat" demuxer, using command line arguments.
#!/bin/bash
# Usage:
# ./ffmpegconcat.sh input1.mp4 input2.mp4 input3.mp4 output.mp4
# See: https://trac.ffmpeg.org/wiki/Concatenate
for input in "${@:1:$#-1}"; do echo "file '$input'"; done > filelist.txt
ffmpeg -f concat -safe 0 -i filelist.txt -c copy "${@: -1}"
echo "Concatenated:" && cat filelist.txt && rm -f filelist.txt
@ryanfb
ryanfb / m4adetag.sh
Created March 17, 2023 13:38
Undo accidentally running id3tag on an M4A or M4B audio file. Assumes GNU grep and head are available at ggrep and ghead respectively (`brew install coreutils` on macOS).
#!/bin/bash
OFFSET=$(ggrep --only-matching --byte-offset --max-count=1 --binary --text --perl-regexp "\x00\x00\x00\x1c" "$1" | head -1 | cut -d':' -f1)
tail -c +$(( $OFFSET + 1 )) "$1" | ghead -c -128 > untagged.m4b
if ffprobe -loglevel quiet untagged.m4b ; then
echo "Untagging succeeded for: $1"
mv untagged.m4b "$1"
else
echo "Untagging failed for: $1"
fi
@ryanfb
ryanfb / mbox-size.rb
Created July 11, 2022 21:49
Get the total number of bytes used for each sender in an Mbox email file
#!/usr/bin/env ruby
emails = {}
email_length = 0
last_email_from = nil
File.open(ARGV[0], "r:ASCII-8BIT").each_line do |line|
if line.start_with?('From ')
unless last_email_from.nil?
emails[last_email_from] ||= 0
@ryanfb
ryanfb / bookmarks_export.rb
Last active November 21, 2022 22:13
Export your Twitter Bookmarks to JSON. This will also delete all your Twitter Bookmarks, 50 Bookmarks at a time, to get around API limits. Now at: https://github.com/ryanfb/twitter-bookmarks-export
#!/usr/bin/env ruby
# Based on: https://github.com/twitterdev/Twitter-API-v2-sample-code/blob/main/Bookmarks-lookup/bookmarks_lookup.rb
# See: https://github.com/ryanfb/twitter-bookmarks-export
require 'json'
require 'typhoeus'
require 'twitter_oauth2'
# First, you will need to enable OAuth 2.0 in your App’s auth settings in the Developer Portal to get your client ID.
# Inside your terminal you will need to set an enviornment variable
# export CLIENT_ID='your-client-id'