Pages

Reading RSS Feed in Groovy

The more I explore, the more I love groovy. Last week while I was demonstrating a few colleagues of mine, that how simple things are really dead-simple in groovy, I wrote this small code that fetches the rss feed and prints the headlines. Just thought of sharing with all.
// setup proxy, if any
System.properties.putAll(["http.proxyHost":"your.proxy", "http.proxyPort":"8080"])             

// define the url, change it to whatever rss url you like
def url = "http://news.google.com/news?ned=us&topic=h&output=rss"

def rss = new XmlSlurper().parse(url) 

println rss.channel.title
rss.channel.item.each {
    println "- ${it.title}"
}
That's it! You have headlines in your output. How can you not love the brevity yet expressiveness of this code:)

ASCII Art Editor in Java

I am Huge fan of README files. When looking at any new library/software, I would at least skim through a README once, if not gulp it thoroughly. So I was writing a README for my project yesterday. I wanted to have a simple diagram in the readme, but it was getting sorta complex to do that with Notepad++, Netbeans or Eclipse. I have always wondered how people make nice ASCII Art Logos (I found that 'it' is called so after some google searches) and diagrams in Text Files.

Anyways, so I found out this cool ASCII Art Editor in java called JavE. And it really helped me to create the desired diagram in the text file. Bonus: I came to know how to create ASCII Banners as well. You have to download optional FIGlet fonts (available on the same website) to create text banners like this one.
 
   _   _      _ _        __        __         _     _
  | | | | ___| | | ___   \ \      / /__  _ __| | __| |
  | |_| |/ _ \ | |/ _ \   \ \ /\ / / _ \| '__| |/ _` |
  |  _  |  __/ | | (_) |   \ V  V / (_) | |  | | (_| |
  |_| |_|\___|_|_|\___/     \_/\_/ \___/|_|  |_|\__,_|