Tuesday, May 15, 2012

Java 5 autoboxing fail on equality check

  Double d1 = 25d;
  Double d2 = 25d;

  if (d1 == d2) {
            System.out.println("equal (==)");
  } else if (d1.equals(d2)) {
            System.out.println("equal (using equals() method)");
  }

The output is:
equal (using equals() method)

Wednesday, May 2, 2012

Reverse search for a previous command on Linux

Use CTRL-r to reverse search through a history of your previous commands executed in Linux e.g.
$(reverse-i-search)`':

Type in the text for a command you are searching for e.g. 'cat'
$(reverse-i-search)`cat': cat test.txt

In this case the last command executed with the substring 'cat' is 'cat test.txt'.

To exit the reverse search just use CTRL-g.