Monday, August 17, 2009

FileZilla: Can't parse "FileZilla.xml", the file may be corrupt

When your computer turns off abnormally e.g power failure, and you were using FileZilla, most likely next time when you will run FileZilla you will get an error message that "Can't parse "FileZilla.xml", the file may be corrupt". Clicking OK button will run the FileZilla but this message will keep appearing every time you try execute FileZilla. You can easily fix this error by renaming or deleting "FileZilla.xml" file in C:\Program Files\FileZilla directory (Replace C:\ with your System Drive Letter).

Note: deleting FileZilla will also delete all the saved sites from Site Manager.

Blogger: Wider Rounder Template

The Rounder Template for Blogger is very elegant looking and easy to modify. But many peoples like me thinks that width of template is not enough. To help myself and others, I designed 4 rounder templates with different widths.
  • template-745px(500px).xml - Actual Width 745px, Post Area: 500px
  • template-845px(600px).xml- Actual Width 845px, Post Area: 600px
  • template-945px(700px).xml - Actual Width 945px, Post Area: 700px
  • template-980px(725px).xml - Actual Width 980px, Post Area: 725px
You can download all these templates from here. Images are also included if you want to host them on your own Server. Currently, all images are hosted at Google Pages.

Saturday, August 15, 2009

Modified version of FreeSans Font

Recently I designed a custom font which is actually a modified version of FreeSans. In this font characters are appearing white out of black with some extra glyphs. Here is the sample of that font.
You can download this font from here. You are free to use and distribute but don't forget to acknowledge :-)

ColdFusion - Check version of CF

To check which version of ColdFusion you have, following code can be used. This code is highly helpful when you have limited access to Control Panel or your hosting company do not reveals the version details.


<cfscript>
versinfo = arraynew(1);
versinfo[1] = structnew();
versinfo[1].name = "the base version, with no updater";
versinfo[1].number = 48097;
versinfo[2] = structnew();
versinfo[2].name = "Updater 1";
versinfo[2].number = 52311;
versinfo[3] = structnew();
versinfo[3].name = "Updater 2";
versinfo[3].number = 55693;
versinfo[4] = structnew();
versinfo[4].name = "Updater 3";
versinfo[4].number = 58500;
curversion = listlast(Server.ColdFusion.ProductVersion);
</cfscript>

<cfoutput>
<p>This server is running <b>#Server.ColdFusion.ProductName#, #server.coldfusion.ProductLevel#</b> <br />
#Server.ColdFusion.ProductVersion#
<br/>
<cfif left(Server.ColdFusion.ProductVersion,5) is "6,0,0">
<p>Which means it?s running with
<cfif server.coldfusion.appserver is "j2ee" and curversion is 58096>
 Updater 3 on ColdFusion MX for J2EE.
<cfelse>
<cfloop from="1" to="#arraylen(versinfo)#" index="i">
<cfif curversion eq versinfo[i].number>
<b>#versinfo[i].name#</b>.
<cfbreak>
<cfelseif curversion lt versinfo[i].number>
<b>patches not yet up to the final release of
#versinfo[i].name#</b>
<cfbreak>
<cfelseif i is arraylen(versinfo)>
a version <b>greater than the final release of
#versinfo[arraylen(versinfo)].name#</b>.
This tool has not been updated yet to recognise that
version number.
</cfif>
</cfloop>
</cfif>
<cfelse>
</cfif>
</cfoutput>

ColdFusion - Automatically Update cfdiv after every x seconds

One of my client asked me to provide him proof of concept that real-time auction website "swoopo.com" can be created in ColdFusion. The only real challenge in this project was real-time update of cfdiv after every x seconds.

For all those who don't know about cfdiv, here is the description from documentation.
Creates an HTML div tag or other HTML container tag and lets you use asynchronous form submission or a bind expression to dynamically control the tag contents.
Anyhow, to update cfdiv after every x seconds, you have to use Javascript. Here is the sample code.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
<script language="javascript" type="text/javascript">
function updatestats()
{
_cf_loadingtexthtml=""; // This will remove "Loading..." preloader
ColdFusion.navigate('emp.cfm','GetDataNow');
}
</script>
</head>
<body onload="window.setInterval('updatestats()',1000)">
<cfdiv id="GetDataNow" bind="url:emp.cfm" />
</body>
</html>

You can see in this code that we have created a function Javascript "updatestats" which uses ColdFusion.navigate to update GetDataNow (cfdiv id). And also note that we used window.setInterval in onload event of body tag. The setInterval() method calls a function / evaluates an expression at specified intervals (in milliseconds), in our example 1000 or 1 second.

ColdFusion - cfdocument, pdf and html tables

cfdocument tag of ColdFusion 8 is a great tool to generate extremely good looking PDF files/reports. Yesterday, when I was working on a PDF Generation System built on ColdFusion, I just noticed that cfdocument do not understand style="border-collapse: collapse" style. Therefore, if you are using tables in your PDF, you will see a lots of spaces and thick borders all around your tables and cells.

I highly recommend to use tableless structure inside cfdocument to avoid such problems. But if is absoulte necessary for you to use tables, then here is a fix for you :-)

  • Make sure that values of attribute border, cellpadding and cellspacing is set to 0 in each table. e.g <table cellspacing="0" border="0" cellspacing="0">

  • Add following style in your style sheet.
    td {
    margin-left:0;
    border-bottom:0;
    border-top:0;
    border-right:0;
    padding-left:0;
    }
Please also keep in mind that do not use <hr/> tag to generated colored horizontal line. Instead use colored image. And last but not the least, if your code inside cfdocument tag is XHTML validated, you will get perfect output.

Friday, August 14, 2009

Keyword-Links - Open external links in new window

Few days back, I was working on a clients website which was built on Joomla. Client asked me to install Keyword-Links component on her Joomla website. I never had used this component before. As per the description from Joomla Extensions Directory, Keyword-Links is a native Joomla 1.5 extension that enables Joomla websites to dynamically establish links for keywords or keyword-phrases in Joomla articles. With this extension, the administrator can manage all internal and external links in articles in a central location at the backend. Keyword-Links supports unlimited keywords for link-management and advertising.

No doubt about usefulness of this component but still I found a major draw-back in it. You can not configure this component to open all external links in new window or tab. Therefore, this component can reduce the stay time of visitor on your website.

To overcome this issue, I had to find a way to open all the external links to a new window. And after spending couple of hours, I realized that instead of changing component's core files, I should dynamically add "target" attribute to all the external links. Therefore, I included following Javascript in the index.php of template.


<script type="text/javascript">
function getElementByClass(theClass) {
var allHTMLTags=document.getElementsByTagName("a");
for (i=0; i<allHTMLTags.length; i++)
{
if (allHTMLTags[i].className==theClass)
{
allHTMLTags[i].target='_blank';
}
}
}
getElementByClass("keyword_extern");
</script>


Make sure that you paste this code in the bottom of template's index.php.

The above code is very easy to understand and self explanatory.