Skip to content

Instantly share code, notes, and snippets.

Robin Sloan robinsloan

View GitHub Profile
@robinsloan
robinsloan / gif-to-vid.sh
Created Aug 28, 2017
FFMPEG command to convert GIF to proper MP4
View gif-to-vid.sh
ffmpeg -i this_here.gif -vcodec h264 -y -pix_fmt yuv420p that_there.mov
@robinsloan
robinsloan / unfave.rb
Last active Jun 8, 2020
Unfave script, because why not??
View unfave.rb
#!/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
View videopan.py
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
View stitch.py
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:
View unfollow.rb
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 / LSTMBeam.lua
Created May 25, 2016
Beam search, kinda?
View LSTMBeam.lua
require 'torch'
require 'nn'
local layer, parent = torch.class('nn.LSTM', 'nn.Module')
--[[
If we add up the sizes of all the tensors for output, gradInput, weights,
gradWeights, and temporary buffers, we get that a SequenceLSTM stores this many
scalar values:
@robinsloan
robinsloan / makevideo.rb
Last active May 21, 2016
Very brittle, but maybe useful
View makevideo.rb
# 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]
View em-dash-drama.php
// 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 Aug 29, 2015
FLOOD OF FIRE, Amitav Ghosh:
View battles.md

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 Jul 8, 2015
Little things I tend to forget
View grammar-punctuation-etc.txt
Don't hyphenate very or an -ly adverb in a compound modifier. For example, a very good time, an easily remembered rule.
You can’t perform that action at this time.