Saturday, November 17, 2012

Avoiding Perl Locale Errors with Remote Git

I've long been troubled with annoying locale warnings that I got with every Git command.

$ git pull
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
        LANGUAGE = (unset),
        LC_ALL = (unset),
        LANG = "fi_FI.UTF-8"
    are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").
Current branch master is up to date.

Generating the locales with "locale-gen fi_FI fi_FI.UTF-8", which was suggested by some, didn't help at all.

It seems that the problem occurs with remote SSH repositories, when Git makes an SSH call to the server. Apparently, it runs a shell in the remote host. It forwards language environment variables to the remote host, but when the remote host doesn't have the locale installed, the error occurs.

So, the solutions are:

  1. generate the locales in the remote repository server, or if that is not possible,
  2. change the locale to LANG=C in the local host.

I prefer to have the fi_FI as my system locale, so I wrapped the git calls in the following Bash script:

#!/bin/bash

# This is needed when git makes an SSH call to a remote
# server which doesn't have # all the locales installed
export LANG=C

# Note: the "$@" is important notation to avoid
# splitting arguments at spaces
/usr/bin/git "$@"

Monday, November 12, 2012

Scala Streams

The Scala course at Coursera is on its last week. The course has been quite an interesting introduction to Scala, from the pure functional point of view, which is probably the most relevant one from Computer Science perspective. I'm still doing the last excercices, which should be finished the next Sunday. The excercises have been quite interesting; I haven't gotten full points but almost.

Anyhow, the streams are quite an interesting data structure in Scala. Yesterday, I did the following small encoder, which encodes any text input in the pattern of the SETI (Search for Extra-Terrestial Intelligence) message sent from Arecibo radio telescope in 1974. Fairly limited purpose, but anyhow, the streams worked quite nicely in solving this problem.

So, here's my solution:

  def setiencode(input: String): String = {
    val seticode =
      "00000010101010000000000\n" +
        "00101000001010000000100\n" +
        "10001000100010010110010\n" +
        "10101010101010100100100\n" +
        "00000000000000000000000\n" +
        "00000000000011000000000\n" +
        "00000000001101000000000\n" +
        "00000000001101000000000\n" +
        "00000000010101000000000\n" +
        "00000000011111000000000\n" +
        "00000000000000000000000\n" +
        "11000011100011000011000\n" +
        "10000000000000110010000\n" +
        "11010001100011000011010\n" +
        "11111011111011111011111\n" +
        "00000000000000000000000\n" +
        "00010000000000000000010\n" +
        "00000000000000000000000\n" +
        "00001000000000000000001\n" +
        "11111000000000000011111\n" +
        "00000000000000000000000\n" +
        "11000011000011100011000\n" +
        "10000000100000000010000\n" +
        "11010000110001110011010\n" +
        "11111011111011111011111\n" +
        "00000000000000000000000\n" +
        "00010000001100000000010\n" +
        "00000000001100000000000\n" +
        "00001000001100000000001\n" +
        "11111000001100000011111\n" +
        "00000000001100000000000\n" +
        "00100000000100000000100\n" +
        "00010000001100000001000\n" +
        "00001100001100000010000\n" +
        "00000011000100001100000\n" +
        "00000000001100110000000\n" +
        "00000011000100001100000\n" +
        "00001100001100000010000\n" +
        "00010000001000000001000\n" +
        "00100000001100000000100\n" +
        "01000000001100000000100\n" +
        "01000000000100000001000\n" +
        "00100000001000000010000\n" +
        "00010000000000001100000\n" +
        "00001100000000110000000\n" +
        "00100011101011000000000\n" +
        "00100000001000000000000\n" +
        "00100000111110000000000\n" +
        "00100001011101001011011\n" +
        "00000010011100100111111\n" +
        "10111000011100000110111\n" +
        "00000000010100000111011\n" +
        "00100000010100000111111\n" +
        "00100000010100000110000\n" +
        "00100000110110000000000\n" +
        "00000000000000000000000\n" +
        "00111000001000000000000\n" +
        "00111010100010101010101\n" +
        "00111000000000101010100\n" +
        "00000000000000101000000\n" +
        "00000000111110000000000\n" +
        "00000011111111100000000\n" +
        "00001110000000111000000\n" +
        "00011000000000001100000\n" +
        "00110100000000010110000\n" +
        "01100110000000110011000\n" +
        "01000101000001010001000\n" +
        "01000100100010010001000\n" +
        "00000100010100010000000\n" +
        "00000100001000010000000\n" +
        "00000100000000010000000\n" +
        "00000001001010000000000\n" +
        "01111001111101001111000\n"

    val parts: List[String] = seticode.split("1").map(x => x.replace('0', ' ')).toList
    val parts0: List[String] = parts.dropRight(1)
    val partsn: List[String] = parts0.updated(0, parts.last + parts.head)
    val partstream: Stream[String] = parts0.toStream ++ (Stream.continually(partsn).flatten)

    (input.toList zip partstream).map(x => x._2 + x._1).reduce(_ + _)
  }
Especially the possibility to repeat an infinite stream infinitely with Stream.continually() was quite interesting, as well as the joining of a string and a stream with with zip method, were quite interesting. I suppose an even better solution would have used a stream split operation, but I didn't find one built-in, so the above seemed to be the easiest.

Friday, October 5, 2012

Process your waste by eating it

We usually have a lunch buffet at work every second Friday together with some project presentations. Today, I was disappointed to see a big unopened box of huge chicken legs be thrown to waste, because it had gone unnoticed at the bottom of the keep-it-warm box. Together with all the thrown-away rice and salad, that would have made some 20 meals. Unfortunately, I didn't have my leftover containers with me, so it was thrown away. Well, the chicken would have been difficult to warm up again later anyhow.

Waste to be eaten while writing this - olives, cheese cubes, tomatoes, rice, etc.

