Unsatisfied By My Specification Pattern

February 7th, 2010

This week, I hit an interesting problem which I don’t feel like was solved in the best possible way. The problem was that we needed to filter a list of objects based on some known criteria. Testing the specification is pretty important as there are a series of and’ed negating conditions (eg: IF this AND NOT that AND NOT the other etc…), in total about 5 unique criteria for the one filter.

Ordinarily this kind of implementation would lend itself nicely to the Specification Pattern given that all information required to determine if the specification is satisfied exists on the object member being passed in at the time of evaluation. In my case, however, I had 3 conditions that the object being evaluated must not exist in 3 different lists. To give you an example the object under evaluation is a model, and this step of filtering is part of a much larger process involving running the model through a recursive algorithm. At each step of the algorithm, the model object could have

  • Run through the algorithm succesfully
  • Been aborted during execution of the algorithm
  • Still awaiting to be executed through the algorithm

These three states are tracked by keeping 3 lists – one for each criteria. The filter that I was working on had to filter based on whether the model under evaluation was NOT in those three lists. I realise the wordiness of me explaining this doesn’t really clear the air, so lets look at some code (with relevant types changed).

This is my model:

    public class User
    {
       public bool Enabled { get; set; }
       public string Name { get; set; }
       public UserType TypeOfUser { get; set; }
    }

The code which uses my filter looks something like this. This guy will be called recursively based on the result that gets returned from here. In this case, i’m building the allValidUsersFilter.

public class ReplacementUserFinder
{
        ...ctor...fields...etc

        public User FindReplacementUser(User userToReplace, IList<User> allPossibleUsers, IList<User> usersStillToBeEvaluated, IList<User> usersAlreadyEvaluated, IList<User> usersAbortedDuringEvaluation)
        {
            var validUsers = _allValidUsersFilter.Filter(allPossibleUsers, usersStillToBeEvaluated, usersAlreadyEvaluated, usersAbortedDuringEvaluation);
            var replacementUser = _bestReplacementCandidateFinder.Find(validUsers, userToReplace);

            return replacementUser;
        }
}

and the interface for the AllValidUsersFilter – it’s purpose is to filter the list of all users to a list of potential candidates given the list of all users:

        public IList<User> Filter(IList<User> allpossibleUsers, IList<User> usersStillToBeEvaluated, IList<User> usersAlreadyEvaluated, IList<User> usersAbortedDuringEvaluation)
        {
            return allpossibleUsers.Where(x =>
                _isUserEnabledSpecification.IsSatisfiedBy(x) &&
                _isOverseasUserSpecification.IsSatisfiedBy(x) &&
                    !_isUserStillToBeEvaluatedSpecification.IsSatisfiedBy(x, usersStillToBeEvaluated) &&
                    !_isUserAlreadyEvaluatedSpecification.IsSatisfiedBy(x, usersAlreadyEvaluated) &&
                    !_isUserAbortedDuringEvaluationSpecification.IsSatisfiedBy(x, usersAbortedDuringEvaluation)
            ).ToList();
        }

The specification instances here are being ctor injected into my filter’s instance so that I can use a behavioural style assertion to check that the specification is invoked correctly by the filter.

The IsUserEnabledSpecification, and IsOverseasUserSpecification just use the well-known ISpecification interface pattern, but in order to evaluate the the other three, I had to create an IListSpecification and it feels somehow unsatisfying because the only thing different between them is that I have to pass in the list to the IsSatisfiedBy methods.

I’m not happy with this result, and we went through several different options before settling on this one purely just so we could move forward, and come back to address this later.

Hoping someone out there might have some suggestions…After writing this post, i’ve come up with another idea which would probably be cleaner…need to try it out.

Xerxes IT & Software , ,

Mount a VHD in Windows 7

January 19th, 2010

Windows 7 (and possibly even Vista) has the ability to mount a VHD. The VHD could have been created from Virtual PC or Virtual Server, or it could be a System Image backup created by Windows Backup.

To mount the VHD, open the Computer Management console (Start -> “Computer Management”). Right-click the Disk Management option in the tree and select Attach VHD.

Awesome.

Xerxes IT & Software

Coo….Cooooooo

January 7th, 2010

Making any kind of noises is apparently all the rage now….ha-ha-ha….coo ooo ooo mmmm. basically anything which doesn’t add up to “i’m hungry” or “i need my bum changed”.

