Sep
2
2009

Use Ant to Generate ChangeLogs From CVS ang Group by Date

Since version 1.6.1, Ant, the java build tool, has a core task called “cvschangelog“. It is quite useful to use this task to grab a list of recent changes committed to the CVS repository. The output of this task is in XML format. Something like the following:

<changelog>
<entry>
<date>2009-09-02</date>
<time>12:00</time>
<author>robin</author>
<file>
<name>test/ant/task/ChangeLog.txt</name>
<revision>1.2</revision>
<prevrevision>1.1</prevrevision>
</file>
<msg><![CDATA[A commit message]]></msg>
</entry>
<entry>

</entry>

</changelog>

To transform the xml formatted changelog into a human friendly html, you can do an XSL transformation with a XSL file. There is a default one in the Ant distribution, so you can use the following task to get a change log in html format.

<style in=”changelog.xml”
out=”changelog.html”
style=”${ant.home}/etc/changelog.xsl”>
<param name=”title” expression=”Ant ChangeLog”/>
<param name=”module” expression=”the_module”/>
<param name=”cvsweb” expression=”the_url”/>
</style>

The default generated html lists each commit change one by one. In some cases, we want to group the commit changes by dates. To do so, we have to change the default xsl file.

It seems that the new XSLT version 2.0 has specified a group functionality. However, it turns out only a few XSLT tools support this new feature. Fortunately, There is a way that allows us to do the grouping using XSLT version 1.0. By applying this method, we have the following looking xsl code for the HTML <BODY> part.

<body>
<h1>
<a name=”top”><xsl:value-of select=”$title”/></a>
</h1>
<p style=”text-align: right”>Designed for use with <a href=”http://ant.apache.org/”>Apache Ant</a>.</p>
<hr/>

<xsl:key name=”log-by-date” match=”entry” use=”date” />

<xsl:template match=”changelog”>
<xsl:for-each select=”entry[count(. | key('log-by-date', date)[1]) = 1]”>
<xsl:sort select=”date” order=”descending” />
<h2><xsl:value-of select=”date”/><xsl:text></xsl:text></h2>
<xsl:for-each select=”key(’log-by-date’, date)”>

<xsl:sort select=”time” order=”descending” />

<table border=”0″ width=”100%” cellspacing=”1″>
<tr>
<td class=”dateAndAuthor”>
<!– <xsl:value-of select=”date”/><xsl:text> </xsl:text> –>
<xsl:value-of select=”time”/><xsl:text> </xsl:text><xsl:value-of select=”author”/>
</td>
</tr>
<tr>
<td>
<pre><xsl:apply-templates select=”msg”/></pre>
<ul>
<xsl:apply-templates select=”file”/>
</ul>
</td>
</tr>
</table>
</xsl:for-each>
</xsl:for-each>
</xsl:template>

</body>

Use the above code to replace the <body> part in the original changelog.xsl file, then it  will allow you to group the change logs by date.

Jul
23
2009

JSP Expression Language in GWT’s embedded Jetty

JSP expression language (EL) is quite handy. but it only works when you indicate your web application is using version 2.4 or higher. That means you have the following in your <Your-Web-App>/WEB-INF/web.xml:

<?xml version=”1.0″ encoding=”UTF-8″?>
<web-app id=”WebApp_ID” version=”2.4″ xmlns=”http://java.sun.com/xml/ns/j2ee” xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance” xsi:schemaLocation=”http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd”>

Google Web Toolkit (GWT) is a handy Ajax Web application development tool. Since version 1.6.4, GWT uses Jetty instead of Tomcat as the embedded Web application container.

However, when I installed GWT plugin (version 1.6.4) for Eclipse, the default generated web application used the version 2.3. So when i used expression language in the jsp pages, it didn’t evaluate. Something like “${title}” as the output in the hosted mode running on jetty. It should also be the same result even i deployed to a tomcat container, as the web app version is still 2.3. This is understandable, as Expression Language is part of JSP version 2.0 standard, which is bound with Servlet (Web App) version 2.4. So if you want to make the expression language work, make sure your web app is using 2.4 or higher.

