More Olympic Medal Visualisation

14 08 2008

After speculating what this year’s medal table might look like, I came across this visualisation of the medal standings in this year’s Olympics.  As you scroll into the map, the total number of medals for a country splits out into gold, silver and bronze medals won.





Ruby Tuesday #18 : Ruby meets .NET

12 08 2008

A couple of weeks ago, I posted that John Lam had announced a binary release of IronRuby.  So, I downloaded the zip file and extracted it to the root of my C drive.  That created a folder called IronRuby on my C drive containing all the IronRuby goodness.  In the IronRuby folder, there’s a bin folder in which is ir.exe, so I added C:\IronRuby\bin to my system PATH variable.  I opened a command window and typed ir and saw this:

image

Now that I had IronRuby running, I did the obvious stuff – putting Hello World, adding some numbers and so on.  Next, I tried calling .NET from IronRuby.  I typed the following lines into the console;

require ‘mscorlib’ require ‘System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089′ require ‘System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a’ Form = System::Windows::Forms::Form $f = Form.new $f.Text = “Hello World!” System::Windows::Forms::Application.run $f

I’m using $f (a global variable for those new to Ruby) because, as the console says, local variables aren’t supported yet in console mode.  And, this is what I saw:

image

.NET written in Ruby.  There’s a lot more here to explore.





The new ility

6 08 2008

As an architect, you’ll be concerned with a number of qualities that you need to ensure your systems, applications, services and infrastructure have.  I use PASSME as a handy mnemonic to remember the most common of these qualities (performance, availability, security, scalability, maintainability and extensibility.)  It’s fairly common to use the shorthand "ility" to refer to any of these qualities.  When making architectural decisions, you will be keenly aware which ility you are trading for which other ility.  A key ility is affordability.  Most of us do not treat money as an infinite resource.  However, when it comes to energy consumption, there are many among us who do assume there is an infinite supply.  Pretty soon if not already, energy consumption and environmental impact are going to become an ility - and a very important one.





Visualising Olympic medals

6 08 2008

Via the ever interesting FlowingData, I discovered this visualisation in the New York Times of medals won by country.  There’s a slider that lets you select which Olympics and a choice between a ranking view and a geographic view.  Selecting a country will show you the medals won by that country in that Olympics.  This is an interesting and engaging way of presenting the medal data.  I wonder how the results from this year’s Olympics will look.





Ruby Tuesday #17 : Ain’t no party like an HTTParty

5 08 2008

This week, I noticed on RubyInside that there’s a new gem called HTTParty that simplifies calling APIs over HTTP.  Since this is exactly what I have been doing with Twitter and SSDS I thought I’d have a look at it.  First port of call is the example on RubyForge.  There’s some more examples on github - the Twitter example is here.

The next step is to take the Twitter client I wrote before and refactor it to use HTTParty.  Here’s the resulting code:

require 'httparty'

class Twitter
  include HTTParty
  base_uri 'twitter.com'
  format :xml

  def download_public_timeline
    download_timeline('statuses/public_timeline.xml')
  end

  def download_friends_timeline(username, password)
    download_timeline("statuses/friends_timeline/#{username}.xml", username, password)
  end

  def download_user_timeline(username)
    download_timeline("statuses/user_timeline/#{username}.xml")
  end

  def update(update_text, username, password)
    self.class.post("update.xml", { :query => {:status => update_text}, :basic_auth => {:username => username, :password => password}})
  end

  private

  def download_timeline(path, username=nil, password=nil)
    self.class.get(path, {:basic_auth => {:username => username, :password => password}}
  end
end

Add a little code to call the class to make sure it works:

require "Twitter"
require 'pp'
$KCODE = "u"
username = 'Put your username here'password= 'Put your password here'
client = Twitter.new
puts "Public Timeline\r\n"
puts "***********************"
pp client.download_public_timeline
puts "***********************"
puts "Friends Timeline\r\n"
puts "***********************"
pp client.download_friends_timeline(username, password)
puts "***********************"
puts "User Timeline\r\n"
puts "***********************"
pp client.download_user_timeline(username)
puts "***********************"
client.update("Tweeting with Ruby via HTTParty", username, password)

And it all works - apart from a few of the usual timeouts and grumbles from Twitter.  Less code and simpler code.  This time around I’m using pp (pretty-printer) to format the output - this gives a good view of what HTTParty is returning.  My next step with HTTParty is to use it for the SSDS code I wrote.





Made Up Technical Terms #14

3 08 2008

Napplication - An application that freezes intermittently.





Made Up Technical Terms #13

3 08 2008

Emptyty - a class that is simply a data structure, i.e. it has no behaviour.





Ruby Tuesday #16 Part 2 : IronRuby news

29 07 2008

At OSCON last week, John Lam made a number of announcements about IronRuby (and speaking of OSCON, you should check out the announcements Sam Ramji made, too.)  In summary:

There’s a binary release of IronRuby, which includes the standard Ruby libraries.

An ironruby-contrib project has been established – another way to get involved in the IronRuby community.

A set of changes to RubySpec have been submitted.

The full blog post on the IronRuby announcements is here.  Well worth reading in full.





Ruby Tuesday #16 Part 1 : A Little Light Metaprogramming

29 07 2008

One of the reasons I was interested in learning about Ruby is metaprogramming.  For those new to Ruby, consider the following code:

class Test
 (0..5).each do |i|
    define_method "method_#{i}" do
      puts "Hello World #{i}"
    end
  end
end

Ok, it may not be the most useful piece of code in that form, but I think it shows just how metaprogrammable Ruby is.  When you remember that you can modify classes at runtime, alias methods and so on, the possibilities start to become clear.  If this has got you thinking about metaprogramming and what you could use it to achieve, this post goes into more detail on metaprogramming techniques in Ruby.





Ruby Tuesday #15 : Ruby Round Up

23 07 2008

There’s a few things I’ve noticed over the last week in the Rubyverse that I thought it was worth highligting.  In no particular order, here we go.

In my Ruby doodlings, I’ve spent quite a bit of time with REXML.  GIven that I’m focussed on learning Ruby rather than deploying code, there’s no issue.  However, this post from RubyInside shows there are alternatives such as libxml-ruby.

Testing, both TDD and BDD style, are prominent in the Ruby community.  This post examines the reasons to unit test, questions the emphasis placed on unit testing and highlights the importance of remembering why you test.  Well worth reading and relevant regardless of your preferred language.

Finally, I came across a couple of resources that those who, like me, are learning Ruby may find valuable.  The first is the news that there is a new chapter in the Book of Ruby.  The second is a couple of posts about learning Ruby for C#ers.  These posts also mention IronRuby, so well worth reading.