Share Pastebin
Guest
Public paste!

jk

By: a guest | Apr 26th, 2009 | Syntax: Groovy | Size: 0.41 KB | Hits: 323 | Expires: Never
Copy text to clipboard
  1. /**
  2.  * Easy tinyUrl usage from grails
  3.  * Put this code into bootstrap or somewhere where it will be executed once at startup
  4.  */
  5. 5.0%2Fdocs%2Fapi%2F">String.metaClass.getTinyUrl = {
  6.   new 5.0%2Fdocs%2Fapi%2F">URL("http://tinyurl.com/api-create.php?url=${delegate.encodeAsURL()}").text
  7. }
  8.  
  9. // now you can use the tinyUrl property of every string to get a tinyUrl for given address
  10. println "http://www.nabble.com/codehaus---grails-f11860.html".tinyUrl