patience, xerx….

Xerxes IT & Software

Relocating Your Windows Profile To A Different Location

January 6th, 2010

In the last few OS rebuilds of my machine, i’ve preferred to relocate my user profile to a different partition, and leave my C:\ as small and light as possible. The added benefit is that I can then backup an entire partition in a snap and be guaranteed i haven’t lost any major user-data.

To do this (under Windows 7), follow the steps below. This assumes you have formatted your machine and have a clean install of Win7 with your user account (with admin access) created.

Enable the Administrator account

This account is disabled by default and you will need to enable it in order to move your profile around.

  1. Press Start, and type “Computer Management” and run the first program
  2. Under Local Users and Groups\Users, you will see the Administrator account. Right-click the Administrator, select Properties. In the General tab, uncheck “Account is disabled”. Apply. Ok.
  3. If you don’t know the password for the Admin account, I suggest right-clicking the Administrator and Reset Password
  4. Log out of your current user account and log in as the Administrator
Enabling the Administrator account

Enabling the Administrator account

 

Copy The Profile To Its New Location

Logged in as Administrator, open Windows Explorer and navigate to C:\Users\. You will see your account folder there. **Move (dont copy!)** your account folder to the new location you want. In my case, I moved it to D:\home\.

Update The Profile’s Home Folder Path

You now need to update the user account to tell it that the profile exists in a different location.

  1. Press Start, and type “Computer Management” and run the first program
  2. Under Local Users and Groups\Users, you will see your user account. Right-click the account, select Properties. In the Profile tab, select “Local path”, and type in the new path of the profile. (eg: D:\home\xerxes). Apply. Ok.
Profile Home Path

Profile Home Path

 

Update Registry To Find New Profile

I probably should have mentioned this before, but if you’re not comfortable modifying your Windows Registry, you probably shouldn’t attempt this. Moreover, you probably shouldn’t be reading my blog.

  1. Start -> Run, “Regedit”, Enter
  2. Find the key HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList. There will be a string value called Profiles Directory. Update the value to be your new profile home directory. (eg: D:\home)
  3. Within the ProfileList key, there are a bunch of sub-keys, one for each user profile registered on the system. Scroll through them and look at the value ProfileImagePath, and find the one which mentions your username. Update the value of the ProfileImagePath to be the new path to your user profile (eg: D:\home\xerxes)
Updating User Profile Location In Registry

Updating User Profile Location In Registry

 

Fin//

You’re all done. Log out of the administrator account and try logging back into your own profile. If you did everything right, this should just work. If you want to disable the Administrator account again, you can do so after logging back into yours.

Xerxes IT & Software

Increase Development Productivity With Tomatoes

October 9th, 2009

Recently, my programming-pair and I adopted the Pomodoro time-management technique and applied it to our software dev tasks. We’ve been doing this for about a week and we’ve found it incredibly helpful. Our work environment is fantastic, but sometimes it’s too easy to be distracted by work-related interruptions (or other). This system allows us to focus on core development activities for a block of time, and a short-break in between. The purpose of this system is NOT to force us into being more productive for the sake of management or metrics – it’s to allow us to make the best use of the time we already have.

In a nutshell, the pomodoro (tomato in Italian) technique involves:

  1. Pick a task and work to complete it in 25 minutes
  2. Break for 5 minutes
  3. Repeat steps 1 & 2 three more times (4×25min blocks + 5×5min breaks in total)
  4. Have a 15 minute break

Although we’re still aiming to achieve 4 consecutive pomodoros in a row, we both have noticed the increased focus and commitment to delivering on our development tasks. The 25 minute time block actually acts as an incentive to try and complete a problem up to a logically clean point before time runs out – this has in turn helped us break the problem down into smaller tasks.

This system worked so well within the first few days of using it, we even set-up a box and screen right in the middle of our desks which (amongst other things) is used to display a big timer from the website http://tomatoi.st/. Any visitors who come to talk to us are kindly pointed to the big count-down and asked to come back at a time that’s better for us. Whilst it might seem unprofessional, we’ve yet to encounter someone who felt it important to disturb us in the middle of a timed task. There’s something about two people working diligently at a desk with a count-down over their heads that prevents others from wanting to disturb them.

