Skip to content

Instantly share code, notes, and snippets.

View robinsloan's full-sized avatar

Robin Sloan robinsloan

View GitHub Profile
@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
@robinsloan
robinsloan / pcal.rb
Created March 11, 2015 17:42
Add entries for prime-numbered weekdays to your Google calendar. Useful to literally no one but me.
require "rubygems"
require "google_calendar"
require "date"
require "prime"
# Create an instance of the calendar.
cal = Google::Calendar.new(:client_id => "foo"
:client_secret => "bar",
:calendar => "blee",
@robinsloan
robinsloan / basic.html
Created October 14, 2014 19:12
This little page was so simple and fast and readable, it made my heart sing. From http://totallynuclear.club/~crm/
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>~crm</title>
<style>
body {
max-width: 600px;
margin: 0 auto;
Believe It
Hard to believe that, after all of it,
in bed for good now, knowing you haven’t done
one thing of any lasting benefit
@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
#!/usr/bin/env ruby
require 'rubygems'
require 'twitter'
require 'json'
require 'faraday'
TWITTER_USER = "your_username_here"
TIMEOUT = 1 # increment this if you're getting a lot of rate limit errors
# get these from dev.twitter.com