Archive for May, 2009

Announcing new league on Cricinfo Fantasy Cricket for T20 World Cup 2009

Folks, join my League on Cricinfo Fantasy Cricket for T20 World Cup 2009 with this LPIN:


Cricinfo Fantasy Cricket for “International 20-20” tournament aka T20 World Cup is commencing on the 5th of June, 2009. It’s a pretty simple game which requires you to create a cricket team comprising of 11 players and then wait for the match to commence. After every match you are given out points based on the performance of your cricketers (wickets taken, catches taken, runs scored, sixes scored, maidens bowled, Man-of-the-match award winner etc. ). So, all you need to do is create a team with good bunch of players who are likely to give you good points at the end of every match. That’s it! So, please take a little time to register yourself on their site first and then just create your team wisely. Mind you, you can have substitutes as well but for the game rules, please read the game pages carefully. Here you go, I am really looking forward to locking horns with you guys there to see who has the shrewdest cricketing mind amongst us.

To sum things up, just register and then go to the Fantasy home page from where you will select the” Join League” menu option from the left and use the LPIN provided at the top to join in my league. That’s it, you are done! Let’s beat the world!

Hilarious programmer cartoons

Today I bumped into this funny piece from stackoverflow titled What’s your favorite “programmer” cartoon? It has most of the programming/programmer cartoons you have ever seen. Truly good collection including the “Swing Tire Cartoon” on Project Management. Don’t miss it guys, it’s a must-see!

The wisdom to know what you don’t know

Here are few quotes regarding Knowing or not Knowing, for that matter, the Unknowns:

If you don’t know what you want, you won’t know when you’ve gotten it.

What You Don’t Know Can Hurt You.

You Don’t Know What You Don’t Know Until You Take the Next Step.

What you don’t know is often far more relevant than what you do know!

You don’t know what you do until you know what you don’t do.

It Pays To Know What You Don’t Know.

And finally the best of the lot – known unknown:

The Unknown
As we know,
There are known knowns.
There are things we know we know.
We also know
There are known unknowns.
That is to say
We know there are some things
We do not know.
But there are also unknown unknowns,
The ones we don’t know
We don’t know.

—Feb. 12, 2002, Donald Rumsfeld, Department of Defense news briefing
(From Slate)

Survey for the most used contemporary .NET platform

Just visit the link here folks and vote – it’s that simple!

Diabetes – What you must know

While I am not a medial expert, this is my small endeavor to shed some light on the deadliest of diseases. It is the most dangerous silent killer.

There are two types of diabetes mellitus:

1. Diabetes Type 1 – This might have some connection to hereditary genes but it’s not absolutely clear what causes Type 1 diabetes. If diabetes is known to run in the family for many years then heredity plays a major role in development of diabetes. People who belong to family background having history of diabetes are 25% more prone to develop diabetes.

2. Diabetes Type 2 – This has to do with obesity, diet/overeating, lifestyle, emotional stress, smoking, age etc. Most people with diabetes, nearly 90 percent of sufferers are Type 2. Type 2 diabetes usually starts around age 45, but a recent report showed children in Australia are now suffering from the disease.

For more on the causes of diabetes, please visit here and here to enlighten yourself. Here’s an article from BBC web site here for the causes of diabetes.

Now, the question most ask is ‘Does Sugar Cause Diabetes’? Most people think it does. This is probably the most common misconception about diabetes. The short answer is a ‘NO’. For the long answer please visit here.

Fixing param value passing problem into ActiveX control from html web page

This one was a hair-puller, hair-loser, you-name-it kinda problem I was facing the last few days. Visual Basic 6 or VB6, in short, not being my primary language was one of the reasons for this. But the main reason was almost nobody knew why an ActiveX control inside an html page doesn’t get passed the param value although most know how to build a simple ActiveX control in VB6.

Let me guide you through the entire process of creating the ActiveX and embedding it inside Html lest anybody should miss it.

VB6 Code for the ActiveX property getter & setter :

Dim m_propertyNameToBeExposedThroughParam As String

Public Property Get propertyNameToBeExposedThroughParam() As String
propertyNameToBeExposedThroughParam= m_propertyNameToBeExposedThroughParam
End Property

Public Property Let
propertyNameToBeExposedThroughParam(ByVal vNewValue As String)
'Some code
End Property

'The following lines are important for reading the param value from inside html page
Private Sub UserControl_ReadProperties(PropBag As PropertyBag)
propertyNameToBeExposedThroughParam = PropBag.ReadProperty("propertyNameToBeExposedThroughParam", "")
End Sub