What’s also nice about the tomatoi.st timer, is that it keeps track of the last 7 actions (either pomodoro or break). I whipped up a Yahoo pipe to convert the pomodoro list into an RSS feed. The purpose of the RSS feed is to at least keep historical records of how we’ve been tracking to see how whether or not we’re improving. This content could be fed into uladoo and tracked via Twitter or some other unnecessarily Web 2.0 service.

No doubt we’ll refine this process the more we work with it, but it’s been quite beneficial thusfar. I suspect a lot of other development teams will also benefit from this practice.

Reblog this post [with Zemanta]

Xerxes IT & Software ,

Viewing a File’s History in Git

September 10th, 2009

To view the full history of a file in your Git repo, use this:

gitk <filename>

Xerxes IT & Software

Recovering your Git repository after doing a “git reset –hard”

August 28th, 2009

There are many stupid people in this world. This guy is another one of them:
Picture of Xerxes Battiwalla

Yes that’s right, yours truly really screwed up this time.

For future reference (and in a nutshell), git checkout is not the same as git reset, particularly when you throw in the hard option. I know this now, and in fact I knew it when i accidentally blew away half my repository – didn’t make the end result any less pleasing.

Here’s the gitk output of what my tree looked like before the wipe:

Full project history from gitk

I was intending to checkout a previous revision of the repo to show how some code had evolved over time. Normally I would do this from the command line, but this time I (crazily) chose to use (the very disabled) gitk to do this, and blindly chose the “hard” option without thinking. So what I was left with was a very lacking repository and even sorely bruised ego. Goodbye repo history! It’s been nice knowing you….

Wiped Repository

Thanks to the ever-knowledgeable davesquared, there’s a way to recover your git repo once you bone yourself. If you escape the clutches of the gitk demon, the command line interface gives you a better level of control (and content which is crawlable by search engines ;) )

It turns out that until the repository is cleaned (git gc) and stale objects are cleared, the repo still has the necessary content stored, it’s just not visible. (if the following block looks terrible in your renderer, click through the link to read it properly.)

