Linux on Netbooks at the Netbook World Summit in Paris

•December 15, 2009 • 1 Comment

I’m just double-posting this here because not everybody is using Twitter *g*. This is an interesting interview of Aron Seigo (of KDE) and Arnaud Laprévote (Mandriva CTO) about Linux on Netbooks. Quite interesting..

KDE SC 4.4 Preview

•December 8, 2009 • 2 Comments

Here are some YouTube videos about the upcoming visual improvements in KDE-4.4. Mostly Kwin (window manager) and Plasma (desktop shell) features like window tabbing or edge snapping is shown. Those are HD videos, so you should enlarge them. Remember, this is still the first Beta, so there are some glitches left.

Some stuff more related to the Plasma netbook shell:

SSH session timeouts

•November 25, 2009 • 2 Comments

Recently I’ve experienced some odd SSH behavior, my connection is lost after not issuing a command for a while. Usually I get this message:

ME@SERVER:~% Read from remote host SERVER: Connection reset by peer
Connection to SERVER closed.

Nice, indeed. However, this can be fixed by creating the file ~/.ssh/config and pasting this into it:

TCPKeepAlive no
ServerAliveInterval 15

What happens here is that you overwrite the default SSH configuration usually found in /etc/ssh/ssh_config with a different behavior. A timeout interval is set after which your SSH client will request a response from the server. This is usually done via TCP keep-alive, which is unreliable (and insecure) and therefore turned off. So, no more timed-out connections here, great! Feel free to read the ssh_config manpage for more insight.

Productivity

•November 20, 2009 • Leave a Comment

Backups! Yep, that thing you’re ought to do regularly. Today’s the day for me to do it. As being not quite content with the available solutions out there I tend to do it all by hand. This involves some tedious repetitions like packing directories. So here’s a little script that might be handy:

#!/bin/sh
#
# Create a packed tarball of a directory or file in the
# current working directory with an optional filename prefix.
#
DATE=`date +%Y%m%d-%H%M%S`
case “$#” in
“1″)
NAME=`echo $1-$DATE | sed “{s/ /_/g;s/\/$//}”`
;;
“2″)
NAME=`echo $2-$1-$DATE | sed “{s/ /_/g;s/\/$//}”`
;;
* )
echo “Usage: pack FILE [PREFIX]“
echo “Create a packed tarball of FILE with an optional filename PREFIX.”
exit 1
;;
esac
tar -cf “$NAME.tar” “$1″ && bzip2 “$NAME.tar”

Just paste that into for example /usr/local/bin/pack and set the executable bit. Afterwards, if you want to pack a directory test you can do a simple pack test or provide a prefix to the resulting file with a more complex pack test $HOST-$USER which results in something like festor-saschpe-test- 20091120-122101.tar.bz2 on my machine. And don’t forget to listen to classy music like this while backing up your stuff:

That’s it, have a nice weekend.

Back at home

•November 13, 2009 • Leave a Comment

I had an awesome week in Nice! But as everything has an end, I’m updating my openSUSE installation right now and sipping a cup of coffee. Back to normal, one could say. A more detailed post about recent adventures can be found here (in german).

IASRA is a stupid recursive acronym!

•October 19, 2009 • Leave a Comment

To recurse or not to recurse? This is of course a brilliant idea if you’re in search for a cool and geeky name for your new pet project. But is it also wise to code your-favorite-algorithm ™ in a recursive manner?

Let’s start with the basics, Wikipedia has a good definition available:

Recursion, in mathematics and computer science, is a method of defining functions in which the function being defined is applied within its own definition.

Furthermore, in our first Computer Science semester we where taught the logical equivalence of coding an algorithm in an applicative or imperative way. So what’s the matter then? As usual, problems arise when reality hits (Computer Science) theory hard. Generally spoken, those two methods of encoding an algorithm differ physically. Ok, what’s meant by that? Well, depending on the used language (more to that soon), it is wise to use the former or the latter way. Let’s start out with good old procedural languages like C, C++, Java and all the others that actually matter. Procedural languages use functions to encapsulate sub-problems. For example, when a C++ program is transformed into machine-specific assembly, the compiler enforces certain conventions that ensure that these functions can be called in an uniform way. Executing a function usually means to jump to a different portion of code, do something and to jump back to where you’ve been before to use the computed result. So we have to store that return address. The function concept becomes more powerful if you can send parameters to them, so we have to store those too. Functions tend to use local variables for saving intermediate result and every function call needs a local copy of those variables, so these have to be stored somewhere too. The convention on how to store all this is usually referred to as a stack frame. As the name implies, a certain frame is stored on the stack, a certain memory area that was set up by your kind operating system for your proggy’s process in advance. Let’s shamelessly steal a picture from Wikipedia to visualize this concept:

Stack frame example

Note that the actual frame layout differs with the language that you use. For example Pascal-derived languages use a different layout than the C world. It easy to see that this unavoidable overhead gets bigger (relative, not absolute) the shorter your functions are. Recursive algorithms generally tend to use short functions, which is shown exemplarily with this C++ implementation of the Fibonacci numbers:


int fib(unsigned int n)
{
if (n == 0) {
return 0;
} else if (n == 1) {
return 1;
} else {
return fib(n - 1) + fib(n -2);
}
}

This means big relative overhead. Let’s look at the imperative (and optimised) version of the same algorithm:


int fib(unsigned int n)
{
static unsigned int tmp[] = {0, 1};
static std::vector fibs(tmp, tmp + sizeof(tmp) / sizeof(unsigned int));

if (n >= fibs.size()) {
for (unsigned int i = fibs.size() - 1; i < n; i++) {
fibs.push_back(fibs[i] + fibs[i - 1]);
}
}
return fibs[n];
}

One function means one stack frame, easy peasy. So to say, the overall runtime and memory cost of those stack frames increases the more excessive you execute short functions from within functions (hey, that’s recursion!). The imperative version only uses one stack frame, which saves us countless bytes on the stack (speak, main memory) and reduces the risk of stack overflows. Furthermore it saves CPU cycles for those push/pop and store/fetch instructions you don’t have to execute (The inline keyword in C/C++ comes to mind here). Therefore it is always faster to go imperative than recursive in the real world. This concludes to:

NEVER EVER USE RECURSION IN A PROCEDURAL LANGUAGE !

However, the situation looks slightly different if you use a functional language (or even handcraft the Fibonacci algorithm in assembly, but that’s another story). Functional languages often use the tail recursion idiom to allow (or force, depending on personal opinion) the user to encode algorithms recursively. What happens when that get’s translated into assembly? That idiom is simply mappend back to simple loops for the exact same reason (remember, they’re equivalent logically). This post already got longer than I expected, so let’s keep it short. Functional languages allow convenience recursion idioms that get translated back to imperative idioms to run performant on real hardware. Maybe someone more experienced in Haskell can provide more detail how this is done exactly (assembly listings appreciated).

If you want to confirm the above, take the attached little test programs and run them through your favorite profiler and compare jump/call counts and stack changes. You might want to check what time one iteration of the algorithm takes (speak one loop iteration versus one recursive function call). That’s it!

GSoC updates: the client agent

•August 4, 2009 • 28 Comments

This follow-up post is about my proceedings for my GSoC project to integrate SyncML support in Akonadi. This consists basically of two parts, a server agent and a client agent. The former allows other devices to talk to your Akonadi server while the latter let’s your Akonadi server speak with others. Quite simple? Not really, SyncML is a complex and error-prone beast. That said, the server component might take some time to be ready, but the client agent is actually useful now. So let’s have a little test session!

The following stuff is pretty low-level, requires some compiler/shell knowledge, a KDE development environment set up and is not intended for end-users. Still there?

Compilation
If you have your KDE development environment up and running, just checkout trunk/playground/pim/syncml from KDE SVN. You need to have libfunambol installed, which you can either compile for yourself from source our use a package from that repository (a patched libsyncml is available too, if you want to build the server agent). Not much to say here, just build and install it.

Setup
If you’ve reached this step you now should be able to add a SyncML client agent in the Akonadi resource configuration control module (system settings -> advanced tab -> akonadi configuration):

syncmlclient-agent-3

If you did so, you should now be presented with the following configuration dialog:

syncmlclient-agent-4

There you can setup the remote server (speak web-service) you want to sync with. Your job is basically to decide what parts of your PIM-data you want to be synced (contacts, calendar, etc.) and how to match the corresponding local Akonadi resource with the remote database on the server. Some more advanced values will be exposed soon, SyncML has gazillions of options available! Here are some possible values to toy with:

myFunambol.com

URL: http://my.funambol.com/sync
username/password: you should register!
contacts remote db: card
events remote db: event
tasks remote db: task
notes remote db: note

ScheduleWorld.com

URL: http://sync.scheduleworld.com/funambol/ds
username/password: you should register!
contacts remote db: card
events remote db: cal
tasks remote db: task
notes remote db: note

Mobical.net

URL: http://www.mobical.net/sync/server
username/password: you should register!
contacts remote db: con
events remote db: cal
tasks remote db: task
notes remote db: vnote

Rumors have it that some Google services are also SyncML-capable but I don’t know the settings needed. Feel free to post a comment if you know something here. As a sidenote, you can actually have multiple agents for several remote sides in parallel.

Showtime!
For now all that stuff lacks a GUI, there’s some initial work on a KControl module but for now we have to communicate via D-Bus with the client agent. The same is true for visual feedback. The agent is able to tell you whether the sync succeeded or not. If you want to know more, you have to watch Akonadi’s debug output for now. Fire up a terminal and enter the following stuff:

$ akonadictl restart
$ qdbus org.freedesktop.Akonadi.Agent.akonadi_syncmlclient_agent_0 / sync

Before you actually try this, be warned! This is unstable code that is still in heavy development and all kind of weird things may happen to your PIM data, so make a backup before you proceed.

syncmlclient-agent

Opinions on Microsoft’s GPL’ed code

•July 23, 2009 • Leave a Comment

There’s been much debate about Microsoft releasing code under the GPL lately. Linus Torvalds was intervied by the Linux Magazine, here’s what he thinks about it. Also interesting is Greg Kroah-Hartman’s related blog entry. According to him Microsoft simply had to comply to the GPL because they used Linux code (to avoid a lawsuit) and they want to have it included in the kernel. A future model? We’ll see..

Palm Pre SDK

•July 16, 2009 • Leave a Comment

Finally, Palm opened up developer.palm.com to the public. Read more in this announcement. Apple also recently released a “fix” to shut out the Pre from iTunes, this GCDS talk talks about open alternatives. Hopefully the GSM version of the Pre gets released real soon :-)

Update:
Another article in the same vein just popped up.

Origins of the moonwalk

•July 3, 2009 • 1 Comment