Skip to content

Instantly share code, notes, and snippets.

Avatar

Ryan Baumann ryanfb

View GitHub Profile
@ryanfb
ryanfb / ffmpegconcat.sh
Last active Jan 19, 2021
Short shell script for concatenating video files with ffmpeg's "concat" demuxer, using command line arguments.
View ffmpegconcat.sh
#!/bin/bash
# Usage:
# ./ffmpegconcat.sh input1.mp4 input2.mp4 input3.mp4 output.mp4
# See: https://trac.ffmpeg.org/wiki/Concatenate
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
ryanfb / id3v2len.sh
Last active Jun 12, 2020
Set MP3 id3v2 duration from actual MP3 duration
View id3v2len.sh
#!/bin/bash
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"
done
@ryanfb
ryanfb / blender_compress_mesh.py
Created May 21, 2020
Blender Python script for converting a mesh to GLB with Draco compression
View blender_compress_mesh.py
# 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 / 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("https://api.github.com/repos/{{ 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 != "{{ page.date | date: "%Y-%m-%d" }}") {
document.getElementById('last-modified').textContent = "Last Modified: " + modified;
@ryanfb
ryanfb / fusion-tables-migration.md
Created Nov 26, 2019
Fusion Tables Migration Alternatives
View fusion-tables-migration.md
  • 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
ryanfb / ancientgreekspeak.rb
Last active May 9, 2019
Ruby script for transliterating Ancient Greek to Apple phonemes for text-to-speech synthesis - updates at https://github.com/ryanfb/ancientgreekspeak/
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
ryanfb / test_a1.txt
Last active Aug 10, 2018
dhSegment MicroPasts train/val/test split
View test_a1.txt
DSC_0484.png
IMG_0989.jpg
IMG_6717.jpg
IMG_1511.jpg
IMG_7308.jpg
IMG_1344.jpg
IMG_3407.jpg
IMG_3661.jpg
IMG_8855.jpg
IMG_3205.jpg
View geocollider-lightning.md

Geocollider

Ryan Baumann

Duke Collaboratory for Classics Computing

@ryanfb