Saturday, December 16, 2006

VNC server on Mac classic (8.6)

Similarly, like in the former post I would like to work from my Mac X Tiger, Linux, Solaris, Windows or any other system that I use at work, on my old Mac OS 8.6.
I decided to try to install VNC server on Mac classic and try how it goes.

I installed chromivnc server 3.40a5. The only thing after the installation, or rather I should say unpacking, was to copy vncPatches file to Systems Folder/Extensions and restart my mac. Afterwards, I started vnc server without any problems, and that was it. My vnc server on Mac 8.6 was working.

Nevertheless, I have to admit, that it is considerably slower with comparisons to more newer version of vnc for Mac X, or Linux. However, it is enough for fast, small work on Mac OS 8.6.

Below image showing Kubuntu with VNC connection to Mac X Tiger and Mac OS 8.6

Friday, December 15, 2006

VNC client on Mac classic (8.6)

Sometimes in my work I had to use Mac OS 8.6. Problem with this is, that this is very old operating system, and there are not new application on it. Most importantly the problem is with web browser. There are only Internet Explorer 5.0, Mozilla 1.3, and few other very, very old ones; thus, when I work on Mac 8.6 and want to use the Internet there is problem, because many web-pages don't work on such old browsers (e.g. google spreadshead). Of course, other programs like Matlab or GIMP are unavailable on Mac classic. This was of course very annoying me, because when I was using 8.6 I could not do other my work, because of lack of software.
Finally, recently I found solution. It is simply installing VNC server on my Mac X 10.4 and installing VNC client on Mac 8.6 and using this client to work on Tiger, while being on Classic.
Nonetheless, finding and starting VNC client on Mac Classic was not so simple. After some searching and reading I found what I was looking for, and I would like to shear with it. Hopefully it will be useful for someone :-)

VNC client on Mac Classic is VNCThing 2.2 to download e.g. from here.

Morever, to run this client it is necessary to have
CarbonLib 1.6 from here.

After installation of those programs I could enjoy my Mac X 10.4 from Mac 8.6.

Below to screen showing Mac 8.6 with VNC client connected to Mac X Tiger.

Tuesday, December 05, 2006

Ruby: Using DarwinPorts' Ruby instead of Mac X's

If you are familiar with Mac X, probably you heard about DarwinPorts ("The DarwinPorts Project's main goal is to provide an easy way to install various open-source software products"). If you are interested in Ruby, you probably know that Mac X Tiger comes with pre-installed Ruby 1.8.2. Nevertheless, using DrawinPorts you can install more newer version of Ruby (1.8.4) just by writing: sudo port install ruby .

Unfortunately after the installation you will have two Ruby's in your systems, and your xterm console by default will use the first one. In order to use second one, the PATH environmental variable must be slightly change i.e. putting directory /opt/local/bin (DarwinPorts default directory) before every other directory in PATH. As a results programs in /opt/local/bin will have priority over the other programs.

To change the path you can execute just:
export PATH=/opt/local/bin:$PATH

Sunday, November 26, 2006

Ruby: one liners

Sometimes it is necessary to do some simple things, like replacing some words in given file, processing output of the Unix command. To such operation, usually writing a Ruby script is just unnecessary, due to possibility of creating one line so-called one liners programs, short script as Ruby command-line option: -e 'command' and -n , where:
  • -e 'command' - Executes command as one line of Ruby source. Several e’s are allowed, and the commands are treated as multiple lines in the same program. If programfile is omitted when e is present, execution stops after the e commands have been run. Programs 1.8 run using e have access to the old behavior of ranges and regular expressions in conditions—ranges of integers compare against the current input line number, and regular expressions match against $_.
  • -n - Assumes a while gets; ...; end loop around your program.

For example simple grep program can be implemented in Ruby as:

ruby -n- e "print if /blabla/" *.txt

Or, for instance, if one wants to save a list of all *.tif, *.TIF, *.tiff, *.TIFF files in given directory in lowercase:

ls -l | ruby -n -e ' puts split[8].downcase if $_.to_s.upcase =~/TIFF?/' > list.txt

Of course, those examples can be done without the need of Ruby, just by using standard Unix command, but sometimes it is easer to use e.g. Ruby (the same thing can be done using Perl, Python, awk,...) than to look for syntax of a given command. If one is familiar with e.g. Ruby, few separate Unix commands can be done in one Ruby command-line program.

Many other handy examples of ruby one liners can be found here.

Tuesday, November 07, 2006

Firefox 2.0: Session Restore

After more then a week of using Firefox 2.0 on my Intel Mac X 10.4 I can say it is nice, especially spell checking. Nonetheless, it is not super due to crashes.

For example, one of many websites that crashes Firefox 2.0 is . I do not know why, but I know that when it happens I have to use Safari to look for those 'bed' sites. Of course I do not say it is in general and true for every user of Firefox 2.0, I assume that it is only my Mac that has problem with this one website.

Despite this problem with some pages, it could be worse. The fact that it is not so totally bed, is new option in second edition of Firefox called Session Restore. From Firefox web side:

Now, with Session Restore, if Firefox has to restart or closes when it comes back you’ll pick up exactly where you left off. The windows and tabs you were using, the text you typed into forms, and the in-progress downloads you had running will all be restored. You can even set Firefox 2 to always restore your previous session instead of loading a home page, so you’ll never lose your place again.

And this is nice. Even thought my Firefox crashes, I do not loose all tabs and most importantly I do not have to go to pages again which sometimes may be difficult if you have many tabs open. I have them automatically restored.

Sunday, November 05, 2006

Matlab: Lack of multithread

In my everyday work I use Sun-Fire-V440 server. The main characteristics of this machine is the fact that it contains four processors, which is great. I use it mainly
to write image processing algorithms in Matlab 7.0, which are usually very time consuming and require wast amount of resources.

