Skip to content

Instantly share code, notes, and snippets.

@juno
Created February 14, 2009 08:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save juno/64315 to your computer and use it in GitHub Desktop.
Save juno/64315 to your computer and use it in GitHub Desktop.
URL shorten script. require: gem install shorturl
#!/usr/bin/env ruby
# -*- coding:utf-8; mode:ruby-mode -*-
require 'rubygems'
require 'shorturl'
ARGF.each do |line|
puts line.gsub(%r|(s?https?://[-_.!~*'a-zA-Z0-9;/?:@&=+$,%#]+)|) {|s| ShortURL.shorten($1)}
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment