Wednesday, November 24, 2010

Validation Application Block and Unit Testing

The Enterprise Library VAB is a very sane way of maintaining validation rules for your Model entities. I love the idea that you can keep the validation rules in a separate configuration file, because that enables you to more clearly check what rules are being applied, the messages, etc, without having to open many files.

The problem with this approach is that unit tests will fail to open the .config is usual circumstances, which will frustrate many developer. But, like almost everything in life, there's a solution, and a good one.

Check it here.

Tuesday, October 19, 2010

Enlarging/Expanding a VirtualBox HDD

I've been  using VirtualBox as a development host for quite some time now. But I've recently ran into a problem: the HDD that I defined wasn't large enough to install all tools I need (it ran out of 20G of space when I decided I needed to install management tools for SQL Server Express 2008).

So I've looked around the net searching for how to do this. First, I'm quite disappointed that VirtualBox itself doesn't accompany a tool that does that. Secondly, most of the solutions I found were complex or involved downloading large LiveCD images. Until I found this blog, which not only compiles many links to other solutions, but provides a simple one -- the one I used and recommend.

If you're brave enough (you must be; We are dealing with disk partitions here) all you have to do is:

  1. Download GParted LiveCD (~150MB) from here.
  2. Define a new HDD in VirtualBox and set it to be your secondary partition.
  3. Mount the live cd as the primary IDE controller. Make sure the BIOS in your Virtual Machine is configured to boot from the CD first (and HDD next).
  4. Boot GParted in command line (shell) mode.
  5. Use fdisk -l to identify the old disk and the new one. Be careful! 
    1. Usually, your original partition will be /dev/hda*, where * is a number. It can also be /dev/sda*. The new partition can have another number (higher one, in most cases) or be something like /dev/sdb.
    2. Remember that GParted will have a partition of its on, mounted on /. Use mount to list mounted partitions.
    3. If you try to mount a unpartitioned hdd mount will tell that you need to inform its file format. That is a good clue you are talking about the right partition. 
  6. Once you identified the source and target devices, all you have to do is dd if=[source] of=[target]. It will take a long time, since its doing a byte-by-byte copy of your partition. 
    1. Assuming your source device is /dev/hda2 and your target is /dev/hdb, the command above should be: dd if=/dev/hda2 of=/dev/hdb

Once the copy is over, all you need to do is shutdown the system, map only the new drive as the main HDD of your VM, and boot it up. 

Good luck.

Wednesday, September 8, 2010

Better Cygwin Terminal

It's been a while since my last post. I still don't have time to do it properly, but here goes a tip for those of us who use Cygwin:

Make sure rxvt is part of your Cygwin install, and update your C:\cygwin\cygwin.bat to this:

@echo off
 C:
 chdir \cygwin\bin
 start rxvt -sr -sl 10000 -fg white -bg black -fn fixedsys -fb fixedsys -tn cygwin -e /bin/bash --login -i

(If you don't want the first window hanging around)
@echo off
 C:
 chdir C:\cygwin\bin
 set EDITOR=vi
 set VISUAL=vi
 set CYGWIN=codepage:oem tty binmode title
 rxvt -sr -sl 10000 -fg white -bg black -fn fixedsys -fb fixedsys -tn cygwin -e bash --login -i


Check out this site for more info.

Tuesday, August 3, 2010

SourceMaking

This one is for developers and architects out there. An excellent site about Design Patterns and UML:

https://sourcemaking.com/