Home » Blog

Percentages with JSF NumberConverter

Posted by Roger Keays, 3 July 2009, 12:06 AM

Hooray for buggy javadocs. The JSF taglib describes the type attribute of an f:numberConverter as:

Specifies how the number string will be formatted and parsed. Valid values are "number", "currency", and "percentage".

Nice, but wrong. For percentages, the correct value is percent, as defined in the JSF spec.

<f:convertNumber type="percent"/>

Where do I apply for my refund on that hour of my life?

No comments yet, be the first to comment!

Une Autre Perspective

Posted by Roger Keays, 15 June 2009, 1:35 AM

Actuellement, je cherche nouvelles occasions d'investissement. J'ai aussi viens de finir lire un livre sur Warren Buffet et sa approche d'investissement. Une chose qu'il dit souvent est "investissez dans les affaires que vous aimeriez posséder". Je sais, bon sens. Mais après j'ai regardé de près mes investissements, j'ai pris conscience qu'ils ne sont pas vraiment ce type de affaires que je voudrais posséder moi-même.

Alors, quel type d'affaire voudrais-je posséder? Je préfère surtout les affaires avec peu d'employés et grande marges. Voila une comparaison de plusieurs entreprises et leurs importance et marges. Les différences entré ces statistiques sont très évidente.

Enterprise Employés Bénéfice Bénéfice / Employé Marge
Berkshire* 19 4,994M 262M 4.6%
ASX 542 365M 673K 58.5%
Google* 20,222 4,226M 208K 19.4%
Westpac 28,000 3,859M 137K 33%
Telstra 46,649 3,711M 80K 14.8%
H. Norman 4,760 385M 81K 6%
Qantas 37,000 1,400M 26K 5.9%
Wesfarmers 200,000 1,050M 5K 3.1%

* US Dollars

No comments yet, be the first to comment!

Mon Achats

Posted by Roger Keays, 19 May 2009, 1:53 AM

Coles, mon local grand magasin, sont maintenant en ligne à http://www.colesonline.com.au. Je ne pense pas que je vais acheter en ligne à ce moment, mais c'est encore très pratique parce qu'on peux voir toutes les prix. Et aussi, on peux voir les unit prix par 100g ou 100mL. C'est intéressent comparer les produits comme ça. Pour votre commodité (et à cause je suis un peu frugal) j'ai fait une liste de prix de les choses que j'achète :)

J'ai choisi le moins cher produit pour chaque cas.

Read more...

No comments yet, be the first to comment!

Monitoring the JVM with SNMP + MRTG

Posted by Roger Keays, 10 April 2009, 3:16 AM

Some time ago I blogged about monitoring the JVM with SNMP and OpenNMS. Here is an alternative method using the more lightweight MRTG which makes graphs such as the one below.

First you need to enable SNMP in your jvm by adding -Dcom.sun.management.config.file=snmp.properties to your java command line. You can do this for tomcat by adding it to CATALINA_OPTS in your startup script. Next, you need to create that properties file properly. The following example configures the daemon to listen on all interfaces on port 1161. The ACL is disabled so you keep your security configuration in your firewall instead.

com.sun.management.snmp.interface=0.0.0.0
com.sun.management.snmp.port=1161
com.sun.management.snmp.acl=false

Read more...

No comments yet, be the first to comment!

Secret Weapon Against Noise

Posted by Roger Keays, 21 March 2009, 12:59 PM

Call me noise-sensitive if you must, but somehow my block seems to be like some sort of equivalent of the Roman Forum for noisy, lost animals ... crows, dogs, frogs, students. Those freaking small yappy house dogs are the worst and you won't believe how long and loud frogs can croak for. The students think they're pretty bad but they've usually crashed and burnt by 1 or 2am.

Fortunately, there's a solution to this ever-recurring problem. Below is an mp3 I found on the 'net. It is 45 minutes of heavy rain noise. Load it into your iPod, crank up the volume and enjoy your new found peace.

rain_vbr.mp3

2 comments, post a comment!

Pitman Shorthand Cheat Sheet

Posted by Roger Keays, 1 March 2009, 6:12 PM

Some time last year a customer who runs a Pitman Shorthand course in Brisbane contacted me. Shorthand is really fascinating and, without knowing it, it was my first real introduction to linguistics because the whole system is phonetic. I had found one of the original Pitman shorthand books in the restricted section of the library at UQ. It was so old that the pages were falling apart - kind of exciting, like a lost art.

It's hard to find shorthand books these days, but I've managed to collect a few - even some reading books. One of the really weird things about reading shorthand is you can read the authors accent (usually British).

Here's a shorthand cheat sheet that I put together for a bit of fun, and just in case all those books disappear one day.

Read more...

No comments yet, be the first to comment!

Laconic Log Formatter

Posted by Roger Keays, 19 February 2009, 1:10 PM

/**
 * Formats log messages onto one line only with only the time, level and
 * message. The date is ommitted because the log files are rotated daily
 * anyway.
 */
public class LaconicFormatter extends Formatter {

    @Override
    public String format(LogRecord record) {
        return new SimpleDateFormat("HH:mm:ss ").format(
                new Date(record.getMillis())) +
                record.getLevel().getName().substring(0, 4) + " " +
                record.getMessage() + "\n";
    }
}

No comments yet, be the first to comment!

Fluid CSS Menus and Sub-Pixel Workaround

Posted by Roger Keays, 28 January 2009, 1:08 AM

A long standing CSS problem, best described by John Resig in his blog, is the different approach browsers use when rounding widths calculated from percentages. Firefox rounds alternately up and down in order to make elements fit perfectly, Opera and Safari always round down so that elements will never overflow the container, and Internet Explorer always rounds up so elements often overflow their container and developers get to practise using profanities.

My use case is a fluid css menu with no gaps between the elements or at the end. If you don't know how to build css menus you might want to start by reading my blog on css menus. CSS menus are useful because they are built with <ul> and <li> markup which is a natural representation for hierarchies. The problem is that since menu items are floated, using percentage widths does not guarantee the space will used perfectly (unlike tables).

The basic concept behind the workaround is to leave the last element of the list unfloated so it occupies the entire width of the menu bar underneath the floated elements. Essentially the last item has the following style:

.web_cssMenu li.web_last { float: none; width: auto; }

Read more...

2 comments, post a comment!

Onward Travel Extortion

Posted by Roger Keays, 24 January 2009, 3:52 AM

When I left for Singapore in December I gained some unfortunate insight into the nature of the airline business. I was checking in for my flight and my interlocutor was enquiring about my itinery. Since she was having a bad hair day and I was traveling without a return ticket she insisted that I had to buy a return flight before I was allowed to board, citing that proof of onward travel was required to enter Singapore.

Puuuuuurlease!! Singapore?! A laissez-faire* democracy covering 650 square km that issues 90 day tourist visas on arrival? I mean, the country is so small you could crawl out on your hands and knees if you had to. No. Nobody in Singapore cares, least of all the immigration officers processing queues and queues of people. BUT, the airlines care because the sooner they get your money the sooner they can put it to work.

Read more...

No comments yet, be the first to comment!

Removing Line Feeds in Java

Posted by Roger Keays, 22 January 2009, 10:18 PM

This should be a fairly cross-platform way to remove line feeds from a string using Java:

string.replaceAll("[\r\n]", "")

Why do the smallest issues always take the longest to resolve?

No comments yet, be the first to comment!

1 2 3 4 5 6 7 8 9 10 11 12