Luckily that was exceptional - we usually have some like myself who take the leftovers home. I'm not saying that everyone should participate, as there wouldn't really be enough leftovers for many people, but there should always be some to take care of it. I'm perfectly happy to be able to get a full week's food for free on some occasions. Our company may be exceptional, in most places such leftovers are probably just thrown away.

For another example scenario, some years ago I was at a meeting at the Ministry of Education of Finland. As is the custom at meetings, there was some snacks served. Quite a lot actually, bread, butter, ham, cheese, tea, coffee, etc. In this meeting, there was exceptionally much and the participants ate only about half, while the other half was left over. At the end of the meeting it became obvious to me that they would have been thrown to waste. Being a bum, I collected the leftovers and ate them for several days. After that, I've tried to have some containers for the leftovers in similar meetings.

One problem seems to be in the social conventions involving offered food. In normal human social behavior, collecting leftovers would also be a sign of low socioeconomic status, suitable mainly for a bum, and most people avoid that instinctively. Given that the offered food is intended to be shared jointly, collecting the leftovers would also be a sign of greed, taking more than your share, even a bit like stealing if you are not the host. Also, if not everyone participates in the collection of the leftovers, which would not even be practical, collecting them would make you nonconforming, which is rarely socially a good thing.

It could also be considered a "luxury situation" where you are being served or indulged. Being free of problems is part of and a form of indulgence, so you assume that the fate of any excess food should not be your concern, but somebody else's. Going further, it's one thing to take some leftovers from the table, but it would indeed be considered quite odd and exceptional, for example, to go to the kitchen and ask for the leftovers. The purpose of free snacks is not to give you economic support, but to make the occasion more enjoyable.

For meetings and parties arranged at someone's home there is probably less waste, as the hosts can collect the (untouched) leftovers and perhaps do something useful with them.

It is more common to keep the leftovers that you personally paid for. Restaurants around the world offer "doggy bags" specifically for that purpose. Surprisingly, the use of doggy bags is more common in US that in Finland, even though the proportion of domestic food waste is as high as 50% in the US. One reason could be that the US restaurant portions are huge, while in Finland the portions are usually such that almost everyone can eat them. The restaurant cultures are quite different in different countries. For example, in Middle-East, many common meals such as mezes are replenished as you eat them, and after you finish, quite a lot of food is thrown away. In one country leaving food on the plate could be considered rude - it signals that it wasn't good enough - while in other countries the opposite - it signals that there wasn't enough of it.

Globally, some one third of all produced food is wasted. Given that food production one of the biggest causes of global ecological problems, this is a huge problem. With overpopulation, economic rise of the Asia, biofuels, and loss of arable land to erosion, the rising cost of food can become a significant contributor to social division and unrest in the world.

The good aspect is that you don't have to care about the penguins, seals, kittens, or the hungry poor. You can just think about your own wallet. Please, be a greedy bum. Please, be a jerk and take the last piece of the cake.

Some minor observations:

  • White bread made from wheat flour is good essentially just for one day, while dark breads made from rye are good for several days. Rye breads are almost exclusive to Finland, I have rarely seen them elsewhere, although they are made in Scandinavia, Germany and in some other places to some extent. Rye is also much healthier than wheat, especially non-whole-wheat.
  • Vegetables are healthy, but get spoiled quickly
  • Quick-spoiled ingredients which require other ingredients to make meals have higher probability to get spoiled at home. I often have milk and vegetables get spoiled because of this.
  • You are more likely to discard cheap than expensive food.
  • Some leftovers are easier to keep than others. Pizza, bread, unprepared vegetables, cookies, dry food in general, etc. are easy. Soups, fried chicken, beer, etc. are less easy.

Saturday, August 18, 2012

Desktop Reinstallation Struggle

For many years, I struggled to stay with KDE 3.5 in my primary desktop computer, as I found it much more stable than the KDE 4, which had serious issues every time I tried it. Kubuntu 8 was the last system version to come with KDE 3.5, so I was stuck with it. After a hard drive failure some two years ago, I finally installed a newer Kubuntu, and also went for 64-bit to get a bit more memory. My life has been struggle since then.

Issues, issues

Often after some upgrades, the machine has worked well for a day or two, and then become sluggish as hell, with random jams that can last from 5 to 30 seconds. Some applications cause especially much problems. One is Thunderbird, for some odd reason. Another is Digikam, for which the reason is that it doesn't really scale up very well and hogs memory (2.5 GB currently).

Also, successive system upgrades from Kubuntu 9 to 12 had also broken something. One of the most problematic background processes was "semantic Nepomuk Desktop". Do not even ask me what that is, but it is currently an integrated part of KDE. It can be disabled, but doing so causes a lot of annoying alerts that it should not be disabled, even though those alerts are only relevant if you use KMail, which I don't.

I've been struggling to identify the underlying problem. I've suspected an interrupt in DMAs, interrupts, or some other resources. However, the most probable cause is the Nvidia GeForce 8800 GT, which was the source of most problems with this installation as well.

I wholeheartedly agree with Linus's opinion about Nvidia. While they do offer a proprietary driver for Linux, it is riddled with problems and they refuse to give out specs for making a possibly better driver.


Linus delicately expressing his opinion about Nvidia

For the most time in these two years of struggle, the system has worked reasonably well for a few days, before the memory has fragmented, etc. So, after the two years, I finally bought another 4 GB of memory this week, hoping that it would make the problems easier. It didn't at all. So, I finally decided to reinstall everything, even as annoying that is.

Installing the Pangolin

Running the installation for Kubuntu 12.04 LTS (nicknamed Precise Pangolin) was really easy and simple. I have it on two other machines as well, my work computer and my netbook. The only slightly worrying step was not formatting the drive. I took full backups to an external drive (took almost a day), then started the Live Kubuntu, mounted the drive from console, and moved everything under root to an "old" directory. Then, did not allow the installation to partition and format the drive, but assigned the root mount point for the partition. Well, I've done that probably dozens of times, but you can never be too careful with that.

