Introducing MemoryStorage

Web Storage API

web-storage
HTML5 gave us this beautiful thing: consistent cross-browser local storage of ‘vast amounts’ of data on the visitor’s computer in the form of the Web Storage API. The default quota is 5MB, which is huge compared to cookies. I’m using it in the development of Bridal App. It allows the app to respond near-instant to user actions and continue to function even when offline. All modern browsers support it (on desktop as well as on mobile) so life is great. Right?

Continue reading

Use MySQL utf8mb4 if you want full Unicode support

MySQL’s utf8 is broken

MySQL really made a mess here. What they are calling utf8 really isn’t. Hidden away in the MySQL manual we can read this:

“The character set named utf8 uses a maximum of three bytes per character and contains only BMP characters.”

Loosely translated: MySQL utf8 is broken. Don’t use it.

MySQL-logo

Continue reading

How Java’s text Formats can subtly break your code

Today at work we found a subtle issue that will sometimes break your code in very difficult to find ways. Read this if you don’t like days of bug hunting for mysterious issues only occurring on high-load production machines.

Ever wrote code like this?

private static final DateFormat FORMAT = new SimpleDateFormat("yyyy-MM-dd");

prevent-debugging-headache
Most of us did. It’s the most intuitive way to use a DateFormat to format some Date object as a human-readable String.

Unfortunately, it’s wrong.

When used in a multi-threaded context (e.g. in a Servlet), this will end up breaking. Sometimes. When you least expect it.

Continue reading