Fork me on GitHub

Snippets #121

Snippets #120

It's amazing what a spot of re-factoring does to simplify your application. I just hope I haven't went too far. 

  • Sinatra-tests - This gem should come in handy for providing extra tests for my little Sinatra apps.
  • Simpleconfig - I'm already using basic configuration settings in a couple of Rails apps, but this gem will make my settings easier to manage and use.
  • Ruby 1.9.2 RC1 released - Good thing I'm using RVM.

I also started reading The Passionate Programmer last night. I'm already 50 pages into the book, so I'm aiming to finish it over the weekend. The best part will be putting some of this new found knowledge into action.

New in the incubator - keywordr.rb

The other day I wondered what kind of keywords that websites had been using but I wanted to see them in the context of a search, just like Google's search results. I need a mini-app!

The gist of the mini-app is this.

You key in the query and keywordr will do a search on Google for your query. It will scan through the list of returned results and check each URL in the results for a list of keywords.

Using Sinatra, I was able to put together an application the does this. You can see the latest version of it here.

I did initially want to return the keyword metatag for each website, but I found that Peter Cooper's pismo gem does a keyword search of any URL you pass to it.

What I learned

  1. Searching a page using Nokigiri's CSS selector - This seems a much easier way of searching a page. I had only used XPath's previously.
  2. Embedded tests in a Sinatra file - I'm trying to keep my mini-apps in single files, but I wanted to use TDD as well. This was a good place to learn how to embed tests with a single file Sinatra app.
  3. Some basics of Haml - I tried Haml before but never took to it. Too keep my mini-apps small, I wanted use a more concise and readable syntax for layouts and views. Back to Haml.

What next

  1. A nice way paging through the next set of results would be nice.
  2. Being able to get more results on the page would be good.
  3. I don't like the way I run my tests for the mini-app, but it works for the moment.

I've neglected my little incubator project for sometime, but in the future I'm hoping to add a mini-app every month.

Snippets #99

Got an hour's work done last night and then crashed out for the rest of the night. Must have needed it.

Snippets #92

Still haven't nominated someone for Ruby Heroes. There's just too many people to choose from!