Skip to content

Instantly share code, notes, and snippets.

Robin Sloan robinsloan

Block or report user

Report or block robinsloan

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
from PIL import Image
import glob
import numpy as np
def tukey_window(window_length, alpha=0.5):
# Special cases
if alpha <= 0:
View unfollow.rb
require "rubygems"
require "twitter"
# get these from
OAUTH_TOKEN = "abcd"
TWITTER_USER = "your_username" # needs to be the one associated with keys above
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 / 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"
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 /
Last active Aug 29, 2015
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 / 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.
robinsloan / transcriber.rb
Last active Aug 29, 2015
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!
View transcriber.rb
=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
robinsloan / pcal.rb
Created Mar 11, 2015
Add entries for prime-numbered weekdays to your Google calendar. Useful to literally no one but me.
View pcal.rb
require "rubygems"
require "google_calendar"
require "date"
require "prime"
# Create an instance of the calendar.
cal = => "foo"
:client_secret => "bar",
:calendar => "blee",
robinsloan / basic.html
Created Oct 14, 2014
This little page was so simple and fast and readable, it made my heart sing. From
View basic.html
<!DOCTYPE html>
<html lang="en">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
body {
max-width: 600px;
margin: 0 auto;
You can’t perform that action at this time.