Wednesday, December 31, 2008

Validation Application Block Gotchas

The Microsoft Enterprise Library's Validation Application Block is really neat for validation of data, but with the way it's been implemented, it can be difficult for developers to diagnose problems with it, especially when declaratively defining the validators using XML. Often, a validator returns true even for invalid data. Let's look at a few common causes:

1. The RuleSet specified does not exist

When you use a validator defined as
Validator<NitinR> validator = ValidationFactory.CreateValidator<NitinR>("Rule1");
the Validation Application Block looks around for Rule1 and if it doesn't find a definition, it simply indicates that the object being validated is true. I'm pretty sure everyone would expect it to throw an exception, but it doesn't!

2. The Member Is Of An Incorrect Type

If you've defined a validation for a field, but change it to a property while re-factoring, the library simply assumes that you haven't defined any validation for that property so it returns a ValidationResults object with IsValid set to true.

3. NotNullValidator On A Value Type

If you think the NotNullValidator is going to tell you that a value-typed member variable has not been initialized, think again. For an Int32 member, the default value is a zero. When the NotNullValidator looks at the Int32 member, it sees the value zero instead of a null, so the data is valid. To get around this issue, add a "?" suffix (C#) to the data type to declare the variable as a null-able value type.

4. RelativeDateTimeValidator Needs Negative Values For Dates In The Past

This one sounds obvious but was a bit tricky. It took me a while to figure out through trial-and-error (as opposed to reading the source code or reverse engineering) that if I want to refer to a date in the past, I'm supposed to use negative values, especially since the Enterprise Library Configuration tool reports a configuration error. (I'm guessing the error from the configuration tool is because my lowerBound was set to -1 with the lowerUnit Day and the upperBound was set to -5 with the UpperUnit Seconds, and the configuration tool ignores the units so it sees the lowerBound value greater than the upperBound)

Tuesday, December 30, 2008

Extending the Oracle Single Sign-On Server

From: kurtvm,
2 days ago
Extending Oracle SSO
View SlideShare presentation or Upload your own. (tags: server application)

With a complete new Identity/Access Management Suite on the Oracle market, one might forget the good old SSO server, bundled with the IAS server. Although it has some out-of-the-box capabilities like WNA and X509 certificate support, it can be customized to set up an authentication scheme just the way you (or your customers) like it. Using a case study, this presentation discusses how you can extend Oracle’s Single Sign On (SSO) server to your needs. It covers:

  • Integration & authentication with smartcard passports (eID)

  • Authentication with digital certificates

  • Implementing fallback authentication schemes

  • Integration with SSL terminators and reverse proxies

  • DIY federated authentication

  • writing your own SSO plugin

SlideShare Link

Duplicate Key From Scanned Image

LifeHacker reports an incident in which a reader, Mark, left behind his keys while on holiday so got a scanned copy of his keys from his girlfriend.

The locksmith took the scanned image and matched the numbers from the key and the car model against a database of known keys. The first cut key worked and it only cost $29!

That's one tech-savvy locksmith.

Quiz: How Web 2.0 Are You?

Quizzible has a really cool quiz titled "How Web 2.0 Are You?".

You are shown parts of 34 logos that you have to identify. Check it out here

PS: You can type the names without bothering about capitalization!

Lenovo 3000 Fan Replacement

My Lenovo 3000 N100 work laptop always had a noisy fan but over the past couple of days, its been pretty noisy and the overheating causes my laptop to turn off.

I got the tech support guy to give me a replacement, so he checked the inventory and they had another slightly-used Lenovo 300 N100. After swapping hard disks which was pretty simple, I wanted the 2x512MB RAM replaced with the 1x1GB, 1x512MB RAM from my former laptop so things went quite well till I discovered the "k" key on the keyboard wasn't working.

Then, we decided to get the hard drive and RAM back to the laptop that I started off with and transplant the cooling fan. There was a tiny connector on the motherboard for the fan along with a couple of screws - they have a case panel to replace the fan too! There was a pretty big gang of dust bunnies covering the air vent, preventing air flow - no wonder it was overheating! After getting rid of the dust, transplanting the new fan in place and getting the case closed, I'm back in business.

Monday, December 29, 2008

CSS Essentials

From: iamtin,
7 hours ago
Css Essential
View SlideShare presentation or Upload your own. (tags: openparty css)

SlideShare Link

Fennec Alpha 2 Released

Mozilla released Fennec Alpha 2, a mobile browser with a small memory footprint. If you would like to try it out, a desktop version of Fennec is available for Windows, Mac OS X and Linux to try out and build add-ons.

Windows Powershell CTP3 Available

Last Monday, Microsoft made available the 3rd Community Technology Preview edition of the Windows PowerShell. The new released features 63 new Cmdlet, several bug fixes and many new features.

You can get the new version for Windows XP SP3, Windows Server 2003 SP2, Windows Vista SP1 and Windows Server 2008 from here

Linux 2.6.28 Released

The 2.6.28 Linux kernel was released last week. Among the new features in the new kernel are the Graphics Execution Manager (a GPU memory manager), a stable release of the Ext4 file system. More information on the release is available here and here.

Sunday, December 28, 2008

AMD Phenom II Reaching Shelves As Early As Next Week

The AMD Phenom II was made available to retailers this week so you can expect to see them on store shelves as early as next week. The processors are AMD's answer to Intel's Core i7, both of which are quad-core. The Phenom II offers slightly less performance than the Core i7, but costs roughly half as much which makes it quite attractive to system builders.

The Art of Software Estimation


The Art Of Estimation

From: codeburns,
1 day ago


The Art Of Estimation
View SlideShare presentation or Upload your own. (tags: mcconnell software)



I read, reviewed and digested the excellent The Art of Estimation by Steve McConnell and presented back what I'd learned about software estimation to the team.



SlideShare Link

CES: Panasonic To Unveil Powerline Network; Sharp displaying LCD-Bluetooth TV