This is how an ActiveX control is embedded inside an html page:

<OBJECT name="activeXControlName" id="activeXControlID" width="widthInPixels" height="heightInPixels" classid="clsid:YOUR-32-DIGIT-CLASS-ID-FOR-THE-ACTIVEX-CONTROL">
<param name="propertyNameToBeExposedThroughParam" value="SomeValue"/>

This is pretty elementary thus far. In an ideal world, that should have sufficed for creating a property for the ActiveX and then exposing/consuming it through html. But hey life’s not perfect and so aren’t we 🙂 Hence read on.

Now, when I ran the html page inside the internet explorer browser window, lo & behold,  the property setters inside my ActiveX control was not firing.

I googled around for 3 days when I began trusting myself more than Googlers :). I observed that my IE was complaining whenever I ran the html inside the browser saying it is a potentially unsafe activeX. Initially, I didn’t pay heed to it for I ‘assumed’ all ActiveX controls give such warnings and guess what, they don’t say ‘Assumption is the root of all ‘f#$%-ups’ for nothing :). Then I started realizing that I might need to sign the control because IE wasn’t passing the parameter to my ActiveX for it was ‘unsigned’. You know what folks, “figuring out a problem is 90% of the solution”, IMHO. Because, after realizing the actual problem, Google asked me to pay a visit to “How To Implement IObjectSafety in Visual Basic Controls” whereby I learnt that I needed to implement IObjectSafety in my ActiveX control.

I am sure most understands implementing an interface in a non object oriented language like VB6 is less than trivial if I may use the euphemism.

According to the above article from Microsoft, one needs to create the following ‘Interface Definition Language File‘ (odl) file:


