Monday, May 12, 2008

Multiple websites on XP

XP Pro IIS Admin is a free tool for using on Windows 2000/XP Pro. It allows you to create multiple websites and easily switch between those websites. Without this utility on Windows 2000/XP Professional, only one website can be created.

You can get it here: http://jetstat.com/iisadmin/

Wednesday, April 30, 2008

Not able to map Network Drive? Read on..

Ever got this problem while mapping a network drive:

The network folder specified is currently mapped using a different user name and password.To connect using a different user name and password, first disconnect any existing mappings to this network share.

And when you see your network mappings, strangely the drive is not mapped :(

Well, the solution is old reliable DOS commands. here it goes:

> net use
> net use \\SharedDrive /delete

net use command displays a list of all mapped drive. there will be a IPC$ mapping for the drive you want to connect to. Just delete the sharing and then you will be able to connect to the server.

FYI: The Inter-Process Communication (IPC) share or ipc$ is a network share on computers running Microsoft Windows. This share is used to facilitate communication between processes and computers, often to exchange authentication data between computers.

Wednesday, April 11, 2007

HTML Table Sort

Many a times we have a table populated with data and we want to sort on a specific column. It doesn't makes sense to hit the server for data that we already have. The solution is to use DOM to sort the data and repopulate table using JavaScript. There are a number of such scripts available on net and a simple Google search returns a lot of results. For e.g. try searching for "HTML table sorting". One very simple to use script is available at http://webfx.eae.net/dhtml/sortabletable/sortabletable.html.

Tuesday, February 27, 2007

Regex | Validate email

There are a number of JavaScript modules available online which validates email address. But there are instances when a valid mail address is also invalidated for e.g. some assume all domains end in .com, .net, .edu, or .org; and other invalidate mail ID with a + in the local-part. RFC 2822 (former RFC 822) describes the format of mail address.

So, here's the JavaScript code to validate the e-mail address as per RFC. Please correct it if there are any discrepancies.

function checkMail(emailAdd)
{
var regExobj = /^[-!#$%&'*+/0-9=?A-Z^_a-z{|}~](\.?[-!#$%&'*+/0-9=?A-Z^_a-z{|}~])*@[a-zA-Z](-?[a-zA-Z0-9])*(\.[a-zA-Z](-?[a-zA-Z0-9])*)+$/;

return(regExobj.test(emailAdd));
}

.Net Free Charting Solution | ZedGraph

ZedGraph is a set of classes, written in C#, for creating 2D line and bar graphs of arbitrary datasets. The classes provide a high degree of flexibility -- almost every aspect of the graph can be user-modified. At the same time, usage of the classes is kept simple by providing default values for all of the graph attributes. The classes include code for choosing appropriate scale ranges and step sizes based on the range of data values being plotted.

ZedGraph also includes a UserControl interface, allowing drag and drop editing within the Visual Studio forms editor, plus access from other languages such as C++ and VB. ZedGraph is licensed under the LGPL.


ZedGraph Home Page: http://zedgraph.org/wiki/index.php?title=Main_Page

ZedGraph Tutorial: http://codeproject.com/csharp/zedgraph.asp

Wednesday, January 17, 2007

Create Comments Faster | Visual Studio 2005

GhostDoc is an add-in for Visual Studio .NET 2003 and 2005 that tries to automate XML documentation. With GhostDoc installed, you move the cursor into the method or property you want to document, invoke the "Document This" command using either the source editor's context (right-click) menu or a hotkey, and GhostDoc will create an XML documentation comment. The result for

public void AppendHtmlText(HtmlProvider htmlProvider){...}

would be:

///
/// Appends the HTML text.
///

/// The HTML provider.
public void AppendHtmlText(HtmlProvider htmlProvider)
{
...
}


Some more examples are:

///
/// Gets the at the specified index.
///

///
public string this[int index] {
get { ... }
}

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

///
/// Gets or sets a value indicating whether
/// this is cool.
///

///
/// true if cool; otherwise, false.
///

public bool Cool
{
get { return true; }
set { ; }
}


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

///
/// Determines the size of the page buffer.
///

///
/// Size of the initial page buffer.
///
public int DeterminePageBufferSize(int initialPageBufferSize)

GhostDoc can be downloaded from here.

Tuesday, January 16, 2007

Smart Paster | Add-In for Visual Studio

SmartPaster is a plug-in for Visual Studio .NET 2003 and 2005 that allows text on the clipboard to be pasted in a format compatible with C# and Visual Basic code. SmartPaster can be downloaded from here.

Wednesday, December 20, 2006

JavaScript | String Concatenation

While implementing AJAX, very frequently we cam to situation where we had to parse large XMLs and create HTML out of these. This included looping over XML nodes and appending items to HTML string.

There are some options to improve performance in these scenarios where string concatenation is required:


  • Minimize the size of the string that is being appended to (so there is less memory to reallocate) . This means use local variables inside for loop and the concatenate these small strings to main HTML string variable. e.g.:

buf += "

";
for (var i=0; i < ROWS; i++){
var row = "";
for (var j=0; j < COLS; j++){
row += "";
}
row += "";
buf += row
}
buf += "
" + CELL + "
";

  • The Array object join method provides us a way to join all the elements of an array into a single string separated by a specified string separator. If we will assign each string as an element in the Array and will join all the elements with an empty char as our separator we will have the same result as using the + operator. This method is very similar to Java's StringBuffer object. e.g.:

var buffer = new Array();
buffer[buffer.length] = "Hello";
buffer[buffer.length] = " World";
buffer.join("");

Monday, November 27, 2006

Zip-Up

In case you want to add the "zip" or "unzip" functionality in your application, Info-Zip is your best bet. Info-Zip is portable, high-quality, used in many commercial applications and best of all it's FREE.

A sample implementation for VB6 can be found HERE

Another freeware (this one for .Net) is available at kellermansoftware.com

So, Zip-Up ur application ;)

Monday, September 04, 2006

Is 0=="" true or false?

In JavaScript that's true. And it was a cause of major bug in one of our application that took us 3 hrs. to debug :(

Hope you guys don't have to go through such bugs. Best of Luck.

Monday, August 28, 2006

Impersonation in .Net

There are scenarios when you may want to impersonate in .Net. What this means is you want to execute a part of your code with different authentication information. There are numerous scenarios when you may want to do it. An example: suppose you want to write a file to shared location where the user authentication running the application doesn't have write permissions. So what do you do? Impersonate your piece of code as the user who has rights to write file.

Here's the Microsoft kb article to how to impersonate your piece of code:
http://support.microsoft.com/kb/306158/

Sunday, August 20, 2006

CTRL + C, CTRL + V

Have you ever been in a situation where a dialog box pops up with some message which you need to copy? Many times. Right? Well, at least I have in the course of my development career.

Till date I was not aware of an easy way to copy this text and was manually typing the content. But recently one of my friend showed me a very simple way to do this, CTRL+C, CTRL+V. Yes, it works for dialog boxes. Whenever a dialog box pops up, just do a copy paste and you have the contents.

That's the power of copy-paste ;)

Monday, August 14, 2006

JavaScript | Redirect Parent Window

Have you ever faced a situation where you wanted to close a child window and redirect parent window to a new URL?

Well the solution to this problem is a simple javaScript. It goes something like this (I have executed the script on page load. It can be used with any event)

<body onload="opener.location='http://google.com';self.close();">

Sunday, August 13, 2006

Interesting XSLT Problem

This weekend I worked on a very interesting XSLT problem. I had to convert an XML like:



<?xml version="1.0" encoding="UTF-8"?>
<category>
    <type>1</type>
    <value>20</value>
</category>
<category>
    <type>2</type>
    <value>10</value>
</category>
<category>
    <type>1</type>
    <value>25</value>
</category>
<category>
    <type>2</type>
    <value>40</value>
</category>
<category>
    <type>2</type>
    <value>41</value>
</category>
</categories>


to something like:


<?xml version="1.0" encoding="UTF-8"?>
<output>
    <grid>
        <type val="1">
            <value>20</value>
            <value>-NA-</value>
            <value>25</value>
            <value>-NA-</value>
            <value>-NA-</value>
    </type>
        <type val="2">
            <value>-NA-</value>
            <value>10</value>
            <value>-NA-</value>
            <value>40</value>
            <value>41</value>
        </type>
    </grid>
</output>

I spent couple of hours figuring out how to solve it. Then I came across an interesting XPATH statement at http://www.topxml.com/code/default.asp?p=3&id=v20040207215613&ms=100&l=&sw=All to retrieve distinc values. I worked upon it and wrote the following XSLT which strangely worked :)



<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
    <xsl:template match="/">
        <Output>
            <Grid>
                <xsl:for-each select="//category[not(type=preceding::category/type)]/type">
                    <xsl:element name="type">
                        <xsl:attribute name="val"><xsl:value-of select="."/></xsl:attribute>
                        <xsl:call-template name="map">
                            <xsl:with-param name="type">
                                <xsl:value-of select="."/>
                            </xsl:with-param>
                        </xsl:call-template>
                    </xsl:element>
                </xsl:for-each>
            </Grid>
        </Output>
    </xsl:template>
    <!--Called Once for each type -->
    <xsl:template name="map">
        <xsl:param name="type"/>
        <xsl:for-each select="//category[not(value=preceding::category/value)]/value">
            <xsl:call-template name="checkAvailability">
                <xsl:with-param name="type">
                    <xsl:value-of select="$type"/>
                </xsl:with-param>
                <xsl:with-param name="value">
                    <xsl:value-of select="."/>
                </xsl:with-param>
            </xsl:call-template>
        </xsl:for-each>
    </xsl:template>
    <!-- Called once for each value -->
    <xsl:template name="checkAvailability">
        <xsl:param name="type"/>
        <xsl:param name="value"/>
        <value>
            <xsl:choose>
                <xsl:when test="//category[type=$type and value=$value]">
                    <xsl:value-of select="$value"/>
                </xsl:when>
                <xsl:otherwise>
                    <xsl:text>-NA-</xsl:text>
                </xsl:otherwise>
            </xsl:choose>
        </value>
    </xsl:template>
</xsl:stylesheet>