Skip to content

Instantly share code, notes, and snippets.

View robinsloan's full-sized avatar

Robin Sloan robinsloan

View GitHub Profile
@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
@robinsloan
robinsloan / save-followings.rb
Created April 6, 2013 16:52
Export IDs of the people you're following on Twitter.
#!/usr/bin/env ruby
require 'rubygems'
require 'twitter'
require 'json'
require 'faraday'
TWITTER_USER = "blahblah"
# get these from dev.twitter.com
CONSUMER_KEY = "blahblah"