Archive for April, 2010

Installing Java on Ubuntu Intrepid

April 22nd, 2010 by pyrat

Always doing this on different ubuntu versions and always having to look it up.

Here is a guide for Ubuntu Intrepid

Google Product Search Xml Generator

April 16th, 2010 by pyrat

I have been working on a google base product search xml feed generator. It is in the form of a semi-customizable rake task. I have released this as a kind of rails plugin.

rake googlebase:generate generates an xml file of your products.

Configuration

To configure, add Rails.root/config/google_base.yml

Example google_base.yml file in files/google_base.yml

As the structure of the xml is dependant on your product models I have left it to the programmer to modify the google.rake file and set the correct instance methods for returning product information, along with the named_scope for returning live products.

TODO:

Instead of editing this rake file manually it would be good to add a plugin type class method which can take the configuration of your products and generate this automatically.

Its is available on github

Jquery Assertion for Rails

April 10th, 2010 by pyrat

When doing functional testing of ajax actions it is nice to be able to test the format of the javascript returned to the browser.

When using rjs I was using the excellent arts testing library, now I have moved to raw jquery instead. The method below provides a short hand way to test simple jquery methods. it can be built upon for sure but this little regex is quite powerful.

  def assert_jquery(effect, id)
    assert_match(/\$\(['"]+##{id}['"]+\).#{effect}\(.*\);/, @response.body)
  end

Consider the jquery

$("#announcement").hide();

  assert_jquery('hide', 'announcement')

This currently only works for id methods and when jquery isnt in compatibility mode. Also integration testing using something like env.js and harmony is a better way of javascript testing. Things like blue ridge actually integrate the env.js framework into a rails plugin and are a great solution if you have to do some real heavy lifting.

However, this method brings maximum results for minimum effort.

Kazakhstan Avalanche Control

April 9th, 2010 by pyrat

Often the ski patrol does avalanche control after a big dump. You normally hear it before you get out of bed.

Here in Kazakhstan the ski patrol might have had one too many vodkas as the avalanche control didnt go so well!