Converting OS X .plist to XML

The failure of my MacBook Pro seems that it didn’t cost much in terms on data loss, actually all the really crucial data were there. There are though some bits here and there that need to be moved over to my Linux box. One of the most important for everyday use the was the feed list for my RSS Aggregator. I was using the elegant, nice and simple NewsFire which uses binary plists (XML-like) for storing the feed list and I was never bothered exporting the feed list to OPML. The plist command in OS X can convert the .plist file into a .xml file, however I had no other Mac to do this operation or copy over the plist and export in OPML from there. Therefore I had to find a workaround for getting the plist working on RSSOwl or Liferea. Found the Perl plutil for Linux which converted the binary plist to standard XML. RSSOwl managed then to import the XML with all the blogs’ feeds as on NewsFire.

Regarding liferea, it wouldn’t import the XML file as it wasn’t proper OPML. But since RSSOwl imported the XMl file, I exported the feed list as OPML, which would be imported into Liferea or any other application.


HFS+ on Linux

My MacBook Pro seems to have died. Its hard disk holds lots of data that have not been backed up anywhere else. The important data have been mostly backed up but latest changes haven’t been backed up. Other than that, I had to check the hard disk for bad sectors etc and since I don’t have another Mac to test it on I had to do it on my Fedora box. My system (Fedora 15) would automatically detect and mount the HFS+ hard disk on read only mode. It was also missing the fsck tool for HFS+ partitions. Getting the fsck tool for HFS+ required downloading and installing hfsplus-tools via yum.However, fsck.hfs will not allow you, except if you use the –force option, to scan the partition if it has journalling on, which is the case with HFS+ partitions by default.

But how would I turn off journalling when I don’t have a Mac system to attach my disk on? After a couple of minutes I came across a post on the Ubuntu forum which linked to this blog. The author has a C code that turns journalling off. A fixed version of this code can be found here. The compiled code results in an executable which gets as its only argument the partition that you want to get journalling off.

# gcc journalling_off.c -o journalling_off
# ./journalling_off /dev/sdg2

Next step was to perform the fsck check on the target disk

# fsck.hfs /dev/sdg2
** /dev/sdg2
** Checking HFS Plus volume.
** Checking Extents Overflow file.
** Checking Catalog file.
** Checking multi-linked files.
** Checking Catalog hierarchy.
** Checking Extended Attributes file.
** Checking volume bitmap.
** Checking volume information.
** The volume OS X appears to be OK.

Disk looks OK. Next step is to mount it with read-write permissions:

# mount -t hfplus -o rw,user /dev/sdg2 /mnt/osx

Next issue encountered was the different UIDs between my account on the OS X system and that on the Linux system. Therefore, next step was to change the UIDs under the whole user directory on the OS X disk so I could access without problem with write permissions from my Linux box:

# find panoskrt/ -uid 501 -exec chown panoskrt {} \;

Speedup and efficiency shell calculator

The following script can be used to calculate the speedup and efficiency of a parallel code when compared to its serial version. Pretty much straight forward process. This script can be used either individually or as part of another script to automate the process of generating the required results. It accepts three arguments: 1) serial execution time 2) parallel execution time 3) number of processors.

./ <serial> <parallel> <procs>


# Copyright (C) 2011  Panagiotis Kritikakos <>           #
#                                                                          #
#    This program is free software: you can redistribute it and/or modify  #
#    it under the terms of the GNU General Public License as published by  #
#    the Free Software Foundation, either version 3 of the License, or     #
#    (at your option) any later version.                                   #
#                                                                          #
#    This program is distributed in the hope that it will be useful,       #
#    but WITHOUT ANY WARRANTY; without even the implied warranty of        #
#    GNU General Public License for more details.                          #
#                                                                          #
#    You should have received a copy of the GNU General Public License     #
#    along with this program.  If not, see <>. #


