Skip to content

Instantly share code, notes, and snippets.


Ryan Baumann ryanfb

View GitHub Profile
ryanfb / wait_for_deploy.rb
Created Jul 9, 2021
Run from a Git repository with a properly configured Rapporteur ( status endpoint as the first argument, this script will wait until the live revision matches the latest local revision
View wait_for_deploy.rb
#!/usr/bin/env ruby
require 'json'
require 'shellwords'
unless ARGV.length == 1
$stderr.puts "Usage: wait_for_deploy.rb"
exit 1
ryanfb /
Last active Jul 29, 2021
Short shell script for concatenating video files with ffmpeg's "concat" demuxer, using command line arguments.
# Usage:
# ./ input1.mp4 input2.mp4 input3.mp4 output.mp4
# See:
for input in "${@::${#@}-1}"; do echo "file '$input'"; done > filelist.txt
ffmpeg -f concat -safe 0 -i filelist.txt -c copy "${@: -1}" && rm -f filelist.txt
ryanfb /
Last active Jun 12, 2020
Set MP3 id3v2 duration from actual MP3 duration
for i in *.mp3; do
duration=`echo "$(( $(sox "$i" -n stat 2>&1|fgrep 'Length'|cut -d':' -f2|xargs) * 1000 ))"| awk '{printf("%d\n",$0+=$0<0?0:0.9)}'`
echo "$i: $duration"
id3v2 --TLEN "$duration" "$i"
ryanfb /
Created May 21, 2020
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 -- -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 / last-modified.js
Created Apr 27, 2020
snippet for setting the last modified date on a GitHub Pages post using the GitHub API
View last-modified.js
function setModifiedDate() {
if (document.getElementById('last-modified')) {
fetch("{{ site.github.owner_name }}/{{ site.github.repository_name }}/commits?path={{ page.path }}")
.then((response) => {
return response.json();
.then((commits) => {
var modified = commits[0]['commit']['committer']['date'].slice(0,10);
if(modified != "{{ | date: "%Y-%m-%d" }}") {
document.getElementById('last-modified').textContent = "Last Modified: " + modified;
ryanfb /
Created Nov 26, 2019
Fusion Tables Migration Alternatives
  • Datasette on Heroku
  • Heroku Postgres
  • Google Bigtable - $.65/hr
  • Google BigQuery - $5/TB of queried data, $.02/GB/mo stored
  • Google Cloud Datastore - 1GB free, .18GB/month above
  • Google Cloud Firestore - similar to Datastore
  • Google Sheets
  • Google Cloud SQL (MySQL/PostgreSQL)
  • AWS DynamoDB - NoSQL, 25GB free, $0.25/1M read request units
  • AWS Athena - costs per TB scanned, reads data from S3 buckets
View pdftogt.rb
#!/usr/bin/env ruby
Encoding.default_external = Encoding::UTF_8
Encoding.default_internal = Encoding::UTF_8
require 'nokogiri'
pdf_filename = ARGV[0]
xml_filename = File.basename(pdf_filename,'.pdf') + '.xml'
ryanfb / ancientgreekspeak.rb
Last active May 9, 2019
Ruby script for transliterating Ancient Greek to Apple phonemes for text-to-speech synthesis - updates at
View ancientgreekspeak.rb
#!/usr/bin/env ruby
require 'i18n'
Encoding.default_external = Encoding::UTF_8
# Usage: Takes Unicode Polytonic Greek on STDIN or as arguments, outputs
# phonetic pronunciation on STDOUT designed to be piped into the Mac `say` command.
# e.g.:
# echo 'ἄγω ἄξω ἤγαγον ἦχα ἤγμαι ἤχθην' | ./ancientgreekspeak.rb | say
ryanfb / test_a1.txt
Last active Aug 10, 2018
dhSegment MicroPasts train/val/test split
View test_a1.txt