Thursday, May 22, 2008

total and unread in Thunderbird

When thunderbird 2.0 came out, one of the things I soon noticed was that in the folder pane, only the number of unread messages was visible and there was no way to see also the number of total messages for each folder. That's one of the things I missed most...

Well, actually it's quite easy to have this feature back: you only need to enable "expanded columns in folder pane" in the "Advanced" tab preference, as shown in the following picture. Then, you'll be able to show also the "total" in the folder pane. Hope this helps :-)

Saturday, May 17, 2008

The elegance of C++

Yes, C++ is my favorite language; it's one of the first I learned (surely the first OO language I learned) and I kept using it through the years. Of course, for network applications I used Java, since I admit it's easier for that context; but when I can, I always go back to C++.

One of the things I like most is the STL library; it uses generic programming extensively with nice and elegant results; by the way, we're talking about true generic programming... not the one provided by Java, which is very little generic :-)

Last day I had to copy the elements of a list into a set, and I was about to write the classical for loop using iterators, especially for printing the results to the screen, and then I said to myself "what are you doing? You're not using Java! You're in C++ now, you can use generic algorithms!"

You can use the insert method of the class set that takes two generic iterators and you can use the copy algorithm to "copy" all the elements of iterators into the standard output (by using an ostream_iterator).

It surely is a matter of taste (and de gustibus non est disputandum), but I find the resulting code very very elegant... probably stl lacks some functionalities when it comes to for_each loops that need to invoke class methods with some parameters... but you can always rely on the fantastic boost libraries!

#include <set>
#include <list>
#include <iostream>
#include <algorithm>
#include <iterator>

using namespace std;

int main() {
list<int> mylist;
set<int> myset;

mylist.push_back(10);
mylist.push_back(11);
mylist.push_back(1);
mylist.push_back(2);
mylist.push_back(10);
mylist.push_back(10);
mylist.push_back(10);
mylist.push_back(2);
mylist.push_back(20);

myset.insert(100);
myset.insert(2);

cout << "list: " << endl;
copy(mylist.begin(), mylist.end(), ostream_iterator<int>(cout, "\n"));

cout << "set: " << endl;
copy(myset.begin(), myset.end(), ostream_iterator<int>(cout, "\n"));

myset.insert(mylist.begin(), mylist.end());

cout << "set after insertion: " << endl;
copy(myset.begin(), myset.end(), ostream_iterator<int>(cout, "\n"));

return 0;
}

Saturday, May 03, 2008

Konqueror instead of Dolphin

I've always loved KDE, but the latest file manager introduced with KDE 4, i.e., Dolphin... well... I just can't stand it. I prefer using Konqueror, the powerful Konqueror. However, after an upgrade of the system, although I was using Konqueror, when clicking on a folder it was using Dolphin to open it... really bad.

Fortunately, it was (relatively) easy to revert to the old behavior, and in particular, to set Konqueror as the default application for folders!

You need to run KControl (kcontrol from the command line) and then choose "File Associations" under "KDE Components", then select "inode" and "directory". Here, you only need to move up Konqueror in the list "Application Preference Order". Hope this helps.