Archive for the 'Software Development' Category

Parsing ISO 8601 Date Format in Java

Tuesday, July 27th, 2010

These are dates in a format like “2010-05-17T09:30:47-04:00″ optionally including date, time and time zone, which are commonly found in XML documents.

In .NET you can just use DateTime.Parse(), but in Java the answer is not as obvious.

Assuming that you are using the Apache libraries, the simplest approach is probably to just use org.apache.xmlbeans.XmlCalendar:

Calendar c = new XmlCalendar("2010-05-17T09:30:47-04:00");

If that isn’t an option, try this.

Solving Port Conflicts in Windows

Monday, July 26th, 2010

Suppose that you start a server application like JBoss and get an error message like this one:

14:13:51,561 ERROR [AbstractKernelController] Error installing to Start: name=jboss.remoting:protocol=rmi,service=JMXConnectorServer state=Create mode=Manual requiredState=Installed

java.rmi.server.ExportException: Port already in use: 1090; nested exception is:
java.net.BindException: Address already in use: JVM_Bind

“Wait a minute,” you say, “That port should be free! Who’s using it?”

To find the answer, open a command window and type:

netstat -ab | findstr 1090

substituting the actual port number for “1090″. Under Windows 7 you will need to open the command window as an Administrator.

The netstat command will take a long time to run, but eventually it will give you the name and PID of the offending process. At that point you can decide whether to kill the offending process or make your application use a different port.

Ship Party

Tuesday, July 13th, 2010

A “ship party” is a celebration held when your product is ready to ship. Apparently the ones at Microsoft get pretty wild.

Bad Code Offsets

Wednesday, November 18th, 2009

In a development of world-shaking importance, Alex Papadimoulis announces a new technique that can totally eliminate the problem of bad code.

Original aLinks 2.0 code

Saturday, July 25th, 2009

I got a request for Sean Hickey’s original aLinks code.

Here it is

Download

…but be warned that it has some serious bugs. However it includes features that are not in my fixed version.

Go here for my fixed version, which omits some broken features that I never got around to fixing (because I don’t use them.)

.NET Dictionary with Case-Insensitive Comparison

Tuesday, March 24th, 2009

How do you create a IDictionary that does case-insensitive key matches. There are a number of solutions posted on the web, but none of them seem quite correct. The following should work.

IDictionary map = new Dictionary(new StringCompInsensitive());

where

public class StringCompInsensitive : IEqualityComparer
{
    public bool Equals(string x, string y)
    {
         return String.Compare(x, y, true) == 0;
    }

    public int GetHashCode(string obj)
    {
          return ((string)obj).ToLower().GetHashCode();
    }
}

Blog Personality Analysis?

Thursday, November 20th, 2008

Typealyzer asks you the enter the URL of a blog, and attempts to determine the personality of the author according to the Myers-Briggs Type Indicator. (via Megan McArdle.)

Naturally I immediately put in the URL of this blog and was told I am an “INTJ”, which it describes as a nerdy scientist type. Then I put in the URL of my other blog, where I write about “fun” stuff. This time it said I was an “ESTP”, which it describes as “active and playful.”

Of course these blogs have very different tones. Nevertheless the term “personality” as used by psychologists (including Meyers and Briggs) is something that applies to people, not blogs, and it is not supposed to change depending on what you are writing about. If Typealyzer gives different results for two blogs written by the same person, then it is not a reliable measurement technique.

Typealyzer also displays a chart purporting to show which areas of the brain were used in writing the blog. I’m not an expert in this field but I suspect this is pure hokum.

aLinks 2.0 Bug Fixes

Friday, November 14th, 2008

I had been happily using the “aLinks” WordPress plugin by Sean Hickey for quite a while. The plugin automatically generates links for keywords that you specify. Version 1 did everything that I wanted, but it broke when I upgraded to WordPress 2.6. I found that Sean had written a completely new aLinks 2.0, so I installed it and found that it mostly worked, though with some minor problems.

Then Sean seemed to vanish from the face of the Internet. His web server went off line, making it impossible to even send him an email, and has been that way for several months.

So I had no choice but to go into the source code and fix the bugs that were bothering me. Since the code is released under the GNU General Public License (GPL) I am making the revised plugin available to anyone who is interested.

New WordPress 3.x compatible version.

Old WordPress 2.x compatible version.

Bugs Fixed

  1. aLinks failed to respect word boundaries when identifying keyphrases, causing links to be inserted in the middle of words.
  2. aLinks was ignoring the “classes” setting which allows you to assign one or more CSS classes to the links.

Warning

If you are upgrading from aLinks 1.x you must first export your keyphrases to a file, then import them back in after you have installed version 2.0. Otherwise you will lose your keyphrases.

Other Notes

To install, unzip and copy the entire alinks directory to your wp-content/plugins directory.

The documentation is included as a PDF file in the alinks/includes directory.

Using Fiddler to Capture Web Traffic from an Application Running Under IIS

Tuesday, October 28th, 2008

Just add the following to the web.config file for the application:

<system.net>
 <defaultProxy>
  <proxy proxyaddress="http://127.0.0.1:8888" />
 </defaultProxy>
</system.net>

Thanks to Rick Strahl.

Get Fiddler here.

Application Configuration Error Converting to .NET Framwork 2.0

Tuesday, May 20th, 2008

I converted an old console app from .NET Framework 1.1 to 2.0 using Visual Studio 2008. When I ran it I got the following helpful error message

This application has failed to start because the application configuration is incorrect. Reinstalling the application may fix this problem.

Looking in the Security Event Log I found the following messages:

Generate Activation Context failed for C:\ParsII\bin\server\CCSWinService2.exe. Reference error message: The operation completed successfully.

Syntax error in manifest or policy file “C:\ParsII\bin\server\CCSWinService2.exe.Config” on line 1.

The last one was the key. In the app config file the first line was

<?xml version="1.0" encoding="Windows-1252"?>

That should be perfectly legal for an XML file, but deleting it caused everything to work perfectly.