Skip to content

Instantly share code, notes, and snippets.

@takkkun
Created March 21, 2010 20:56
Show Gist options
  • Save takkkun/339563 to your computer and use it in GitHub Desktop.
Save takkkun/339563 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
require 'optparse'
radix = 36
OptionParser.new do |opt|
opt.on('-d') { radix = 10 }
opt.on('-z') { radix = 36 }
opt.on('-r VAL') {|v| radix = Integer v }
opt.parse! ARGV
end
def bad_url; abort "Please specify the URL to Twitter's status"; end
url = ARGV.shift
bad_url unless url
STATUS_URL_REGEXP = /^https?:\/\/twitter\.com\/\w+\/status(?:es)?\/(\d+)\/?$/
status_id = STATUS_URL_REGEXP.match(url).to_a[1]
bad_url unless status_id
case radix
when 10
puts "http://ex.itter.ch/#{status_id}"
when 36
puts "http://#{status_id.to_i.to_s radix}.itter.ch/"
else
abort 'The radix should be 10 or 36'
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment