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:

81336-52e0151f02531085

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.

http://fantasy.cricinfo.com/fantasy/fantasyleague/user/game_home.html?game_id=59

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)
m_
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"/>
<OBJECT>

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:

objsafe.odl

[
uuid(C67830E0-D11D-11cf-BD80-00AA00575603),
helpstring("VB IObjectSafety Interface"),
version(1.0)
]
library IObjectSafetyTLB
{
importlib("stdole2.tlb");
[
uuid(CB5BDC81-93C1-11cf-8F20-00805F2CD064),
helpstring("IObjectSafety Interface"),
odl
]
interface IObjectSafety:IUnknown {
[helpstring("GetInterfaceSafetyOptions")]
HRESULT GetInterfaceSafetyOptions(
[in]  long  riid,
[in]  long *pdwSupportedOptions,
[in]  long *pdwEnabledOptions);

[helpstring("SetInterfaceSafetyOptions")]
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”:

basSafeCtl

Option Explicit

Public Const IID_IDispatch = "{00020400-0000-0000-C000-000000000046}"
Public Const IID_IPersistStorage = _
"{0000010A-0000-0000-C000-000000000046}"
Public Const IID_IPersistStream = _
"{00000109-0000-0000-C000-000000000046}"
Public Const IID_IPersistPropertyBag = _
"{37D84F60-42CB-11CE-8135-00AA004BB851}"

Public Const INTERFACESAFE_FOR_UNTRUSTED_CALLER = &H1
Public Const INTERFACESAFE_FOR_UNTRUSTED_DATA = &H2
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

pdwSupportedOptions = INTERFACESAFE_FOR_UNTRUSTED_CALLER Or _
INTERFACESAFE_FOR_UNTRUSTED_DATA

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, _
INTERFACESAFE_FOR_UNTRUSTED_CALLER, 0)
Exit Sub
Case IID_IPersistStorage, IID_IPersistStream, _
IID_IPersistPropertyBag
pdwEnabledOptions = IIf(m_fSafeForInitializing, _
INTERFACESAFE_FOR_UNTRUSTED_DATA, 0)
Exit Sub
Case Else
Err.Raise E_NOINTERFACE
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) <> _
INTERFACESAFE_FOR_UNTRUSTED_CALLER) Then
Err.Raise E_FAIL
Exit Sub
Else
If Not m_fSafeForScripting Then
Err.Raise E_FAIL
End If
Exit Sub
End If

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

Case Else
Err.Raise E_NOINTERFACE
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:

http://www.indiangeek.net/programmer-competency-matrix/

Panoramic Image & Viewer related resources:

http://krolik.net/PIV/
http://flashpanoramas.com/player/
http://www.mojavelinux.com/cooker/demos/panojs/
http://www.eurofresh.se/test/shockwpanos.htm
http://www.michielpost.nl/panorama/

File conversion utility for panoramic photos:

http://www.outerspace-software.com/bixorama.html

Automatic image stitching:

http://www.cs.ubc.ca/~mbrown/autostitch/autostitch.html

Panoramic Image App (Commercial):

http://www.autopano.net/

Panorama Gallery:

http://www.cs.ubc.ca/~mbrown/panogallery/panogallery.html

Panoramic Viewer:

http://s3.envato.com/files/4810/index.html

TDD Links:

http://codebetter.com/blogs/darrell.norton/articles/50337.aspx
A Conversation with Martin Fowler
Mocks Aren’t Stubs
Learn about .NET Unit Testing with Typemock

Old Version Downloads:

http://www.oldapps.com/

10 Youtube URL Tricks You Should Know About

http://www.makeuseof.com/tag/10-youtube-url-tricks-you-should-know-about/

100 Best JavaScript Resources

http://www.spoonfeddesign.com/100-best-javascript-resources

Performance killer: Disk I/O

http://nathanaeljones.com/11061_Performance_killer_Disk_I_O

Top 20 Best Agile Development Books, Ever

http://www.noop.nl/2008/06/top-20-best-agile-development-books-ever.html

Top 100 Best Software Engineering Books, Ever

http://www.noop.nl/2008/06/top-100-best-software-engineering-books-ever.html

Top 20 Programming Books

http://yaneshtyagi.blogspot.com/2008/04/top-20-programming-books.html

Top 10 Concepts That Every Software Engineer Should Know

http://blog.csdn.net/andylin02/archive/2008/07/26/2716304.aspx

Securing ASP.NET Applications

http://www.novologies.com/post/2009/04/08/Securing-ASPNET-Applications.aspx

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.

http://www.hunlock.com/blogs/Howto_Dynamically_Insert_Javascript_And_CSS

Yahoo! Pipes and JQuery : Goodbye Same Origin Policy

http://www.badlydrawntoy.com/2008/07/08/yahoo-pipes-and-jquery-same-origin-policy/

URL Shorteners:

http://is.gd/
http://tr.im/
http://ow.ly/url/shorten-url
http://bit.ly
http://tinyurl.com

Interview Tips:

http://interviewtips.org/

LINQ to Entities:

http://www.linqdev.com/PublicPortal/publicportal/linq-to-entities.aspx

LINQ Learning Guide: LINQ to Entities

http://searchwindevelopment.techtarget.com/generic/0,295582,sid8_gci1299600,00.html

The ADO.NET Entity Framework Overview:

http://msdn.microsoft.com/en-us/library/aa697427(VS.80).aspx

Parallelism Videos Galore

http://blogs.msdn.com/pfxteam/

Writing LINQ Queries with the Entity Framework:

http://www.informit.com/articles/article.aspx?p=1237071

ASP.NET Dynamic Data Overview

http://msdn.microsoft.com/en-us/library/cc488546.aspx

Inheritance and Associations with Entity Framework Part 1

http://mosesofegypt.net/post/Inheritance-and-Associations-with-Entity-Framework-Part-1.aspx

Model Domain Objects with the Entity Framework

http://visualstudiomagazine.com/features/article.aspx?editorialsid=2425

Lambda the Ultimate : Programming Languages Weblog

http://lambda-the-ultimate.org/

Introduction to Domain Specific Languages

http://www.infoq.com/presentations/domain-specific-languages

Good blog site on Patterns:

http://blogs.msdn.com/erwinvandervalk/default.aspx

Pattern site on Hexagonal architecture

http://alistair.cockburn.us/Hexagonal+architecture

JSINQ – LINQ to Objects for JavaScript

http://www.codeplex.com/jsinq

JSINQ: LINQ style access for JavaScript objects

http://ajaxian.com/archives/jsinq-linq-for-javascript

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

http://msdn.microsoft.com/en-us/library/bb386909.aspx

LINQ to SQL : Object Identity (LINQ to SQL)

http://msdn.microsoft.com/en-us/library/bb399376.aspx

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