Panasonic's networking-over-electrical wiring system will be unveiled at the Consumer Electronics Show in Las Vegas next month (Jan 8 - 11 '09). The prototype on display will be with an electric vehicle and security devices.

Meanwhile, Sharp will be releasing 32" and 42" LCD TVs with integrated Blu-ray players at the CES. The 42" version is priced at roughly $2,000.

Nintendo To Offer Videos On Wii


Nintendo has teamed up with Dentsu, an advertising firm, to provide videos for Wii boxes. It hopes to provide both free and payable services. Sony has a similar service for the PlayStation for online movie sales, while both Sony and Microsoft also feature commercials within games.

CES: NetBooks Turn Into TouchBooks


The next generation of netbook are making their entry into the mainstream at the CES. Asus is introducing the Asus Eee Touch while Intel is showcasing its Classmate notebook. Gigabyte already has its M912V touchscreen netbook on sale.

.NET: Implement IEnumerable to use a foreach? Not really.

To use your class with a foreach loop, you don't have to implement the IEnumerable interface - you simply have to write a public method that matches the signature:
public IEnumerator GetEnumerator()

The Microsoft guys probably thought they could sneak that past us, but they couldn't now, could they?

Getting Creative with my GTalk Status Message

My GTalk status:

Click on image to enlarge

Saturday, December 27, 2008

A Ubuntu ISO Video for Beginners

If you are trying to teach co-workers, friends or family to install Linux and hop onto the Linux bandwagon, you might want to send them this video link.

It's a screencast by Alan Pope on downloading Ubuntu and writing the ISO to install Ubuntu Linux.

Vietnam Restricts Blogging

The Vietnamese government approved a law on 18th December 2008 restricting bloggers from posting anything that the government believes is sensitive information or has malicious intent. This extends the laws governing the state-controlled media to the Internet.

The government plans to impose this restriction by forcing 'Internet companies' to provide information about blog authors.

My First Test Run with Sun VirtualBox 2.1.0

Ever since the release of the VirtualBox 2.1.0, I've been wanting to try it out. Today, I finally decided to kill a part of the holiday and give it a first run.

I looked around on the website but didn't find separate installations for the open source edition and the regular edition so I just clicked away on the only link for the VirtualBox Windows x86 version I saw. The installation popped up a few driver signing warning dialogs which was pretty annoying, but apart from that the installation went without any concern.



I then whipped up a quick guest setup for Ubuntu with most of the default options but without the virtual hard drive setup, I tossed in my Ubuntu bootable DVD and off I was. I noticed after bootup that Ubuntu didn't detect the sound hardware from within VirtualBox. Also, the Windows-Tab keyboard combo for switching between windows Vista-style didn't seem to work when Ubuntu ran within VirtualBox.



I noticed the status bar of Virtual Box displays if the mouse has been captured by VirtualBox, which is a pretty neat feature - it also indicates the 'host' key to un-capture the keyboard and mouse.

When I finally close a VirtualBox guest window, I popup dialog prompts me to shutdown or save the state of the guest virtual machine - that's a pretty neat feature, especially since Ubuntu takes so long to boot off the DVD.

I find VirtualBox pretty responsive compare to some other virtualization software that I've tried. The fact that it is open-source ought to make it more appealing to some. Over the next couple of days I'll be running Ubuntu within VirtualBox so I'll post about any glitches if any happen to show up.

Free Microsoft Virtualization Solutions E-Book


Microsoft is offering a 450 page ebook on virtualization titled "Understanding Microsoft Virtualization Solutions" by Mitch Tulloch. The book includes chapters on Hyper-V and Terminal Services. The book is available as a free download in PDF format here.

Friday, December 26, 2008

Make Up Your Mind - Does TCP/IP Have 4 Layers Or 5?

There isn't a consensus over how many layers the TCP/IP protocol stack has - we've got 2 major camps, one of which says there are 5 layers while the other claims that it has 4 layers.

If you look at this article on Wikipedia, the table on the different layers and the names of the layers pretty much summarizes the disagreement. Tanenbaum and Kurose, along with the Cisco Academy, believe that there are 4 layers in the TCP/IP stack and the RFC 1122 document says so too. However, Forouzan, Comer, Kozierok and Stallings insist that there are 5 layers.

Now, let's say sometime in the not too distant future, in 2010, if they all do reach an agreement on the number of layers, the argument would continue over the names that we ought to assign to the layers :-)

PS: Did you know we have a standard for the transmission of IP packets with carrier pigeons? Look up RFC 2549 - IP over Avian Carriers with Quality of Service.

Why I Like Linux As A User

The best thing about Linux distributions today is that pretty much all the stuff that I would need is in there or can be installed quite easily.

In the Windows world, if I want to get rid of everything and start over, I have to re-install Windows, find and install all the drivers which means changing a bunch of CDs and manually running the setup, install all the software (MS Office, Firefox, Chrome, Opera, Safari, MS Visual Studio, MS SQL Server, MS Enterprise Library, other 3rd party .NET development libraries, Adobe Reader, Antivirus software, VLC player, Flashget, Nero, Java Runtime Environment).

With Linux, I boot up with the DVD and start the Linux OS installation which installs pretty much everything. If anything is missing, I use 'yum' on the command line (that can probably be scripted) and everything is setup with minimal user interaction.

The one thing I don't like about Linux is the time it takes Linux distros to get working drivers out-of-the-box. Till the last version of Fedora and Ubuntu, the wireless on my notebook didn't work on install.

C# - ?? Operator

C# 2.0 has the little-known ?? (double question mark) operator which returns the second operand if the first operand is null. It's the equivalent of the NVL or COALESCE function in SQL.

Example:
using System;

class Program
{
static void Main(string[] args)
{
int? cole = null;
string str1 = null;

Console.WriteLine(cole ?? 4);
Console.WriteLine(str1 ?? "Nitin");

Console.ReadLine();
}
}

Intel Moves Away From NVidia Ion

NVidia has been looking to pair up its chipsets with the Intel Atom processor, however Intel doesn't seem to want to play along. Intel has recently sent around a memo indicating that the Atom processor should only be used with it's i945GSE and i945GC chipsets.

