How to correclty calculate days between two days

The standard Java API has no solution to calculate the period between two days, although this is a common request for someone who is doing calendar arithmetic.

Googling around, the are many people who expose their own solutions (see some of them 1, 2, 3, 4).  All them suggest getting difference between the two dates, measured in number of milliseconds, and divide by 1000 * 60 * 60 * 24 (that means, the number of milliseconds in a day typical day).

Regex that matches path, filename and extension

I was looking for a regular expression for Python capable to match a string containing a valid path, file name and extension. Finally, I discovered following solution:
^(.*/)?(?:$|(.+?)(?:(\.[^.]*$)|$))
Let me explain how I got this regular expression. Fortunately, Scott Carpenter has written an excellent article about a regular expression to match a file name with extension. Matching the file name extension is not trivial for all possible situations.

Skype on Ubuntu 8.10: microphone and internal speaker issues

It has been a long time since my last post… Also, it has been some time I managed live without a PC and Internet. Now I have a PC and Internet again and I took the chance to immediately install Linux!

Updated: I also solved the issue of skype consuming 100% cpu during a call.

Although the Ubuntu Guide has a good description how to install Skype on Ubuntu Intrepid, it can be quite challenging to place a call successfully. Shame on Gnome, Pulse Audio and Skype! I had to overcome following issues:

Resume scp/rsync file transfer

This is very basic Linux knowledge, but the question has arisen too often and I decided to document it.

Problem:

Transfer (or upload/download) a large tree of files and directories from one machine to another using a ssh connection, and being able to resume/continue if the operation is interrupted.

Solution:

Until now, I believe that the best solution is using rsync over ssh, since rsync has a feature to resume interrupted file transfer, even when an entire tree of directories is involved.

About Trilead SSH open source project

Some time ago I have written an article about the JSch open source project. However, I soon lost all my motivation when I faced, again, the code complexity required for JSch just to start a execution session, a file copy or a port forwarding with JSch. Nevertheless the completely misunderstood authentication API for JSch let me to a mood even worse. I started looking for alternatives and fortunately I found Trilead SSH, a pure Java implementation of SSH, available with the BSD license.

PCMan: the real and true Gnome file manager

I have modified this post after several people complained that I was misunderstood: Nautilus can, sure, display a tree view of the file system. Sure, but only for “who-knows-how”.

I do not like Gnome desktop environment because of its excessively simplified GUI that leverages all users as if they lack minimal skill to interact with a computer. And what I dislike most on Gnome is even more oversimplified vision of the file system provided by Nautilus on its default configuration.

Fortified compiling prevents building older RPM

Today I had to build and test some older Open MPI RPM packages. However, I was prevented to build them, although the code apparently was correct.

The command:

rpmbuild -ba openmpi-1.2.1.spec

The error message was:

In function 'open',
    inlined from 'orte_abort' at runtime/orte_abort.c:91:
/usr/include/bits/fcntl2.h:51: error: call to '__open_missing_mode' declared with attribute error: open with O_CREAT in second argument needs 3 arguments

The line of source code that causes the error is:

A poem about Subversion

I found an interesting poem from Peter Kriens about SVN (subversion) that was posted to the Eclipse committer mailing list. Really interesting how frustration can encourage your imagination in others arts besides computer programming.

(I do not want to start a new discussion about pros vs. cons of SVN. Neither discuss who is right or who is wrong. I am sharing the poem just because it is curious.)

Hear! Hear! And I started drinking way too much coffee due to SVN because it gives me ample time … Last year I wrote my first poem ever (and likely last) during a checkout:

Oh, how I long for the days of CVS
When checkouts were a bless
Updates found to be a breeze
And a build went in a wheeze
Now we are old and wise
It is SVN that I despise
A simple checkout takes forever
And often it ends never
It is hungry for files and directories
About disk usage it has no worries
And with its split personality
Using it from the shell has a penalty
But alas, progress should not be blamed
Directories can now be renamed!- A sad SVN user

Ok, I won’t pursue a career in this area, but it illustrates my frustration …

Kind regards,

Peter Kriens

About JSch open source project

There are many, many open source, pure java implementation for the SSH/SFTP protocol. However, in my opinion, there are two of them that can be taken seriously. One of them is JSch, the other one is Trilead SSH. I will talk about my experience on the former one while implementing the RemoteTools framework for the Parallel Tools Platform for Eclipse.

JSch is one of the few (if not the only one) open source, pure Java implementation with the a complete implementation of the SSH specification, covering both SSH versions. It also covers less common ssh use cases, like High Performance Enabled SSH/SCP (although I have not yet seen a SSH server willing to easily support this). The JSch maintainers are very careful to adhere strictly to the ssh specification. They even refuse to implement workarounds for known issues for common ssh servers. They reply: “Ask your ssh server provider for a fix”. And I tend to agree with them.

Smaller font sizes for Eclipse on Linux

This article describes some approaches to launch Eclipse on Linux with smaller font sizes and customized graphical user interface (GUI).

The modern desktop environments like KDE or Gnome use larger font sizes to enhance readability of screen contents. However, Eclipse, looks better with a clean design and small fonts.

Views like Package Explorer or Outline may contain very large listings of important information. Eclipse uses are not willing to waste precious space neither with large fonts nor with fancy window decorations.