Skip to content

Instantly share code, notes, and snippets.

View robinsloan's full-sized avatar

Robin Sloan robinsloan

View GitHub Profile
@robinsloan
robinsloan / gif-to-vid.sh
Created August 28, 2017 21:16
FFMPEG command to convert GIF to proper MP4
ffmpeg -i this_here.gif -vcodec h264 -y -pix_fmt yuv420p that_there.mov
@robinsloan
robinsloan / unfave.rb
Last active June 5, 2022 21:32
Unfave script, because why not??
#!/usr/bin/env ruby
require "rubygems"
require "twitter"
require "json"
require "faraday"
# things you must configure
TWITTER_USER = "your_username"
# get these from dev.twitter.com
import subprocess as sp
import numpy as np
import signal
from PIL import Image
### TUKEY WINDOW
# https://leohart.wordpress.com/2006/01/29/hello-world/
def tukey_window(window_length, alpha=0.5):
# Special cases
from PIL import Image
import glob
import numpy as np
### TUKEY WINDOW
### https://leohart.wordpress.com/2006/01/29/hello-world/
def tukey_window(window_length, alpha=0.5):
# Special cases
if alpha <= 0:
require "rubygems"
require "twitter"
# get these from apps.twitter.com
CONSUMER_KEY = "abcd"
CONSUMER_SECRET = "abcd"
OAUTH_TOKEN = "abcd"
OAUTH_TOKEN_SECRET = "abcd"
TWITTER_USER = "your_username" # needs to be the one associated with keys above
@robinsloan
robinsloan / makevideo.rb
Last active May 21, 2016 04:26
Very brittle, but maybe useful
# for when you have a bunch of images in a dir that are not *quite*
# numbered the way ffmpeg wants them to be, e.g.
# image-1, image-2, ... image-10, image-11, ... image-100, image-101
if ARGV.length < 1
puts "Usage: ruby makevideo.rb name-of-directory-with-all-your-dang-images-in-it"
exit
end
dir = ARGV[0]
// for functions.php
function em_dash_filter($content) {
# add to css: .nobr { whitespace: nowrap; }
return preg_replace('/(\w+)(—|&mdash;|&#8212;)/', '<span class="nobr">$1$2</span><wbr>', $content);
}
add_filter( "the_content", "em_dash_filter" );
@robinsloan
robinsloan / battles.md
Last active August 29, 2015 14:26
FLOOD OF FIRE, Amitav Ghosh:

In other ways too the day was a revelation to Neel. He had never witnessed a battle before and was profoundly affected by what he saw. Thinking about it later he understood that a battle was a distillation of time: years and years of preparation, decades of innovation and change were squeezed into a clash of very short duration. And when it was over the impact radiated backwards and forwards through time, determining the future and even, in a sense, changing the past, or at least the general understanding of it. It astonished him that he had not recognized before the terrible power that was contained within these wrinkles in time -- a power that could mould the lives of those who came afterwards for generation after generation. He remembered how, when reading of long-ago battles like Panipat and Plassey, he had thought of them as immeasurably distant from his own life, a matter of quaint uniforms and old-fashioned weaponry. Only now did it occur to him that it was on battlefields such as those that his own pl

@robinsloan
robinsloan / grammar-punctuation-etc.txt
Created July 8, 2015 23:13
Little things I tend to forget
Don't hyphenate very or an -ly adverb in a compound modifier. For example, a very good time, an easily remembered rule.
@robinsloan
robinsloan / transcriber.rb
Last active August 29, 2015 14:22
Voice memo transcriber engine. This is a very simple, highly inflexible script that probably won't be useful to many other people, but hey, you never know!
=begin README
Here's what this script does:
1. checks a Gmail inbox
2. finds attachments (which it expects to be WAV files)
3. pipes them through Google's voice transcription service
4. emails you the results
I use it with the Instacorder iPhone app for a super-fast, push-to-talk