I’m a big fan of what Cucumber has to offer a .NET developer like myself. What gets me down is the problem that IronRuby never seems *quite* mature enough to run it.

I’ve encountered (what i believe to be) a bug in IronRuby 0.9.0.0. The following feature (with no .NET interop) works using the Ruby interpreter, but fails under IronRuby.

The specification to reproduce the bug is based on a simple calculator performing an addition task. IronRuby barfs with the following error:

D:sourcerubycalculator>icucumber features
Feature: Addition
In order to save time
as a math n00b
I want to be able to add 2 numbers

wrong number of arguments (1 for 0) (ArgumentError)
c:/Ruby/lib/ruby/gems/1.8/gems/cucumber-0.3.94/bin/../lib/cucumber/ast/feature_element.rb:24:in `name_line_lengths’
:0:in `send’
IronRuby.Libraries:0:in `SendMessageOpt’
:0:in `each’
c:/Ruby/lib/ruby/gems/1.8/gems/cucumber-0.3.94/bin/../lib/cucumber/ast/feature_element.rb:20:in `first_line_length’
IronRuby.Libraries:0:in `Each’
:0:in `collect’


Hopefully the problem turns out to be something weird in my environment, but I’m reproducing the code below in case someone else would like to try it:

(i’ve also pushed it to Github: Ruby Calculator)

featuresaddition.feature
Feature: Addition
	In order to save time
	as a math n00b
	I want to be able to add 2 numbers

Scenario: Addition
	Given I have entered the first number 2 into the calculator
	And I have entered the second number 3 into the calculator
	When I call the add method
	Then the result 5 should be returned

Scenario Outline: More Addition
	Given I have entered the first number  into the calculator
	And I have entered the second number  into the calculator
	When I call the  method
	Then the result  should be returned

Examples:
	| x  | y | method | result |
	| 2  | 3 | add    | 5      |
	| 1  | 1 | add    | 2      |
	| 0  | 0 | add    | 0      |
	| -2 | 3 | add    | 1      |

 

featuresstep_definitionscalculator_steps.rb
require "spec"
require "lib/calculator"

Before do 
	@calc = Calculator.new
end

Given /^I have entered the first number (-?d+) into the calculator$/ do |n|
  @x = n.to_i
end

Given /^I have entered the second number (-?d+) into the calculator$/ do |n|
	@y = n.to_i
end

When /^I call the add method$/ do	
	@result = @calc.add(@x, @y)
end

Then /^the result (d+) should be returned$/ do |n|
  @result.should equal(n.to_i)
end
libcalculator.rb

class Calculator
	def add(x, y)
		return x+y
	end
end

To run any command under the credentials of a different user, *nix systems have the sudo command. For example:

$> sudo pico /etc/hostname

To run a program under the credentials of a different user under Windows, you can use the runas command.

runas /user:administrator notepad

i use this command to quickly create batch files which i can drop into my c:windowssystem32 folder for immediate path happiness

This post serves as a reminder for myself.

I use the very capable e-text editor pretty much as my notepad replacement. I also spend a fair bit of time in console windows, and require a quick command to edit files using E.

I create a batch file called “e.bat” in %SYSTEMROOT%System32 and pop the following inside the file:

@start c:progra~1ee.exe %1 %2 %3

The added benefit is that this works from within a cygwin or msysgit console, too.

Another way would be to add e to the path, but i don’t think that’s really necessary – the path gets unwieldy and unmanageable quite easy.

I recently became owner and custodian of one of these cheap puppies

asus_eeebox_eb1006_01
Image by nDevilTV via Flickr

It’s a cute bit of hardware. Not sporting a powerful CPU, not boasting a kachunga of RAM and not carrying a large HDD, but for $360 what can you expect? The original intention behind this purchase was to use it as a cheap replacement for a Linux based web-server, but it seemed like such a shame to let what little spare power it has go wasted – turning it into a miniature media centre was an easy decision. The nice thing about XBMC is that there’s a version for Linux running on Ubuntu. This brief notation is my experience setting it up to run on my TV. It assumes you know Ubuntu reasonably well and are comfortable hacking at it.

Tools Required

Preparation

The eeeBox doesn’t come with a native CD/DVD-ROM, but you can easily jig something together by using an external EIDE HDD enclosure and a DVD-drive from any old PC. Just connect the cables together and you have yourself a working USB DVD-ROM.

Install Ubuntu

Firstly make sure you run a network cable into the eeeBox. Even though the wifi works fine, you’ll be downloading a stack of updates and doing that over 100MBps is better than 54MBps.

So pop in the Ubuntu desktop live CD and go through the standard installation. This might take a while depending on your setup, but just install the plain operating system and reboot. The installation has good defaults for partitioning when you let it decide what to do with the whole disk – just roll with it, unless you know what you’re doing. The nice thing about the desktop edition of Ubuntu as opposed to (say) the server edition is that it comes pre-packaged with all the necessary drivers:

  • Video: Intel Mobile 945GME Express Integrated Graphics Controller
  • Audio: Intel 82801G High Definition Audio Controller
  • WiFi: RaLink RT2860
  • Ethernet: Realtek RTL8111 Gigabit Ethernet controller

Additionally, it installs things like a working x-server and ALSA so that you don’t have to. It’s (by far), easier to start with desktop edition and cut-back, than to start with server and build up.

After reboot and login, the system will take you directly to your Gnome desktop. The autoconf would have detected the network connection and (assuming you have a local router/DHCP server) you’ll be on the network in seconds. Update Manager will then run a check for updates. You want to download and install these updates! In particular, Jaunty had graphics performace issues with the Intel GME 950 in its original release. I’ve found that an out-of-the-box installation doesn’t exhibit this problem anymore but its still a good idea to run the update first.

The desktop edition of Ubuntu doesn’t come with ssh natively installed. you can rectify this with:

$> sudo apt-get install ssh

There’s a good chance you’ll need to restart again after the updates.

Install XBMC

Once re-booted, we want to install XBMC from the package archive for your version of the system (again, assuming Jaunty). Using your fresh ssh install, you can PuTTY into the box (my personal favourite) and add the two following lines to your /etc/apt/sources.list:

deb http://ppa.launchpad.net/team-xbmc/jaunty-ppa/ubuntu jaunty main
deb-src http://ppa.launchpad.net/team-xbmc/jaunty-ppa/ubuntu jaunty main

Then you need to add the signed public key to the apt key register:

$> sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 9317790E

The most important step of all:

$> sudo apt-get install xbmc-standalone

Why standalone? The standalone version of XBMC contains “certain functions that are not available in normal XBMC for Linux, (or XBMC for Mac, or for Windows), these functions include Power Management, and Network Management.“. The power management alone is worth it.

At this point I recommend testing the installation. Load XBMC from the Applications menu and set your resolution + other options. Setting the resolution is quite important here because (as i found out later) you’ll need them if you decide to run a seamless boot sequence into XBMC

Configuring A Seamless Boot Sequence

By this, what I mean is that when your system boots, it will automatically log in as you and boot into XBMC and you wont incur the unnecessary overhead of running Gnome in the background as you might otherwise have. You can fall-back to Gnome if need be, but the default desktop environment will be set to XBMC.

In Gnome, click System > Administrator > Login window. In the dialog, make sure you set your password and for the default session choose XBMC. I’d also suggest the auto-login feature. It gives you a chance to break into Gnome or a failsafe terminal should you need it.

Restart your box in preparation!

At this point, if you should be unlucky (like me) and your resolution settings are lost after changing the default session, you’ll need to copy them from the original settings we set earlier. Fortunately this should be easy. Log onto the box as you and enter the following:

$> cd ~/.xbmc
$> mv userdata userdata_backup
$> cp /usr/share/xbmc/userdata . -r
$> killall xbmc

If you set up Gnome correctly, you should go back to the login screen and be able to log back into XBMC with full res.

Wireless Configuration

The last piece of the puzzle is getting the wireless to work. This should be too easy. Just edit the /etc/network/interfaces file and add the entry for the RaLink RT2860 wireless device (ra0). In my setup, i’m using WEP so it looks like this:

iface ra0 inet dhcp
  wireless-essid <SSID>
  wireless-key s:<PASSPHRASE GOES HERE>
auto ra0

Reboot one last time just to make sure it all works and you’re done!

What this doesn’t cover is how to configure an IrDA device for truly integrated experience. The B202 doesn’t have IR built-in but once i find a suitable device, you can bet i’ll be writing about it.

:)

Reblog this post [with Zemanta]

I’ve needed this a few times in the past and figured I best note it down for my own reference.

If you have created a number of objects and you want to be able to compare them during debugging, you can assign an Object ID to each instance of the object in the watch window like this:
Assign Object ID to object instance

Once assigned, you can evaluate that particular object instance either in the watch window or in the expression evaluator:
Evaluating an object using its ID

(The above images have been pilfered from Jim Griesmer)

i’ve installed e text editor on my desktop and trying it out for some Ruby development.

E is heavily dependent on using Ruby in the background to perform a number of its refactoring and text-based actions. Unfortunately, sometimes you can end up in a situation where E reports the following error whenever you trigger one of these actions:

ruby: no such file to load — ubygems (LoadError)

It looks obvious that the error is caused because E is trying to load the gem ubygems when it actually meant rubygems, but the problem is more involved than just that.

In my case, it turns out that after running the Ruby one-click installer, the installation creates an system-level environment variable RUBYOPT=-rubygems. This variable setting is what’s giving E its grief.

To fix: Simply remove the environment variable from your system settings and restart e for safe measure. In my experience, there’s no need to download the rubygem package and re-install it as mentioned on another site.

I had the following email exchange this morning:

---------- Forwarded message ----------
From: Xerxes Battiwalla
Date: Wed, May 20, 2009 at 10:31 AM
Subject: Re: Email Account Verification Update
To: account_upgrade1@programmer.net


Sure thing - happy to oblige.

My username is: Whydontyou
And my pass is: Shoveitupyourarse

Enjoy!


On Wed, May 20, 2009 at 9:52 AM, HELPDESK ADMINISTRATOR
<Amanda.Warren@selu.edu> wrote:
>
> The Helpdesk Program that periodically checks the size of your e-mail
> space is sending you this information. The program runs weekly to ensure
> your inbox does not grow too large, thus preventing you from receiving or
> sending new e-mail. As this message is being sent, you have 18 megabytes
> (MB) or more stored in your inbox. To help us reset
> your space in our database, please enter your current
> username (_________________) password (_______________).
>
> You will receive a periodic alert if your inbox size is between 18 and 20
> MB. If your inbox size is 20 MB, a program on your Webmail will move your
> oldest e-mails to a folder in your home directory to ensure you can
> continue receiving incoming e-mail. You will be notified once this has
> taken place.
> If your inbox grows to 25 MB, you will be unable to receive new e-mail and
> it will be returned to sender. All this is programmed to ensure your
> e-mail continues to function well.
> Thank you for your cooperation.
>
> HELPDESK ADMINISTRATOR.
>
>
>
>
>
>
> ----------------------------------------------------------------
> This message was sent using IMP, the Internet Messaging Program.
>
>


Just quietly, i’m surprised it managed to get through GMail’s spam filter….

In Windows 2000/XP you can add/remove content from your Send-To menu just by navigating to the SendTo directory of your profile (eg: C:Documents and SettingsXerxesSendTo

In Vista they changed the location of the SendTo directory and I never found out where until now! If you navigate to the shell extension “sendto” (eg: Start –> Run –> “shell:sendto”), it opens up the list of items in the send-to menu when you right-click a file in Explorer.

I normally like to add a shortcut Notepad so no matter what file type i’m opening, I can have quick access to drop it in Notepad if necessary.