Despite the power of this machine, I cannot use it fully due to Matlab. This is because by definition it is only singe threaded application and there is on way of creating few threads. This of course causes that even thought given algorithm or application could be divided to e.g. four parallel threads, it cannot be done due to Matlab.

This drawback of Matlab is really frustrating, because Matlab uses fully only one processor out of four. On the other words, while one processors is fully loaded, three others do not do anything useful. As a result of that, my computations take four times more time to finish, compared with the situation if I could use all four processors in Matlab.

For instance, sometimes I write something in ANSI C, and there is no problem of creating threads; hence, my algorithms in ANSI C are four time faster than the same single threat algorithms on this Sun server, because they use all four processors.

Nevertheless, using single thread Matlab on four-processors server has some advantage. The main advantage of this is that I can run four separate Matlab instances, which I do often. For example, if I have one thousand images to process, I can run four matlab in four consoles, and I can tell that the first instance processes images from 1 to 250, second one processes 251 to 500, third and forth one 501-750 and 751 to 1000 respectively.
Moreover, I can run four Matlabs processing 1000 images each, but with different parameters. Consequently I can check my program with four different parameters and check their impact on the results simultaneously, rather than execute one version of program by another. This also uses four processors and I can do my work four times faster than on single Matlab instance.

Thanks to this, even though my application is single threaded, I can process 1000 images four time faster using four Matlabs than using one Matlab. This way, 100% of computation power of my server is used, and all four processor are doing something useful.

Below I present screen from top command, showing four Matlabs using in summary almost 100% of CPU power of my Sun.

Thursday, November 02, 2006

Mac X: Virtual desktops

Yesterday by a chance I went to Apple website and I found a sneak peak of Mac X 10.5 (Leopard).
I have to admit that it looks impressive; nevertheless, as far as I am concerned the only thing that I really look forward to is Spaces, or just simply virtual desktops, which by the way is great news.

I think I do not have to explain what virtual desktops are. Everyone who has every used Gnome or KDE in Linux should know it. The only thing I can say is that they are very, very convenient because:

They increase a user's ability to organize their windowed applications that are currently running by reducing clutter. - wikipedia

Lack of virtual desktops systems (free ones of course) on Mac X 10.4 used to annoy me a lot, because I use considerable amount of windowed application everyday at my work. Consequently, few months ago I started to look for some freeware application that provides virtual desktops for Intel iMac with Mac OS X 10.4. Nevertheless, at the time the only free program that I found did not work on Tiger - after starting it, my Mac just freezed. Unfortunately I do not remember the name of that program, or even where did I take it from.

Recently, due to sneak peak of Leopard I decided to give it one more try and to look for some free virtual desktop manager working on Tiger. And for my big surprise I have found it. It is called just Desktop Manager and its official site is here. I downloaded DesktopManager-0.5.3.dmg and I installed it and it worked!!!.

Thanks to this little program now I use six virtual desktop which is great. Finally I can open as many window application and consoles as I want, and I can manage through them very easily.

Bellow some pictures of my Mac and transition between desktops. Sorry for the quality, but I had to use digital camera to take them, because normal screen shots do not work with this.

Wednesday, November 01, 2006

Mac X: Ogg files and iTunes

Today I received some audio files in Ogg Vorbis format. I use Mac X 10.4, so I was very, very surprise that iTunes does not support Ogg files. As a result of that I did a little of reaserch and I found Quicktime Components Project which supposable is audio codec that adds Ogg Vorbis to QuickTime and iTunes. Unfortunately it did not help, thus my iTunes still does not support Ogg. Fastly I checked Whamb player and it worked.

Nevertheless I did not wanted to use Whamb - I just dont not like it - hence, the only choice I had (and the fastest because at the very moment I did not have time to struggle with that) was to decode my *.ogg files to mp3 files. To to this I had to use oggdec program which gave me wave files, and than using lame encoder I converted those *.wav files to mp3. Of course prior to this, I had to install all necessary stuff like oggdec and lame.

I wander why Apple does not support ogg? I thought it was free open source format?

Gimp: Changing language back to english

I do not know why, but one day my Gimp 2.2.10 on my Mac X changed its language from English to Japaneses. I do not know how it happened, but it happened.

As usually in such cases I did a little of web searching and I found some solutions. First proposed solution was to set LANG environment variable to 'en'. Of course I tried it, and of course it did not work.

Second solution that fortunately worked was to delete folder containing Japanese language in Gimp's directory. Hence, I deleted folder ja from:


After restarting Gimp I had it finally in English.

In conclusion, as far as my case is considered the solution to Gimp language problems is to delete given lang folder from directory.

Sunday, October 29, 2006

Measure program execution time

To measure execution time of any program under UNIX (Linux, Mac X, Solaris) one can use time command. For example

>time ls

>real 0m0.006s
>user 0m0.001s
>sys 0m0.004s

Command time ls measures time used by ls program.

Saturday, October 28, 2006

Matlab: Working with text data files using Perl (2)

This post is continuation of the former post concerning Matlab and Perl work with text files.
Former program, reading rectangles.txt file can be of course written in Matlab, without any Perl help. My example with rectangles.txt is quite simple as far as text file is concerned; nevertheless, I used Perl to read and search this file in order to show how Perl can be used within Matlab.

Below I present Matlab code, that does exactly the same task as Perl script presented in my former post.

function [rect_1 rect_2 point]= getRects(filename)



while true
tline = fgetl(fid);
if tline(1)=='#', continue;end;
if ~ischar(tline), break, end;

[file,theRest] = strtok(tline);
if ~strcmp(file,filename), continue; end;

RECTs= sscanf(theRest,'%f')';




The question now is which method (Matlab+Perl or Matlab only) is faster?

To check it I used tic;getRects('105aty.tiff'); toc; combination in Matlab both for full Matlab script and Matlab/Perl script. Each script was tested 100 times.