if [ "$#" -eq "3" ]; then
   speedup=`echo "${runtime1proc}/${runtimeNproc}" | bc -l`;
   efficiency=`echo "${speedup}/${totalprocs}" | bc -l`;

   printf "\n Total processors: ${totalprocs}\n\n";
   printf " Runtime for serial code: ${runtime1proc}\n Runtime for parallel code: \
   printf " Speedup: ${speedup}\n Efficiency: ${efficiency}\n\n";
   printf "\n Usage:   \n\n";
   printf " 0.350 0.494 2\n\n";

Running Fortran on ARM

Generally and very briefly, there is no official Fortran compiler available for the ARM architecture. The easiest way to get Fortran code (specifically Fortran 77) to run on the ARM architecture, or any other architecture that doesn’t have a Fortran compiler, is to convert the Fortran code to C. In order to do that efficiently, we can use Netlib’s f2c command line tool, available for Linux, Unix and Windows.

The steps that need to be followed are:

1) Compile the library – source at
Rename makefile.u to makefile and do make. Copy the generated libf2c.a to /usr/lib and the f2c.h header under /usr/include.
2) Compile the binary – source at
Rename makefile.u to makefile and do make. Copy the binary f2c under /usr/local/bin.

Supposing we have the foo.f file we can generate the C version by running f2c foo.f, giving us foo.c. It can now be compiled using ‘gcc foo.c -o foo -lf2c‘.

In order to automate this process a while, the following script can be used. It accepts only one argument, the Fortran source file.

fileName=`echo $1 | sed 's/\(.*\)\..*/\1/'`
echo $fileName
f2c $fortranFile
gcc ${fileName}.c -o $fileName -lf2c

UPDATE: There is GCC Fortran compiler for ARM Fedora and Debian and I presume for other distros as well. The issue now is that these distributions are compiled for ARMv5, while the latest ARM processors (Cortex-A8, A9, A15) are of the ARMv7 architecture. The compilers, and the OS in general is therefore unable to make use of the additional instructions sets and FPU. Other distros, such as Slackware, are compiled on even older architecture, ARMv4.

GPU programming in a glance

On my MacBook I have a nVIDIA GeForce 8600M GT which is CUDA enabled, something I never bothered checking until very recently. nVIDIA provides online the required driver, SDK and additional “CUDA Developer”, as they call it, resources with lots of sample files to test the hardware of your system as well as actual code, including some parallel samples.

The CUDA toolkit seem to provide all you need to start with:

  • C/C++ compiler
  • Visual Profiler
  • GPU-accelerated BLAS library
  • GPU-accelerated FFT library
  • GPU-accelerated Sparse Matrix library
  • GPU-accelerated RNG library
  • Additional tools and documentation

It does also include OpenCL samples to play about. However, the OpenCL driver will need to be installed at first place. There’s a pre-release version and in order to download it you’d need to register yourself with nVIDIA. They have also published a book, “CUDA by example”, which is not for free apart from some fragments. Nevertheless, the sample codes of the book are free to download.

AMD / ATI have also their answer to CUDA, “ATI Stream“. From what I got it seems to support only OpenCL. I don’t have a Stream-supported ATI card at the moment so I couldn’t try that one.

To close this, there’s an interesting presentation that covers basics of GPUs and how to program them (CUDA based): Programming and optimization of applications for multiple GPU

Restarting VMware Fusion functionality

I just tried to boot my FreeBSD-7.2 VM on VMware Fusion and got an error message that it will not have any network availability as “network bridge on device /dev/vmnet0 is not running“. I checked and indeed, there was no vmnet* interface up. A look in /Library/Application Support/VMware Fusion reveals the file, which happens to be the only available script.

