OpenID Broken on WordPress.com [Updated]

1. February, 2011

If you’re trying to use your wordpress.com blog to login to some site via OpenID, you’ll see this error:

Unable to log in with your OpenID provider:

Cannot decode Key-Value Form because a line was found without a ':' character. (line 3: '<head>') 

See also:
http://meta.stackoverflow.com/questions/76841/cant-log-in-using-wordpress-com-openid

http://en.forums.wordpress.com/topic/openid-not-functioning

[Update] According to the WP support “We have corrected a glitch and the problem should no longer be occurring.”

At least for me, it works again.


Finally: Homebrew for PS3

10. January, 2011

As the last console, the PS3 has been opened for homebrew software. Fetch your SDK.

Kudos go to ~geohot.


PS3 was hacked

6. January, 2011
Tux, the Linux penguin

Image via Wikipedia

Like so many people, I was upset that Sony discontinued support for Linux. I understand that it was a security risk (people were dabbling with the encrypted hypervisor and the encryption) but no one really cared enough to actually invest the huge amount of time necessary to really break it. I also understand that supporting Linux was a cost issue for Sony while it didn’t bring that many customers. At the same time, I knew I could run Linux on my PS3 but never did.

So it wasn’t an actual issue for me either, it just upset me. I bought the PS3 for many reasons and being able to run Linux had been one of them. Not the major point but I still got mad when they took that from me.

At the 27C3, they showed how it was hacked but I was intrigued by short appearance of a guy who had analyzed the time it took to break a console and why it was hacked. While piracy is a side effect of hacking a console, it’s probably not the driving force. The statistics say that it took at most 12 months to hack a console make Linux run. The PS3 was unscathed for three years – until Sony stopped support for Linux. After that, the hackers really dug into it and – what surprise – they pwn3d it.

Made me wonder why Sony dropped support? As we know from the history of Microsoft, piracy is actually a major driving force for software sales. The calculation goes a bit like this: If you don’t want to pay for something, it’s hard to force you. But once you’re used to something, and you like it, you stick with it. A good example was Office 97. It wasn’t that great but companies were forced to buy it quickly because all people working at those companies had got free, time limited copies along with their PCs. I’ll let you assume how many people bought the product after the time was up.

The thing was: People took work home (good for the companies), work on it and then bring it back to work. Then, something happened: The “old” Office 95 did display a warning, about 90% the size of the screen “I can’t open this! You may lose your work! Help!” So suddenly, there was a strong pressure on the company to upgrade 95 to 97 – because everyone had got a free copy of Office 97!

The key here is to be able to balance sales with piracy. Microsoft knows the Spiel best: Really smack down on people selling pirate copies but leave the home users alone. C= (and the Amiga) couldn’t play it. In the end, piracy overtook sales and the platform died. The lesson we learn here: Piracy is something that must be managed carefully. No piracy and sales will be much lower than they could be; too much and you go bankrupt.

So here is my heretic thought: Maybe Sony didn’t have enough piracy. ^_^

References: Video of the 27C3 talk “”. Go to the documentation site and search the download links for “console_hacking_2010”. The statistics part is at 05:33.


pygments syntax highlighting

4. January, 2011

Need a good syntax highlighter? Check out Pygments.


Paul Bilnoski: On Exception Management

3. January, 2011

If you want to widen your understanding of exceptions and how to handle them, you should read Paul Bilnoski’s post “On Exception Management


Need something in SWT?

2. January, 2011

When the guys at SWT can’t be bothered, there is now an alternative: A little project to create drop in replacements for stuff that you want in SWT. Check it out here.

In the same place, you can find a slightly modified version of StyledText. When I say “slightly modified”, then I mean “at the API level”. I’m currently heavily refactoring the code inside to make it maintainable and more easily extendable.

Some achievements from the latest hacking session:

  • It’s now possible to write tests that verify the rendering of StyledText
  • Bullets are managed and rendered in their own special classes. Same goes for StyleRanges. That reduced the size from 1’700 lines to just about 1’100 lines – not that much but a good start. This also means I can write tests that just check the management of StyleRanges – without bothering with a main loop, resource management, etc.
  • There are a bunch of helper methods to debug the model behind your text. They can dump the text in readable form.

What’s next? I’m really starting to think about turning StyleRange and TextStyle into independent classes. Right now, the former inherits from the latter which means there is some really ugly code when it comes to reusing styles, merging styles, font handling, etc. One effect is that the current implementation violates the contract of equals() and hashCode(): equals() takes the range into account while hashCode() doesn’t. While that may not have an effect (StyleRanges with the same style just pile up in a hash map), it’s still a sign of a skewed API.

