136 views
1 Star2 Stars3 Stars4 Stars5 Stars (4 votes, average: 4.25 out of 5)
Loading ... Loading ...

18.04.13

Using Apache Commons CLI to Parse Arguments

Posted in Blogroll, Tech at 2:23 pm by Liv About Liviu Tudor

computer codeI’ve talked before on this blog about Apache Commons CLI project and showcased how easy it is to use it to build a rather complex command-line syntax for your Java application. If you find yourself at any point writing an application which needs more than one command line switch, I strongly recommend Commons CLI is the way to go: it takes care of basic “syntax” validation, missing command-line parameters, help screens and so on, and all of this in exchange of pretty much providing a structured set of options describing the parameters expected / accepted by your application.

One of the problems when dealing with command-line arguments is that in a lot of cases the application needs to interpret these not as simple strings but parse them in some different data types and interpret them as numbers, file names, url’s etc. A classic example is specifying the max heap space when starting a Java process:

Java -Xmx512m ...

In the above case, the Java process needs to interpret the argument after -Xmx as a number followed by a “denominator” (e.g. kilobytes, megabytes etc) — as such will employ a process of extracting the digits in a separate string, parsing them, ensure they are a valid number, then separately identify the denominator (“m” in this case), ensure it’s a valid one and find the multiplier (megabytes in this case – i.e. 1024 X 1Kb) and based on these 2 finally compute the final result.

Read the rest of this entry »

Disclaimer

1,237 views
1 Star2 Stars3 Stars4 Stars5 Stars (4 votes, average: 4.50 out of 5)
Loading ... Loading ...

14.11.12

(Disappointing) Review of My Blog’s Traffic

Posted in News, Random Thoughts, Tech at 7:09 pm by Liv About Liviu Tudor

iStock_blog write keyboardA while back I’ve boasted on this very blog about the amount of traffic it has reached — based on stats that I have pulled up from the Wassup WordPress Plugin. I have decided recently to have a closer look at the traffic — any blogger who’s taking himself seriously checks now and then on his audience! — and part of this I have decided to look in the server access logs myself and see how much they tally up with Wassup, as well as looking for a trustworthy 3rd party to quantify some figures for me too on this so I can have 3 reference points in this comparison.

For the purpose of this exercise, I have decided to use QuantCast as my 3rd party provider of analytics — they are a well established name and provide interesting analytics not just on page views, visits etc but on unique users, audience breakdown and so on.

Read the rest of this entry »

Disclaimer

1,490 views
1 Star2 Stars3 Stars4 Stars5 Stars (5 votes, average: 5.00 out of 5)
Loading ... Loading ...

26.10.12

Perf4J and Object Creation/Destroy

Posted in Blogroll, News, Random Thoughts, Tech at 2:40 am by Liv About Liviu Tudor

If at any point in your coding life you had to measure some component performance, chances are that you came across Perf4J at some point. To quote from their own website:

Perf4J is to System.currentTimeMillis() as log4j is to System.out.println()

There are of course other ways to measure timings of components execution, however, I found Perf4J to be rather neat as it plugs into Log4J, Apache Logging, JDK Logging and a whole bunch of others. It also has a bunch of tools you can use to analyze the output and generate some interesting stats analysis or even graphs. Basically, if you haven’t looked into it by now, do so! ;)

Read the rest of this entry »

Disclaimer

322 views
1 Star2 Stars3 Stars4 Stars5 Stars (3 votes, average: 3.67 out of 5)
Loading ... Loading ...

30.09.11

Server Migration

Posted in Blogroll, News, Tech at 8:17 am by Liv About Liviu Tudor

Some of you might have noticed, some might not, but I finally got off my arse to migrate my liviutudor.com domain to a proper hosting package. Gone are the days where I had 2 servers stuck under my desk at home — as much as I had fun X11-ing into my Linux boxes and adding things like mod_jk to apache and plugging in some Tomcat niceties, it came to the realization that lately I didn’t have time to do that so much nowadays :) (Blame the folks at Apache Commons for hijacking my spare time :) )

So I finally decided to migrate to a proper hosting and take the opportunity to actually unify all the other subdomains I had under liviutudor.com into one single website. Since the one that I kept maintaining the most was my blog (the old http://blog.liviutudor.com) I decided to have this as the main website and then “migrate” over old content from the other sites, keeping only the bits that were interesting. So right now you have one single website, http://liviutudor.com, and the old blog redirects to this, same with www.liviutudor.com — and the other subdomains don’t exist anymore (I’m pretty sure no one would miss them, as they were more coding experiments rather than fully fledged websites).

So bear with me while I do the full migration and if there’s something I’ve missed, feel free to drop me a line and let me know which bits I’ve missed from the old websites and I’ll try to add them in.

 

Disclaimer

8,465 views
1 Star2 Stars3 Stars4 Stars5 Stars (8 votes, average: 5.00 out of 5)
Loading ... Loading ...

18.04.11

Data Validation inside a List

Posted in Blogroll, Random Thoughts, Tech at 2:28 pm by Liv About Liviu Tudor

Felt like sharing this, since there might be some other “dinosaurs” like myself (i.e. slow in their using the Apache Commons Collections) — and those guys might find this useful :)

Occasionally you find yourself providing components that will be used by various modules in a project, and as such you have to employ strict validation of how the callers pass you information and reject those invalid calls — typically by throwing some exception declared in the component “contract” (interface). (I say typically as this is the preferred — read “recommended” — way of signalling these situations in Java, however, I’m not denying that there are cases when one has to instead return true / false or 1 / 0 or use some other method; in such cases, this approach can be still adapted by catching the exception at a high level and returning the corresponding value to signal failure.)

Read the rest of this entry »

Disclaimer

« Previous entries Next Page » Next Page »