August 16th, 2012 | Tags: , ,

The Nokia N900 is getting a little old now, but it still an amazing piece of kit. This post has a few pointers for making the most out of command line usage it enables.

  • Command Line Execution Widget: This widget lets you run commands from the desktop and outputs the results..
  • Cmd Shortcuts: Allows you to quickly run your own defined commands.
  • gPodder: This excellent podcast catcher comes with a command line interface. Run gpo from the terminal to get the full list of options.
  • FeedingIt: This RSS aggregator can be run from the command line. The known options are /usr/bin/FeedingIt update and /usr/bin/FeedingIt status.
  • Alarmed: This is a graphical interface to the cron scheduler. Apart from neat access to phone functionality (e.g. switching profiles, networking, and yes alarms) it also allows arbitrary shell commands to be scheduled. This is particularly useful with the gPodder and FeedingIt mentioned above. To use this tool you currently need to enable the testing repository.
August 11th, 2012 | Tags: , , ,

Most digital cameras store Exif data in the JPEG photo files. This includes things like date and time, camera model and camera settings and in some cases even GPS coordinates. jhead is a very useful command line utility which can read and edit the Exif data. For example, you may wish to remove the data from photos published online.

Another useful thing is to rename photos using the date and time information stored in Exif (note: read the documentation before running):

And best of all jhead is in the Ubuntu universe repository, so installing it is as simple as:

April 20th, 2012 | Tags:

If you are evaluating reporting or analytics tools, or just like to mess about with them, it’s always good to get your hands on some “real world” data sets. It sure beats using the Steel Wheels, Classic Models, eFashion etc. sample databases typically shipped with the products.

For a truly comprehensive list of free data sets, check out this page on Quora. Below are some of my favourites:

The following sites are also worth following on a more ongoing basis:

February 4th, 2012 | Tags: ,

Steps to install Oracle Express Edition (XE) database 10g on Ubuntu 11.10 (Oneiric).

  1. Download the Oracle XE deb package (free registration is required).
  2. Double click the downloaded file and select to install it.
  3. In terminal run sudo /etc/init.d/oracle-xe configure.
  4. You will be prompted to enter the following parameters: HTTP port number, database listener port number, SYSTEM and SYS database accounts password and whether the service should be started upon boot.
  5. Thereafter the configuration might take a few minutes. That’s it. To start the service in the future run sudo /etc/init.d/oracle-xe start and to stop sudo /etc/init.d/oracle-xe stop.
October 17th, 2011 | Tags: ,

GNU/Linux includes many utilities for working with text files through the shell. In this post we take a quick look at accessing and manipulating text files in a “column-wise” mode.

Suppose you have the following two files, each with two columns separated by the TAB character.

$cat file1
Alice   Paris
Bob     Tokyo
Mary    London
John    New York

$cat file2
13 May    Orange
19 Oct    Blue
11 Nov    Black
29 Feb    Red

The data in the two files are in fact related, i.e. file2 contains the date of birth and favourite colour of the people mentioned in file1 (assuming also that the files are sorted correctly). It would make sense to combine the two files together so that each row has the full data for each person. The paste command does just that.

$paste file1 file2 > file3
$cat file3
Alice   Paris     13 May    Orange
Bob     Tokyo     19 Oct    Blue
Mary    London    11 Nov    Black
John    New York  29 Feb    Red

Suppose that we are only interested in the name and date of birth of each person, and we can discard the hometown and favourite colour information. The cut command is what we shall use:

$cut file3 -f 1,3 > file4
$cat file4
Alice   13 May
Bob     19 Oct
Mary    11 Nov
John    29 Feb

Our next and final requirement is to reorder the columns differently. Instead of having the name followed by date of birth, suppose we want to have the columns the other way round. Unfortunately cat -f 3,1 produces exactly the same output as cut -f 1,3, so the cut command will not be sufficient. We have to use sed instead.

$sed -e 's/([^t]*)t([^t]*)/2t1/' file4 > file5
$cat file5
13 May    Alice
19 Oct    Bob
11 Nov    Mary
29 Feb    John

How does that work? Well ([^t]*) is a “named expression” which matches all characters except TAB. The search pattern looks for two of them, separated by TAB (t). In the replace-with part, they are referred to as 2 and 1, again separated by t.

