Positive logic

20. August, 2010

I just read another great post on Daily WTF (“Boolean Illogic“). Question: Does validation occur when the status is valid?

if (statusIsNotValid.compareTo( Boolean.FALSE ) != 0) skipValidation = false;

Another great example why you should prefer positive logic.


StarCraft 2 on openSUSE 11.3 [update]

13. August, 2010

As you may have heard, StarCraft 2 works on Linux. It’s even officially supported by CrossOver Games. It’s only Silver (which means “runs with minor issues”.

One of the issues is that the game crashes at startup or shortly afterwards. This seems to be a kernel bug.

To solve the issue on openSUSE 11.3, you need to install a kernel with version 2.6.35. Luckily this is pretty simple:

  1. Add the repository http://download.opensuse.org/repositories/Kernel:/HEAD/openSUSE_Factory/  with Yast2 (under “Software Repositories”). Give it any name you like.
  2. I suggest to set the priority to 120; that way, the other repositories will be considered first and entries in this new repository won’t pollute your system unless you ask for them.
  3. Open “Software Management” in Yast2
  4. Open the tab “Repositories”
  5. Select the new kernel repository
  6. Locate the package “kernel-desktop” and select it
  7. Click on the “Versions” tab at the bottom
  8. Select the one with version “2.6.35.1” (the last digit can be different).
  9. Click “Accept”

Yast2 will download the new kernel and install it. After a reboot, you can enjoy StarCraft II.

[Update] I’ve played the first six single player missions and had no major problems so far. The frame rate could be better but that’s about it.

[Update 2, 11th Nov. 2010] Kernel 2.6.36 has been released. You can find it here.


Dynamic mesh painting in Blender

12. August, 2010

Blender has an awesome new feature: Dynamic mesh painting. Visit the blog post for some awesome videos!


Strange text entry behavior in KDE 4.5

11. August, 2010

As I write the last blog entry, I noticed that the cursor was somehow … glued to the last character. In the web browser, the last character would be underlined and in the shell, it would be displayed in reverse. When typing a symbol like comma or tick, I would get an umlaut like ç or é.

The culprit is called SCIM – “Smart Chinese/Common Input Method”. If you look at the running tasks, you should see a small window in the lower right corner of your screen:

SCIM main window

SCIM can get in your way

Click on the icon to quit this beast.

As I found out while writing this blog post, SCIM is pretty dangerous. If you start it in the foreground and then press Ctrl+Z to put it in the  background, all programs which take text input freeze. Stopping SCIM in the middle of a session can also leave Google Chrome dead. Great.


Plasma doesn’t come up after updating to KDE 4.5

11. August, 2010

If the desktop doesn’t come up after upgrading to KDE 4.5, check that the file “/usr/bin/ksmserver” exists. If it’s missing, look for the package “kdebase-workspace-bin” and install it (again) if necessary.


Could not start ksmserver. Check your installation. [solved]

11. August, 2010

SOLVED (see below)

I just upgraded to KDE 4.5 (for openSUSE 11.3, see here for instructions) but it won’t start. All I get is a xconsole with this text:

Could not start ksmserver. Check your installation.

The .xsession-errors log shows that the server unexpectedly dies. I check that all the libraries are there and stuff but to no avail. If I start it from the command line, it says “Can’t connect to X server on :0”. If I use a different window manager, I get “Can’t connect kdm. Use –replace to …”

Will keep trying.

[Update 1] It seems that this is a bug in the package version resolution of zypper. It only updates some packages but not all. So far, I couldn’t figure out which package breaks ksmserver. Using yast2 to install all KDE-related packages from the new 4.5 repository doesn’t help.

[Update 2] The error message in .xsession-errors looks like:

kdeinit4: (ksmserver /usr/bin/ksmserver) Pipe closed unexpectedlykdeinit4: Pipe closed unexpectedly: Resource temporarily unavailable

[Update 3] After some prodding, I found a solution. Here is a recipe:

  1. Run the installation via the one-click install. If one-click is broken for some reason, just invoke /sbin/OneClickInstallUI "http://download.opensuse.org/repositories/KDE:/Distro:/Factory/openSUSE_11.3/KDE4-BASIS.ymp"
  2. This will get you most of KDE 4.5 but not everything, so don’t reboot, yet. If you did reboot, you will have to do the following from the console which isn’t that much fun. If your KDE is broken, select a different window manager in the login screen (like TWM or MWM).
  3. What is missing? First locate the name of your KDE Factory repository. Run zypper lr One line of the output should read “KDE:Distro:Factory” or very similar. Note the value in the column “Alias” for this entry.
  4. Now we can ask zypper to list all updates that it didn’t install: zypper lu -a|grep KDE:Distro:Factory (use the name from above). This can be a long list. Don’t worry.
  5. To install the missing things, restrict zypper to the KDE Factory repository: zypper install --from KDE:Distro:Factory ...package names... Zypper will ask whether it’s OK to change the vendor. Answer “y” (yes).
  6. When zypper lu doesn’t print anything anymore, KDE 4.5 should start.

Next stop: Working around all the new bugs in KDE 4.5.

Maybe related: KDE startet nicht mehr, ksmserver error (German)


New W3C validator: Unicorn

4. August, 2010

The W3C has rolled all their validators (HTML, XML, CSS) into one: Unicorn.


TNBT: Connecting unrelated code

3. August, 2010

Today, I start a new series: The Next Big Thing. I plan to collect all my ideas for the next generation of programming languages.

If you’ve ever worked with I/O in Java, you will have stumbled over the “Closable” API. The idea is simple: If you request a resource from someone, you must tell that someone when you’re done with said resource. Remember garbage collection? That was the very same idea for memory: People eventually forget to free something or free it twice.

Java has two solutions for this problem: Either there is a close() method of some kind or there is nothing. “What?”, I hear you say, “When doesn’t Java offer nothing if you need to release a resource?” When the resource is allocated in place A and used in place B. Just today, I had an example where I created an InputStream, wrapped that in an XML InputSource and passed that to a class in dbunit which would eventually create an XML parser. In a new thread. What was I supposed to close the stream? There was no way to do it since I didn’t create either the thread nor the parser. The code in dbunit couldn’t do it either because the XML API has no way to say “close input when done.”

What I needed was a way to say: When the thread created deep inside dbunit terminates, then close the stream.

Or more abstract: I needed a way to create a piece of code at runtime and attach that to a certain point in the execution flow of my program.

Sounds like AOP, doesn’t it? Yes but AOP comes with two problems which effectively prevent its wide-spread adoption:

  1. The syntax for cutpoint definition is too complex
  2. There is no way to get an error if a cutpoint doesn’t exist. I want my compiler to warn me if the code in dbunit changes.

So that’s my first feature of TNBT: Adding code to specific places in existing code with a simple API. This is also known as “patching”. It would solve the copy’n’paste problem (“Oh, that code does almost what I need … let’s copy it and change one line”). Now you can make your compiler copy the code for you.

Related Articles:

  • The Next Best Thing – Series in my blog where I dream about the future of software development

Bored?

2. August, 2010

Your current assignment bores you or you need a couple of minutes off with a puzzle that is both rewarding and useful? Spend it on Project Euler:

Project Euler is a series of challenging mathematical/computer programming problems that will require more than just mathematical insights to solve. Although mathematics will help you arrive at elegant and efficient methods, the use of a computer and programming skills will be required to solve most problems.

The motivation for starting Project Euler, and its continuation, is to provide a platform for the inquiring mind to delve into unfamiliar areas and learn new concepts in a fun and recreational context.


Starting the network with openSUSE’s rescue system

1. August, 2010

To start the network after booting into openSUSE’s rescue system:

dhcpcd eth0