$ ls -lrt
total 16944
drwxr-xr-x   3 root  wheel      102 12 Jul  2007 licenses
drwxr-xr-x   6 root  wheel      204 12 Jul  2007 kexts
-rw-r--r--   1 root  wheel      373 30 Oct  2007
drwxr-xr-x   3 root  wheel      102  2 Nov  2007 vmx
-rwxr-xr-x   1 root  wheel  3590412 19 Apr  2008 vmware-vdiskmanager
-rwsr-xr-x   1 root  wheel   366264 19 Apr  2008 vmware-authd
-rwsr-xr-x   1 root  wheel  3194884 19 Apr  2008 vmware-rawdiskCreator
-rwxr-xr-x   1 root  wheel   200968 19 Apr  2008 vmware-ntfs
-rwxr-xr-x   1 root  wheel   152533 19 Apr  2008
-rwxr-xr-x   1 root  wheel    74916 19 Apr  2008 vmnet-sniffer
-rwxr-xr-x   1 root  wheel    61428 19 Apr  2008 vmnet-netifup
-rwxr-xr-x   1 root  wheel   501632 19 Apr  2008 vmnet-natd
-r--r--r--   1 root  wheel     1241 19 Apr  2008 vmnet-nat.conf
-r--r--r--   1 root  wheel      742 19 Apr  2008 vmnet-dhcpd.conf
-rwxr-xr-x   1 root  wheel   333464 19 Apr  2008 vmnet-dhcpd
-rwxr-xr-x   1 root  wheel   120612 19 Apr  2008 vmnet-bridge
-rwxr-xr-x   1 root  wheel     7932 19 Apr  2008 vm-support.tool
-rwxr-xr-x   1 root  wheel    17186 19 Apr  2008
drwxr-xr-x   7 root  wheel      238 15 May  2008 tools-upgraders
drwxr-xr-x   6 root  wheel      204 15 May  2008 messages
drwxr-xr-x  13 root  wheel      442 15 May  2008 isoimages
drwxr-xr-x  17 root  wheel      578 15 May  2008 vnckeymap
drwxr-xr-x   5 root  wheel      170 15 May  2008 vmnet8
drwxr-xr-x   3 root  wheel      102 15 May  2008 vmnet1
-rw-r--r--   1 root  wheel     5612 15 May  2008 locations
-rw-r--r--   1 root  wheel       81 15 May  2008 config
drwxr-xr-x   3 root  wheel      102 15 May  2008 Uninstall VMware

Its execution pretty simply:

$ ./
Usage: ./ {--start|--stop|--restart}
$ sudo --start
VMware Fusion 87978: Starting VMware Fusion:
kextload: extension /Library/Application Support/VMware Fusion/kexts/vmmon.kext is already loaded
kextload: /Library/Application Support/VMware Fusion/kexts/vmci.kext loaded successfully
kextload: /Library/Application Support/VMware Fusion/kexts/vmioplug.kext loaded successfully
kextload: extension /Library/Application Support/VMware Fusion/kexts/vmnet.kext is already loaded
Internet Software Consortium DHCP Server 2.0
Copyright 1995, 1996, 1997, 1998, 1999 The Internet Software Consortium.
All rights reserved.

Please contribute if you find this software useful.
For info, please visit

Configured subnet:
Setting vmnet-dhcp IP address:
Opened: ??
Recving on     VNet/vmnet8/
Sending on     VNet/vmnet8/
Internet Software Consortium DHCP Server 2.0
Copyright 1995, 1996, 1997, 1998, 1999 The Internet Software Consortium.
All rights reserved.

Please contribute if you find this software useful.
For info, please visit

Configured subnet:
Setting vmnet-dhcp IP address:
Opened: ??
Recving on     VNet/vmnet1/
Sending on     VNet/vmnet1/

Once finished, the VM could start again without complains and gets its IP via LAN’s DHCP.

Counting words in TeX/LaTeX

I was trying to find an easy way to count the words in LaTeX documents. I guess there must be clients that do this for you, but I don’t use such a client and many times I’m using vi to edit LaTeX documents.

An way to go with it is to use a filter to strip as much as possible the TeX/LaTeX commands from the .tex file. This can be easily done with the detex command and the wc command:

detex report.tex | wc -w

Another way to filter the .tex document is to use untex in the same way as detex. This link describes lists also an alternative way of counting the words by converting the .dvi file to a plain text file:

dvips -o - report.dvi | ps2ascii | wc -w