Of course if file5 was what we ultimately wanted from the beginning as our output, we could have simply piped commands together:

$paste file1 file2 | cut -f 1,3 | sed -e 's/([^t]*)t([^t]*)/2t1/' > file5

or alternatively

$paste file1 file2 | sed -e 's/([^t]*)t([^t]*)t([^t]*)t([^t]*)/3t1/' > file5

October 17th, 2011 | Tags: ,

Sed can be used to strip out all HTML or XML tags from a file and get the plain text version. Suppose you have file gnulinux.html with the following contents:


<p>The combination of <a href=“/gnu/linux-and-gnu.html“>GNU and Linux</a> is the <strong>GNU/Linux operating system</strong>, now used by millions and sometimes incorrectly called simply “Linux“.</p>

Tempting but incorrect – sed finds the longest possible match which in this case is the entire file, and thus will output nothing:

$sed -e 's/<.*>//g' gnulinux.html
 

Correct version:

$sed -e 's/<[^>]*>//g' gnulinux.html
The combination of GNU and Linux is the GNU/Linux operating system, now used by millions and sometimes incorrectly called simply “Linux“.

August 16th, 2011 | Tags: , , ,

If you use TrueCrypt under Ubuntu 11.04 Natty you would have noticed an annoying behaviour. Under previous versions an icon is present in the system tray which remains there whilst a volume is mounted even if the TrueCrypt window is closed. Under Unity the tray icon is not shown. If you accidentally close the window (instead of minimizing it), there’s no easy way of getting back to it. Launching TrueCrypt again results in a error message.

The fix as suggested on shocm.com is to set the systray-whitelist property by running the following through command line (you will need to restart afterwards):

gsettings set com.canonical.Unity.Panel systray-whitelist "['all']"

However, your mileage may vary, and on my netbook this did not fix the issue. It seemed like the icon was placed in the tray, but it was rendered as a very thin strip about 1-2 pixels wide which could not be clicked.

The only way I found of getting out of missing window scenario was to resort to using TrueCrypt through the command line to dismount all mounted volumes.

truecrypt /d

This will also exist TrueCrypt and afterwards it can be launched as usual.

August 11th, 2011 | Tags: , ,

Sometimes it may be useful to know inside the report which servlet mapping is used to run the report (e.g. frameset, run, preview).


var sMapping = reportContext.getHttpServletRequest.getRequestURI();
var nPos = sMapping.lastIndexOf( "/" ) + 1;
this.text = sMapping.substring( nPos );

You can place the above code inside a label to see the servlet mapping.

June 28th, 2011 | Tags:

BIRT 3.7, previously codenamed Indigo, was released on June 22. Here are the necessary links to find out more about this latest version:

June 9th, 2011 | Tags: , ,

In an earlier post we discussed a generic way to dynamically get the list of report parameters at run time without having to hardcode the parameter names in the script. As was correctly pointed out in the comments, the code did not work for parameter groups (and also cascading parameters). However, it is possible to modify the code to get it working even for those cases, and the change is not a huge one.

The main difference is we will use the method getAllParameters() instead of getParameters() of ReportDesignHandle. It seems that getParameters returns only the “top level” parameters, whereas getAllParameters flattens the groups and the nested as well as top level parameters. One thing to watch out for is that the return types of the two functions are different: java.util.List (getAllParameters) vs. org.eclipse.birt.report.model.api.SlotHandle (getParameters). Also, we have included a check for the class of the parameter entry in the list, in order to exclude the groups themselves. You can comment out the if statement in case you wish to see the group names as well.

Here is the updated working code:


var sOutput = "";
var parameterArray = reportContext.getDesignHandle().getAllParameters();
var parameterCount = parameterArray.size();
for( var i = 0; i < parameterCount; i++ )
{
  var sParClass = parameterArray.get( i ).getClass().toString();
  if( sParClass == "class org.eclipse.birt.report.model.api.ScalarParameterHandle" )
  {
    var sParName = parameterArray.get( i ).getFullName();
    var sParVal = reportContext.getParameterValue( sParName );
    sOutput = sOutput + sParName + " = " + sParVal + "n";
  }
}
this.content = sOutput;