The results are:
Matlab only version : 0.18 (std=0.03) sec
Matlab+Perl version: 0.10 (std= 0.02) sec

It is clearly seen that connection Matlab+Perl to work with text data is considerably faster
that of Matlab only.

Test was made on:
Matlab 7.0.0 (R14) and Perl 5.6.1 running on Sun Fire V440 Server.
std - standard deviation

Friday, October 27, 2006

Matlab: Working with text data files using Perl (1)

Matlab is a great tool when you work with mathematic related software like image processing (assuming that you have appropriate toolboxes, like Image Processing Toolbox). It is very convenient high level programing language, in which you can do, I think, almost everything and many things that are almost impossible in other languages like (C, Java, Perl) are extremely easy here.

Nevertheless, there are few things that are easy and natural in those other languages, whereas in Matlab they become quite difficult. What really annoys me, and not only me, are: (i) lack of hash arrays, (ii) working with text files and (iii) lack of multi-thread work.

Factors (i) and (ii) are closely related. Everyone who has ever used Perl, Ruby or Python to work and mine text files knows that hashes are essential. Of course, they are useful to many other things, however based on my own experience, vast majority of operation of files were based on hash arrays usage. What is more, I have to say, that you can easily work with Matlab without hash tables, and I really did for a long time. But, when recently I needed to process (write/read/create/joining data from few files/extracting and looking for string and numeric data) text files in Matlab, lack of hash tables, and poor file handling operation in Matlab become very frustrating.

Fortunately there is Perl, which is excellent in dealing with text files. However, the most important thing about this, is the fact that Matlab has embedded support for using Perl scripts within Matlab programs using perl function:
Perl is included with MATLAB on Windows systems, and thus MATLAB users can run M-files containing the Perl function. On Unix systems, MATLAB just calls the Perl interpreter that's available with the OS - from Matlab help.
This function can save a lot of work, and make working with files in Matlab very fast, and convenient; in fact, as convenient as Perl is. At the same Matlab page we read:
It is sometimes beneficial to use Perl scripts instead of MATLAB code...
Indeed, it is very beneficial, especially if one works for example with text files and further in this post I am going to show one example how Perl can be used withing Matlab while working with txt files.

1. Data File

My test text file is called rectangles.txt. It contains file names (first column) and description of two rectangles and one point. Each rectangle is characterized by four values: [x y width height].
First rectangle is described in columns 2-6, second in 7-10. Two last colums (11,12) contain
position [x,y] of a point.

2. My task

Little script in Matlab (getRects('filename')), which takes file name, searches given file name in the file, and returns three vectors ( rect_1=[x y width height]; rect_2=[x y width height]; point=[x y]) based on info in the file, for instance:

[rect_1 rect_2 point] = getRects('001anv.tiff');
rect_1 = [113 302.5 49.035541 58.514286];
rect_2 = [274 292.5 90.87837491 89.96484776];
point = [5.220703 4.375];

3. Method

To do my task, I will create simple Perl script, that will take file name form Matlab, search for data, and returns required vectors to Matlab.

4. Matlab script

Lets start from creating our Matlab script.

function [rect_1 rect_2 point]= getRects(filename)

%execute Perl script
eval(a); %evaluate string returned from Perl

As can be seen the script is very easy. It just executes Perl program passing two arguments to it: (i) filename to be search in the file; (ii) 'rectangles.txt' - name of file to look from.

The interesting fact about this is the eval(a) operation. As described in my former post, Perl returns string representing its standard output. Hence, in order to get Matlab data structures and variables from Perl, it is required to return them as strings, and then execute that string using eval function.

5. Perl script

Finally, we come to the Perl script it self.


#Read arguments from Matlab
my $fileName = $ARGV[0];
my $fileWithRect = $ARGV[1];

#create piece of Matlab code - declaration
#of variables.
my $out="rect_1=[]; rect_2=[]; point=[];";

