Skip to content

Instantly share code, notes, and snippets.

@juno juno/tinyurlify.rb

Created Feb 14, 2009
Embed
What would you like to do?
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
You can’t perform that action at this time.