The API would be much more clean if there was a style manager (which you could dispose to free all fonts, colors, etc, at once) and when StyleRanges were just tiny classes that contain a range and a pointer to a style. That would allow to get rid of the ranges int array, we could use Set and List to manage style ranges, etc.

Something that I’ve been testing is hierarchical styles (i.e. styles that inherit from other styles). Works like in word processors where you define a basic style and then derive from that. I’m not happy with the performance right now but I’ve got some ideas.

How to use my version? Simple: Clone the StyledText project and install it. Check the POM to see which dependencies you need in your project. Now replace

import org.eclipse.swt.custom.*;

with

import de.pdark.styledtext.*;

That’s it.


Pestered by deadlocks?

30. December, 2010

Serge Beauchamp wrote a tool to automatically locate and report places where they can occur: Freescale’s Deadlock Preventer is now released!

Details can be found in this blog post.


Another lesson in performance: NIO

29. December, 2010

Remember when I wondered how slow it is to copy data around in memory?

This time, I needed to load a 2MB file from disk and examine it for certain patterns.

The original from jazzy spell checker worked like this: It did a binary search in the file for a code. The code would be at the start of each line and be separated from the correct word by an asterisk:

    AT*wide
    AT*widow
    AT*width
    AT*wight
    AT*wit

The search algorithm would seek somewhere in the file, skip the current line, read the next one, compare the code against the one we look for. If our code was smaller, we would seek backward; if it was larger, we would seek forward. Standard binary search.

Only it didn’t work. The test took 4 seconds to load the file without finding anything. Debugging recursive algorithms isn’t as nice as looking at them …

So I considered a different approach: I would load the whole file, character by character, and remember the lines with the same code in an index. A good time to have a look at NIO, especially the grep example.

Question: If it takes 4 seconds to seek ten times in a RandomAccessFile and read about 2000 bytes from it, how long would it take to read it character by character, examine each line, build an index and then load whole chunks (say, 1KB each) from the file when a word needs to be looked up? Plus the additional work of removing the code pattern from the chunk to produce a list of words …

Answer: 0.3 seconds. That’s more than ten times faster. And I could probably optimize the code some more.

Conclusion: When it comes to performance, measurement beats superstition.

And the new code is easy to understand, and to test, too! ^_^


Fixing problems in models

29. December, 2010

MDD is nice as long as you don’t have exceptions. If you generate 1,000 classes and then one of them needs something special, you’re in trouble.

I think support for applying patches to the result of the code generation step would be a nice feature.


Java tip: Getting most out of exceptions

28. December, 2010

Exceptions should have two purposes: 1. Clean up after an error and 2. help you solve the issue. Sadly, many Java developers often forget about #2.

So you end up with an exception thrown in SignatureFileVerifier (no source). Or even in a native method. The error message is:

Invalid signature file digest for Manifest main attributes

Right. Which tells us exactly … nothing. The stack trace isn’t better:

java.lang.SecurityException: Invalid signature file digest for Manifest main attributes
	at sun.security.util.SignatureFileVerifier.processImpl(SignatureFileVerifier.java:221)
	at sun.security.util.SignatureFileVerifier.process(SignatureFileVerifier.java:176)
	at java.util.jar.JarVerifier.processEntry(JarVerifier.java:233)
	at java.util.jar.JarVerifier.update(JarVerifier.java:188)
	at java.util.jar.JarFile.initializeVerifier(JarFile.java:325)
	at java.util.jar.JarFile.getInputStream(JarFile.java:390)
	at sun.misc.URLClassPath$JarLoader$1.getInputStream(URLClassPath.java:620)
	at sun.misc.Resource.cachedInputStream(Resource.java:59)
	at sun.misc.Resource.getByteBuffer(Resource.java:84)
	at java.net.URLClassLoader.defineClass(URLClassLoader.java:249)
	at java.net.URLClassLoader.access$100(URLClassLoader.java:56)
	at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:268)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
	at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
	at org.eclipse.jface.action.LegacyActionTools.initLocalizedModifiers(LegacyActionTools.java:699)
	at org.eclipse.jface.action.LegacyActionTools.findLocalizedModifier(LegacyActionTools.java:356)
	at org.eclipse.jface.action.LegacyActionTools.convertLocalizedAccelerator(LegacyActionTools.java:167)
	at org.eclipse.jface.action.Action.setText(Action.java:665)
	at de.pdark.epen.editor.actions.ForwardAction.(ForwardAction.java:29)
	at de.pdark.epen.editor.actions.ForwardActionTest.testCreate(ForwardActionTest.java:21)

So LegacyActionTools needs a class. Which one? Since I don’t have the source, how can I set a breakpoint?

Simple: Set the breakpoint in the constructor of the exception! Even native code has to pass through here, eventually.