Monday, March 15, 2010

IE Debugging - Using Fiddler and IE Developer tools

I have been developing web applications for a long time and I have gone through the pain of debugging them by putting "alert" stmts after each line of code.

Until Firebug came to the rescue. God bless the Firebug team! Firebug is such a strong tool that I almost immediately dumped IE and did all my development on FireFox. Firebug's debugging capabilities, HTTP tracking, dynamic content editing, DOM inspection were just too good to believe. And, very frankly I used to curse IE if something worked on FF and not on IE, since I had to go back to the "alert" approach.

Not anymore! I had started using Fiddler some time back but didnt find it very useful as my application was on HTTPS. After the release of Fiddler2 I am able to track each and every request and response. I have also started using the bundled Developer Tools in IE8 (under Tools menu or F12) that allow me to debug my JS scripts, check my CSS, inspect my HTML, check my browser cache and profile my pages. However, the developer tools are clunky, not very intutive and keeps crashing, but you would get used to it!

Few tips on using Fiddler2 efficiently:
  • I was unable to track requests originating from localhost. I followed what the team at Fiddler suggested. It works, although if you still want to stick with localhost you can use it this way-
    https://localhost.:8080/myapp/.. ("dot" after localhost)

  • To inspect the request parameters, I prefer to use the "WebForms" section in the request area.

  • To check the response, you can use either the "Raw" or "XML" section in the response area.

Using Fiddler2 alongside the Developer Tools, I can use IE as my development browser, but I have got so used to Firebug now, that I am gonna stick with it for a while!

Monday, March 8, 2010

Convert Excel Columns to Number

A code snippet that contains a utility method to get the column number from a column character, e.g. A -> 0 or AA -> 26

public int getColumnCount(String column, int multiplyFactor){
int col=0;
int minusFactor = -10;
if(column.length()==1){
col = minusFactor + Character.getNumericValue(column.charAt(0));
}else{
multiplyFactor += minusFactor + Character.getNumericValue(column.charAt(0)) ;
col = 26 * multiplyFactor + getColumnCount(column.substring(1),multiplyFactor+25);
}
return col;
}

Usage:
int colCount = getColumnCount(String columnChar,1)

Hope this helps!

Friday, March 5, 2010

Convert Numbers To Excel Columns

Another code snippet that contains a utility method to get the column character from a column number, e.g. 0 -> A or 26 -> AA


public String convertColumnNumberToChars( int i ){
int iBase = 26;
String interConversion = Integer.toString(i, iBase).toUpperCase();

char[] ac = interConversion.toCharArray();
for( int j = 0; j < ac.length; j++ ) {
int arrLen = ac.length - j - 1;
char c = ac[j];
ac[j] = (char) ('A' - arrLen + Character.digit( c, iBase ));
}
return String.copyValueOf( ac );
}

Usage:
String colChar = convertColumnNumberToChars(int columnCount)


In the next post i will also put down a method to convert a column character to column number.