helpstring("VB IObjectSafety Interface"),
library IObjectSafetyTLB
helpstring("IObjectSafety Interface"),
interface IObjectSafety:IUnknown {
HRESULT GetInterfaceSafetyOptions(
[in]  long  riid,
[in]  long *pdwSupportedOptions,
[in]  long *pdwEnabledOptions);

HRESULT SetInterfaceSafetyOptions(
[in]  long  riid,
[in]  long  dwOptionsSetMask,
[in]  long  dwEnabledOptions);

Thereafter, one needs to convert the olb file to a Type Library (tlb) through a command like this:

MKTYPLIB objsafe.odl /tlb objsafe.tlb

Then one needs to do a Project menu -> References -> browse to and add Objsafe.tlb inside VB6.

After you are done making the reference, you need to add the following module to the ActiveX project and set the “Sub Main” as the “Startup Object”:


Option Explicit

Public Const IID_IDispatch = "{00020400-0000-0000-C000-000000000046}"
Public Const IID_IPersistStorage = _
Public Const IID_IPersistStream = _
Public Const IID_IPersistPropertyBag = _

Public Const E_NOINTERFACE = &H80004002
Public Const E_FAIL = &H80004005
Public Const MAX_GUIDLEN = 40

Public Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" _
(pDest As Any, pSource As Any, ByVal ByteLen As Long)
Public Declare Function StringFromGUID2 Lib "ole32.dll" (rguid As _
Any, ByVal lpstrClsId As Long, ByVal cbMax As Integer) As Long

Public Type udtGUID
Data1 As Long
Data2 As Integer
Data3 As Integer
Data4(7) As Byte
End Type

Public m_fSafeForScripting As Boolean
Public m_fSafeForInitializing As Boolean

Sub Main()
m_fSafeForScripting = True
m_fSafeForInitializing = True
End Sub

Now one needs to go to the code for the ActiveX UserControl itself and paste the following just after the “Option Explicit” statement like this:

Option Explicit

Implements IObjectSafety

And the final task is to paste the following code onto the end of the ActiveX UserControl code:

'Code related to ActiveX Container Signing
Private Sub IObjectSafety_GetInterfaceSafetyOptions(ByVal riid As _
Long, pdwSupportedOptions As Long, pdwEnabledOptions As Long)

Dim Rc      As Long
Dim rClsId  As udtGUID
Dim IID     As String
Dim bIID()  As Byte


If (riid <> 0) Then
CopyMemory rClsId, ByVal riid, Len(rClsId)

bIID = String$(MAX_GUIDLEN, 0)
Rc = StringFromGUID2(rClsId, VarPtr(bIID(0)), MAX_GUIDLEN)
Rc = InStr(1, bIID, vbNullChar) - 1
IID = Left$(UCase(bIID), Rc)

Select Case IID
Case IID_IDispatch
pdwEnabledOptions = IIf(m_fSafeForScripting, _
Exit Sub
Case IID_IPersistStorage, IID_IPersistStream, _
pdwEnabledOptions = IIf(m_fSafeForInitializing, _
Exit Sub
Case Else
Exit Sub
End Select
End If
End Sub

Private Sub IObjectSafety_SetInterfaceSafetyOptions(ByVal riid As _
Long, ByVal dwOptionsSetMask As Long, ByVal dwEnabledOptions As Long)

Dim Rc          As Long
Dim rClsId      As udtGUID
Dim IID         As String
Dim bIID()      As Byte

If (riid <> 0) Then
CopyMemory rClsId, ByVal riid, Len(rClsId)

bIID = String$(MAX_GUIDLEN, 0)
Rc = StringFromGUID2(rClsId, VarPtr(bIID(0)), MAX_GUIDLEN)
Rc = InStr(1, bIID, vbNullChar) - 1
IID = Left$(UCase(bIID), Rc)

Select Case IID
Case IID_IDispatch
If ((dwEnabledOptions And dwOptionsSetMask) <> _
Err.Raise E_FAIL
Exit Sub
If Not m_fSafeForScripting Then
Err.Raise E_FAIL
End If
Exit Sub
End If

Case IID_IPersistStorage, IID_IPersistStream, _
If ((dwEnabledOptions And dwOptionsSetMask) <> _
Err.Raise E_FAIL
Exit Sub
If Not m_fSafeForInitializing Then
Err.Raise E_FAIL
End If
Exit Sub
End If

Case Else
Exit Sub
End Select
End If
End Sub

Now you are all ready to go. Just compile the ActiveX into an OCX and embed it inside the html like it mentioned at the top of the post. Do remember to change the class id in the object tag. The fastest way to get the class id for the ActiveX is to debug start the control inside a browser and take a look into the html source to grab the clsid or class id as it is called.

Weekly Link Roundup – 2

Links published on May 04, 2009:

Math world, simple mental calculations or what’s going on with education?

Most interesting math blog post I have read for a long time. Have a read guys and tell me how you find it.

Programmer Competency Matrix:

Panoramic Image & Viewer related resources:

File conversion utility for panoramic photos:

Automatic image stitching:

Panoramic Image App (Commercial):

Panorama Gallery:

Panoramic Viewer:

TDD Links:
A Conversation with Martin Fowler
Mocks Aren’t Stubs
Learn about .NET Unit Testing with Typemock

Old Version Downloads:

10 Youtube URL Tricks You Should Know About

100 Best JavaScript Resources

Performance killer: Disk I/O

Top 20 Best Agile Development Books, Ever

Top 100 Best Software Engineering Books, Ever

Top 20 Programming Books

Top 10 Concepts That Every Software Engineer Should Know

Securing ASP.NET Applications

The ADO.NET Entity Framework must read:

Introducing the Entity Framework [MSDN]
The ADO.NET Entity Framework Overview
ADO.NET Tech Preview: Entity Data Model

Introduction to the Entity Framework [Code Project]

Windows Communication Foundation must read:

Fundamental Windows Communication Foundation Concepts
What Is Windows Communication Foundation?

A Guide to Designing and Building RESTful Web Services with WCF 3.5

Howto Dynamically Insert Javascript And CSS:

This is a short and sweet little tutorial to show you how to dynamically insert a new Javascript (or style sheet) into your web pages, and explores how you can exploit cross-domain includes in your applications.

As JSON and DHTML start to get pushed more and more to the forefront of web-based applications, the web designer is faced with a new problem: how to dynamically insert a script element into an existing web page. It won’t take long to figure out that ajax loads and innerHTML injections won’t work.

Yahoo! Pipes and JQuery : Goodbye Same Origin Policy

URL Shorteners:

Interview Tips:

LINQ to Entities:

LINQ Learning Guide: LINQ to Entities,295582,sid8_gci1299600,00.html

The ADO.NET Entity Framework Overview:

Parallelism Videos Galore

Writing LINQ Queries with the Entity Framework:

ASP.NET Dynamic Data Overview

Inheritance and Associations with Entity Framework Part 1

Model Domain Objects with the Entity Framework

Lambda the Ultimate : Programming Languages Weblog

Introduction to Domain Specific Languages

Good blog site on Patterns:

Pattern site on Hexagonal architecture

JSINQ – LINQ to Objects for JavaScript

JSINQ: LINQ style access for JavaScript objects

LINQ to SQL: SQL-CLR Type Mismatches (LINQ to SQL)

LINQ to SQL : Object Identity (LINQ to SQL)

Most interesting math blog post I have read for a long time. Have a read guys and tell me how you find it.