That ought to turn NVidia toward Via and AMD for a netbook processor.

There still is a webpage from NVidia that says "NVidia GeForce 9400 plus Intel Atom". I guess the PR guys at NVidia didn't get Intel's message :-P

Thursday, December 25, 2008

GIT as an SVN Replacement


Git As A Subversion Replacement

From: technicalpickles,
6 months ago


Git As A Subversion Replacement
View SlideShare presentation or Upload your own. (tags: rails ruby)



Gives an intro to git, from the perspective of subversion. Then goes on to show other git goodness.



SlideShare Link

HTML 5: In a big nutshell


Html 5 in a big nutshell

From: lensco,
3 weeks ago


Html 5 in a big nutshell
View SlideShare presentation or Upload your own. (tags: development web)



A presentation at BarCamp Ghent 2 (nov 29, 2008), providing a quick overview of HTML 5. Includes two detailed cases, one about local storage APIs and one about the new video element.



SlideShare Link

Merry Christmas

Merry Christmas

Wishing you a Merry Christmas!

Best Wishes,
Nitin Reddy Katkam

Image from StockXchng

Enterprise Library VAB Validators (Part 1 of 2)

If you've been following my blog this week, you've probably read the post I made earlier about using the Microsoft Enterprise Library Validation Enterprise Block (VAB). I continue from where I left off by discussing the different types of validators available as a part of the VAB.

The different validators available with VAB are:

  • Not Null

  • Domain

  • String Length

  • Date Range

  • Contains Char

  • Range

  • Regular Expression

  • Property Comparison

  • Enum Conversion

  • Type Conversion

  • Relative Date Time

  • Object

  • Object Collection

  • Or Composite

  • And Composite



Let's start off by looking at the common attributes for each of the validators viz. Type, messageTemplate, lowerBound, lowerBoundType, upperBound, upperBoundType

Type

All of the validators have a type attribute which indicates which validator you are defining (Eg. NotNullValidator).

messageTemplate

A messageTemplate defines the validation message to be returned when validation fails. You can use tokens ({0}, {1}, ...) as placeholders, but the values represented by the tokens are validator-specific.

lowerBound, upperBound

These attributes define the minimum and maximum permissible values for range validators (Range, Date Range, Relative Date Time etc)

lowerBoundType, upperBoundType

The lowerBoundType and the upperBoundType indicate whether the value for the lowerBound and upperBound should be ignored (used when you only want to specify one of the two - either the minimum or the maximum value) and if a value is valid if it is equal to the boundary value (inclusive or exclusive).

negated

The negated property is used to turn a validator around so it says the data is invalid when the condition is true and vice-versa.


Now, moving on to the each of the 15 validators listed above.

Not Null Validator

The Not Null Validator can be used to ensure that an object reference is not null. You can't use this validator with a regular value type but you can use this with nullable value types.

Example:
<validator messageTemplate="validation error" type="Microsoft.Practices.EnterpriseLibrary.Validation.Validators.NotNullValidator, Microsoft.Practices.EnterpriseLibrary.Validation, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" name="Not Null Validator" />

Domain Validator

The Domain Validator can be used to limit the values of a member to a list of values. If a member is null or un-initialized, the validator indicates that the data is invalid. To allow un-initialized (non-nullable) value types, you can simply use the default value for the value type (Eg. 0 for int).

Example:
<validator messageTemplate="" type="Microsoft.Practices.EnterpriseLibrary.Validation.Validators.DomainValidator`1[[System.Object, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]], Microsoft.Practices.EnterpriseLibrary.Validation, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" name="Domain Validator">
<domain>
<add name="DXB" />
<add name="SHJ" />
</domain>
</validator>

Notice the use of generics with the DomainValidator - the Enterprise Library Configuration tool simply uses the Object type.

String Length Validator

The String Length Validator, as the name indicates, validates a string to ensure that its length is within a specified range. If a string is null, it is invalid even if the lowerBound is set to 0 (inclusive lowerBountType).

Example:
<validator lowerBound="3" lowerBoundType="Inclusive" upperBound="3" upperBoundType="Inclusive" messageTemplate="" type="Microsoft.Practices.EnterpriseLibrary.Validation.Validators.StringLengthValidator, Microsoft.Practices.EnterpriseLibrary.Validation, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" name="String Length Validator" />

Date Range Validator

The Date Range Validator checks if a date field/member/method is within a specified date range.

Example:
<validator lowerBound="1950-01-01" lowerBoundType="Inclusive" upperBound="2000-12-31" upperBoundType="Inclusive" messageTemplate="" type="Microsoft.Practices.EnterpriseLibrary.Validation.Validators.DateTimeRangeValidator, Microsoft.Practices.EnterpriseLibrary.Validation, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" name="Date Range Validator" />

Contains Char Validator

The Contains Char Validator checks if a string contains a particular character.

Example:
<validator characterSet="@" containsCharacter="Any" messageTemplate="" type="Microsoft.Practices.EnterpriseLibrary.Validation.Validators.ContainsCharactersValidator, Microsoft.Practices.EnterpriseLibrary.Validation, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" name="Contains Characters Validator" />

Range Validator

The Range Validator is used to check if a numeric type is within the specified range.

Example:
<validator lowerBound="0" lowerBoundType="Exclusive" upperBound="" upperBoundType="Ignore" messageTemplate="" type="Microsoft.Practices.EnterpriseLibrary.Validation.Validators.RangeValidator, Microsoft.Practices.EnterpriseLibrary.Validation, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" name="Range Validator" />

Regular Expression Validator

The Regular Expression Validator checks if a string matches the specified pattern.

Example:
<validator pattern="[A-Z0-9 ,\.]" options="IgnoreCase" messageTemplate="Upper case letters, numbers, comma and period allowed for address" type="Microsoft.Practices.EnterpriseLibrary.Validation.Validators.RegexValidator, Microsoft.Practices.EnterpriseLibrary.Validation, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" name="Regex Validator" />

