Skip to content

Instantly share code, notes, and snippets.

View robinsloan's full-sized avatar

Robin Sloan robinsloan

View GitHub Profile
@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]
@robinsloan
robinsloan / unbroken-spine-id-notes.txt
Created October 7, 2012 04:39
Unbroken Spine member ID notes
Just a few notes for the curious.
* Every number in Mr. Penumbra's 24-Hour Bookstore is a least a little bit meaningful
* The Unbroken Spine member IDs are extra meaningful
* I checked in the roster and Peter Richardson's member ID is 6K6DV8
* I checked in the roster and Patrick Ewing's member ID is 6L9SN2
* Peter and Patrick had different mentors
* Beware the missing letter
More to come, here and there...
// 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 / gist:7751895
Created December 2, 2013 16:11
OS X airport command; for location detection w/ scripts.
sudo ln -s /System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport /usr/sbin/airport
@robinsloan
robinsloan / gsub-with-hash.rb
Created October 10, 2013 16:37
Didn't know about this.
def doctorize(string)
string.gsub(/M(iste)?r/, 'Mister' => 'Doctor', 'Mr' => 'Dr')
end
@robinsloan
robinsloan / gsub-block.rb
Created September 5, 2013 17:14
Ruby gsub with block
# http://batsov.com/articles/2013/08/30/using-gsub-with-a-block/?utm_source=rubyweekly&utm_medium=email
# num will be passed the string '12'
"Apollo 12".gsub(/\d+/) { |num| num.to_i.next }
# => "Apollo 13"
# string yielded to block is always entire match; can't do matched groups at |m1, m2| etc.
// this is the part i always use
$.ajax = function(url, callback) {
var xhr = new XMLHttpRequest();
xhr.open("GET", url, true);
xhr.onload = callback;
xhr.send();
}
#!/usr/bin/env ruby
require 'rubygems'
require 'numbers_and_words'
VOWELS = ['a','e','i','o','u']
CONSONANTS = ('a'..'z').to_a.delete_if do |char|
VOWELS.include?(char)
end

It was the end of the day and we were off to have a drink in the cafeteria just as a low-flying plane in the distance came zooming our way. As the roar grew louder, people shouted, "It's the president! It's Lindy!" Men, women, and children all ran out onto the great front lawn and began to wave at the approaching plane, which as it crossed over the Potomac tipped its wings. "Hurray!" people shouted. "Hurray for Lindy!" It was the same Lockheed fighter we'd seen in the air over the city the previous afternoon, and we had no choice but to stand there like patriots and watch with the rest of them as it banked and flew back over George Washington's home before it turned to follow the Potomac north.

@robinsloan
robinsloan / cook.md
Created December 6, 2012 18:38
"So, anyway."

This part was charming:

BUSINESSWEEK: Nothing hardens faster than the details of a CEO’s bio. Every story about you mentions the following: You’re a Southern gentleman. An Auburn football fan. Always early to work, always the last one to leave. None of it is negative, but do you recognize yourself in those descriptions or do you find yourself a little bit distorted? If so, would you like to correct a few things?

COOK: I think when you start reading about yourself, it’s almost -- it’s like a caricature. It begins to sound like someone else. That’s probably a better question to ask people that really know me vs. me. I hate talking about me. You know, it’s not something I do well or do a lot. I generally avoid it.

But I would say that the person you read about is robotic. There are some good things about that, perhaps. (Laughs.) Discipline comes to mind. But it sounds like there is just no emotion. People that know me, I don’t think they would say that. I certainly am not a fist-pounder. That isn’t my style.