Nvidia Problems

However, after the installation, the computer didn't work at all. Simply clicking anything with the mouse didn't work. The reason was apparently that compositing was not enabled. The quick (and unobvious) fix to be able to use the system at all was to disable the 3D effects mode with Alt+Shift+F12. Also, all fonts were so tiny that I couldn't read them. The reason was probably with my monitor (a 42" TV actually), which detects the signal so slow that the system can't detect it, and then calculates the DPI resolution with some insane defaults.

So, to edit xorg.conf. Actually, it wasn't really initialized at all, but running nvidia-xconfig in console reinitialized it with a bit more sane values. Then, make the following monitor settings to get the DPI resolution sane:

Section "Monitor"
    Identifier     "Monitor0"
    VendorName     "Unknown"
    ModelName      "Philips FTV"
    HorizSync       15.0 - 70.0
    VertRefresh     48.0 - 62.0
    Option         "DPMS"
    Option         "UseEdidDpi" "False"
    Option         "DPI" "120 x 120"
EndSection

Those aren't really the correct DPI values for the TV, which would be about 47 DPI, but something that makes it readable from 1,5 meters.

Then, the compositing:

Section "Extensions"
    Option         "Composite" "Enable"
EndSection

The biggest issue was the nvidia 290.40 display driver, which was essentially broken, so that the user interface became unbearably slow. Simply switching between windows would take some 15 seconds. The driver had broken at about version 290.33 or so, and while many versions had made some fixes for some cards, they didn't work for me. After struggling for hours, the finally working solution was to install the latest driver from an alternative repository:

sudo apt-add-repository ppa:ubuntu-x-swat/x-updates
sudo apt-get update
sudo apt-get install nvidia-current

This installed the 304.37 driver version from the 304.37-0ubuntu1~precise~xup1 package, which actually worked.

So, for the first time in two years, everything seems to work pretty well. For now.

The Rest of It

The rest of the installation was very boring routine. KDE has a zillion settings with which I'm not satisfied and making it bearable always takes half a day, which is the reason I don't want to make installs very often. I did my netbook install just a month earlier, so most of the difficult-to-find settings were in almost fresh memory.