(Contd. in Part 2 of 2)

Wednesday, December 24, 2008

The 4 Tenets of Service Oriented Architectures

There are 4 basic guiding principles when developing a system with a service oriented architecture. They are:
1. Service boundaries are explicit
2. Services are autonomous
3. Clients & services share schema and contracts
4. Service compatibility is determined by policy

Service Boundaries are Explicit

When we say a service boundary is explicit, we mean a consumer cannot call methods that are not exposed by a service nor can modify data private to the service. The operations that the consumers can perform are limited to those that are exposed by the service.

Services are Autonomous

Services have to be independent entities. You can deploy a new version of a service without any of its consumers being aware of the change. The service should not depend on the consumer to perform any operation, such as validation of data - this has to be performed by the service itself.

Consumers and Service Share Schema and Contracts

The only way for a consumer to communicate with a service should be through the defined interface. The service shouldn't enable the consumer to perform anything other than the operations defined in the contract. If your service and consumer share a class instead of an interface, then you know you aren't implementing an SOA correctly.

Service Compatibility is Determined By Policy

Just as a schema defines the structure of the data and the contract defines the operations that can be performed, a policy determines how the communication occurs between the consumer and the service. A policy can determine the data representation (encoding), security and reliability features for the consumer-service interaction.

The 4 tenets of service orientation provides a basic definition that is applicable to all implementations of a service oriented architecture.

jQuery in 15 minutes


jQuery in 15 minutes

From: simon,
2 years ago


jQuery in 15 minutes
View SlideShare presentation or Upload your own. (tags: javascript jquery)



A short introduction to jQuery.



SlideShare Link

jQuery 1.3 and jQuery U.I.


jQuery 1.3 and jQuery UI

From: jeresig,
2 weeks ago


jQuery 1.3 and jQuery UI
View SlideShare presentation or Upload your own. (tags: jquery javascript)



A talk given at Mexico Web 2.0, November 2008.



SlideShare Link

Pick a Different CPU Core

If you use CPU core affinity to keep one application from affecting other application on your server, you would be in for a surprise while benchmarking your application with a different core.

Researchers from Virginia Tech have published a research paper indicating that not all the cores on a CPU offer the same performance. Often, interrupts in a CPU are handled by a single core, thus reducing the performance of the applications running on that core.

If you aren't using CPU affinity, you might run into cases where the data that you need is cached with one core (each core has it's own L1 cache) while the software is running on a different cache.

You can get a copy of the research paper here.

Google Has No Idea Where I Am

Today, I fired up my browser and went to Google.com but it redirected me to Google.com.pk instead of Google.ae.

Due to the severed network cables off the shore of Egypt last week, the ISPs in Asia and the Middle East have had to re-route traffic so Google thinks I'm in Pakistan when I'm actually in the United Arab Emirates.

Here's a screenshot:


Notice the "http://www.google.co.pk" in the address bar (which Google Chrome calls the 'Smart bar'), the "pages from Pakistan" radio button, and the "Google.co.pk offered in Urdu (اردو)" language setting.

TortoiseSVN Checkout URL

If you've got a whole lot of SVN repositories that you access but don't have the Einstein-like brain to remember the location of all of them, you ought to create a webpage on your I.T. intranet portal with the location of all the repositories that you work with. If you use TortoiseSVN as your SVN client, you can turn the locations into hyperlinks that users can click on by adding a "tsvn:" as a prefix to the location in the HREF attribute.

Example:
I have an SVN repository located at http://nitinwritescode/svn/RedInk so the HTML that I write up looks like this:
<html>
<head>
<title>SVN Repositories</title>
</head>
<body>
<h1>SVN Repositories</h1>

<ul>
<li>
<a href="tsvn:http://nitinwritescode/svn/RedInk">Click here</a>
</li>
</ul>

</body>
</html>

When I click the link, I get the following dialog box from TortoiseSVN

Tuesday, December 23, 2008

Minify Your Web Page

If you're optimizing the performance of your website, you should try minifying your Javascript. What I mean is get rid of all the comments, line breaks and other whitespace. You will find a significant difference in the file size for larger Javascript files. Using JsMin can automate the minification of your Javascript but you really ought to read the documentation that they provide before using it. Get JsMin here - you can get both the .EXE executable and the source code.

You might want to try server-side compression configuration so the web server can compress the content before sending it to the browser. Caching is also something you can optimize to work in your favor.

PS: The Google home page is heavily minified - they even use short variable names!

A Simple MS Enterprise Library Validation Block Example

I've been building an example on using the MS Enterprise Library Validation block for my co-workers. Here's a pretty simple step-by-step guide to getting started.

Let's start off with a Console application. (This could even be a Windows Forms application, a Windows service or a Web Application/Web Site.)

Step 1: Add references to Microsoft.Practices.EnterpriseLibrary.Common and Microsoft.Practices.EnterpriseLibrary.Validation

Step 2: Create a class that can store your data

namespace MyApplication1
{
public class UserProfile
{
public int ID { get; set; }
public string Name { get; set; }
public string Email { get; set; }
public DateTime DOB { get; set; }
public string Address { get; set; }
public string CityCode { get; set; }
}
}

Step 3 (GUI):
Start the Enterprise Library Configuration tool by going to Start > Programs > Microsoft patterns and practices > Enterprise Library 4.1 - October 2008 > Enterprise Library Configuration.

You may have a different version of the Enterprise Library installed - I'm using 4.1, but you can use 3.1 just as well.

Using the Enterprise Library Configuration tool,
(i) add a Validation Application block section,
(ii) Add a type,
(iii) Add the properties (or fields/methods, as the case may be),
(iv) Add validators to the properties (or fields/methods from iii ), and
(v) Provide the parameters for the validators, if applicable

Microsoft Enterprise Library Configuration for the Validation Application Block

Step 3 (Manual Config):
Add the validation configuration section in the config file (App.config or web.config) by adding the following line into the configSections tag:
<section name="validation" type="Microsoft.Practices.EnterpriseLibrary.Validation.Configuration.ValidationSettings, Microsoft.Practices.EnterpriseLibrary.Validation, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />

