Merge Adobe PDF files

I was looking for a program that would merge Adobe PDF files.  At first I found this trial program, A-PDF Merger, which worked fine but left a small watermark on the first page.  Then I found this open source program, PDF Split and Merge, which did the trick but the UI is kind of slow, possibly because it is written in Java.  It looks like there are plenty of other free programs available too.

How Facebook Stores Billions of Photos

Those guys at Facebook sure are smart. Here is an online presentation titled Needle in a Haystack: Efficient Storage of Billions of Photos.

Jason Sobel, the manager of infrastructure engineering at Facebook, … explains how Facebook efficiently stores ~6.5 billion images, in 4 or 5 sizes each, totaling ~30 billion files, and a total of 540 TB and serving 475,000 images per second at peak.

Slashdot | How Facebook Stores Billions of Photos

Test if empty in JSTL

Singur suflet pustiu on Flickr

(Photo: Singur suflet pustiu by dani81_const)

This article, Expression Language Overview” href=”http://www.informit.com/articles/article.aspx?p=30946″>InformIT: The JSTL Expression Language > Expression Language Overview, informed me on how to test if something is empty or not.

Empty?

<c:if test="${empty foo}">...</c:if>

Not empty?

<c:if test="${not empty foo}">...</c:if>

Interface Members

Because interfaces are static, public and don’t change, by definition any members you declare in them are static, public and final. Therefore you don’t need to qualify such members.

For example:

public interface A {
  String FOO = "foo";
}

is the same as:

public interface A {
  public final static String FOO = "foo";
}

You can read some more about this in the forum Interface member variable by default static?

Eclipse memory settings

Recently I have been having problems with Eclipse running out of memory.

Previously I had as my command line argument for Eclipse.

eclipse.exe -vmargs --Xmx512m

The double dashes were a problem, preventing Eclipse to properly load the correct memory settings from eclipse.ini.

I then removed the -vmargs –Xmx512m from the command line argument and instead modified eclipse.ini which is in the top level of the Eclipse installation. This blog article, Eclipse and memory settings, explains how you should put each argument on a separate line and that you can go to Help > About Eclipse Platform and then click on the Configuration Details button to check that Eclipse is running with the correct settings.

I changed this:

-Xms40m
-Xmx512m

to:

-Xms120m
-Xmx1024m

but I reverted back when I realized it was my original command line argument that was the problem.

I tried to use these settings as recommended in this forum, [news.eclipse.tools.jdt] Re: How to prevent out of memory errors?

-Xms120m
-Xmx1024m
-XX:PermSize=256M
-XX:MaxPermSize=512M

But for some reason that kept crashing the Eclipse startup.

Maven Profiles

Maven profiles are a pretty neat concept for organizing different settings for different builds.

Typically one sets them up in your settings.xml.  Projects will also have profiles in profiles.xml whose values you can override with your values in settings.xml.

A few observations I made about profiles.

  1. Your profile is the conglomeration of all your active profiles in your settings.xml.
  2. To activate other profile during a single maven execution, mvn -P profile1, profile2.

Droplet Name Case Sensitivity

In one of our JSP files we included a droplet like this:

<dspel:droplet name="/betweengo/droplet/foo">

However the actual properties file is named Foo.properties. On Windows this was not an issue because Windows file system is case insensitive but when we moved to UNIX we saw this exception:

javax.servlet.jsp.JspException:  CANT_FIND_DROPLET: Unable to find the droplet with name  "/betweengo/droplet/foo"

This is not surprising since UNIX’s file system is case sensitive. Once we corrected the capitalization ATG was able to locate the droplet.

Covariant Return Types in Java

dolphin's dance on Flickr

(Photo: dolphin’s dance by kalandrakas

This article, Covariant Return Types, from java.sun.com and reprinted in a nicer format by Java Tips, explains well what covariant return types are.

You cannot have two methods in the same class with signatures that only differ by return type. Until the J2SE 5.0 release, it was also true that a class could not override the return type of the methods it inherits from a superclass. In this tip you will learn about a new feature in J2SE 5.0 that allows covariant return types. What this means is that a method in a subclass may return an object whose type is a subclass of the type returned by the method with the same signature in the superclass. This feature removes the need for excessive type checking and casting.

An example is:

public class Shape {
  private Shape shape;
  public Shape getShape() { return shape; }
}

public class Circle extends Shape {
  private Circle circle;
  @Override
  public Circle getShape() { return circle; }
}

Not the best example but a succinct one. 🙂

URLHammer

URLHammer is a simple tool from ATG for doing load and performance testing.

Here is an example of using it.

E:\>cd ATG\ATG2006.3\DAS\lib

E:\ATG\ATG2006.3\DAS\lib>set CLASSPATH=classes.jar

E:\ATG\ATG2006.3\DAS\lib>java atg.core.net.URLHammer
http://localhost:8080/test.jhtml 10 100 -cookies

Time = 110068 ms   (9.09 requests/s; average latency = 1101 ms)
0 errors out of 1000 requests