Sunday, June 05, 2016

enums IV

So you find yourself calling values() lots in your code. Since this allocates a new array every time and this does not get optimized away, you might want to create a local copy, or an immutable collection and use that instead:

public enum Day {

  private static final Day[] values = values();


or alternatively use an immutable Set.

Thursday, May 26, 2016

enums III

Enums have a name() method. And it has a very precise meaning. Now imagine:
public enum Day {
  MONDAY("code1"), TUESDAY("code2");

  private final String code;
  private Day(String code) {
    this.code = name;

  public String getName() {
    return code;
Now good luck finding out what is and what is Day.getName(). You'd be much better off calling this other method of yours getCode(). If name looks like a good name for your attribute, think long and hard to find an alternative.

enums II

public enum Days {
Then is it:
Days day = MONDAY;
or is it:
Days days = MONDAY;
How about a set of days? Would you call it days? Is it a set of days or a set of dayss? It can get worse: DaysEnum or DayEnums? Don't call your day days... To be fair such atrocities already exist in jdk, like LayoutFlags or CssFlags (these particular ones thankfully in the bowels of com.sun.javafx). Not one of their best moments.

enums I

Imagine Month being MonthEnum. What is Monday? A month? Or a monthEnum? Do everyone a favour then and stop calling your enums, well, enums.

Monday, December 24, 2012

test your timestamp server with openssl

Generate the timestamp query:
openssl ts -query -data <filename> -out tsareq.tsr
You may optionally set the policy adding the -policy object_id parameter.
View the generated request in human readable form:
openss ts -query -in tsareq.tsr -text
Send the request to the timestamp server and store the timestamp response:
./tsget -h <timestamp server url> -o tsarep.tsr tsareq.tsr

View the reply in human readable form:

openssl ts -reply -in tsarep.tsr -text

You may find that tsget is stored in /usr/share/ssl/misc.
Alternatively, you may also send the timestamp request manually, and have finer control over the protocol and transport headers. One way would be using the almighty curl:
curl -X POST <timestamp server url> -H "Content-Type: application/timestamp-query" -H "Content-Length: <tsareq.tsr length>" --data-binary @tsareq.tsr -v -o tsarep.tsr

Saturday, September 22, 2012

generate HTML for your web services

Grab a copy of Tomi Vanek's wsdl-viewer.xsl. Then use your favourite transformation tool. Yes, it's that simple. I recommend xsltproc, the open-source command line XSLT processing tool, bundled with most Linux distributions, also used in soapUI. Windows fellas can get the binaries prepared by Igor Zlatkovi─ç. Then simply type:
xsltproc -o the-wsdl-report.html wsdl-viewer.xsl your-wsdl-file.wsdl

Saturday, June 11, 2011

why zmeeagain?

I think my -not so many- readers long deserved an explanation on the seemingly peculiar choice of the word zmeeagain for my web persona. Here it is:

Saturday, July 10, 2010

daily tweets

  • 19:05 Potokaki beach volley bar. F-awesome. #

Friday, July 09, 2010

daily tweets

  • 17:22 Psili Ammos Samos. Cooling after having been grilled. #

Thursday, July 01, 2010

daily tweets