You would need to change the Version and PublicKeyToken if you're using a different version of the Enterprise Library.

Create the validation section, reference the type to be validated (from Step 2), add a ruleset, define the properties for the type (only the ones you need validated), and create the validators within the type. The hierarchy is validation > type > ruleset > properties > property > validator.

<validation>
<type assemblyName="MyApplication1, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" name="MyApplication1.UserProfile">
<ruleset name="RuleOne">
<properties>
<property name="Name">

<validator name="Not Null Validator" messageTemplate="Name must be entered" type="Microsoft.Practices.EnterpriseLibrary.Validation.Validators.NotNullValidator, Microsoft.Practices.EnterpriseLibrary.Validation, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />

</property>
</properties>
</ruleset>
</type>
</validation>

Step 4: Add the .NET code

Add the following using statement to the top of your code file:
using Microsoft.Practices.EnterpriseLibrary.Validation;

Add the following code to perform the validation:
UserProfile usrProfile = new UserProfile();
Validator<UserProfile> validator = ValidationFactory.CreateValidator<UserProfile>("RuleOne");
ValidationResults results = validator.Validate(usrProfile);

StringBuilder strBuilder = new StringBuilder();
foreach (ValidationResult iterResult in results) {
strBuilder.Append(iterResult.Message + "\n");
}

Console.WriteLine(results.isValid.ToString());
Console.WriteLine(strBuilder.ToString());

Step 5: Run the application

You can add different kinds of validators or even write your own custom validator, but that's something for another blog post.

Sun VirtualBox runs 64-bit Guest OS on 32-bit Host


Sun's VirtualBox 2.1.0 (released on 17th December 2008) supports running a 64-bit virtual machine even when your host machine is 32-bit. That should like a really cool feature to me. It also supports OpenGL 3D acceleration. Both of these are experimental features, but it sounds like Sun is getting serious about virtualization with these offerings.

UPDATE: I've got another post about my first test run of VirtualBox here.

Forcing IE 7 Compatibility in Internet Explorer 8

If your website doesn't display correctly in Microsoft Internet Explorer 8 but works fine in the IE-7 Compatibility mode, you can force the browser to automatically render your pages in IE-7 Compatibility mode by simply adding the META tag:
<meta http-equiv=”X-UA-Compatible” content=”IE=EmulateIE7″ />

Microsoft plans to address the compatibility issues with Internet Explorer 8 by building a community-driven list of websites that require the browser to render in IE-7 Compatibility mode so the users would not have to manually switch from the native IE-8 rendering mode - the browser would retrieve a fresh copy of the list periodically through updates.

Monday, December 22, 2008

Abit To Shut Down On 31-December-2008

Abit, a computer motherboard and graphic card manufacturer, will be shutting down at the turn of the year on 31st December 2008.

Following the 2006 sale of the Abit brand to Universal Scientific Industrial, sales began to decline due to which the company pulled out of the graphic card industry and finally made the decision to pull the plug from its motherboard manufacturing business.

Universal Scientific Industrial intends to focus on the manufacture of other electronic devices.

Internet Problems in Asia

3 cables, providing data & voice network connectivity from Asia to Europe and the United States, were severed last Friday (19th December 2008).

France Telecom has despatched a ship with 20km of cable for the repairs, with partial connectivity expected by Thursday (25th December 2008). The repairs would be completed by next Wednesday (31st December 2008).

This is the 3rd incident of severed submarine network cables since last year.

UPDATE: The Register has an article on the severed cables here.

Sunday, December 21, 2008

Unpaid Overtime in the I.T. Industry

The I.T. industry is infamous for employers requesting overtime from staff but getting away without paying for it. Here's an extract from a discussion thread I came across on SlashDot:

heretic:

In the IT industry as I've known it, 'part time work' is anything less than 80 hours/week.

hobo sapiens:

Not sure if you are joking, but if not...then you need a new job. Or you may just need to put your foot down. I have been in IT for years as a web developer for a few diff companies, and have never worked like that. Get your stuff done at work, make it clear you are willing to work a little extra where needed (which should be rare) but if there is bad planning, well, tough. IT shops need to be brought back to reality, namely, that poor planning cannot be overcome by stressing out your workers. And I've done pretty well, and thus far my family hasn't starved. The people who are often overworked are overworked because they let it happen. I have known way too many "heroes" who are all willing to work as long as needed for no good reason at all. Trouble is, today's hero is tomorrow's burnout.

Or become a consultant. You may work the hours, but they are no longer a free gift from you to the company. You bill every hour you work.

nabsltd:

Any project that requires "significant overtime" is a project that was planned with unrealistic ideas of how much work would be required.

This assumes the overtime is free because the workers are on salary. If the overtime gets paid (even as normal hours instead of 1.5x), then it's possible the planning took this into account and was just willing to pay the price to get the job done in fewer calendar days.

Otherwise, it's most likely a company with employees who aren't able to get jobs anywhere else, so they can't push back against the unreasonable demands of management.

Web Reference vs Service Reference

A co-worker recently asked about the difference between "Add Web Reference" and "Add Service Reference" in Visual Studio when working with WCF/Web services.

The difference between the two is quite simple - with Add Web Reference, Visual Studio uses the wsdl.exe utility to generate the proxy classes (.NET 2.0 compatible) while Add Service Reference uses svcutil.exe (requires .NET 3.0 or higher). When using Add Service Reference, you would also get additional entries in web.config for the proxy.

I *might* have another post that goes into more detail over the differences.

Saturday, December 20, 2008

Top 10 Things in VS 2008 since VS 2005

Check out this SlideShare Presentation:

Lenovo's latest addition to the Thinkpad W700

Lenovo announced their latest addition to the Thinkpad W700 - a second LCD display!

The primary LCD display is a 17" WUXGA supporting 1920x1200 while the secondary LCD display is a 10.6" WXGA supporting 768x1280. The secondary LCD display would unfold/swing to open next to the primary display providing an extended desktop.

