May 19th, 2008
Here is some simple java code for getting ordinal numbers out of integers.
public static String getOrdinal(int number){
int mod100 = Math.abs(number) % 100;
int mod10 = Math.abs(number) % 10;
if (mod100 < 4 || mod100 > 20){
if (mod10 == 1) {
return number + "st";
}
if (mod10 == 2) {
return number + "nd";
}
if (mod10 == 3) {
return number + "rd";
}
}
return number + "th";
}
Just don’t use this for anything that may need to be internationalized one day… non-English languages may have entirely different sets of ordinals.
Posted in Uncategorized | No Comments »
May 7th, 2008
You would think it would be easy to find good documentation on how to create a hyperlink to a servlet deployed inside a JSR 168 war file, but you would be wrong. Specifically, I couldn’t figure out what context root to use. I finally found the answer at the bottom of this forum thread.
I’m calling the servlet which is defined inside the portlet project from a jsr 168 jsp page as follows:
<a href=”<%=renderResponse.encodeURL( renderRequest.getContextPath() + “/start”) %>?… any request parameters..”>TheLink
where start is the url-pattern configured in the web.xml.
<servlet-mapping>
<servlet-name>ServletName</servlet-name>
<url-pattern>/start</url-pattern>
</servlet-mapping>
Posted in Websphere Portal | No Comments »
October 20th, 2007
Ubuntu Linux version 7.10 was released last week. My current Ubuntu install is from, I think, 3 releases ago, so at this point I am very much looking forward to the upgrade. The critical buzz on this latest version: “The new Ubuntu is more polished, more professional and in general, better than the previous one, which was already a great OS. Minor glitches? Present, as always.”
I like Ubuntu because it has the power of a unix-based operating system without the inanity of the Mac OS X interface. They took the good usability features out of Windows and added a few others. The downside is that it can be rough around the edges, and sometimes getting various multimedia applications to work can be a real pain.
The company that puts out Ubuntu supplies free disks by mail, and I’ve ordered a couple. I suppose I could download and burn my own copies of the installation, but I’m lazy like that… Still, theres is a 6 to 10 week delay in delivering - I may not be able to wait that long.
Posted in Computer Geekery | Comments Off
October 11th, 2007
The hosts file is a text file that can be configured to override IP addresses for domain names. This can be useful for a number of reasons - like pranks, blocking access to certain sites, or, if you are setting up a new website but you haven’t yet set up a DNS record for it, you can set that file so that your machine can access the site using the domain name, even though no one else’s can. This comes in handy for me about, oh, once every six months.
And every six months I get pissed of at Windows because I can never remember quite where they keep the hosts file. For reference, it is a file called
C:\WINDOWS\system32\drivers\etc\hosts
This is a stupid place for Microsoft to have put an important file… on an obscure path, deep in the belly of the system folder - under “drivers” (it is completely unrelated to drivers) and under “\etc”, which is where you would expect to find it in Unix, but never Windows. Also, the file name “hosts” lacks an extension (i.e., “hosts.txt”), unlike every just about other file in the operating system.
I am convinced that this file would be far more widely used and its uses better understood if they put it, you know, some place where people could find it. Say “C:\WINDOWS\Config\hosts.txt”.
Posted in Computer Geekery | Comments Off