ShortURL 0.8.4 released and gets a new mainainer... me! 2
Earlier today, Vincent Foley was kind enough to hand over maitenance of the the ShortURL project on RubyForge to me. He first released it back in 2005, which I blogged about as RubyURL was the first shortening service that it supported (and is the default). Unfortunately, the release of RubyURL 2.0 broke backwards compatibility and Vincent wasn’t maintaining it anymore. So, earlier, I decided to patch this and got a new version released that now works with the current RubyURL site.
While working on the code, I decided to extend the compatible services to include moourl and urlTea.
These updates are available in ShortURL version 0.8.4.
Install the ShortURL gem
Installation is a snap… (like 99.7% of rubygems…)
~ > sudo gem install shorturl Password:
Successfully installed shorturl-0.8.4
1 gem installed
Installing ri documentation for shorturl-0.8.4...
Installing RDoc documentation for shorturl-0.8.4.
Using ShortURL
The ShortURL gem provides the ShortURL library, which you can use from any Ruby application.
Using the ShortURL library
~ > irb
irb(main):001:0> require 'rubygems'
=> true
irb(main):002:0> require 'shorturl'
=> true
irb(main):003:0> ShortURL.shorten( 'http://www.istwitterdown.com' )
=> "http://rubyurl.com/P9w"
As you can see…it’s really straight forward.
Let’s try it with a few other services.
irb(main):004:0> ShortURL.shorten( 'http://www.istwitterdown.com', :moourl )
=> "http://moourl.com/fvoky"
irb(main):005:0> ShortURL.shorten( 'http://www.istwitterdown.com', :tinyurl )
=> "http://tinyurl.com/2t3qmh"
Using the shorturl command-line tool
Many people don’t know that ShortURL provides a command-line tool, which you can use after installing the gem.
~ > shorturl http://istwitterdown.com
http://rubyurl.com/Lwk
If you’d like to see more services provided than the ones listed here, please submit feature requests and/or patches on the rubyforge project.
ShortURL Documentation
To see the latest documentation for the project, please visit:
My favorite part about this? My rbot plugin for RubyURL works again!
Happy URL-shortening!
Meet the Cheat 1
Hey! You’re a cheater!
Well, if you’re not… I’m hoping to make one out of you.
“A thing worth having is a thing worth cheating for.”—W. C. Fields
I’m a fan of the PDF cheat sheets as I like the consolidated content contained in them. However, I don’t like having to read PDFs any more than I have to. Printing them isn’t always ideal either as I really don’t like to carry around extra paper in my laptop bag. So, what are we to do?
Well, you can cheat the system! ...and I’m going to show you how!
Cheat is this really nice command-line tool that outputs a plain text cheat sheet whenever and wherever you want.
Install the Cheat
Like all the happy and good Rubygems, this is quite simple…
$ sudo gem install cheat
Done! Okay… let’s try to do some cheating. Don’t worry, your friends and family will forgive you.
Becoming a Cheat(er)
To view a cheat sheet, just run the cheat command from your favorite terminal window.
$ cheat _cheat name_
So, for example… to see the cheat sheet for RSpec, run cheat rspec.
$ cheat rspec
rspec:
INSTALL
=======
$ sudo gem install rspec
$ ./script/plugin install
svn://rubyforge.org/var/svn/rspec/tags/REL_X_Y_Z/vendor/rspec_on_rails/vendor/p
ugins/rspec
Where X_Y_Z is the version number.
$ ./script/generate rspec
create spec
create spec/spec_helper.rb
create spec/test2spec.erb
create test/test2spec_help.rb
create script/rails_spec
create script/rails_spec_runner
HOW TO USE
==========
./script/generate rspec_model User
####################################################
# truncated to save precious bandwidth
####################################################
Because this is all printing out in your shell, you can take advantage of your favorite command line tools.
Piping to grep
$ cheat rspec | grep 'equal'
@user.errors.on(:username).should_equal "is required"
target.should_equal <value>
target.should_not_equal <value>
Piping to TextMate
$ cheat rspec | mate
Find more Cheats
Head over to this list of cheats to see what is currently available.
Thanks to the Err team for putting this together!