However, while using version 2.4 works fine, i’ve got the same problem when i use version 2.5, which is hard to understand why. This problem seems only in Jetty, not in Tomcat. I don’t know if anyone else have encountered the same problem as I did, but the following link seems to explain the reason behind: http://docs.codehaus.org/display/JETTY/JSP+expression+do+not+evaluate

Apart from this problem (which can be worked around), the use of GWT plugin seems more convenient than the traditional web app development in eclipse. :)

Apr
3
2009

List of Personal Finance Software / Websites for Money Management

It’s a good habit to keep an eye on your money and know how much you have spent in the past and how much you can spend in the future.

Although bank statements, credit card statement or online bank accounts provide all such information, these pieces of information scatter here and there and you lose track quickly and don’t have a whole picture to see where you are going. It gets worse when there are several bank / credit card accounts. So having a software or web sites to consolidate all such information seems a good idea.

Other than using a spread sheet to keep all the information together, there are quite a few sophisticated software or web site to do this job, some cost your money, some just free. The following lists some choices.

Desktop Financial Software – not free
Quicken, Microsoft Money. They are traditional desktop applications. That means you have to install them one your computer before you want to use them to manage your money. I haven’t used them but it should be easy to get started for a normal person.
It seems that quicken has a free online version for money management. However, don’t know how “free” it is and how many features it has.

Desktop Financial Software – free
GnuCash, jGnash. Both of them are free and probably open source software. GnuCash is actually beyond the personal level and can be used for catering small business (seems equivalent to Microsoft office accounting software). To use them, you may probably need to have a little bit of financial knowledge. For example, what is double entry?

Websites / online services / personal finance 2.0?

If you are confident enough to allow third party websites to handle your financial information, then you may embrace such so-called personal finance 2.0 websites. Among them are greensherpa.com, justthrive.com, rudder.com, mint.com and etc.

Most of them can retrieve your transactions from your nominated financial institutions or banks and aggregate them automatically for you and provide basic financial advice based on the data. Some of them charge you subscribe fee to use the online service, while some of them have free versions. However, it seems most of them are US version, i.e., they can only retrieve data from US banks.

Finally, a few words on the financial data formats and standards.
Quicken Interchange Format (QIF) is an open specification for reading and writing financial data to media.
Open Financial Exchange (OFX) comes from Microsoft and Intuit (the maker of Quicken) and it is a data-stream format for exchanging financial information.

The above two formats are quite popular and most of the financial software support the importation and exportation of the files in such formats. And most of the online banking system support them as well.

Mar
12
2009

Tips for installing Windows xp, vista and 7 without cd/dvd driver

Here i’ve gathered some links pointing to tips for installing windows xp, vista or 7 without cd/dvd driver (Imaging your laptop/notebook/netbook does not have an internal cd/dvd driver, and you don’t have an external one either.)

Windows xp

When windows xp came into market, the usb keys/external drivers are not as popular as they are now, nor is the volume of them. So windows xp is not designed with the function of installing from usb keys as I believe. However, the following link Installing Windows XP from USB provides information that helps you install windows xp from USB.

Windows Vista and  windows 7

It seems easier when it comes to windows vista and windows 7. The method of installing them from USB can be found from the link below:
Tips: How to boot/install Windows 7/Vista from USB Flash/Hard Drive

Feb
4
2009

Encode/Decode HTML in Java

It is often necessary to escape the special html code from the user input in case of avoiding cross site attack (XSS).

Initially i thought jdk provides a method somewhere to do this like function htmlentities() in php, but i failed to find it. All i found is a class called “URLEncoder ” which i don’t think can do this job.

I don’t want to reinvent the wheel as I believe there must be some java packages available that do this job. Googling “java encode html” didn’t lead me straight to the right java package (at least not the one I’d like to use).

After a while, I finally found one package i’d like to use. it’s from Apache Commons project, called “Commons Lang“. The method “StringEscapeUtils.escapeHtml(…) ” can do the encode job while the other method called unescapeHtml can do the decode job. So, I don’t have to write my own method… :)