Skip to content

Instantly share code, notes, and snippets.

View ryanfb's full-sized avatar

Ryan Baumann ryanfb

View GitHub Profile
#!/bin/bash
PREFIX=$(basename "$1" .pdf)
if [ ! -z "$TESSERACT_FLAGS" ]; then
echo "Picked up TESSERACT_FLAGS: $TESSERACT_FLAGS"
fi
echo "Prefix is: $PREFIX"
echo "Converting to TIFF..."
if command -v parallel >/dev/null 2>&1; then
LAST_PAGE=$(($(pdfinfo "$1"|grep '^Pages:'|awk '{print $2}') - 1))
$ g++ -o untrunc file.cpp main.cpp track.cpp atom.cpp mp4.cpp -L/usr/local/lib -lavformat -lavcodec -lavutil
track.cpp:106:26: warning: 'avcodec_alloc_frame' is deprecated [-Wdeprecated-declarations]
AVFrame *frame = avcodec_alloc_frame();
^
/usr/local/include/libavcodec/avcodec.h:3513:10: note: 'avcodec_alloc_frame' declared here
AVFrame *avcodec_alloc_frame(void);
^
track.cpp:217:8: error: use of undeclared identifier 'avcodec_open'
if(avcodec_open(codec.context, codec.codec)<0)
^
@ryanfb
ryanfb / twitch2mp4.sh
Created August 26, 2014 15:44
Script to convert and join a directory of youtube-dl flv files from Twitch to mp4 for upload/archiving to YouTube
#!/bin/bash
function join { local IFS="$1"; shift; echo "$*"; }
outfile="$(basename "$(ls -1 *.flv|head -1)" .flv).mp4"
if [ ! -f outfile ]; then
i=0
lnfiles=()
for j in *.flv; do
echo $j
@ryanfb
ryanfb / fly6.md
Last active July 1, 2016 13:29
Useful commands for Fly6 camera owners

Set date and time:

date "+%Y/%m/%d %H:%M" > /Volumes/Fly6/config.txt

Concatenate/join videos from a folder and make the result YouTube-friendly:

ffmpeg -f concat -safe 0 -i <(for f in *.AVI; do echo "file '$(pwd)/$f'"; done) -c:v libx264 -preset slow -crf 18 -c:a copy -pix_fmt yuv420p ~/Movies/youtube-fly6-ride-$(date "+%Y-%m-%d").mkv

Don't try to write the output to the Fly6 SD card, as the filesystem won't support files >4GB.

@ryanfb
ryanfb / .gitignore
Last active November 18, 2023 15:21
Geographic distribution of texts/collections in Trismegistos
.DS_Store
build
node_modules
@ryanfb
ryanfb / README.md
Last active December 31, 2015 21:29
Lace hOCR + PDF recombination

Lace hOCR + PDF recombination

Use the lace branch of my fork of HocrConverter: https://github.com/ryanfb/HocrConverter/tree/lace (make sure you git pull to get the latest changes)

Download and compile jbig2enc in your script path. Modify pdf.py to use 300 instead of 72 dpi.

Example run:

./lace2pdf.sh xenophon04xeno

@ryanfb
ryanfb / network_grep.sh
Last active December 27, 2015 02:59
Search all branches of all git repositories in a directory. ./network_grep.sh parentdir pattern [path]
#!/bin/bash
for i in $(find $1 -type d -name '.git')
do echo $i
git --git-dir=$i --no-pager grep $2 $(git --git-dir=$i rev-list --all) -- $3
done
@ryanfb
ryanfb / clone_github_network.rb
Created October 31, 2013 19:53
Clone all forks in a GitHub repository's network.
#!/usr/bin/env ruby
require 'json'
require 'open-uri'
require 'fileutils'
def clone_repo(repo)
puts repo['full_name']
owner, path = repo['full_name'].split('/')
FileUtils.mkdir_p(owner)
@ryanfb
ryanfb / gist:6995359
Created October 15, 2013 17:31
remove all corrupt jpg files in a directory
for i in **/*.jpg; do jpeginfo -c $i; if [ $? -eq 1 ]; then rm -v $i; fi; done
@ryanfb
ryanfb / flickr-dl.rb
Created September 13, 2013 18:45
Command line Flickr batch download script
#!/usr/bin/env ruby
require 'nokogiri'
require 'open-uri'
ARGF.each_line do |line|
line.chomp!
save_file = line.split('/')[-2..-1].join('_') + '.jpg'
doc = Nokogiri::HTML(open(line + "/sizes/o/"))