Friday, December 16, 2005

A nice search engine...

Here's a search engine which organizes the
search results into various categories.

Pretty cool.. huh...

A comparison of c# and Java !!!

The following website outlines the similarities and differences between c# and

Saturday, December 10, 2005

Delving into MSMQ, Biztalk etc..

Currently delving into MSMQ< Biztalk and other related enterprise application integration technologies....

Wednesday, November 30, 2005

Science toys..

Make toys at home with common household materials, often in only a few minutes, that demonstrate fascinating scientific principles

Have a look at this..


Saturday, November 26, 2005

What an average programmer does..?

A routine job..
Going to office, reading mails, fixing bugs..
Same stuff...
Same database, same code, same logic in different variations...

Isn't there a need for a change..
Trying something different out of our comfort zone...

For eg.. a web developer, trying hands at windows programming,
a windows programmer dirtying hands with systems programming.. etc.. etc...

Tuesday, November 08, 2005

Useful web url for developers...

Above is the url of Nikhil Kothari, the developer of Webmatrix project and pioneer in server controls.

Tuesday, October 04, 2005

MIT open courseware..

Here's a link

This contains most of the course lecture notes from MIT.

Wednesday, September 07, 2005

Currently delving into..

Posting after quite a good gap.
That's because currently I am trying to digest basic computer science concepts related to algorithms, data structures, application of logarithms, the Big O notation etc..

Its not that I am not aware of the above concept, but occassionally everything needs brushing, so that the accumulated dust gets wiped off..

Monday, August 15, 2005

And the learning continues..

Away from c#, into the realms of javascript, xslt, xml etc...
Hope its fun..

Wednesday, August 03, 2005

When nature plays game, its always one sided!!!

This has what happened when nature plays game !!!

The rains which began on 26th July, halted mumbai's pace.
The most affected place were kurla, sion, chembur, goregaon, santacruz, kalyan,
badlapur, thane, andheri (sakinaka)...

The loss cannot be written down in this blog. This space is too little to understand the emotions and truama of those suffered....

But, its amazing to see, how fast mumbai is back to life...

Sunday, July 24, 2005

Time management !!!

Yesterday, attended my first lecture on Time Management as part of my E-MBA course.

The crux of the matter was to able to save 20 minutes of quality time a day.

Some sample equation...

20 minutes a day
600 minutes a month
7200 minutes a year. i.e 120 hours a year..

For 25 years + more of life time you have got 3000 hours of more time which you can utilise to achieve your life goals..

To manage time ==> is to manage self.
And self management requires some discipline which is not developed overnight.
Patience and practice is required...

More to come...

Wednesday, July 13, 2005

Replacing cursors and while loops...

Cursors and while loops seems to be bit evil in terms of gaining performance..
Here's a solution to it...
Avoiding Cursors and While Loops


Monday, July 11, 2005

Really Simple Syndication (RSS)

RSS is a Web content syndication format.
Its acronym stands for Really Simple Syndication.
RSS is a dialect of XML. All RSS files must conform to the XML 1.0 specification, as published on the World Wide Web Consortium (W3C) website.

For more info...
Click here RSS

Sample code to read RSS feed in

private DataTable GetRSSFeed(string strURL )
//Retrieve the XML data
XmlTextReader reader = new XmlTextReader(strURL);
DataSet ds = new DataSet();
ds.ReadXml(reader) ;
return ds.Tables[2];

// for displaying the RSS feed add the following code to the page load event.
private void Page_Load(object sender, System.EventArgs e)
string strURL = Server.MapPath
("rss.xml"); //"";
dgRSS.DataSource = GetRSSFeed(strURL);

When the dataset is generated from ReadXML, three tables are created in the dataset, one for each rss, channel and item tag.
Since we are only interested in the item we are returning ds.Tables[2].
We can easily display this information in a datagrid or datalist.

Happy Syndicating...

Thursday, July 07, 2005

Design Pattern - Strategy

Today out of curiosity, I was experimenting with strategy design pattern.
Here's the outcome of my experiment.

Strategy pattern falls under the Behavioral category.

The Intent:
Define a family of algorithms, encapsulate each one, and make them interchangeable. Strategy lets the algorithm vary independently from clients that use it.
The strategy pattern embodies two fundamental principle of object oriented programming. First encapsulate the concept which changes behaviour and program against the interface.

I had written a small notepad application to illustrate the use of strategy.
Other things remaining same, the dynamics of the pattern is applied when using the "find" method in the notepad. Based on the user's selection either a normal "find" alogrithm is invoked or a "regex" based algorithm is used.

The application being trivial, you wont find much regex code. Its used only for demonstration purpose.

Dissecting the application

(1) Program against the interface

// IFind.cs - This would be our strategy interface
using System;
using System.Windows.Forms;
namespace DesignPatterns
public interface IFind
int Find(RichTextBox textControl,string str);

// NormalFind.cs - An implementation of 1st algorithm - ConcreteStrategyA
using System;
using System.Windows.Forms;

namespace DesignPatterns
public class NormalFind : IFind
static int filePointer = 0;
public NormalFind()

int IFind.Find(RichTextBox textControl, string str)
int start = -1;
start = textControl.Text.IndexOf(str, filePointer);
int len = str.Length;

textControl.Select(start, len);
filePointer = start + len;
catch (Exception e)
MessageBox.Show("Reached End of Document.");
filePointer = 0;
return start;

// RegexFind.cs - An implementation of 2nd algorithm - ConcreteStrategyB
using System;
using System.Windows.Forms;
using System.Text.RegularExpressions;
using System.Diagnostics;

namespace DesignPatterns
public class RegexFind : IFind
static int filePointer = 0;
int start = -1;
public RegexFind()

int IFind.Find(RichTextBox textControl,string str)
Regex r = new Regex(str);
Match m = r.Match(textControl.Text,filePointer, textControl.TextLength);
textControl.Select(m.Index, m.Length);
filePointer = m.Index + m.Length;
start = m.Index;
catch (Exception e)
MessageBox.Show("Reached End of Document.");
filePointer = 0;
return start;

// FindManager.cs - Handles the strategy context -
using System;
using System.Windows.Forms;
namespace DesignPatterns
public class FindManager
IFind find;
RichTextBox rtb;

public FindManager()

public FindManager(RichTextBox rbox)
this.rtb = rbox;

public void SetFindStrategy( IFind myfind)
this.find =myfind;

public int Find(string findString)
return find.Find(rtb, findString);

// The client code extract
private void btnFind_Click(object sender, System.EventArgs e)
FindManager fm = new FindManager(this.richTextBoxInstance);
// dynamically set the strategy
if (chkRegEx.Checked == true)
fm.SetFindStrategy(new RegexFind());
fm.SetFindStrategy(new NormalFind());


For more information go to
Also refer the GOF pattern book.

UML class diagram has been adapted from I hope they don't mind it.

Enjoy patterning :)

Tuesday, July 05, 2005

Circular reference assembly...

Here's a link which describes how to create circular reference assembly in .net.

Monday, July 04, 2005

.net Reflection Tip

To convert a string to its corresponding type use the following code snippet...
/// To get the underlying property type for the object

/// The object for which u r finding the property info.
/// The name of the property.. eg. For form object, say finding the Location property
/// The property value.
/// An object containing the underlying propertytype.
private object ConvertStringToPropertyType(object control,
string propertyName,
string val)
object result = null;

Type type = control.GetType();
PropertyInfo p = type.GetProperty(propertyName);
Type propertyType = p.PropertyType;

TypeConverter converter = TypeDescriptor.GetConverter(propertyType);
result = converter.ConvertFrom(val);

return result;

for eg. if you pass

Yesterday went to chill out at Zenith waterfall and lonavala!!!

Snaps, soon to be uploaded..

Thursday, June 30, 2005

Javascript Mouse Event I

My attempt at learning javascript...

Call the init() method from the body tag..
The text should follow the cursor when u execute this script.

ns4 = (document.layers)? true:false
ie4 = (document.all)? true:false

