Friday, August 14, 2009

Flex Time

The last 3 to 4 weeks were terribly tiresome. The application that we were building was already running on a stiff deadline and we had entered into the meat of it at this point. It was thrilling to execute everything that was earlier planned. I kept foraging my desk draw for the invaluable information I had had hurriedly scribbled some weeks back. They help me to remind myself of what exactly was discussed. Somehow, no soft copy could do that for me.

Anyways, working late night continuously has helped me gain some decent level of fluency in coding with Flex. The Java Web Services were pretty straightforward.
Also, since I was at times given company by my colleague who is from Orissa, I have learnt how to swear in Orriya. I often swear at the Flex builder for being so shamelessly slow or at some of the insipid methods or definitions in ActionScript.

Somehow a few of the bigger challenges have been taken care of. There are a few more to go before we reach the comfort zone. Of course, when the testing phase is on it could all come down – but then that is a different story altogether.

Wednesday, July 8, 2009

Dynamic Menu using Flex

I think it is time now to share some of the initial work I have done in Flex which served as a part of my learning process as well.

A dynamic menu - fully populated from data stored in MS SQL - fed via a web service.
It is important to mention that most of the functionality was pretty much handled in the web service (IMO, that is how it should be).

The only thing I learnt in flex through this project was to use the Menu control and to perform a simple WS call.

The database has a table 'tbl_menu' that stores all the menu details. It references itself via the field ParentMenu_id for sub menus.



The only input the Flex page needs is a cleanly formatted xml string. So that is what the WS is going to return:


