Speaking at Scotland on Rails 2009
January 17th, 2009
I’m really excited to be giving a talk at this years Scotland on Rails conference in Edinburgh.
I’ll be talking about working outside-in with Cucumber and RSpec. Having used Cucumber and as a member of the Cucumber core developer team I hope to share lots of experiences and lessons about getting the most out of the tool.
It’s looking like a great line up with with some really interesting presentations across a broad number of topics. The keynotes speakers are Michael Feathers and Marcel Molina, Jnr.
If you’re going to be in Edinburgh for the conference or have any burning questions about Cucumber, let me know.
Latent Semantic Analysis in Ruby
November 21st, 2008
I’ve had lots of requests for a Ruby version to follow up my Latent Semantic Analysis in Python article. So I’ve rewritten the code and article for Ruby. I wrote LSA from scratch this time and test driven so it has some subtle differences from the Python version.
What is LSA?
Latent Semantic Analysis (LSA) is a mathematical method that tries to bring out latent relationships within a collection of documents. Rather than looking at each document isolated from the others it looks at all the documents as a whole and the terms within them to identify relationships.
An example of LSA:
Using a search engine search for “ruby“.
Documents are returned which do not contain the search term “ruby” but contains terms like “rails“.
LSA has identified a latent relationship, “ruby” is semantically close to “rails“.
How does it work?
Given a set of word documents, each word in those documents represents a point in the semantic space. LSA uses a mathematical technique called Singular value decomposition to take the documents/words represented as a matrix and produce a reduced approximation of this matrix. In doing this it reduces the overall noise in the semantic space bringing words together. Hence after applying LSA some words share similar points in the semantic space, they are semantically similar.
These groups of semantically similar words form concepts and those concepts in turn relate to documents.
Term a < -----------> Term b < -----------> Concept d < ---------> Document e Term c < ----------->
Rboss RubyGem for Yahoo! Search BOSS
August 23rd, 2008
With Search BOSS (Build your Own Search Service) Yahoo has freed up a lot of the restrictions on their previous search service. Like removing the cap on the number of searches and allowing re-purposing of results. I’ve been doing some work on using the service in Ruby. I wrote a little RubyGem called Rboss which wraps around the BOSS webservice. It makes life nice and easy using Ruby and BOSS.
require 'rubygems'
require 'boss'
api = Boss::Api.new('boss-api-key-got-from-yahoo')
#Find news articles that are not older than 7 days
results = api.search_news('monkeys', :age => '7d')
results.each do |news|
puts news.title
puts news.abstract
puts news.date
puts news.url
end
Install Gem from GitHub:
- Add github to gem sources
- Install the gem:
- If you don’t already have a BOSS api key signup for one: http://developer.yahoo.com/wsregap
gem sources -a http://gems.github.com
sudo gem install eshopworks-rboss
Checkout the Rboss documentation and example usage at: http://github.com/eshopworks/rboss-gem
Thanks to eShopworks for sponsoring this project.
Telling a good story – Rspec stories from the trenches
August 15th, 2008
I’ve been developing multiple systems using Rspec stories for a little while now. There are a lot of great resources to get you started with a taste of what you can do with stories. Some of the resources I found useful where:
- http://peepcode.com/products/rspec-user-stories
- http://blog.davidchelimsky.net/2008/6/16/slides-from-railsconf
- http://www.benmabey.com/2008/02/04/rspec-plain-text-stories-webrat-chunky-bacon/
- http://dannorth.net/whats-in-a-story
- http://evang.eli.st/blog/2007/10/8/story-runner-top-to-bottom-screencast
However once I had understood the basic idea I struggled to find practical examples and general guidance on writing real stories. So I’ve collected some of the lessons I’ve learnt along the way with story examples taken from real systems and how I’ve improved them as I learnt. Most examples are from web based applications.
Ruby/Rails interview questions
July 25th, 2008
I’ve recently been helping interview some ruby/rails developers. I searched the web for some inspiration but I could not find any example questions that had real depth to them. I like my questions to be a point of discussion rather than one word answers. Most importantly I want a wide enough scope to let those talented individuals shine through. So here are some of the questions I’ve been trying out recently.
Rspec-rails is a rails plugin which brings the Rspec Ruby Behaviour Driven Development framework to rails along with some rails specific helpers. One of these hugely useful helper functions is:
mock_model(model_class, options_and_stubs = {})
This creates a mock object with the common methods stubbed out. It also allows you to specify other methods you want to stub.
Read the rest of this entry »
Textmate bundle for RR test double framework
July 7th, 2008
A simple Textmate bundle for RR the Ruby test double framework. You can read about RR at http://github.com/btakita/rr/tree/master and look through the latest rdocs at Rubypub
Install with Git
- Run this:
- Reload bundles in Textmate
- Enjoy!
mkdir -p ~/Library/Application\ Support/TextMate/Bundles/
cd ~/Library/Application\ Support/TextMate/Bundles/
git clone git://github.com/josephwilk/rr-tmbundle.git rr.tmbundle
Rspec Stories – Keeping Steps Dry
April 30th, 2008
When using Rspec stories you have plain text stories which we call the ’story’ file and the ’story steps’ file that maps the plain text story to programmatic code. Generally you end up with your story files not being DRY. This is not a worry, your stories are the domain specific languages detailing your acceptance/integration tests. Its like saying that your Rails Models are not DRY because they repeat lots of 'has_one'!
Read the rest of this entry »
JavaScript Acting as a Robotic Agent
February 23rd, 2008
We can think of JavaScript running within a clients browser as a robotic agent. It has an environment in which it can sense things. The ability to look at the environment and make decisions based on plans.
So whys that useful, well why is a robot useful? You can produce many different complex plans and give them to the robot and forget about it while it does the work potentially over and over again. If we are really lucky the robot can demonstrate some intelligence and deal with uncertainty.
Well I tried out a small part of this idea to build a server side service which delivered plans in JavaScript to the client. The JavaScript planning agent followed the plans. Its not a intelligent robot but this is just a prototype. The plans where focused on validation conditions that a user needed to get through to post a form.
Rails Admins Plugins Review
February 14th, 2008
A brief examination of some of the major Admin plugins for rails.
- Lipsiaadmin
- AutoAdmin
- ActiveScaffold
- Hobo
- Streamlined