var str = "Javascript magic!!!"
var block;

function init() {
document.onmousedown = mouseDown
document.onmousemove = mouseMove
document.onmouseup = mouseUp
if (ns4) document.captureEvents(Event.MOUSEDOWN | Event.MOUSEMOVE | Event.MOUSEUP)

if (ns4) block = document.blockDiv
if (ie4) block =

function mouseDown(e) {
if ((ns4 && e.which!=1) || (ie4 && event.button!=1)) return true
var x = (ns4)? e.pageX : event.x+document.body.scrollLeft
var y = (ns4)? e.pageY : event.y+document.body.scrollTop

return true

function mouseMove(e) {
var x = (ns4)? e.pageX : event.x+document.body.scrollLeft
var y = (ns4)? e.pageY : event.y+document.body.scrollTop
status = "x:"+x+" y:"+y

block.left = x = y
document.getElementById('blockDiv').innerHTML = str;
return true

function mouseUp(e) {
var x = (ns4)? e.pageX : event.x+document.body.scrollLeft
var y = (ns4)? e.pageY : event.y+document.body.scrollTop
return true

Wednesday, June 29, 2005 -> Server.Execute and Server.Transfer

The Server.Execute function accepts a URL parameter, stops execution of the current page (where the call to the function is made), and transfers the current environment to the new page. When that new page finishes execution, then control returns to the calling page just after where the Server.Execute was called

Terminates execution of the current page and begins execution of a new page for the current request.

Friday, June 24, 2005


Today created a nibble game, just for the sake of refreshing myself.

Friday, June 10, 2005

Some Interview Questions!!!

(1) Explain Indexing [In detail].
(2) What is the difference between regular dll and COM dll.
(3) Cursor, Triggers, Stored Procedures [also exception handling].
(4) For XML, OPENXML ins SQL Server.
(5) Web Services (consuming from Javascript, security[WSE], SOAP authentication].
(6) Web Server Control and HTML Controls
(7) DataGrid, DataList and Repeater server controls.
(9) Application architecture [NTier]
(10)Types of authentication in
(11)Response.Redirect v/s Server.Transfer
(12)State Management in [emphasis on ViewState]
(13)Caching (types of cachng - Page caching/output caching, fragment caching, data catching)
(14) page life cycle and application life cycle.
(15)Remoting (ClientActivated/ServerActivated), channels.
(16)Javascript (Confirm, alert, accessing objects on page, GetElementByID)

Tuesday, May 17, 2005

Bye-bye to ND

Yesterday was my last working day at Netdecisions..

Tuesday, March 22, 2005

Monday, March 07, 2005

COM Interoperability in .NET Framework: Part I

Tuesday, February 22, 2005

Understanding Interfaces and Their Usefulness

When to use datagrid, datalist or repeater?

Friday, January 14, 2005

Restricting addition of new rows to Windows Forms Datagrid

/// Set Allownew to false
CurrencyManager cm = (CurrencyManager) this.BindingContext[uDgBookings.DataSource, uDgBookings.DataMember];
((DataView) cm.List).AllowNew = false;

Thursday, January 13, 2005

Rotating text

private void Form1_Paint(object sender, System.Windows.Forms.PaintEventArgs e)
string s = ".net works";


for(int a=0;a<10;a++)

In the above code the origin has been translated to the centre of the screen, and the text is rotated by 30 degrees.

Double buffering !!!

To set up automatic double buffering for a Form, you would use the following line of code in the constructor, after the InitializeComponent method call.


me.SetStyle(ControlStyles.AllPaintingInWmPaint OR _
ControlStyles.UserPaint OR _

User interface Tips

(1) Always create a base control for all you gui widgets.
for eg.

public class UButton : System.Windows.Forms.Button

and similiarly for other controls.
This will help you maintain consistency of gui elements across all user interfaces.

(2) Create your own base form instead of using System.Windows.Forms.Form

public class UForm : System.Windows.Forms.Form

This will help you maintain consistency across all forms.

(3) And similarly for web forms and user controls.

Online c# practice...

Tuesday, January 04, 2005