[WebMethod]
public string GetMenuByClass(String usrclass)
{
StringBuilder sb = new StringBuilder();

Dictionary> dict = new Dictionary>();
dict = GetMenuDict(usrclass);

sb.Append("");
sb.Append("");
foreach (int key in dict.Keys)
{
sb.Append(AddXmlString(dict[key]));
}
sb.Append("
");

return sb.ToString();
}


It is just a plain method that uses StringBuilder to append the xml string. There are a hundred different ways to construct the xml, but that is not part of this sample.

Also you would notice soon that we are using a simple object class 'MenuInfo' that represents the actual DB entity which will be used that to pass around data.

Next, the GetMenuDict function takes care of populating a dictionary with all the menu data it pulled from the DB:


private Dictionary> GetMenuDict(string userAccessCode)
{
Dictionary> dict = new Dictionary>();

List menuItems = new List();

menuItems = GetMenuFromDB(userAccessCode);

foreach (MenuInfo m in menuItems)
{
// root element - 0 or NULL
if (m.Parent_Link_id == 0)
{
if (dict.ContainsKey(m.Parent_Link_id))
{
dict[m.Parent_Link_id].Add(m);
}
else
{
List lst = new List();
lst.Add(m);
dict.Add(m.Parent_Link_id, lst);
}
}
else
{
// not a root element - parent exists. find it and add this guy to his list
MenuInfo mInfo = null;

foreach (int key in dict.Keys)
{
mInfo = FindMenuInfoRecursive(m.Parent_Link_id, dict[key]);
if (mInfo != null)
{
mInfo.menuList.Add(m);
}
}
}
}

return dict;
}


The GetmenuFromDB just reads the data from the Database using a datareader and returns a list of MenuInfo. The more inportant function is the FindMenuInfoRecursive, which takes care of handling the sub menus. With this method the sample supports infinite level of sub listing menu items, by just setting the appropriate ParentMenu_id.


private MenuInfo FindMenuInfoRecursive(int id, List menuList)
{
MenuInfo menu = null;

foreach (MenuInfo item in menuList)
{
if (item.Menu_id == id)
{
menu = item;
break;
}
else
{
menu = FindMenuInfoRecursive(id, item.menuList);
if (menu != null)
{
break;
}
else
{
continue;
}
}
}

//finally return the menu object
return menu;
}


The AddXmlString is the method we are going to see next:


private string AddXmlString(List menuList)
{
StringBuilder sb = new StringBuilder();

foreach (MenuInfo m in menuList)
{
if (m.menuList.Count > 0)
{
//should continue
sb.Append(String.Format("", m.Name, m.Name));
sb.Append(AddXmlString(m.menuList));
sb.Append(String.Format("
", m.Name, m.Name));
}
else
{
sb.Append(String.Format("", m.Name, m.Name));
}
}
return sb.ToString();
}


With all this done at the WS, it leaves us with very little to do at the Flex end. We would just be making the call to the WS and merely bind the results.


public function WSMenuSvcResultHandler(event:ResultEvent):void{
var dataXML:XML = new XML();
dataXML = XML(event.result.toString());

var myMenu:Menu = Menu.createMenu(null, dataXML, false);
myMenu.labelField="@label";
myMenu.show(10, 20);
}


The full C# source for this example is here and the Flex source is here.

Sunday, June 14, 2009

Syntax Highlighter - Where to upload .js javascript files used for blogs

I had read about the syntax highlighter scripts a few months back but never really found the time to add it to my blog.

Today I decided to do it. Soon I ended up with the same problem quite a lot of others had already faced. Hosting .js files. Most of the code examples on the internet showed people uploading the .js files in Google pages. But Google pages is discontinued and it is now Google Sites, and Google sites does not permit uploading .js files.

Though the required files are available in Google code for you to refer, still I had modified a few things in the script which I wanted to host somewhere. Another option was to insert all that script inside my template, which I did not like.

Some blogs suggested some alternative free hosting sites, but I found my way out.

Here is what I did. I renamed all the script files with a .jsc extension and uploaded them in Google sites - it gave me no problem. I then referred these files in my template and it works like a charm. I just did a quick test on my default browser - Chrome. Also tested in IE 6 and Firefox.

Saturday, June 13, 2009

Going with the tide...Flex and Java

For the past few months, I have been coding lesser and lesser in .Net. That was because I was doing some groundwork for the next project, which we had planned to build in Flex consuming either Java or .Net Web Services. Compared to my exposure in Java, I can say I know .Net like the back of my hand. But then, that is what willful programming was all about - exploring new horizons. Added with that was my personal interest in wanting to learn and work in Flex. Besides, I should also learn to go with the tide, shouldn’t I?

I have a moderate level of experience working in Flash, but that was 4 years ago when my friend and I would stay awake all night building flash web templates. She was exceptionally creative at designing and I focused more on the ActionScript.

Also having worked in WPF, I was basing myself a lot on these experiences and began building some sample applications as I learnt. So going forward, one can expect a lot of Flex and Java related posts more often.

Wednesday, June 3, 2009

Debug handle is invalid - Visual Studio 2005

I have had so many people at work coming to me with this issue. So, think it is worth making note of it here.

Problem: Visual Studio 2005 - when you try to run any application pops up this window with a message - "debug handle is invalid".

The fix is to get your "Terminal Services" running.

Start -> Type Run -> type services.msc and hit enter ->
Look for the the Terminal Service -> Right click that and Start.

Probably you could make it Automatic to start every time you boot up.

VS 2005 hooks up with this service to run its debugger session.

Thursday, May 28, 2009

Social Bookmarking your Blogs

I had long wanted to add those tiny icons to my blog posts. Finally found some time today. Googled it and realized it was quite simple. Making very little template code changes would be enough.

1. You need to host the icon images somewhere, I used Google sites.
2. Go to your blogger dashboard. Click on Layout of the blog you wish to modify
3. Click on Edit HTML
4. Check the Expand Widget Template
5. Search for the text “post-footer-line-3”
6. It was a ‘div’ tag in my template. I think it should be the same in most templates
7. Inside this is where you add your code for the links (Which I have explained further below).
8. Save the template

Code to add the links:
It is a simple anchor tag, making an icon/image or some text or both link to the submit url of the respective social site.

Try adding it one by one. Just remember these things:
1. Set the target value to _blank so that the user does not actually navigate away from your blog but instead opens these sites in a new window
2. The post.url and the post.title variables will get you the current page details, which you would be submitting to the respective social site
3. You might encounter some xml parse errors – usually with the actual ampersand symbol – replace it with the text &

Examples from what I have done:

<!--Google Bookmark-->
<a expr:href='&quot;http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=&quot; + data:post.url + &quot;&amp;title=&quot; + data:post.title' target='_blank'> <img alt='Google Bookmark' src='http://YOUR HOSTED URL/googleicon.gif'/></a>

<!--Stumble Upon-->
<a expr:href='&quot;http://www.stumbleupon.com/submit?url=&quot;+ data:post.url + &quot;&amp;title=&quot; + data:post.title' target='_blank'><img alt='Stumble Upon' src='http://YOUR HOSTED URL/stumbleicon.png'/></a>

<!--Del.icio.us-->
<a expr:href='&quot;http://del.icio.us/post?url=&quot; + data:post.url + &quot;&amp;title=&quot; + data:post.title' target='_blank'> <img alt='Del.icio.us' src='http://YOUR HOSTED URL/deliciousicon.png'/></a>

<!--Digg-->
<a expr:href='&quot;http://digg.com/submit?phase=2&amp;url=&quot; + data:post.url + &quot;&amp;title=&quot; + data:post.title' target='_blank'> <img alt='Digg' src='http://YOUR HOSTED URL/diggicon.png'/></a>

<!--Technorati-->
<a expr:href='&quot;http://technorati.com/faves?add=&quot; + data:post.url + &quot;&amp;title=&quot; + data:post.title' target='_blank'> <img alt='Technorati' src='http://YOUR HOSTED URL/technoratiicon.png'/></a>

<!--Reddit-->
<a expr:href='&quot;http://reddit.com/submit?url=&quot; + data:post.url + &quot;&amp;title=&quot; + data:post.title' target='_blank'> <img alt='Reddit' src='http://YOUR HOSTED URL/redditicon.png'/></a>

<!--Twitter-->
<a expr:href='&quot;http://twitthis.com/twit?url=&quot; + data:post.url + &quot;&amp;title=&quot; + data:post.title' target='_blank'> <img alt='Twit This' src='http://YOUR HOSTED URL/twittericon.png'/></a>

<!--Yahoo Bookmark-->
<a expr:href='&quot;http://myweb2.search.yahoo.com/myresults/bookmarklet?t=&quot; + data:post.url + &quot;&amp;title=&quot; + data:post.title' target='_blank'> <img alt='Yahoo Bookmark' src='http://YOUR HOSTED URL/yahooicon.png'/></a>

Tuesday, May 26, 2009

Exception Handling in .Net

A project task came up late last week to revamp and redesign an existing site, which was developed about a year back. The source was in C# and I had to quickly do a code walkthrough and prepare an effort estimate.

While reviewing the code, I noticed that almost every function, method and even tiny code snippets were wrapped around a try catch and the code within the catch section was either left empty or was simply throw ex;

I just wanted to write a quick note about exception handling based on what I have been doing over the last few years:

1. Catch an exception only when:
a. You are really intending to handle it and handle it appropriately
b. You want to find if it was some specific exception

2. There is no point in writing a try catch throw,
i.e. Writing the code given below is equivalent to writing nothing at all:
try
{
//Your code here
}
catch (Exception ex)
{
throw ex;
}

Instead you could just write your code and let the exception to bubble up.

3. Build a decent exception handler module that can contain options to log/publish the exceptions and helps to support the system.

4. A try catch in the UI would make more sense and it should appropriately redirect the user to a common errors page. Usually in the middle tier, the exceptions can be left to bubble up for the UI code to handle.

5. Create custom exception classes for specific purposes and throw them around your MT code. Using a try catch to find out if such a custom exception was thrown makes sense.

Example:
Write a UserNotFoundException that inherits from System.Exception.
You could throw this exception from a method that tries to fetch a user.
From another part of the code you can check specifically if this exception was thrown, and based on that you can route your code.

I am surely going to re-factor this website code and change it accordingly.

Thursday, May 21, 2009

Outlook does not display images

I ran into this problem suddenly last week. None of the forwarded emails, my friends sent (which had funny pictures and some really hot photos) were getting displayed. Instead it got replaced with the standard IE image not found symbol - A big red X.

I then Googled it and realized that the problem was due to Outlook's temporary folder draining out of its designated disk limit;

Solution:

1. Open your registry (Run -> Type "regedit")
2. Navigate to HKEY_CURRENT_USER\Software\Microsoft\Office\11.0\Outlook\Security
3. Find the key "OutlookSecureTempFolder"
4. Copy the value and access the folder (Again try Run -> Paste the path)
5. Clear all contents inside this temporary folder

Now try re-opening the emails. The images would now get downloaded into the temporary folder and the preview pane would display the images correctly.

Monday, May 18, 2009

Training and Knowledge Transfer sessions with the Chinese

For the last 2 weeks we were providing training and knowledge transfers to a team of engineers from Beijing. These people would be supporting one of the major accounts that we were supporting till now.

The team comprised of 4 engineers who arrived to the ‘warm’ welcome of the Chennai summer. Not used to such conditions, they found it a real challenge to make it to the office building after getting out of the car. They saw to it that they never went out during the day time. They got their lunch delivered and served at one of the conference rooms.

I had to do a KT for 2 systems and train a couple of them. They both appeared very friendly and kind. I could sense a fair amount of nervousness, but that is reasonable given the fact that they have not worked in .Net before and also do not have much knowledge about the business. They spoke in low voices and struggled hard to understand our accent which by the way was mutual.

The girl to whom I initially started the training could not follow what I was saying and I had to slow down while I spoke. But still it appeared as if I was difficult for her to follow, so I started writing down while talking. She was able to understand better now and that is how the remaining sessions went by. Almost an entire notepad was over within the next few days. After each session she borrowed my notes and copied them over.

As per plan, I explained everything I knew about the system and emphasized on areas of caution where issues were faced frequently. Also, I gave them the list of items that are pending or partially completed and items that have been completed but are in User Testing status. The overall training went smooth and everyone was happy. The girl to whom I did the knowledge transfer gave me a small present – like a souvenir – a Weifang butterfly kite with some terrific artwork. I liked it and it was so nice of her.

Sunday, May 10, 2009

Web Services: Code-First vs Contract-First approach

One of my colleagues who recently moved to work in a maintenance project based on Java, came back to discuss about the Web Service pattern followed there. He used terms like ‘Top-Down’ and ‘Bottom-Up’ approach and mentioned that so many different things were possible in the Java world.

Curious to find out more on what he exactly meant and also in a secret desire to defend .Net, I explored based on the details he gave.

1. Parameters passed to the web method can be validated based on a limit/range.
a. Ex. Value passed in for an integer parameter can be checked if the value is within a defined range or format. Or a date parameter can have a range specified
2. The Web service code was generated from a defined WSDL and not the usual other way around.

Below are my findings:
There are two approaches to build a web service: Code First approach and Contract First approach.

1. Code First approach – where you write the web methods and then add a web reference of this service in whatever client you are using. If it is a .Net client, it will generate a wsdl file and a reference.vb (or .cs) to define the types and methods used/defined in the service.

2. Contract First Approach – you start working on building the WSDL file first. Define and write your types and methods in the WSDL. The code is generated from this WSDL (.Net provides the option through the wsdl.exe tool).

Which approach to choose, purely depends upon the requirement. The contract first approach is surely the only option when you are leaning on interoperability. If your web service is just going to be consumed internally by your own applications (like how I have been using it all along), then the code first approach should be totally fine.

The contract first approach is tedious and could easily get messy if you are not sure of what you are doing. Also it requires a person to have a very good understanding of the schema design and should be able to fluently code. But then there are quite a few schema designer tools available. But by modifying the schema, you can perform restrictions on the parameters and can even perform schema validations.

One solution that is very popular is Thinktecture Contract First. They provide you with a nice option where it integrates smoothly into the Visual Studio IDE and makes the code generation out of a schema file pretty simple and easy. Also among the many other options, they have encapsulated the Web Service custom validation of SOAP requests against the definitions defined within the source WSDL file using Attributes.

I shared these findings with my colleague and made him realize that what he had seen in his new project is not something related specifically to Java.

References:
http://www.frotscher.com/download/JUG-ContractFirst.pdf
http://ftp.mcs.anl.gov/pub/tech_reports/reports/P1319.pdf

Saturday, May 9, 2009

Project Separation

Similar to how things are in many cases in the industry right now, our company, which is a captive center, lost another account. The client account, an insurance company based out of Singapore, which recently was sold out of the parent corporate company, decided to get its systems supported by another company in Beijing.

Though a lot of reasons were attributed towards this decision, which was so suddenly announced, I can surely tell one thing with a lot of confidence – the decision was not based on any performance issue from our side. There were no loose ends in any delivery or in quality and the managers and stakeholders were clearly pleased and satisfied with our services.

There were corporate political reasons, beyond the control of the managers at the client side; and the shift happened. Now came the phase – project separation. This was a new experience for me. As an individual, many times, I have moved around different projects and twice to totally different companies. But never have I been a part of an account getting shifted. So after being done worrying about what was coming next, a part of me was just curious and excited to see how this whole separation thing goes through; and it sure had a lot of comical moments.

Our delivery manager called upon a meeting to announce this to much of all our surprise.
MOM and takeaways after the meeting:
1. Singapore client is gone. (What the …? Really?)
2. They are shifting their projects to a company in Beijing, China (Yeah, All I care…)
3. We would need to do a knowledge transfer to this Chinese firm (Oh shit!)
4. The shift is only due to the corporate decision at the client end, not us. (Hmmm…)
5. And don’t worry, there are some projects in the pipeline, so you will all be settled soon (Lets see about that)

We came out talking to each other, as usual, making jokes to hide our surprise. In a subsequent meeting, the plan was revealed:

1. People from the Chinese vendor are already at the Singapore office and are receiving KT.
2. The coming week they would be at our office and would require us to do an extensive knowledge transfer and training session for 2 weeks.
3. During this 2 weeks, any production issue, would be primarily supported by us and the new vendor would be secondary support
4. The 2 weeks after that, we would go to secondary support mode and they would be providing primary support.

The plan looked okay to us, given the fact that we were never given any training on the systems and had to work our way up. Also, I strongly believe that any team with some decent technical background can easily support the current client applications.

We were now preparing for the KT. The stakeholders from the client end had prepared a reasonable schedule and we reviewed it. After highlighting a few points we accepted that. Things looked fine till now, but soon turned around.

A couple days before the scheduled arrival of the team from the new vendor, we were called upon and instructed NOT to give a good KT. We were advised to even misguide them. It appeared so stupid to me and a few others. Why should we do such a thing? And when we asked, the answer given was that this is a waste of time. If we were training a resource within our company then it makes sense, but why should we train someone else?

That was OUR next question, why should we?, if we are not going to do a good job? After all we are still going to be in the same business aren’t we? There are very good chances for us to cross path in the future. It is sheer foolishness to burn bridges.

While this was going through, there came another instruction to be extremely pessimistic in our estimations. While it makes sense to give out estimates with some extra buffer, there was one really simple task that was estimated at 20 man days! It would have hardly taken a developer 4 hrs to complete the work. All right, I agree that we have to be cautious; maybe we could add some buffer for that. But even then, how can one explain the 20 man days thing? 

And when I asked the manager, who proposed this oversized estimate about this, he simply kept telling that this is a task that could cause a lot of other impacts and hence needs a lot of analysis. What the hell? I wonder what these sudden impacts would be which pops up just now and not till just the day before until when we had taken up similar tasks and completed even without sending an estimate.

I just could not avoid arguing with him on this one until I got a convincing answer. Now come on – I am not an all innocent, never utter a lie kind of prick; but certainly I would need myself to be able to defend the situation. And when we send such an estimate to a client whom, btw, we have meticulously trained on getting his ass kissed with each project, shit is bound to hit the ceiling, for sure!

And on top of all this, if we tell him the reason for the high estimate, which is as flimsy as a wet toilet paper, it certainly is not going to be taken well. The counter argument is that after all he is a client whom we have already lost, what is there to gain, why should we impress? 
I don’t want to please or impress him, but what about our dignity of work? Okay, forget the dignity shit, what if we get to a point where we may need to work with him again?

After all this gawky behaviour by my immediate manager and some people above him, I realized that such client separations are not new just to me, it was totally new to them too.

I really hate it when managers take some instructions too wrongly into their heads and overdo and overreact. Maybe I am wrong in my thoughts, maybe I should learn to be as dumb and unreasonable as this moronic manager I am working with. I am curious to know how such project closures are handled elsewhere...

Tuesday, April 21, 2009

The administrative limit for this request was Exceeded - LDAP

Last week I was writing an ASP page that fetched information from Active Directory using LDAP queries.

It was a straight forward page - the manager from the client side wanted to check some attributes. I wrote the asp code and began to test it. That’s when this error popped up, after processing the page halfway through:

“The administrative limit for this request was
Exceeded”

The error was self-explanatory and also the error popped up exactly after fetching 499 records. I was quite certain of the issue, but I just wanted to know if I had to access 500 records at a time by modifying the query or could the ADODB Command object (which I was using) do the trick.

Googled it quickly and got the answer – setting the page size on the Command object was enough:

comm.Properties("Page Size") = 100

The Code snippet for reference purpose:

Dim rs
Dim conn, strSQL
Dim dictDeptList, szUserID, szUserName, intDeptID
Dim comm

szCountry = Request.Form("CountrySelCtl")

strSQL = "select cn, " & CONST_TEL_KEY & _
" from '" & GetMemberContainerPath & "/ou=" & szCountry & "' where objectClass='Member' "

Set conn = Server.CreateObject("ADODB.Connection")conn.Provider = "ADsDSOObject"conn.Open "ADs Provider", Application("AD_UserName"), Application("AD_Password")

Set comm = Server.CreateObject("ADODB.Command")
Set comm.ActiveConnection = conncomm.CommandText = strSql
' Removes the Max Allowed Restriction
comm.Properties("Page Size") = 100

Set rs = comm.Execute()

Monday, April 20, 2009

Sorting in Classic ASP

For the past 2 weeks I have been supporting and maintaining a client website, which is huge, but mostly in ASP.

There was one emergency client work order – requesting an ASP page that should provide options to download some error log files located in a virtual directory.
The request was very clear in mentioning that the error log files should be shown in a dropdown, and the files should be sorted chronologically, the recently modified to be on top.

Getting the list of files is easy, using the FileSystemObject. Also getting the modified date is simple, we have the DateLastModified property of the file object. The only additional thing pending was to sort them by this date.

This has to be developed in classic ASP. .Net was not an option – How I miss coding in .Net! This whole thing could have been done in just a couple minutes. Still building this in ASP page only took a few minutes extra. Wanted to share the Sort method for reference to others (and myself too).

Fetch the list of files into an array:

Dim fso
Dim errorDir
Dim file
Dim filesArr()
Dim sortedFiles
Dim cnt
Set fso = Server.CreateObject("Scripting.FileSystemObject")
Set errorDir = fso.GetFolder(Server.MapPath(ErrorLog_Dir))
cnt = 0
For Each file in errorDir.Files
cnt = cnt + 1
Next
Redim filesArr(cnt,1)
cnt = 0
For Each file in errorDir.Files
filesArr(cnt,0) = file.Name
filesArr(cnt,1) = file.DateLastModified
cnt = cnt + 1
Next

Call the Sort function

SortByDate filesArr, 1

Definition of the SortByDate function:


Function SortByDate(arrToSort, intAsc)
Dim temp1
Dim temp2
Dim i, j
For i = 0 To UBound(arrToSort) - 1
For j = i To UBound(arrToSort)-1
'Sort Ascending
If intAsc = 1 Then
If datediff("n",arrToSort(i,1) , arrToSort(j,1)) >= 0 Then
temp1 = arrToSort(i,0)
temp2 = arrToSort(i,1)
arrToSort(i,0) = arrToSort(j,0)
arrToSort(i,1) = arrToSort(j,1)
arrToSort(j,0) = temp1
arrToSort(j,1) = temp2
End If
'Sort Descending
Else
If datediff("n",arrToSort(i,1) , arrToSort(j,1)) <= 0 Then
temp1 = arrToSort(i,0)
temp2 = arrToSort(i,1)
arrToSort(i,0) = arrToSort(j,0)
arrToSort(i,1) = arrToSort(j,1)
arrToSort(j,0) = temp1
arrToSort(j,1) = temp2
End If
End If
Next
Next
fnSort = arrToSort
End Function

Tuesday, February 10, 2009

.Net Regular Expression for Numbers Range

At work, a colleague asked me for help with with a regular expression he was trying to get working. It was simple and quick and worth a post in my blog.

He wanted to validate for numbers between 1 and 50. After a couple of minutes of testing at http://www.regextester.com/, I sent him this:

Dim re As New Regex("^([0-9]|[0-4][0-9]|[5][0])$")

MsgBox(re.IsMatch(“123”))
MsgBox(re.IsMatch(“2”))
MsgBox(re.IsMatch(“50”))
MsgBox(re.IsMatch(“51”))

Tuesday, January 27, 2009

Accessing images from Google Sites

I recently wanted to modify my blog template a bit and had to create my own images and use them. I decided to upload the images to Google sites, where I have kept a bunch of my other files and preferred to maintain them all in one single location.

I uploaded the .gif images which had transparent areas in them and I copied the link and added to my harness blog and tested. I noticed that it displayed fine in Chrome, Firefox, Opera and Safari, but not really so in IE 6.

The transparent areas of the file were filled with a light blue color which was sufficient enough to mangle the appearance of the page.

The problem was with the URL I had used. The actual URL from the Google Sites was:
http://sites.google.com/site/codingpassion/Home/rails_main.gif?attredirects=0

For some reason, I found that query at the end of the URL to be unnecessary and removed it and hence faced this error.

This is what you see when accessing this link in IE6 (notice the blue/gray area? That is supposed to be transparent)
http://sites.google.com/site/codingpassion/Home/rails_main.gif


This is what you see when accessing this link in IE6 (notice the ?attredirects=0 query string)
http://sites.google.com/site/codingpassion/Home/rails_main.gif?attredirects=0


Fiddling with this further showed that when the attredirects=0 query string is passed along, Google appends the URL with an “auth” key value which in turn redirects to a more messy URL. Not sure what happens internally, probably they extract it from some location and authenticate if the file is available to all users, but adding that query string value back to the URL fixed things.

Update 1
Apparently there has been some issues with accessing images from Google sites:
http://groups.google.com/group/sites-help-somethingisbroken/browse_thread/thread/ec167ad76b4ea267/170c3709074f2bf6?lnk=gst&q=

Not sure what exactly Google does to fetch the image and why it would behave differently without the query string input.

Modifying Blogger Template – Resizing main Blog Area

The Google blogger has a decent bunch of templates to choose from and when I had to choose one I took a couple of minutes to think.

I would be posting code snippets and occasionally diagrams or images, maybe screen captures to explain something. But primarily the content will mostly be text with a lot of code.

I did not want a dark background with white fonts – I think no one will ever want to use that for writing technical content. Somehow I did not like the fully white templates as well. Most of the templates offered looked too simple and without many colors.

I finally chose the Rounders-3 (Green version) because it was simple and slick and the colors were fine and looked professional. However there was one drawback with it which I noticed as I started to post. The space reserved for the main blog was too little and any post that I did looked obtrusively lengthy. The code snippets that I posted had to be broken down to multiple lines despite using a smaller font. Making the fonts any smaller would be make it impossible to read.

So the only options I had were to either expand the main blog area or choose another template. But then, since I liked the template and also because did not want to perform a huge face-lift to a blog with steady traffic, I chose option A.

The change, I presumed, should not be difficult to make and it was not that difficult at all.

The default template was done to fit 800x600 resolutions and hence the max size of the title and footer was at 740 px. I am not sure if there are any more people using such low resolutions, but anyways I had my Google analytics stats to answer my question. There was less than 1% of the total visitors in that screen resolution.

Convinced that it would not affect the majority of the users, and even for those affected, they only have to scroll to see the profiles section, I proceeded to make the change.
Just wanted to jot down the exact changes made, as a ready reckoning for myself and others:
1. CSS properties had to be changed for the main blog area and the Title
2. Noticed that the rounded corners were not images for just the corners, but were a strip, hence had to modify the images and adjust it to the new width

That was all that needed to be done.

I used Google sites to upload my modified images. There was a snag in accessing the images from Google sites. Read more about it here.

Actual CSS Changes

#outer-wrapper
width:940px;
change image – used
http://sites.google.com/site/codingpassion/Home/corners_main_bot.gif?attredirects=0

#main-wrap2
change image – used
http://sites.google.com/site/codingpassion/Home/corners_main_top.gif?attredirects=0

#main
change image – used
http://sites.google.com/site/codingpassion/Home/rails_main.gif?attredirects=0

.main .widget
width: 668px;

.main .Blog
width: 684px;

#header-wrapper
change image – used
http://sites.google.com/site/codingpassion/Home/corners_cap_top.gif?attredirects=0

#header
change image – used
http://sites.google.com/site/codingpassion/Home/corners_cap_bot.gif?attredirects=0

#footer-wrap2
change image – used
http://sites.google.com/site/codingpassion/Home/corners_cap_top.gif?attredirects=0

#footer
change image – used
http://sites.google.com/site/codingpassion/Home/corners_cap_bot.gif?attredirects=0

Before


After

Tuesday, January 13, 2009

Fixing Corrupt Fonts Windows XP

Recently while I uninstalled a Game I was playing, it corrupted my Windows XP fonts. It had a copy of it taken from the Windows directory and when it prompted to delete some files, it showed the path of the game directory, and I thought it was safe to delete. But it totally messed up things and left my PC with bloated fonts.

A little bit of googling and quite a few options were suggested including reinstalling the OS (Nah, I was not planning to do that though). But this solution saved my day:

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\FontSubstitutes]
"MS Shell Dlg 2"="Tahoma"
"MS Shell Dlg"="Tahoma"

[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer]
"NoSaveSettings"=dword:00000000

Copy the above content into a text editor and save it with some name and make the extension as .reg - you can then double click this to set Tahoma back as the default font and get back the original Windows XP settings.

Or you can download the one I created from here.

Be careful with editing the registry, if you are not sure of what you are doing, i would advise you to take a backup of the registry before proceeding.

Sybase Stored procedure error Select permission denied on object

Yesterday we finally resolved a strange issue which was troubling us for a few hours.
We had a web page which was calling a newly created stored procedure. This stored procedure was returning results, but most fields of the result set were NULLS.

While we know that there is no chance for the data to go missing, we were left with the following options:
  1. Execute just the query used inside the stored procedure
  2. See the IO statistics to see if the correct tables are internally mapped (we had faced a similar issue a few weeks back, Check it here)

On running the IO statistics, we found that there was a warning - Server Error Number 10330, Severity 14. Select permission denied on object dbName..tableName.

We were logged into the database with very limited access and permissions and so after getting a login which had sufficient Select and Exec permissions, we proceeded to find out and fix the issue.

  1. There were two databases involved. Let us call it db1 and db2
  2. Stored procedure created in db1, selects from a table in db2 (db2..tablename)
  3. The db1 stored procedure was granted exec permissions to user group Group1
  4. The login used from the UI connection string belonged to the db1..group1 but did not belong to db2..group1
  5. The reason why the old stored procedure worked was because – that procedure was created by a user who had sa rights – and Sybase applies the rights of the owner to the queries inside it

Adding the login user (from the UI connection string) to db2..Group1 resolved this issue.