However, this way doesn’t seem to filter the .dvi file that good so you may count more commands as words.

Package managers for OS X

Installing common *nix applications from source on OS X can be a real pain in the neck. It may even defeat Slackware in some occasions :p Tools provided by Macports and Fink make life much easier and productive. On the following example, Fink is used to install gnuplot by using the Debian-like apt-get:

panoskrt$ uname -rs
Darwin 9.6.0
panoskrt$ sudo apt-get install gnuplot
Reading Package Lists... Done
Building Dependency Tree... Done
The following extra packages will be installed:
  aquaterm aquaterm-shlibs gd2-shlibs libjpeg-bin pdflib-shlibs readline-shlibs texinfo
The following NEW packages will be installed:
  aquaterm aquaterm-shlibs gd2-shlibs gnuplot libjpeg-bin pdflib-shlibs readline-shlibs texinfo
0 packages upgraded, 8 newly installed, 0 to remove and 0  not upgraded.
Need to get 5461kB of archives. After unpacking 13.6MB will be used.
Do you want to continue? [Y/n] y
Get:1 10.5/release/main aquaterm-shlibs 1.0.0-1003 [31.6kB]
Get:2 10.5/release/main aquaterm 1.0.0-1003 [88.2kB]
Get:3 10.5/release/main libjpeg-bin 6b-17 [130kB]
Get:4 10.5/release/main gd2-shlibs 2.0.33-3 [130kB]
Get:5 10.5/release/main texinfo 4.8-1002 [1013kB]
Get:6 10.5/release/main readline-shlibs 4.3-1028 [108kB]
Get:7 10.5/release/main pdflib-shlibs 5.0.1-2 [1827kB]
Get:8 10.5/release/main gnuplot 4.0.0-1005 [2133kB]
Fetched 5461kB in 43s (126kB/s)
Selecting previously deselected package aquaterm-shlibs.
(Reading database ... 5617 files and directories currently installed.)
Unpacking aquaterm-shlibs (from .../aquaterm-shlibs_1.0.0-1003_darwin-i386.deb) ...
Selecting previously deselected package aquaterm.
Unpacking aquaterm (from .../aquaterm_1.0.0-1003_darwin-i386.deb) ...
Selecting previously deselected package libjpeg-bin.
Unpacking libjpeg-bin (from .../libjpeg-bin_6b-17_darwin-i386.deb) ...
Selecting previously deselected package gd2-shlibs.
Unpacking gd2-shlibs (from .../gd2-shlibs_2.0.33-3_darwin-i386.deb) ...
Selecting previously deselected package texinfo.
Unpacking texinfo (from .../texinfo_4.8-1002_darwin-i386.deb) ...
Selecting previously deselected package readline-shlibs.
Unpacking readline-shlibs (from .../readline-shlibs_4.3-1028_darwin-i386.deb) ...
Selecting previously deselected package pdflib-shlibs.
Unpacking pdflib-shlibs (from .../pdflib-shlibs_5.0.1-2_darwin-i386.deb) ...
Selecting previously deselected package gnuplot.
Unpacking gnuplot (from .../gnuplot_4.0.0-1005_darwin-i386.deb) ...
Setting up aquaterm-shlibs (1.0.0-1003) ...
Setting up aquaterm (1.0.0-1003) ...
Setting up libjpeg-bin (6b-17) ...

Setting up gd2-shlibs (2.0.33-3) ...
Setting up texinfo (4.8-1002) ...
* Texinfo: (texinfo).           The GNU documentation format.
install-info(/sw/share/info/texinfo): creating new section `Texinfo documentation system'
* info standalone: (info-stnd).            Read Info documents without Emacs.
* Info: (info). How to use the documentation browsing system.

Setting up readline-shlibs (4.3-1028) ...
Setting up pdflib-shlibs (5.0.1-2) ...
Setting up gnuplot (4.0.0-1005) ...
* GNUPLOT: (gnuplot). An Interactive Plotting Program
install-info(/sw/share/info/ creating new section `Math'

panoskrt$ which gnuplot;