The required KDE configurations change a bit from time to time, as some defaults become better and some worse. Just to mention some:

  • Disable unnecessary desktop effects and configure others
  • Change desktop theme to a prettier one
  • Configure Task (window) Switcher to a vertical layout
  • Configure virtual desktops (I always use 8)
  • Configure desktop animations, etc.
  • Configure switching desktops with Win+Tab and Win+Ctrl+Tab (this actually has couple of bugs in KDE 4 which makes the configuration difficult)
  • Configure window behavior rules (force certain windows to always start in certain desktop)
  • Disable annoying confirmations for the KDEWallet
  • Configure other global shortcuts (minimize/maximize windows, etc)
  • Configure session control - restore manually saved session
  • Disable logout confirmation
  • Disable screensaver
  • Disable screen power saving from Power Management
  • Disable network settings in KDE and set them in /etc/network/interfaces
  • Configure printer
  • Configure screen resolution if not correct
  • Delete unnecessary default folders from home folder
  • Change the location of the Desktop folder
  • Set up Firefox as default browser in KDE and with update-alternatives
  • Set up Konsole configurations for root, Irc, and normal use
  • Set up panel
    • Change the terrible new Windows-style application launcher to traditional launcher (great that it's still there as an alternative)
    • Set up application launchers
    • Set up Konsole configuration launchers
    • Set up clock
    • Set up other panel layout
    • Enable auto-hiding
  • Set up desktop background photo
  • ...and other small tuning...

So, there it is (with my System desktop).

Addendum

2012-08-20: Some occasional jams still occur, typically freezing the keyboard for half a minute in one application, such as Firefox. But it's quite different, system loads stay quite low, but one core jumps to 100% when a jam occurs.

Friday, August 3, 2012

Enjoying the Finnish Archipelago

One of my activities this summer has been exploring the Turku archipelago with my kayak. The Finnish archipelago is the largest in the world by some measures. There are 179 584 counted islands in Finland, some of them in the lakes, but most of them in the sea. The largest archipelago area, the Archipelago Sea, is around Turku, where I live, with about 50 000 islands. Most of the islands are tiny, some just ten meters wide, but yet make great places to visit. The archipelago is also really tightly packed, and you could usually throw a rock to the neighbouring islands.

Not amazingly, many people here have a boat. So did my family when I was a child. We had a rather small motorboat, and my family and other kindred would all gather at the Maisaari island. My brother has a motorboat, and many of my friends have had one, or a sailboat. I kind of like sailboats, so I may get myself one some day.

The number of islands is so high that even though thousands of people go out there every summer weekend, everyone can always get their own island to stay in, if they like. Some of the islands are just small treeless rocks, but most have some forest.

Nevertheless, most of us who live here take the archipelago for granted, and rarely even think about it. So have I for most of my life. I kind of rediscovered it last year when I got into paddling. A kayak is really very useful for exploring the archipelago, as you can get everywhere with it. Many parts of the archipelago are unreachable by motorboats or sailboats, as they are too shallow and have too many underwater rocks, but with a kayak or canoe you can get everywhere. It is a bit slow and requires some effort, but on the plus side, it keeps you in shape. Not surprisingly, kayaking and canoeing have become really popular in Finland, and especially so in the Turku area.

I started kayaking mostly last year, and after some trips with rented kayaks, I got myself one. So far, most of my trips have been just daytrips or one-night trips, and one two-night trip for a weekend. But why stay longer, as you can always go next weekend as well.

At Ominainen, the most famous haunted island in Finland. They used to bury criminals and other nasty bastards here.

A private boat is by no way the only way to explore the archipelago. There are many "water buses" that go to some islands daily, and bigger ferries to the more remote islands. Most of these ferries, especially to the most remote islands, are actually totally free of charge. The ferries go also in the winter, pushing through ice. There's also an Archipelago Route, which you can go by car or bicycle, with free ferries between the islands.

Oh, Finland also has 187 888 lakes (larger than an acre). The number of lakes by the land area is also probably the highest or among the highest in the world.

Tuesday, July 17, 2012

Book of Vaadin - Vaadin 7 Draft Edition

I just sent the Book of Vaadin, Vaadin 7 Draft Edition, to print. I've been really busy with it for the last month, as there is so much to do. Some years ago, when we went from IT Mill Toolkit 4 to 5, it took over six months to rewrite it. Now the book is many times bigger and the changes in Vaadin 7 are really radical.


The edition is really a draft, and it says so right in the title and in many places inside the book. Many of the changes in Vaadin 7 require going through the book almost word by word, so I hope to get it done before the end of the year.

Also, the last batch of Vaadin 7 enhancements is yet to be released in the first beta, which should be out at the end of August.

The printed book will be available at JavaOne, and at some other locations. We try not to print this draft in huge numbers, just for the most important conferences in fall of 2012.

Big Changes in Vaadin 7

The first big thing in Vaadin 7 is the renewal of the basic application API. You no longer extend Application to write an application, but a Root (name is subject to change). Root is much what Window used to be, and the Window now means only a sub-window. There's also a separate Page object associated with a Root.



Another big topic is the client-side API, which has been essentially rewritten to use connectors that communicate between a client-side widget and the server-side component. The framework handles state object serialization transparently, and there is also an RPC mechanism. Hence, the client-side development chapter has been rewritten from scratch and it still needs a lot of work.

For most developers, also forms and data conversions are very important. There is no longer a Form component, but a FieldGroup that helps in binding fields and data together. I have written probably a hundred examples that use the old Form, so there's quite a lot work in converting them all to the new model.

And there are dozens of other significant changes.

Vaadin += GWT

Then perhaps the biggest thing in Vaadin 7 is that it now includes GWT. Just putting the GWT classes inside the Vaadin JAR sounds does not itself sound significant, the significance comes from the consequence that as we provide support for Vaadin, which now includes GWT, we also provide support for GWT. Vaadin now also effectively supports two development models: one for the server-side as before, but also for pure client-side applications.

Pure client-side Vaadin applications are of course more restricted, but they have their uses. Not all applications need data from a server, but just work on data input by the user. Also, pure client-side application can work off-line, unlike server-side Vaadin applications (unless you install the server on the client machine). For example, the Vornitologist demo for TouchKit has an off-line mode that displays a pure client-side version of the application when the network is not reachable. It uses HTML5 local storage to store the application itself, as well as the data, until the network is reached again and it can send the data back to the server. Then, the application can revert back to the full-featured server-side application. To try it out, run the demo on either an Android or iOS device.

References

Some links:
Notice again, that the Book and the book examples are really unfinished drafts at this point, and will be in better shape at the end of the year when Vaadin 7 is planned to be released.

Sunday, July 8, 2012

Installing Kubuntu 12.04 LTS on Acer Aspire One D270

I finally bought a new netbook, an Acer Aspire One D270.
  • 10.1" display
  • Dual 1,6 GHz Intel Atom N2600 processor
  • GMA 3600 graphics chip integrated on processor
  • 320 GB hard drive
  • 1 GB RAM, extendable to 2 GB
It appears that the D270 model has many variants. I accidentally purchased a model with a 3-cell battery, as there was another model with the same designation in another shop, but with a 6-cell battery. I read the specs from the other shop, and bought the machine from the shop with the inferior machine. Oh well, can't take it back anymore. On a positive side, it's a bit lighter and smaller with the 3-cell battery. There were a few other alternatives, but this was the cheapest and I thought they were so cheap that I could buy a new one later. There's never enough netbooks lying aroung.

The nasty trade-offs with the D270 are:
  • A glossy screen (oh I hate them)
  • No Bluetooth
  • No built-in 3g
  • The small battery in this model
But it was cheap, so.

The machine came with Windows 7 Starter. It's actually the first Windows I've ever paid for myself, which is kind of shameful. Unfortunately, it's no longer possible to find a netbook/laptop without Windows (Update: Looks like they sell D270 with Linux in Germany). My EeePC 910 was quite great, with almost same performance as this one, but unfortunately they don't sell those any longer. Too bad I managed to soak it in pear juice.

It should be noted that there are no vendor-provided drivers for the GMA 3600 graphics controller in Kubuntu. (Update: Looks like Intel has published a Linux driver last month! But it's only for 32-bit Fedora...)

Some of the configuration given in this article are specific to the Aspire, but perhaps most are quite generic, especially the KDE configuration.

About KDE

I'm a long-standing KDE user and wouldn't really use anything else. The problem is that KDE has been getting worse over the years, not better. I guess it's because KDE imitates Windows a lot, and Windows has gone worse. The problems started with the redesigned KDE 4, which had all sorts of bells and whistles that still don't work some 5 years after the first version. The window manager crashes occasionally, and there are other issues, some of which I will mention later.

One of the most annoying issues is deteriorating keyboard support, some of which issues I mention later. While I initially switched to KDE because of its excellent keyboard support, it has been getting worse. Shortcuts disappear, and no one seems to care about it. I imagine there is nowadays a newer generation of developers who went to school learning to always use mouse for everything. Despite using the keyboard for writing a lot, they nevertheless seem to stick to mouse a lot. Not good.

Mounting the Cow

In any case, Kubuntu, the KDE version of Ubuntu, was my choise. Downloading the ISO image was just a minute. The trouble started with writing the image on USB memory. The instructions give a "normal way" to use "usb-creator-kde" application. The problems started while using it, as it crashed the first time I used it. Trying again, I managed to write the image to the USB drive (or actually an SD card with an adapter). However, trying to boot from it consistently failed and the system dropped to shell prompt. I first feared that it might be a display driver issue, but going through the errors gave me a hint that the USB image might have some issues. It couldn't even mount the system in read-write mode, which caused everything to fail.

The problem was that it couldn't mount a cow. More technically, I got "Can not mount /dev/loop1 on /cow". It has something to do with an overlay filesystem where there is a read-only filesystem on the bottom and a ramdisk read-write filesystem on top of it that takes any modifications. Anyhow, I didn't get the cow error consistently, so it took a bit time to figure out. Well, the installation instructions actually mentioned the issue and adviced to use UNetBootin, another application to create bootable USB disks.

The problems didn't exactly end with UNetBootin, I have no idea why. I managed to boot once, but subsequent attempts didn't work, the boot just got stuck. At this point, I gave up and went to sleep. On the next day, I went to a supermarket and bought a real USB drive instead of the SD+adapter, and tried that. Worked, excellent.

The installer allowed to repartition the 320 GB drive nicely so that it preserved the Windows 7 installation. Not sure what I could use it for, perhaps for some games or something. Not that the machine is fast enough for games. Even basic use with Windows 7 Starter is horribly slow. But I did pay for it! Installing Firefox instead of the IE made browsing much faster though.

Installing Kubuntu was a breeze initially, nothing much to say about that.

The Biggest Task: Basic Configuration

While KDE is great, it unfortunately is not great out of the box. In fact, it appears rather broken in many ways.

Using Regular Desktop

Kubuntu seems to start the "Plasma Netbook" workspace by default. It might be nice for your grandmom or your kids, but for you it isn't. To use a regular desktop, select in the Control Panel "Workspace Appearance and Behavior / Workspace Behavior / Workspace" and select "Desktop" in the Workspace Type. Click Apply and you're much happier.

Tree View in Control Panel

The KDE Control Panel originally had a tree view. In some 3.x version, it was changed to a more "iconic" view, for worse I think. It is still possible to get the tree view simply by clicking Configure in the Control Panel and selecting the Classic Tree View.

With trees or icons, the KDE Control panel is really a huge forest and it can sometimes take ages to find what you want. Sometimes the search functionality helps, sometimes you have to resort to Google to find the settings you want, sometimes it's somewhere else.

Traditional Start Menu

At some point in recent history, KDE wanted to mimick the Vista start menu, which is just as awful in KDE as it is in Windows. To replace it with a traditional start menu, right-click the panel and select Panel Options / Add Widgets. Drag and drop the Application Launcer Menu to the panel. To reposition it in the panel, click the Panel Tool Box at the right end of the panel, select the button, and move it to left. To remove the default launcher, right-click it and select Remove this Application Launcher.

While you're viewing the Panel Tool Box, also select More Settings / Auto Hide. This gives you plenty of more space in the already too small screen.

Desktops and Keyboard Navigation

One of the most important features in KDE is built-in desktop navigation. It has multiple desktops in which you can group windows. These were actually disabled after installation for some reason. To configure them in Control Panel, select Workspace Appearance and Behavior / Workspace Behavior / Virtual Desktops. Often the default is four desktops, I like to use eight. After using same configuration for 15 years, navigation has come pretty easy.

Very importantly, you can navigate between the desktops quickly from keyboard, just like you can navigate between windows with Alt+Tab and Alt+Shift+Tab. The keyboard navigation was actually the reason why I switched to it some 15 years ago from fvwm2 (don't even ask what that is).

The problem is that the proper desktop navigation keys are no longer enabled by default. In fact, because of a bug introduced in Kubuntu 11, they can't be configured from any of the settings at all! The only way to set them is to edit
.kde/share/config/kglobalshortcutsrc and set the following:
Walk Through Desktop List=Meta+Tab,none,Walk Through Desktop List 
Walk Through Desktop List (Reverse)=Meta+Ctrl+Tab,none,Walk Through Desktop List (Reverse)
("Meta" means the "Win" key.) Strangely, the issue was fixed in last October (2011), but the fix was apparently not included in Kubuntu 12.04.

Because of another bug, it's no longer possible to use Win+Shift+Tab in KDE. The keyboard combination simply doesn't work. It was quite annoying to lose that shortcut, as I used it for al-most 15 years, until it was broken in KDE 4.

To get the settings in use, you need to restart KDE by logging out and in again.

Basic Window Management

Unbelievably, KDE windows do not have a "Minimize" button by default! The only way to minimize them is to click the window menu (at the top-left corner) and select Minimize. To enable a Minimize button, you have to customize window buttons. In the Control Panel, select Workspace Appearance and Behavior / Workspace Appearance / Window Decorations, then Configure Buttons. In the dialog, you can drag&drop buttons, such as the Minimize, to the window title bar.

To be able to minimize windows from the keyboard, the shortcut is defined entirely elsewhere in the Control Panel. Select Common Appearance and Behavior / Shortcuts and Gestures / Global Keyboard Shortcuts, and then select KWin in the KDE Component. So, I have to know that this simple shortcut is part of this "KWin" thing, reall obvious. There, set the Minimize Window button to Win+- (Meta+-). While you're at it, you could also set the "Maximize Window" to Win++ or something.

Forcing Windows to Particular Desktops

Normally, when an application opens up a child window, for example a warning, it appears in the current desktop. This is not normally desirable, as it messes up the grouping of windows in desktops. For example, if you have Skype pop up chat windows automatically, you soon have them in every desktop. It becomes a problem.

You can force the windows of a particular application to always open in a fixed desktop. In Control Panel, select Workspace Appearance and Behavior / Window Behavior / Window Rules. The configuration is somewhat complex so I won't go into much details.

You can actually do really many things with the functionality, it's almost like
programming. You can control the desktop, size, positioning, and countless other parameters of windows.

And of course, KDE allows saving the "session", so that after you shutdown the computer and start up and log in again, it restores the session with all the windows. The behaviour can be configured in Control Panel in System Administration / Startup and Shutdown / Session Management. You can choose to save the session automatically when logging out, or just manually, or not at all. Restoring does not restore the applications to the same state though. For some applications, it can save some state parameters, such as the current folder and such, and even which document you were editing. How much state information is restored depends on the application.

Optimizing Performance

It isn't really meaningful to have flashy graphics effects when using a slow netbook. While the basic 2D hardware acceleration seems to work quite well with the GMA 3600 graphics adapter, some effects can be really hard on the poor GPU. In the Workspace Appearance and Behavior / Desktop Effects, disable Enable desktop effects at startup and "Various animations".

You could set the "noatime" option in /etc/fstab. Normally, Linux keeps record of the latest access time for each file and directory. You can see the access times for example with "ls -lu". That recordkeeping requires writing to disk, which takes a bit time, and with flash disks would also consume the prescious rewrite cycles. Just edit the file (with sudo) and add the "noatime" option in the options column, separated with a comma. The setting is used after the next boot.

I am sure there are tons of other optimizations you could do, so the above are just the starters.

Update: The D270 came with just 1 GB of memory, which seemed to fill up pretty fast with KDE 4 and especially when running Java stuff. I got a 2 GB comb and now it works much faster.

Remaining Issues

The remaining problems are:
  • External display (VGA or HDMI) does not work and I have found no mentions how it should work. Apparently it is possible to get it work if they sell the D270 preinstalled with Linux.
  • The keys for changing display brightness do not work. The issue is known with the Aspire One and should be solvable.
  • Kwin has crashed once or twice during a day. This issue is really annoying on my home desktop computer as it can occur several times in an hour. I hope it isn't as bad.

Monday, June 11, 2012

Transit of Venus in Lapland

Last week was the transit of Venus between Earth and the Sun. This is a rare phenomenon that occurs just twice in 120 years. The last time was in 2004, when I was able to observe it in Turku, and the next time is in 2117. While the event has little astronomical significance today, it was quite significant historically, as it was used to determine the scale of the solar system. As I'm a bit interested about the history of astronomy, this was something I didn't want to miss.

So, last Monday I packed my car and headed towards Lapland. Well, actually on Tuesday morning at 2 am, as packing took a bit longer than I had planned. I drove all night and all day, taking just a short nap. The weather was a big question. Most of the Southern Finland was clear, as was Lapland, but the forecasts were changing more quickly than I could drive with my car. I had to make my final decision at Sodankylä and head either towards Utsjoki in the "head" of Finland, or to Kilpisjärvi in the "arm". I chose the arm over the head.

I had never been at Kilpisjärvi before and it was quite beautiful area, in all its barredness. The Kilpisjärvi lake was still almost completely frozen and there were many groups of reindeer on the road.

As was almost expected, it was totally cloudy when I arrived in Kilpisjärvi at Midnight, just an hour before the transit would begin. So, with 1400 kilometers behind in 22 hours, I turned back. If I had not, I would probably have completely missed the event. After driving some 100 km, I got a very short peek of the Sun at around 01:15, just a bit after the transit had begun, but I had to drive yet another 100 km before I found an area free of clouds.

Well, there it was, the Midnight Sun, hovering low behind the hills. It was unfortunate that I had missed the beginning, because measuring the time from the first to fourth or second to third contact was how the scale of the solar system was calculated using the parallax between different latitudes on Earth.

So, I continued driving to East, trying to find even better spot, even one with other amateur astronomers. I knew there was a group in Saariselkä, on top of the Kaunispää fell, some 400 km away, but while driving there I encountered another cloudfront and had to turn back. So, I settled on the top of the Levi fell, where there is a famous skiing center.


I had also my 30-year old RET-45 telescope with me for visual observations. It was a bit unstable and the secondary mirror was a bit loose, so using it wasn't exactly easy. I tried to take some photos through it with my cell phone, but wasn't successful. So, my main instrument was my Canon 40D with a 700-300 mm f/5.6 tube. It wasn't really long enough, but what could I do.

I left the Levi after some hours and observed the third and fourth contacts at a parking place nearby. I stopped there because I had noticed couple of German amateur astronomers there, taking photos of the phenomenon.


Trekking in Lapland

As I was in Lapland, I wanted to see it a bit. Just by coincidence, my brother had rented a cabin there for a few days and I was able to stay there for some nights. I visited mainly the national park around the Ylläs fell. There were quite a few interesting places.

Near the Ylläs fell and the Äkäslompolo village lie two very deep saivo lakes, Äkässaivo and Pakassaivo. The saivo were though to be sort of bottomless lakes that lead to the Underworld. In the other world, there lived some other people. There were also couple of sacred seita stones nearby. I took walks around them on Wednesday, Friday, and Saturday. On Thursday I had to work most of the day - isn't Internet wonderful? I logged four geocaches.

On Saturday evening, I went for a short trip over the Aakenus fell. It was a 17 km nature trail that goes over the fell and through some marshes. On the Eastern side of the fell there were remains of a German Junkers Ju-52 transport plane that had crashed in the fell during the 2nd World War. One of the crew had survived the crash, but was injured and killed himself as rescue proved hopeless. After the rescuers arrived after 2 months, they found a puppy at the site. It had survived by feeding upon the crew...

At the midway of the trail, there was a "Porokämppä", literally "Reindeer Hut", a small wilderness hut, which is free for trekkers. It was quite comfortable and I stayed there overnight. In the Sunday morning, I released Vaadin 6.8.0, as the location was more than convenient for our reindeer-themed product.


I arrived back at my car a bit late in the afternoon and headed back to Turku. The drive 1000 km south took almost 12 hours, so I arrived home at about 6 am. I was quite tired and slept a bit long.


Well, the trip was quite interesting. As I had left everything extra off my car (roof box, rack, bicycle), I managed to squeeze the gas consumption to well under 7 l/100 km. Next time I would probably take my kayak with me, or the roof box, which would raise the consumption a bit. It's usually been around 8 l/100 km with the roof box.

Tuesday, March 20, 2012

New revision of Book of Vaadin is out

Work stuff. We have been getting a new revision of the Book of Vaadin out about every six months and the latest came from print today. This time we didn't increment the edition number, so it is the 1st revision of the 4th Edition. Essentially, one major reason was that we ran out of colors in the Vaadin color palette so the new revision looks just as yellow-orange as the original 4th Edition.

Regardless of the similar appearance, the revision packs almost 100 pages more content. The biggest change is the reorganization into two parts: the core framework and the addons. Some new add-on documentation is included in the core part: Vaadin Control Panel for Liferay, Vaadin IPC, and Vaadin WSRP. The SQLContainer add-on is now part of the core framework.

Of the add-on documentation, the JPAContainer chapter was entirely rewritten couple of months ago and the Calendar chapter was revised more recently.

Unfortunately, there are some outdated parts that went to print. Most notably, there is a really outdated material in the Vaadin embedding section, related to version 5.2. I hope there isn't much Toolkit 4 stuff left, just cleaned some references out at the last minute.

This all applies only to the print edition, which you can pick up for free at some conferences. The web edition is always the latest and it gets all additions on the same day I edit it.

Vaadin 7 is in the works. We hope to get a preview edition of the Vaadin 7 book out in the summer, in July or so. Perhaps it could be red, if we begin the color cycle in the same order we did with Vaadin 6. The color is always a big decision.

Saturday, January 21, 2012

JPA and Vaadin JPAContainer

I've been finalizing the completely rewritten chapter about Vaadin JPAContainer this week. I still need to check that everything really important is included.

I don't have almost any previous experience with JPA, which is kind of good thing when you write documentation about something. That way, you personally know all the questions a beginner would have.

JPA and ORM in general seem pretty important technologies. Whatever your application is, you most probably need some data storage. Using ordinary files is possible, but not near as handy as proper databases. However, stuffing complex class structures through the square holes of database tables was a hell before the ORM technologies emerged. XML databases and NoSQL were much nicer for structured storage.

Some years ago I did some experiments with related technologies, such as JAXB and Hibernate, but using them was a bit too much effort at that time. Using Hibernate with Vaadin really required a Container implementation, but there wasn't one at that time. Well, JPA is quite close to Hibernate, and Hibernate is currently one of the JPA implementations.

Vaadin JPAContainer makes things really easy.
// Create a persistent person container
JPAContainer<Person> persons =
JPAContainerFactory.make(Person.class, "book-examples");

// You can add entities to the container as well
persons.addEntity(new Person("Marie-Louise Meilleur", 117));

// Bind it to a component
Table personTable = new Table("The Persistent People", persons);
personTable.setVisibleColumns(new String[]{"id","name","age"});
layout.addComponent(personTable);
So, just one command to get a container bound to data in a database table. JPAContainer is, however, just for binding user interface components directly to data. You can use it to add or edit the data, but using pure JPA is much nicer, easier, and more flexible for that.
EntityManager em = JPAContainerFactory.
createEntityManagerForPersistenceUnit("book-examples");
em.getTransaction().begin();
em.createQuery("DELETE FROM Person p").executeUpdate();
em.persist(new Person("Jeanne Calment", 122));
em.persist(new Person("Sarah Knauss", 119));
em.persist(new Person("Lucy Hannah", 117));
em.getTransaction().commit();
Well ok, here we got the entity manager from the JPAContainerFactory, which makes that a bit easier than normally.

JPAContainer is a commercial product. That shouldn't be a problem if you're coding for a company that can pay the license. For free software, you can use the AGPL license. I've always felt that this sort of dual-licensing scheme is most difficult for "potential startups" where you experiment with a business idea, but do not yet have a company to back it up financially. You do not normally have the money to invest in licenses at that point, and a company might not want to invest much in such experiments either.

There are of course alternatives for JPAContainer. Using pure JPA is quite OK approach as well, combined with BeanItemContainer in Vaadin. There's also SQLContainer. It is also something I don't know about, as I didn't write the chapter myself. I would need to review and reorganize it in next weeks though, and possibly rewrite at some point.

Well, I did make a couple of mistakes while writing the JPAContainer chapter. The first one was trying to just update a really complex design documentation written by someone else, in a topic I knew nothing about. Writing is always a learning experience and it's not sensible to try to write about something very complex that you don't have a clue about. Sometimes, it's best to start from scratch. Unfortunately, I didn't do that when I started, but just over a week before the release.

Another issue is learning by doing. I usually start writing documentation by experimenting how it works, making some example code. This time, as I was in a hurry, I tried to skip that phase. I only started it as the last effort when I was totally stuck, some 4 weeks of struggle behind and 2 work days before the release date. Just in those couple of days, all pieces fell into place and I finally understood how everything works.

Wednesday, January 18, 2012

Wikipedia and Antipiracy Laws

So, if you have noticed, we've had a Wikipedia blackout. I normally use Wikipedia to look up dozens of articles daily, so I'd be pissed if their protest wasn't really valid.

As innocent they sound, the "Intellectual Property" laws are a big threat, really. They are somehow understandable, which is the reason why they exist, but at the same time, they may be a big threat to modern civilization.

You might think that they are not a problem to you, as they only prevent criminals from making crimes. You might even think that you want your intellectual properties be protected.

Their aim is to prevent illegal copying. Artists and others work so that they would get paid, and illegal copying is kind-of stealing from them. So, forbidding illegal copying is rather understandable.

So what's the fuzz about?

Let's consider the problem with DVDs. They use the "CSS" encryption mechanism to prevent unauthorized copying. Fine, excellent, evil pirates suffer, right?

Unfortunately, watching CSS-encrypted movies requires special software that holds a special decryption key. The software is usually free-of-charge, but it's only for Windows, and perhaps for Mac as well. For Linux, which I use, there is no such authorized software for watching DVDs.

Fortunately, some Norwegian guy cracked the CSS key and wrote a decryption algorithm some 10 years ago and now there's "DeCSS", an algorithm to play (and copy) any DVDs.

So, over the years I've bought some 200 DVD movies and I've always watched them with Linux and nothing else. I've never copied a DVD that I've bought, only watched them.

However, using the DeCSS algorithm for any purpose is illegal in Finland. It's been tried in court.

The fact is that, once cracked, CSS became totally obsolete forever. The laws will never have any effect on unauthorized copying. But they will continue to prevent morally right use of your property.

So, pirates who operate illegally of course use the DeCSS decryption to make one copy which they then copy to millions. But people like myself, who buy DVD movies legally, are criminals. Trying to stop a few criminals, they incriminate perhaps millions of Linux-users around the world.

So why should you care? Linux users are somewhat rare, and you're probably not one of them (except if you use any of the 60% of the web or 55% of smartphones or a TV).

Oh, but it also affects Windows users. There's free DVD watching software for Windows as well, such as VLC, which is actually quite popular as it's very good. But it's illegal, as it has to use DeCSS. The laws prevent writing and distributing any free software that you could use to watch DVDs.

Obviously, preventing the use of free software to watch legal DVDs was not the purpose of the laws. It's just a consequence.

It's a good example of a case where somewhat understandable reasons lead to absurd results. Even so, the vast majority of the Finnish parliament supported the law. And there is a lot more IP legistlation on the way.

Oh, did I mention that Finnish consumers can legally copy movies and music for their own use and to friends. We even pay a tax for that when we buy DVD-Rs. But copying by circumventing CSS is illegal.

Given the absurd criminalization and heavy anti-"piracy" lobbying to take away your rights, you should have no sympathy for the movie industry. O'hoy pirates! Go and board them!

So, to SOPA or PIPA...

I'm not personally familiar with the new legistlation initiatives in the USA. As far as I've understood, it's something similar as the recent Finnish laws that allow blocking child porn and peer-to-peer download sites. The laws already have a sad history of abuse. For example, the laws do not allow blocking websites inside Finland, but they've nevertheless done so as there's no possibility to legally challenge the decisions.

The pattern is that "reasonable requirements" can have devastating effects. The current laws are largely based on the assumption that you are responsible for your own publications. The suggested laws place the responsibility on the owners of web servers and internet providers. So, if me or you were to publish the DeCSS code here in the blog, the Blogspot would be considered the "publisher" that is responsible for our writings. To protect itself, Blogspot would need to have editorial review for everything any one of the millions of bloggers write.

This would quickly kill almost all blogs, discussion forums, and websites in the Internet. Also Youtube and such. It would kill the basic freedoms that we take for granted, and most of the Internet.

Part of the Finnish goverment already has plans to expand the blocking further. Some want to block information about drugs and weapons. Then racism of course, blasphemy, information about bombs, porn, denying the Holocaust, undemocratic thought, ... anything to protect the children, leaders, gods, and corporate owners.

Even though basic IP laws may be necessary, the recent development upholds corporate ownership rights over consumer ownership rights. They are used to buttress dentrimental monopolies and force you to pay vastly overcharged prices, even for basic necessities. They distinguish diversity and freedom, which are the life forces of the modern technological and scientific ecosystem.

So when you see the blackout screen at Wikipedia, just imagine the day when it could be blacked out by your government.

Tuesday, January 3, 2012

Vaadin IPC for Liferay add-on

For Vaadin users, I just finished writing documentation for the Vaadin IPC for Liferay add-on yesterday. The version 1.0 of the add-on will be released tomorrow I think. The add-on is very very useful if you want to have two portlets that communicate with each other on the same page. The add-on uses standard Liferay JavaScript event API, so the other portlets can be any Ajax portlets, not just Vaadin.

Here's how it works:


As a side note, I really like Inkscape for drawing those diagrams. Well, I have no clue how wonderful some "best-of-the-best" vector graphics apps are. But I seem to be able to do practically everything with Inkscape and, after a while, it's not so hard to use. I've also done a nice production pipeline so that I can just save the pictures as SVG and the build scripts for the book do the exporting to PNG automatically. It's not even hard, just one command-line call.

The LiferayIPC is a Vaadin component that you add in the main window (layout). The inter-portlet communication is done between the client-side widgets.
LiferayIPC liferayipc = new LiferayIPC();
layout.addComponent(liferayipc);
...
liferayipc.sendEvent("hello", "This is Data");
To receive an event in other portlets, you define a LiferayIPCEventListener as follows:
liferayipc.addListener("hello", new LiferayIPCEventListener() {
public void eventReceived(LiferayIPCEvent event) {
getWindow().showNotification(
"Received hello: " + event.getData());
}
});
The add-on package includes this nice demo WAR that you can just deploy in Liferay. It demonstrates how to send and receive inter-portlet events.



You can combine this client-side communication method with server-side inter-portlet communication, for example, by using portlet session attributes. You may need to do that for security reasons or if you need to send large amount of data. In such case, you just send a client-side notification that says: "Hey, there's new server-side data available, read it now."

So, go ahead and read the new section in the Book of Vaadin. It explains everything. If it doesn't...go and ask in the Vaadin forum.