xerxes@laptop /d/source/dotnet/CodeKatas/.git/logs (GIT_DIR!)
$ cat HEAD
0000000000000000000000000000000000000000 f167fd4068e4b92134964e073f2e69a0cc8fced9 Xerxes  1250928395 +1000 commit (initial): Initial commit of binary search
f167fd4068e4b92134964e073f2e69a0cc8fced9 dd31afc8d793aaa952e032a77675b8e67f6b26bc Xerxes  1251007341 +1000 commit: Removedbin/obj from source control
dd31afc8d793aaa952e032a77675b8e67f6b26bc 0642a5e64a513f8949f7aa9e1d35a298fb713bfc Xerxes  1251007422 +1000 commit: removed.suo from source control
0642a5e64a513f8949f7aa9e1d35a298fb713bfc 0cf0929cfb9a31707b2ae937f0c6e73bd9e5bcb9 Xerxes  1251007479 +1000 commit: Implemented first binary tree implementation. it is shit
0cf0929cfb9a31707b2ae937f0c6e73bd9e5bcb9 6c27c54370bf2b79369dc5ef02ef7338bbf2865a Xerxes  1251010817 +1000 commit: Refactored first implementation to remove unnecessary elements
6c27c54370bf2b79369dc5ef02ef7338bbf2865a 937fcb1c36bf437e0df11847ee579ca60151144d Xerxes  1251021898 +1000 commit: removedresharper settings file from project
937fcb1c36bf437e0df11847ee579ca60151144d b12a95ea3c636615345559979d3fc0e93fecc0bc Xerxes  1251022036 +1000 commit: Rewritten first implementation of b-search to get practice.
b12a95ea3c636615345559979d3fc0e93fecc0bc f57503a6116822c9632e6b4dc6cb423640c6a152 Xerxes  1251028214 +1000 commit: 3rd implementation of binary search using shifted bounds.
f57503a6116822c9632e6b4dc6cb423640c6a152 be510f0f88baa38d8d2e645f568405d052f5bb14 Xerxes  1251028265 +1000 commit (amend):Another rewrite of binary search using shifted bounds.
be510f0f88baa38d8d2e645f568405d052f5bb14 2c0b21e7aea2dd27fc7281d1a20a887e2e1f3d0d Xerxes  1251090393 +1000 commit: Yet another re-write of the shifted boundary method.
2c0b21e7aea2dd27fc7281d1a20a887e2e1f3d0d d2a23e1cad8b36de1361700b89733a3b08401e2c Xerxes  1251253854 +1000 commit: Moved BinaryTree project to top-level folder
d2a23e1cad8b36de1361700b89733a3b08401e2c 4e8bd70336e89f9000f29553d53d98cb568bc809 Xerxes  1251253901 +1000 commit: Added nunit to the list of dependencies
4e8bd70336e89f9000f29553d53d98cb568bc809 551c754f27f10826dab43c50d8a3151b7e2740f5 Xerxes  1251253922 +1000 commit: Implemented FizzBuzz
551c754f27f10826dab43c50d8a3151b7e2740f5 11884f5935c85d4ec1497fe3a8eb39211d731fdc Xerxes  1251269688 +1000 commit (amend):Moved parameters onto FizzBuzz method and out of constructor
11884f5935c85d4ec1497fe3a8eb39211d731fdc cbda7a8c68c88900eb1c58ab7bf613bad26892ad Xerxes  1251269732 +1000 commit (amend):Implemented FizzBuzz solution
cbda7a8c68c88900eb1c58ab7bf613bad26892ad b40c951696a2d11854fce6a9fca1be9fc436e61b Xerxes  1251341643 +1000 commit: Anotherre-implementation of the shifted-boundaries method
b40c951696a2d11854fce6a9fca1be9fc436e61b b2c2a8b103aa43dac8e443cfc866fa35f9ffb048 Xerxes  1251341967 +1000 commit: RenamedBinarySearch to ShiftedBoundariesBinarySearch
b2c2a8b103aa43dac8e443cfc866fa35f9ffb048 30a224eb40c441df8a18b06eeb68af47a86bc37f Xerxes  1251344036 +1000 commit: Implemented RecursiveBinarySearch (badly). requires refactor
30a224eb40c441df8a18b06eeb68af47a86bc37f 0fbf8ace753f408b0e972b593e2b6a03dd2d0354 Xerxes  1251345463 +1000 commit: CreatedTreeNode Search
0fbf8ace753f408b0e972b593e2b6a03dd2d0354 0cf0929cfb9a31707b2ae937f0c6e73bd9e5bcb9 Xerxes  1251345505 +1000 0cf0929cfb9a31707b2ae937f0c6e73bd9e5bcb9: updating HEAD
0cf0929cfb9a31707b2ae937f0c6e73bd9e5bcb9 2c0b21e7aea2dd27fc7281d1a20a887e2e1f3d0d Xerxes  1251345635 +1000 checkout: moving from master to 2c0b2

xerxes@laptop /d/source/dotnet/CodeKatas/.git/logs (GIT_DIR!)
$

The beauty here is that the log has kept full record of all the SHAs for each commit in the repo. NOW i’m able to reset my master back to the appropriate commit by using the SHA-1 hash. So i checked out onto the master branch and issued:

xerxes@laptop /d/source/dotnet/CodeKatas (master)
$ git reset --hard 0fbf8ace753f408b0e972b593e2b6a03dd2d0354

and that reset my master back to the right revision, thereby restoring my history, code and sanity.

nb: i have taken some of these screenshots trying to reproduce after the event, so they might look a little doctored. Despite this, the findings and end results are the same.

Xerxes IT & Software

IronRuby 0.9, Cucumber and the never-ending story

August 13th, 2009

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:\source\ruby\calculator>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)

features\addition.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      |

 

features\step_definitions\calculator_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
lib\calculator.rb

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

Xerxes IT & Software ,

Run a command as Administrator under Windows

August 10th, 2009

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:\windows\system32 folder for immediate path happiness

Xerxes IT & Software

Opening a file in your favourite editor from the command line

July 28th, 2009

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~1\e\e.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.

Xerxes IT & Software

Turning your Asus eeeBox B202 into a XBMC

June 28th, 2009

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]

Xerxes IT & Software , ,

Using Object IDs in C#’s Debugger to chase object references

June 1st, 2009

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)

Xerxes IT & Software ,

Enabling Colours In Git’s Console Output

May 28th, 2009

Mainly to serve as a reminder for myself: To enable colour output in MSysGit’s console, issue the following command from the bash prompt:

$> git config --global color.ui auto

Xerxes IT & Software

e Text Editor: “ruby: no such file to load — ubygems (LoadError)”

May 27th, 2009

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.

Xerxes IT & Software , ,

What do the following people have in common?

May 20th, 2009