Also in the W700, Lenovo's flagship and the ultimate mobile workstation, is a WACOM digitizer on the palm-rest, and color calibration.

The new model would be available in January 2009.

UPDATE: Here's a YouTube video of how the second screen is integrated into the unit

Student Imprisoned for YouTube video for Terrorists

An Egyption student, Abdellatif Sherif Mohammed, from the University of South Florida was sentenced to 15 years of imprisonment for uploading a video, in Arabic, to YouTube on how to use a radio-controlled toy car from WalMart to create a remote detonated explosive, legally referred to as "providing material support to terrorists". The YouTube screen name used by him was michaljebral.

He also stated in court that "he intended the technology demonstrated in his audio-video recording [was] to be used [by] those who fight the United States."

MCTS 70-536 Resources

If you're planning to read up for the Microsoft 70-536 .NET development foundation exam, check out Stacy Vicknair's blog post here. If you follow the links, you'll get LOTS of material to read.

ASP.NET MVC release delayed

Phil Haack posted a blog entry about the delay of ASP.NET MVC framework :-(

Here's an extract from the blog post:

A while ago ScottGu mentioned in his blog that we would try and have an ASP.NET MVC Release Candidate by the end of this year. My team worked very hard at it, but due to various unforeseeable circumstances, I’m afraid that’s not gonna happen. Heck, I couldn’t even get into the office yesterday because the massive dumping of snow. I hope to get in today a little later since I’m taking next week off to be with my family coming in from Alaska. But do not fret, we’ll have something early next year to release.

I wish the MVC framework release comes out at least by mid-January. I'm dying to implement the RTM version in a project I'm working on.

Friday, December 19, 2008

GTalk Lockout



The GoogleTalk client seems to be acting up today, though the web interface from GMail is still operational. It claims my account has been locked and tries unsuccessfully to download a captcha image.

Oh well, I guess Google is pushing hard for the web interfaces of it's services... it support GMail video chat, but the GoogleTalk client is still audio-only and hasn't had any major update :-(

Thursday, December 18, 2008

VS2008 Intellisense for jQuery

If you use jQuery for your Javascript development needs, you can get Visual Studio to auto-complete stuff for you. All you need to do is download the -vsdoc.js file from
http://code.jquery.com/jquery-1.2.6-vsdoc.js
and add it to your project, followed be adding a reference to it from your file.

To add a reference from an ASPX file, add a
<% if (false) { %>
<script src="jquery-1.2.6-vsdoc.js" type="text/javascript"></script>
<% } %>

To add a reference from a JS file, add a
/// <reference path="jquery-1.2.6-vsdoc.js" />

You can find more about the jQuery intellisense here

VS: Javascript Intellisense for Custom Scripts

MS Visual Studio 2008 supports intellisense when writing Javascript (.js) too! Simple add a:
/// <reference path="filename.js" />
to the file and you'll now get intellisense for functions defined in filename.js

A Simple Log4Net Setup

I've been helping out a co-worker with using Log4Net in an ASP.NET web application. It is really simple once you get the hang of it. If you're having problems setting up Log4Net, go with this simple step-by-step approach.

Step 1: Add a reference to the Log4Net dll

Step 2: Add this to your Global.asax

protected void Application_Start(object sender, EventArgs e)
{
log4net.Config.XmlConfigurator.Configure();
}

Step 3: Add this to the configSections of your web.config

<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" />

Step 4: Add this after the end of the configSections tag

<log4net>
<appender name="LogFileAppender" type="log4net.Appender.FileAppender">
<param name="File" value="C:\Log4Net.log" />
<layout type="log4net.Layout.PatternLayout">
<param name="ConversionPattern" value="%d [%t] %-5p %c %m%n" />
</layout>
</appender>

<root>
<level value="All" />
<appender-ref ref="LogFileAppender" />
</root>
</log4net>

Step 5: Add this in your code

log4net.ILog logger = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
logger.Debug("Nitin");

Run the code and look for the file Log4Net at the root of C drive (configurable in Step 4).

You can add appenders to send out email or log to a remote console, but I'll leave that for another blog post.

Wednesday, December 17, 2008

Ubuntu 8.10 support i3945 out-of-the-box


Ubuntu 8.10 is really cool! I just pop the CD in and boot while it automatically detects all available wireless networks. It's the first Linux distribution that works with my Intel i3945 wireless chip out-of-the-box. That's exactly how Linux has to be for people to adopt it for their common everyday computing needs - something that simply works without fumbling for drivers.

Google Webmaster Event

There was a Google Webmaster event today at the Dubai Press Club in the Dubai Media City. Matthew Chewy Trewhella, a developer advocate from Google, talked about the working of common search engines.

When you specify META keywords on your page, modern search engines compare the keywords with the content of the page to identify web spam.

When Google displays the description for a search result, it usually picks it up from the META description. If this is not specified, Google picks it up from the Open Directory Project (ODP). If there isn't an ODP entry either, Google brings something up on it's own.

You often find websites that make use of Flash and Javascript navigation. While there's nothing inherently wrong with that, search engines would find it difficult to crawl through the site so ideally a text-only version of the site should be built too (did you ever notice the text-only link for Google Maps? That's for search engines!)

Some firms have a corporate website and a micro-website for a product or a project. Google can treat the two sites as one if they have enough cross-links, thus giving the micro-website the PageRank advantage that the parent website has.

The frequency with which Google crawls the website depends on how frequently the website is updated. The PageRank takes about 1-3 months to stabilize so when you launch a new website or change your domain, you would have to wait and watch for a while.

When you're implementing paid links or forums on your site, make sure you add a REL="nofollow" to prevent the target websites from negatively affecting your site's PageRank.

For more control over how search engines visit your website, use a robots.txt file on your website. You can specify the User-Agent, Allow and Disallow to indicate which paths should be avoided and which paths should be indexed by the search engine. A sitemap also helps Google with crawling the website.

The folks at Google are constantly making changes to the search. There are over 200 quality attributes that are used in computing the PageRank and each attribute is managed by a team of about 5 developers. When a tweak is made to a quality attribute, the results are measured and that change is either kept or rolled back.

Trawhella presented the Google Webmaster tools and explained the various options provided by it. There's a lot there that tweaks how Google . He also suggests using the Lynx/Links text browser to see what search engines see on your website.

I didn't stay for the second half in which Trawhella was to speak about Google Analytics and site optimization.

X-Chat for Windows

If you aren't really a fan of web interfaces, you can use X-Chat 2 for Windows:
http://www.silverex.org/download/
There's a Linux version too, but you probably already have it as a part of your Linux distribution.

Watch what you say while you're on an IRC channel though - some channels log all of the messages. Check these out:
http://www.mantisforge.org/irclogs/
http://irclogs.ubuntu.com/

Ribbit-ribbit, meet Mr.Mibbit

If you're all into web interfaces for chat systems, you ought to check out Mibbit.com for IRC. They've got a really cool interface that uses neither Java applets nor Adobe Flash so you don't really have to bother with browser plugins. You can try it at http://www.mibbit.com . You can also add it as a widget to your own website, like the MantisBT guys have it setup at http://www.mantisbt.org/irc.php

Tuesday, December 16, 2008

SQL Server: Use VS or SSMS?

Yesterday, I fired up SQL Server Management Studio 2008 to add a uniqueidentifier column to a table and it just got grumpy and said I would have to drop and re-create the table. I thought it was a server-side thingie when I co-worker asked me to try it in Visual Studio with the Server Explorer and voila!

I was pretty surprised since SQL Server Management Studio is supposed to be the tool of choice for database administration... I guess MS SQL DBAs will now have to re-consider.

Saturday, December 13, 2008

Facebook Development 101


Facebook App Dev101 (Tyler Ballance, Slide.com)

From: dmc500hats,
2 years ago





Facebook App Dev 101 workshop: Intro to Platform / Building Your First App - Tyler Ballance, Slide.com & Ari Steinberg, Facebook @ Graphing Social Patterns Oct 2007



SlideShare Link

Friday, December 12, 2008

Ubuntu 8.10: A Test Run

I finally burned the Ubuntu 8.10 image to DVD and booted off the disc. It's the first version of Ubuntu that actually supports my Intel i3945 wireless adapter out-of-the-box (or rather out-of-the-ISO). I'll spend some more time investigating so look forward to more about it soon.

Google Chrome hits 1.0

Google's Chrome browser is finally out of beta and is at version 1.0. Given Google's track record of beta-to-rtm time, this is really impressive... it's been just about 3 months since the browser was first made public!

Wednesday, December 10, 2008

BizTalk 2009 Beta Released

The public beta of Microsoft BizTalk Server 2009 (formerly called BizTalk 2006 R3) was released yesterday. It's available for download from http://connect.microsoft.com

Tuesday, December 9, 2008

Debugging a Windows Service

Debugging a Windows Service is a pain, especially when you've got some code running on startup - that doesn't give you enough time to attach to the process unless you intentionally add a Sleep or something similar. Anyway, I found a really good blog post here about debugging Windows Services from right within Visual Studio. Click here for the details.

Windows 7 Touch

The Windows 7 touch interface isn't really ready for multi-player gaming yet. This video shows you exactly what I mean.

Windows 7 Aero Peek

Windows 7 adds more functionality to the taskbar and builds upon the Vista experience. Sure, it eats away at performance but for someone who just checks email and surfs the Internet, Windows Vista/7 are like a whole new world.

Introduction to XAMPP


Introduction to XAMPP from Nitin Reddy on Vimeo.

Mozilla and Social Media


Mozilla And Social Media

From: jorendorff,
3 days ago


Mozilla And Social Media
View SlideShare presentation or Upload your own. (tags: twitterfox moco)



Presentation by Jason Orendorff of Mozilla at Memphis Social Media Breakfast, 3 Dec 2008.



SlideShare Link

Saturday, December 6, 2008

SourceForge.NET Login Fixed

Today I noticed the SourceForge.NET interface for login had changed. I've always had problems with the interface they put in a couple of months ago so I had to abandon the projects that I started on SourceForge. Now that they've fixed it, I guess I'm back in business!

Tuesday, December 2, 2008

Why SQL Mail is Dead

I've always wondered why we use SQL Mail instead of Database Mail, mostly because I started off serious work with SQL Server 2005 and used previous versions only to get a feel of what they've got to offer. Database mail offers a separation between SQL Server and the mailing component - SQL mail ran in the same OS process as SQL Server, which meant SQL Server stopped whenever SQL mail came up with an error.

When I read about the shortcomings of SQL Mail, I begin to realise that it's really archaic - you have to install an email client, setup SQL Agent with the account that has access to the right profile of the email client, experience a nightmare with debugging (since SQL Agent can't display any dialogs as it's a Windows Service), and more.

You can get the full list of problems experienced with SQL Mail here:
http://support.microsoft.com/default.aspx/kb/315886

If you've still got any code using SQL Mail instead of Database Mail, you can replace all calls to the xp_sendmail stored procedure with calls to the sp_send_dbmail stored procedure. You can find a mapping of the arguments and further information here:
http://msdn.microsoft.com/en-us/library/ms187891.aspx

Monday, December 1, 2008

Web Content Accessibility Guidelines (WCAG)

The World Wide Web was built with the objective of delivering content to all users, across heterogeneous systems and platforms. The idea worked for the most part, but we still have issues with the way browsers work - some sites require the use of a specific browser and, at times, developers create different versions of the pages for different web browsers. To help remedy the situation, the World Wide Web Consortium (W3C) came up with the Web Content Accessibility Guidelines (WCAG).

The WCAG 1.0 standard was published in May 1999. A draft version of WCAG 2.0 was created in January 2001, and the proposed version was formed in November 2008. WCAG 2.0 is expected to be published as a standard on 3rd December, 2008.

You can access the proposed WCAG 2.0 here. Also useful is the CSS techniques for the proposed WCAG 2.0 here.

Sunday, November 30, 2008

Review: RapidSVN for Windows

While working with Linux and PHP, I used RapidSVN as my preferred client to manage my source code. However, after I made the switch from Linux system administration to .NET development, I used TortoiseSVN and that was pretty cool with the Windows Explorer (shell) integration.

I tried RapidSVN 0.9.6 (March 2008 build) for Windows today and found it to be less than acceptable in terms of stability. The first time I launched the application after installation, I did a Checkout to a new directory and RapidSVN simply crashed after about 2-3 minutes of getting the files from the source code repository. I then tried a clean up (which was under the 'Extras' menu item). I tried getting the source code again, but to no avail so I guess I'll have to work with a different source control repository to try it out.

Perhaps I'll get to use a newer version of RapidSVN sometime soon? I'm really looking forward to a stable release.

If you want to try RapidSVN 0.9.6, you can get a copy from here.

Tuesday, November 25, 2008

Fedora 10 Released Today!

The much-awaited Fedora 10 was released today. It is based on the 2.6.27 Linux kernel. You can view the entire feature set here.

Monday, November 24, 2008

iFrame Background White in IE

I was a little surprised when a page that I developed using IFrames appeared fine in Firefox and Safari, but in Internet Explorer the background of the iFrame appeared white, overlapping another element on the page.

The way around this behavior is to set the allowtransparency attribute of the IFrame tag to true i.e. add the following to your IFRAME tag.
allowtransparency="true"

Sunday, November 23, 2008

Google Whacks Dying Out

I've tried searching for the most recent 5 Google Whacks from the Google Whack site and just one of them continues to remain a Google Whack - "sensex underhairs".

So what happens to these Google Whacks, you ask? Well, when the words are put up on GoogleWhack.com, Google indexes them and that's when Results 1 to 1 of 1 loses the magical 1s. Then, there are bloggers and news reporters who write about them.

The hunt for Google Whacks just keeps getting harder and harder.

PS: Are you wondering what a Google Whack is? Visit http://www.googlewhack.com/rules.htm to find out.

Saturday, November 22, 2008

Identity Columns in MS SQL Server


Identity columns in MS SQL Server from Nitin Reddy on Vimeo.

Yet Another Deathcast

Abraham Biggs (alias CandyJunkie), a 19-year-old teenager from Florida, committed suicide last Wednesday while providing a live video feed via his webcam. The cause of his death was drug overdose.

A video of the incident can be found here.

Thursday, November 20, 2008

Software Engineering Conferences

International Conference on Software Engineering (ICSE)
http://www.icse-conferences.org/

Working IEEE/IFIP Conference on Software Architecture (WICSA)
http://www.wicsa.net/

Association for Computing Machinery: Special Interest Group on Software Engineering (ACM SigSoft)
http://www.sigsoft.org/

Working Conference on Reverse Engineering (WCRE)
http://swerl.tudelft.nl/wcre2008/

IEEE International Conference on Software Maintenance (ICSM)
http://www.icsm2008.org/

Themes in GMail

GMail has introduced a super-cool themes so you can customize the look of the interface. I particularly like the Ninja and the Graffiti themes. The Tea House theme require a really high resolution - my 1280x800 isn't enough and I have to scroll vertically to see the tea houses. Most of the themes work with just about any resolution though.

You can access the themes from the Themes tab under Settings.




Wednesday, November 19, 2008

Windows 2008 R2


Windows Server 2008 R2 Overview

From: aschek,
2 weeks ago


Windows Server 2008 R2 Overview
View SlideShare presentation or Upload your own. (tags: microsoft r2)






SlideShare Link

Javascript Libraries


JavaScript Library Overview

From: jeresig,
2 years ago


JavaScript Library Overview
View SlideShare presentation or Upload your own. (tags: dojo prototype)



JavaScript Library tutorial that I gave at the October 2007 Ajax Experience conference.



SlideShare Link

Monday, November 17, 2008

Multi-row INSERT

With SQL, we can SELECT, UPDATE and DELETE multiple rows simultaneously, but we can normally INSERT only one row at a time.

There ways around this, but they usually involve selecting a resultset and passing it to an INSERT statement like this:
INSERT INTO emp (id, ename)
SELECT 4567, 'nitin'
UNION ALL
SELECT 4568, 'naina'

With Microsoft SQL Server 2008, you can now insert multiple values with an INSERT statement. Example:
INSERT INTO emp (id, name) VALUES (4567, 'nitin') (4568, 'naina')

This ought to make help make applications more efficient as they can send multiple values in one go instead having to send data to the server one row at a time.

Will other database engines follow suit and adopt this syntax? Time will tell.

Windows Scheduler Task or Windows Service

I've noticed a lot of projects on which the developers add windows services when all they need is a console application running as a scheduled task (using the Windows task scheduler).

A windows service is a pretty good approach when you need to have something constantly running such as a network service to respond to client requests or a heartbeat service to check application health every couple of seconds.

However, if you've got a windows service running in the background waiting on a timer to execute some bit of code, then you might want to consider using a scheduled task. They're easier to debug, require less development effort and do their job reasonably well.

Sunday, November 16, 2008

DB Tables for Static Values? Puh-leez!

A couple of developers believe strongly that values for every dropdown list should come from the database, even if it's something like gender and marital status. I mean this is stuff that never changes - I wouldn't wake up to read the newspaper headline on a new gender being introduced unless I lived in mutant city at Chernobyl or Hiroshima.

In a traditional C program, you can use constants to keep track of the values for globally static data. For an ASP.NET application, it makes perfectly good sense to declaratively set the values in the dropdown lists. If you must keep the values as (numeric) IDs, you might as well use an enumeration. To support a null, you can either use nullable types (.NET 2.0 feature) or add a NotSpecified as the first enumeration value. If you have absolutely got to store values in the database, you could create a stored procedure that returns values from a temporary table or put together the values in a single dataset using SELECT and UNION. There's no use adding extra disk I/O or taking up cache space for something you know will absolutely never change!