Ruby Quick Tips in Your Background
This morning I felt the urge to find a nice and easy way to learn more about my favorite language Ruby. I started with a quick google search for Ruby tips and tricks, to find some interesting reads. One of the first ones I came across was Ruby Quick Tips which is just a tumblr blog with an RSS feed.
I subscribed to the RSS feed and then though why not make this part of my background. Refresh itevery day so I have a good way to learn something new about Ruby.
Let the hacking begin. RSS feeds are pretty easy to parse with Ruby, the weird part was that the RSS feed actually came back with HTML for thecode in the quick tip. This is also pretty easy to solve with nokogiri (written by one crazy guy tenderlove and his cat Gorby ). So with all the help from the ruby libraries I wrote this little script. chmod+x it and have GeekTool run the command every day.
#!/usr/bin/env ruby require "rubygems" require "rss/1.0" require "rss/2.0" require "open-uri" require "nokogiri" source = "http://rubyquicktips.com/rss" content = "" open(source) do |s| content = s.read end rss = RSS::Parser.parse(content, false) puts rss.items.title puts Nokogiri::HTML(rss.items.description).text