my %goldHash=&readFileToHash(

if ( exists $goldHash{$
fileName}) {

my @r1 = @{$goldHash{$key}}[0..3]; #(x,y,w,h)
my @r2 = @{$goldHash{$key}}[4..7]; #(x,y,w,h)
my @p = @{$goldHash{$key}}[-2..-1]; #(x, y)

#create the rest of the Matlab code to be executed by eval
foreach my $v (@gmROI) { $out .= "Med(end+1)= $v; "; }
foreach my $v (@glROI) { $out .= "Lat(end+1)= $v; "; }
foreach my $v (@scales) { $out .= "Scales(end+1)= $v; "; }


#print string to Matlab
print $out;

sub readFileToHash {
#read file values to a hash table
#key value in this hash is file name (first column)
#data is all the rest columns: 2-12
my $fname = shift;

my %temp=();

open(FG,"<$fname") || die "Cannot find file ",$fname; while () {
my ($k,my @rec) = split('\t',$_);
close FG;
return %temp;

6. Results

After executing Perl script, Matlab gets string to variable a. Example content of that string is:

rect_1=[];rect_2=[];point=[];rect_1(end+1)= 104.000000; rect_1(end+1)= 303.000000; rect_1(end+1)= 49.035541; rect_1(end+1)= 58.514286; rect_2(end+1)= 282.964459; rect_2(end+1)= 294.000000; rect_2(end+1)= 49.035541; rect_2(end+1)= 58.514286; point(end+1)= 5.220703; point(end+1)= 4.375000;

after executing evel(a), in Matlab environment all required vectors are created (rect_1,rect_2,point).

7. Conclusion

Thanks to Perl and possibility of using it within Matlab many task concering text files can be solve more easily and more convenient.

Tuesday, October 24, 2006

Firefox 2.0 out now

I have just download Intel iMac version of Firefox 2.0 :-)

After maybe two minutes of use, I have to say that one thing about this browser is especially useful for me, and I think for most of the Internet users. I am talking of course about build in Spell Checking which is just great. Now I'm writing this fast post, and Firefox is looking after my spelling. It is much more convenient than using ABS button. Additionally I checked if there are any others languages in spell checking than English, and of course there are plenty of them, including my home one - Polish.

The next two features that are very seen instantly is refreshed look, and improved Tabbed Browsing. Now, each tab has its own close button, which is, I think, better than before.

Next, very useful new thing about Firefox is so-called Search Suggestions. Starting typing in search bar, gives a list of suggestion from search engines. For example from Google or Answers.

Of course there are many more new features than those for example: Session Restore, Live Titles, Live Bookmarks, Streamlined Interface, Phishing Protection, Protection from Spyware ..... List of all is here.

Postfix: message_size_limit

I had problem with Postfix mail server on my Ubuntu 4.10. The problem was simply, that I could not send mails with attachments greater than few MBs. The solution was to add one line to /etc/postfix/ and restarting my mail server:

message_size_limit = 20240000

This increased my mail size to around 20MB.

Perl: Own module with my common functions

Lately, I also needed to create one file containg some of my functions that I use in many Perl programs. First my thought was to create some library or module, that I will include in my programs using just use key word.

I dicided to do my own package, and here I will present some more or less what I have fastly done to get what I wanted.

First I create module. The code goes in the file named within the directory Utilities: that is, Utilities/

  1. package Utilities::MyModule;
  2. use Exporter;
  3. @ISA = qw(Exporter);
  4. @EXPORT = qw(&myFun1 &amp;myFun2);

  5. sub myFun1 {
  6. print "Some action of myFun1";
  7. }
  8. sub myFun2 {
  9. print "Some action of myFun2";
  10. }
  11. 1;
Line 1 declares the package that the module will put its global variables and functions in.

Line 4 assigns the list (&myFun1 &myFun2) to the special, per-package array @EXPORT. When someone imports this module, variables and functions listed in that array are aliased into the caller's own package. That way they don't have to call the function Utilities::MyModule::myFun1() after the import. They can just write shuffle(23) instead. This won't happen if they load Utilities::MyModule with require Utilities::MyModule; only a use imports.

Lines 5 and 8 set up the package global functions to be exported.

Finally, line 11 is a simple 1, indicating the overall return value of the module. If the last evaluated expression in the module doesn't produce a true value, an exception will be raised.

After creating this module, you can import it simply by:
use Utilities::MyModule;

Matlab: java.lang.OutOfMemoryError

Matlab, as I wrote earlier, can use so called interfaces to work with other programming languages. One of them is Java SDK 1.4.2. Because of that, some time ago I was writing one Java application to work within Matlab. It was image processing application (java class) calculating fractal signatures. The problem with that application was that it used a lot of memory. And this was my problem. By defalut, Matlab, allows to use only 32MB of memory by java programs. When I exited that threshold I get error:

Java exception occurred:
java.lang.OutOfMemoryError: PermGen space

So I did a little of the Internet browsing and I found out that the solution to that problem was to create file java.opts in my working directory. In this file, one can put all options to java virtual machine. To increase my memory amount i had to put there:


Only with that option, my Matlab 7.0 and my java program worked. I also tried solution at official matlab site: here. But it didn't work. I had to use all four parameters in order to run my program.

Xemacs and mouse scroll on Mac X and Solaris

Lately I come across of a problem of how to make mouse scroll and two buttons available in XEmacs on Mac X 10.4. Many may know that on iMac there is one button mouse without scroll, but I was pretty annoyed by this fact so I changed Apples mouse to Microsoft's
mouse:-). Of course, it works perfectly, however there is problem with Xemcas which, by default, doesn't recognize actions associated with scroll and additional buttons. I found solution working on my Mac here.

The solution to my problems was to add to the end my Xemacs configuration file (Users/my_user_name/.xemacs/init.el) following lines:

(define-key global-map 'button4
'(lambda (&rest args)
(let ((curwin (selected-window)))
(select-window (car (mouse-pixel-position)))
(scroll-down 5)
(select-window curwin)
(define-key global-map [(shift button4)]
'(lambda (&rest args)
(let ((curwin (selected-window)))
(select-window (car (mouse-pixel-position)))
(scroll-down 1)
(select-window curwin)
(define-key global-map [(control button4)]
'(lambda (&rest args)
(let ((curwin (selected-window)))
(select-window (car (mouse-pixel-position)))
(select-window curwin)

(define-key global-map 'button5
'(lambda (&rest args)
(let ((curwin (selected-window)))
(select-window (car (mouse-pixel-position)))
(scroll-up 5)
(select-window curwin)
(define-key global-map [(shift button5)]
'(lambda (&rest args)
(let ((curwin (selected-window)))
(select-window (car (mouse-pixel-position)))
(scroll-up 1)
(select-window curwin)
(define-key global-map [(control button5)]
'(lambda (&rest args)
(let ((curwin (selected-window)))
(select-window (car (mouse-pixel-position)))
(select-window curwin)

This is what I was looking for, and what's the most important - it worked.

In addition to that, I did exactly the same thing to my XEmacs on my Solaris server (I use X11 to work remotely on Solaris from my Mac). It worked also.

Ruby, intersection of two arrays of objects

One, serious obstacle I have encounter working with Ruby, was how to perform intersection of two arrays of objects.

Ruby comes with overloaded operator &, using which intersection of two array is childish.

For example:

#!/usr/bin/env ruby

a=[1, 2, 3, 4]
b=[1, 2, 2 ,3 ,4, 5, 6]
c= a & b  #intersection of 'a' and 'b' arrays
print c

will produce: 1 2 3 4

And for example this: 

#!/usr/bin/env ruby

a=['aa', 'ac', 'acb', 'acbd']
b=[ 'ac', 'acb', 'bca', 'zwx']
c= a & b  #intersection of 'a' and 'b' arrays
puts c

will produce: ac acb  

Everything is OK, when you perform intersection of standard types, like String or Integers, etc.

However, there is problem when you create your own class, and try to perform intersection of  array of objects of your class.  

#!/usr/bin/env ruby

class MyClass #my own very simple class
   attr_reader :var1, :var2   
   def initialize(arg1,arg2)     
      @var1 = arg1
      @var2 = arg2
    def to_s
        "#{var1}: #{var2}"
a = ['house',3),'mouse',5)]
b = ['cat',3),'house',5),'mouse',5)]
c = a & b #INTERSECTION !!!
puts c

This, unfortunately gives nothing!

After a while I found solution to that. The solution is: you must overload eql? and hash functions in you class. Java programmers should now something, because as I remember in Java, you do something similar while working especially with Comparable interface.

So, to make intersection, final example my program looks like this:

#!/usr/bin/env ruby

class MyClass attr_reader :var1, :var2
    def initialize(arg1,arg2)
        @var1 = arg1
        @var2 = arg2
    def to_s
        "#{var1}: #{var2}"
    def eql? other #OVERLOADED eql? !!!
       other.kind_of?(self.class) && @var1 == other.var1
    def hash #OVERLOADED hash !!!
        @var1.hash #use var1 hash value,
                   #as hash for MyClass
a = ['house',3),'mouse',5)]
b = ['cat',3),'house',5),'mouse',5)]
c = a & b #INTERSECTION !!!
puts c

And this finaly produces what I wanted:

house: 3
mouse: 5

I used only standard hash value from @var1 in my class, because I was only interested in making intersection based on @var1, nevertheless there is noting against to make more complex hash and eql? function.  

NFS sever on Ubuntu 5.10

To setup nfs server on you Ubuntu, few steps are required.

  1. Install packages sudo apt-get install portmap nfs-common nfs-kernel-server
  2. Create, if not exists, file: /etc/exports where you indicate folders you want to share. For example I have in my exports (IP addresses have been change):
    The above means I want to export the /home/me/mynfs directory to computer with the options "read&write" &"sync"&amp;"all_squash".
  3. Start/restart you nfs server: /etc/init.d/nfs-kernel-server start
That should works. To check if you are really exporting something you can use:

showmount -e localhost

and if you see:

Export list for localhost:

it means it work. However, there can be little problem caused by firewall. I had to enable all connection to port 2041, to allow external users to connect to my share. To chack if you can mount this share from other computer, just run showmount -e IP_OF_NFS_server.

To run NFS server it is enought.

Later I will descripe how to mount nfs share and also I try to figure out all those nfs options, you can put to /etc/exports.

Monday, October 23, 2006

Finally my blog is live again

Hi everyone!!
Finally, after few months of absence my blog returns to the Web. Unfortunately, my former blog is down, due to server problem; hence, I decided not to wait longer and to sing up for google blog.

First thing, that I have to do, is to recreate my posts from my former blog. It should not take log. Afterwards, I will put some new content. Hope you will enjoy.

Friday, October 06, 2006

Mac X 10: How to make screenshots

Basically there are to ways of doing screen shots on Mac X:

1. Basic
2. Using Grab program

To capture entire screen you press Command-Shift-3 and the Picture 1.png image file is created on your desktop. You can also use Command-Shift-4 to select only part of your screen, and just like before Picture.png file will be created. On the other hand using Command-Shift-Control-4 instead of file, the screen is copied to the clipboard.

Using Grab program
This program is in Applications -> Utilities folder.

I personally prefer the Basic way of doing screen shots. For me it is more convenient. Moreover I prefer png files over tiff files, which are created by Grab.

Sunday, September 24, 2006

Perl: File handle as function argument

Recently I was writing one function in Perl. And I come across one little problem - I did not know how to pass and file handler to a function. Nothing big, but it gave me a little of googling to find the answer for this.
So, let me just give a solution to this problem, without any further explenation.

use strict;

open(FH,"> some_file.txt");
print FH "Write first line to the file";


sub writeToFile {
my $FH = shift;
print $FH "Write second line to the file";

Hence, one must remember that when we past a file handler to a function in Perl, we must do it using '*', no other way that I know of works.

Ruby, is it worth my interest?

Recently, I read about new scripting language from Japan - Ruby. I already know quite good Perl, so I decided to read a little more about this, because what I had read, expressed very good opinion about this new language.

Ruby, as its homepage says, is: "the interpreted scripting language for quick and easy object-oriented programming. It has many features to process text files and to do system management tasks (as in Perl). It is simple, straight-forward, extensible, and portable ... and free of charge".

On the grounds of above, I decided to give it a try.


I was surprised to find out that my Mac X Tiger has embedded Ruby interpreter. So users using newest Mac's don't have problems with installation. Despite this, i decided to install it on my Ubuntu Breeze, by running sudo apt-get install ruby. As a result, Ruby was installed on my Linux.

My first script

To get an idea about this programming language, I decided to write a little program, that reads two text files containing mainly numerical data, organized into tables (tabulator as separator between columns). Below is an example of file's content:

As can be seen from the table above, it is typical text file with data. I used two such files, but with different numerical data. I wanted to write some script that takes those to files, performs some mathematical operation on numerical data, and gives summary of calculation.

In this moment I'm not going to describe or explain further details attributed to this script, or give any example code. Just want to share my opinion about my first impression of Ruby.

First steps

I must say, that starting to learn Ruby, was quit easy. This is mainly because of book-like tutorials available at Ruby's homepage. I hadn't have any major difficulties in writing my script. However, there was one thing which caused a little of confusion at the start - iterators like in line (2):

myarray = [1,2,3,4] # (1) create array of name
myarray.each { |i| puts i} # (2) for each element in myarray do 'puts i'-print i

But, after a while, you can get used to them, and what's more important, see how useful they are.

There are many more other inventions in Ruby, which I will be describing as time goes.


In conclusion, I must say my program was written relatively fast. I didn't have any bigger problems with it. However, there was huge problem with making intersection of two arrays of objects, but my own solution to this obstacle, I will describe later. Despite this I must definitively say that I will continue to use Ruby, because it is very clean and easy language.

Mysql, mysqld.sock missing

Lately I find my self in trouble with running mysqld 4 on Ubuntu 5.10. The problem was with missing mysqld.sock. While starting mysql I saw:

/usr/bin/mysqladmin: connect to server at 'localhost' failed error: Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock (2)' Check that mysql is running and that the socket: //var/run/mysqld/mysqld.sock' exists !

Normally mysqld.sock is created by running mysqld command. Unfortunately, this command gave:

/usr/sbin/mysqld: Cant't open file: 'host:MYI'. (errno: 142) Fatal error: Can't open privilege tables: File = '/usr/share/mysql/charsets/?.conf' not found (Errcode: 2)

First I tried mysqld --default-character-set=latin1 but it did not help. So I finaly executed

myisamchk -dvv host.MYI

and I saw

myisamchk: Character set '#'83' is not a compiled character set and is not specified in the '/usr/share/mysql/charsets/Index' file myisamchk: error: 142 when opening MyISAM-table 'host.MYI'

The solution was to add to file /usr/share/mysql/charsets/Index only one line:

cp1251 83

Sunday, September 10, 2006

Perl: Creating empty arrays and hashes

Using arrays and hashes in Perl is essential. Nevertheless Perl way of handling those data types is more difficult; by comparison with, for example Ruby or Python. Now I am not going to focus on all aspects of arrays and hashes in Perl, because this topic is just to big for one post. Today, I will describe funny problem that my co-worker had, or rather his little bug in his program.

The problem was with deleting or emptying and array or hash.
For example, let assume that we have one array @a, and one hash %h:

my @a = ( 2, 3, 4);
my %h = ('me'=>2, 'you'=>3, 'he',=>'4');

print 'Size of @a: ', scalar @a; #gives 3
print 'Size of %h: ', scalar keys %h; #gives 3

Now, we want to delete its content. What my friend did, was:

@a=[]; #WRONG: should be @a=();
%h={}; #WRONG: should be %h=();

print 'Size of @a: ', scalar @a; #gives 1 !!!
print 'Size of %h: ', scalar keys %h; #gives 1 !!!

This little mistake cost him a lot of hours of looking for bug in his code. What he did, he created anonymous empty array [] and anonymous empty hash {} and assign them as first element in $a[0] and as first key in %b.

Hence, the correct code to empty an array or a hash is:


print 'Size of @a: ', scalar @a; #gives 0 !!!
print 'Size of %h: ', scalar keys %h; #gives 0 !!!

Thursday, August 24, 2006

Matlab and Perl: returning matrixes and cells from Perl to Matlab

Matlab, as one of the most preferable hight level languages among the scientist all over the world, provides interfaces to other programming languages. Normally you can attach to Matlab scripts programs written in: ANSI C, Java SDK , Fortran. This process is called external interfaces and information about it can be found here.

In addition to those languages, there is also possibility to use Perl programs within Matlab scripts. This can attributed to the fact, that Matlab, by default, has embedded Perl interpreter (in fact, it's tripped-down version of the interpreter). Therefor, you can use Perl scripts without any problems.

However, in contrast to ANSI C, Java SDK , Fortran interfaces, Matlab doesn't have any build in routines, to pass and return matrices, cells, vectors to and from Perl. The only thing returned to Matlab is string, which represents stdout of Perl script, meaning, that Matlab receives everything what is returned by print functions in Perl. Everything which normally is printed on stdout, is assigned to one string variable in Matlab. For instance if is simple perl script print to console something, then executing this in Matlab console:

A = perl('', var1,' var2', var3);

assigns to variable A, all output of

Based on that, my own solution to get matrices, cells, vectors, etc. returned from Perl, is to return string, representing Matlab's code, and executing function eval(A) in Matlab. For example
#Example file, with Perl scribt to be executed by Patlab

$out = "myVector = [2 3 4 5 5 6]; "
#variable with string representing Matlab vector

print $out; #print $out to Matlab

Executing above script in Matlab and evaluating returned string will create myVector variable in Matlab:

A = perl('', var1,' var2', var3);

myVector =

2 3 4 5 5 6

Installation of Kubuntu 6.06

Few days ago I was helpping one friend with installation of Kubuntu 6.06 on a PC. I have to admin that personally I would prefer ubuntu, rather then Kubuntu, but he is a fan of KDE environment, so we downloaded it.

I haven't seen Ubuntu yet, so Kubuntu is my first insight into Dapper Drake (DD) family, which has drawn a lot of public attention lately, as being first distribution from Canonical with three and five year support, for desktop and server usage respectively. Since the release, I have read plenty of reviews and opinions about both Ubuntu and Kubuntu. Majority of them was positive about them, and many authors have stayed that (K)Ubuntu is definitively going in the right direction. Due to the fact there is huge amount of available reviews I'm not intending to write one more. Instead, I just want to describe my own experience and feeling about Kubuntu.

To begin with, I need to write that everything went smoothly, and there was not any single problem with installation, even though this PC was more then seven years old.

First positive aspect of Dapper Drake that I noticed is, that the CD you download, both Live and installation CD. Owning to this I could first check if Kubuntu would be working on my PC. I other world's, I could check if Internet connection, printer, etc. was OK. Afterward, knowing that my hardware worked, I started the installation.

Process of installation went smoothly, within surprisingly short time.

After that, I needed to install some additional stuff to my new operating system, so my first thought was to start Synaptic. And I was quite surprised, to find out that there was no Synaptic (graphical package management program for apt). So, no problem, I just run: sudo apt-get install synaptic and there was another surprise - nothing happened. So still, no problem, I open /etc/apt/sources.list and i had to manually unhashed few repositories. Finally, following all those operation I maneged to install what I wanted. Nevertheless, I had and still have mixed feelings about this.

As most of the users I (my friend) wanted to have mp3 support, video codecs, and other popular things, which desktop user must have, and they are not included in (K)Ubuntu by default, on account of licents difficulties. Because of that, I used easyubuntu. This is Python "script that gives the Ubuntu user the most commonly requested apps, codecs, and tweaks that are not found in the base distribution". It worked perfectly, in few minutes I had everything I wanted, and everything was working (audio/video).

Next, I needed to setup printer. I use netwerk HP printer. And there was no surprise, niether. It just worked, after finding it on the list of all printers in configuration panel.

The last stage, was to install VMware server. Unfortunately, this must be done manually, because there are no apt packages. So, I registered (to download vmware you must to register in order to receive free serial number) and I began the installation. There was another nice surprise, everything went perfectly. All process of vmware setup, consists of accepting default parameters :-). That was it:-)

So in conclusion, I strongly feel that Dapper Drake is good or even very good distribution, if you consider only first impression only. However, that little difficulty with Synaptec and apt, can be problem for newbies. I am sure, that my sister, would have huge problems with that, and what's more, I don't see any reasons why it is done like this.

This was my first text about Kubuntu 6.06. I reckon that during further exploitation there will be something new and maybe more interesting to write about.

Gmail and importing mails from other mail account

Some time ago, I switched from my old webmail, to new gmail provided by

Everything would be perfect if not the fact that gmail, does not have option for importing e-mails form other pop3 servers.

The only solution I found was to download all you emails using e.g. MS Outlook or Evolution. After this, it is necessary to run special program, which will send all your just downloaded mails to gmail account. It isn't the best solution to this problem, but I could not find enythig else.

Fortunetlly, I have access to Linux server with reasonable bandwich, so I downloaded all my mails from former account (more than 600MB) using Evolution mail client. It is client which goes with Gnome as default. Following this, you need to use one of available programs (gExodus - only Windows, gml, ngml) to export you mails from e.g. Evolution to gmail account. Evolution stores all emails in mbox files. If you use Ubuntu Breeze 5.10, this file shoud be somewhere in you home directory.

To export all you emails stored in mbox you can use e.g. gml python script. However, this script wasn't working for me. So, I found modyfied gml (ngml).

Example usage of ngml:

ngml mbox "/home/me/.mail/Inbox/Inbox.mbox"

And, finally it worked. All those operation were performed on Ubuntu server, which was used, in this case as SMTP server to send all those emails.

Nevertheless, I found it very strange that you have to do so many tricks to import your mails to gmail account. I wander why it is so complicated?

Monday, July 24, 2006

Gmail and plus-addressing

Plus-addressing is an additional option in some mail servers including gmail. What I mean by "plus-addressing" I mean addresses containing '+' in the local part of the email i.e. user-host. For example lets assume that someones email is: If given server allows to use plus-addressing, you can append to the above email some string, also called a tag. And the above email may have form:,, or

What are advantages of this plus-addressing? Thanks to this, we can have one email account, and we can have few addresses just by adding tags. Real power of this system can be seen using gmail accounts, when there is possibility to tell what should be done automatically with incoming email containing additional string after '+' sign. In another words, i gmail such action are accessible by filters.

I will show how to create a filter. Lets create filter that looks for tag: 'todo'. Because of that me email address: Such email for example I will give to my boss that he could send me mails to that addres, and in my gmail account they automatically will be assigne to a label called e.g.: 'work_to_do'.

To begin with we need to create 'work_to_do' label. To do this, you go to Setting and than Labels in your gmail account. There new label can be created:

Then filter must be created. To make a filter first click on 'Create a filter':

and after that you create filter in two stages. Frist, you define your tag (string after plus sign in your email address):

In the second step you define what action should be done with such email. In this case we want to assign label 'work_to_do'. To do this, you check 'Apply the label' and select label to apply and you create filter:

And that's it. From this moment on, you can recieve emails in the form of, and they automatically are labeled 'work_to_do'.

Of course, you can consequently create others 'plus-addresses', and you can create different actions for them.

Your PHP installation appears to be missing the MySQL which is required for WordPress

Yesterday I went to this blog and I see:

Your PHP installation appears to be missing the MySQL which is required for WordPress.

I was quite suprise to see it, couse I hadn't been doing anything with my server configuration before, and yet something happend and this site was not working. What's more, my apache, php, mysql, phpmyadmin were working perfectly.

So, I did a little bit of googling, and I found solution on wordpress officiale site here.

I needed to add those lines just before mysql test in wp-settings.php:

if (!extension_loaded('mysql')){
if (!dl('')) {

I also tried the second possible solution listed there, but it wasn't working.

Saturday, June 24, 2006

Mounting nfs share

When my nfs server is running, it would be nice to mount this share. I use Ubuntu 5.10 as one mounting the nfs share. In fact, I have access to few Ubuntu based servers, so my experience is mainly base on Ubuntu distribution.

Firts of all, to mount on Ubuntu you need root privilages. Asummig you have them, mounting is childish.

Actual mounting can be made in two ways:

  1. Manually - as root you mount using mount command:
    mount -t nfs /home/menew/mounted_nfs
    • -t nfs - we mount nfs
    • - IP and sheared folder
    • /home/menew/mounted_nfs - where this share should be installed on our local file system
  2. Using /etc/fstab
    Add one line to /etc/fstab describing your nfs volume e.g.: /home/menew/mounted_nfs nfs noauto,rw,users,owner 0 0
    Thanks to this to mount you as a normal user can execute
    mount /home/menew/mounted_nfs

To unmount nfs partition, you invoke umount /home/menew/mounted_nfs just like normal other partition.

Used options in fstab

  • noauto - the nfs is mounted only explicitly,insead of being mount at bootup
  • users - normal user can mount this volume
  • owner - only owner of local directory (/home/menew/mounted_nfs) can mount
  • rw - mount is read/write

Friday, May 05, 2006

Ruby: One click Installer

I was writing a lot how Ruby is cool and great. But now I have come across two problems, or rather annoyance. First of all few days ago I tried to use Ruby on Windows XP; hence, I had installed One-Click Ruby Installer. According to description it contains 'Ruby language itself, dozens of popular extensions, ...'. So I installed it without any problems, it run also without any problems. Nevertheless, I wanted to program some script using Tk. So I was quite surpriese when I found out that I cannot use Tk. Of course due to this, I did not do any programming. Of course this is because I did not install Tk on Windows, but without the access to the Internet, it was hard to do it.

The funny thing about this is, that when you working mostly with Unix based systems (Mac X, Linux, Solaris) many things you assume for granted, like presence of Tk. I forgot that on Windows there is no Tk, just like many other things :-)

Second thing is rather not Ruby but Tk itself. I think that combo boxes are quite useful in GUI applications; nonetheless, Tk does not have combo box widgets. This I already knew from Perl, but with comparison to Ruby, Perl has third party modules that provide combobox functionality eg. JComboBox, Tix. Problem with Ruby is that there is no combobox out of the box, and even though there is Tix port to Ruby (here), its documentation is in Japanese, so for me and for many other programmers it rather not very useful.

Wednesday, April 19, 2006

Latex: Sorting and referencing using bibtex

Standard way of referencing in Latex is to put references number is square brackets, ,e.g., [3]. However, sometimes it is necessary to put references in superscript. To do this in TexShop it is enough to include package Natbib and use it like this:\usepackage[super,sort&compress,numbers]{natbib} This results in reference numbers as shown below
instead of standard way:

Wednesday, April 05, 2006

Ruby: Real number precision

If you do some things that involve float/real/double numbers in Ruby, you must lookout for one thing. For example if one write code like this:


(0..5).each {|x|
puts x/2

the result will be:


As everyone can see those results are quite incorrect, cause Ruby assumes that x/2 is division of two integer numbers; hence, the result also must be integer. Such small thing, can be very unseen and hard bug to detect, especially if long, mathematical function is written.
Correct version of the above code is:


(0..5).each {|x|
puts x.to_f/2

The result finally is ok:


I had this bug lately and it took me quite a time to find out why my program gives incorrect results.

Friday, March 03, 2006

imagemagick: apply median filter

Apply median filter of radius 2:for f in *.tiff; do convert -median 2 $f ../outDir/$f; echo $f; done

Sunday, February 12, 2006

Matlab code time execution

Most people is familiar with tic; toc; commands in matlab to check execution of their code;

But more detail insight into this problem is by profile viewer.

This nice tool shows exactly how much time is used by each line, how many times it is executed. Moreover, profiler also gives some suggestions how to improve execution time.

For example, thanks to profiler I was able to reduce time of one image processing program from few hours to few minutes. Profiler showed me, that very simple operation, takes huge amount of time. Just by removing, changing and rewriting few time consuming lines, I was able to significantly shorten exec time of my program.

Thursday, February 09, 2006

Mac X: Changing bash prompt in X11's xterm

Default bash prompt in my X11's xterm was:PS1="\h:\w \u"This was very annoying as the prompt contained all the path to the current directory, which was especially bed if I went dip into the directory tree. In such a case it is better to use '\W' option instead of '\w', as this option shows only current directory name, and not full path to it. To change bash prompt use:export PS1="\h:\W \u$ "To make it permanent just add this line to ~/.bashrc.

Thursday, February 02, 2006

Unreal Tournament 2004: Make it slower

UT2004 is very nice and one of my favorite games. One nice option it has it is possibility to setup the speed of the game. You cannot do it in game itself, however, to do it, you must edit: UT2004.ini file in: \UT2004\System and change the value of variable GameSpeed Originally: GameSpeed=1.000000

I use GameSpeed=0.650000 My computer is not fast enough to render the game in its original speed. Moreover, with slower action, it is easier to observe all those special effects that game has - you can observer, e.g., rocked heading your way, which is pretty nice.

Tuesday, January 17, 2006

Latex: draft option

Writing some long document/article in latex with a lot of figures can be not very nice; providing that, the more figures you have the more time it takes to render your documents. Therefore, sometimes it is usefully to just switch off graphics. This can be done by using 'draft' option in a document class e.g.\documentclass[onecolumn,12pt,draft]{article}
Thanks to this embedded pictures are not displayed; instead, only an outline of the box taken up by the picture is shown. This significantly improve rendering.

Sunday, January 15, 2006

Matlab: getargs.m

Get arguments function code (getargs.m)
function S = getargs(defaultS, varglist);

if mod(length(varglist),2) ~=0
error('Odd number of variable parameters');

S = defaultS;
while i <= length(varglist)
if isfield(S, varglist{i})
S.(varglist{i}) = varglist{i+1};
warning_wrap('getargs:unknown_param', ...
['Unknown parameter "' varglist{i} '"']);
i = i+2;

Tuesday, January 10, 2006

Ubuntu: quick setup of vsftpd server

Instead of proftpd it is faster to use vsftpd. After installation (sudo apt-get install vsftpd) just: sudo vim /etc/vsftpd.conf
And uncomment lines:write_enable=YES
and comment line: #anonymous_enable=YES
Finally restart server by: sudo /etc/init.d/vsftpd restart