Is it ok to represent dates as Unix time (seconds since the epoch) in JSON?

Yes.

If your JSON contains integer numbers that represent Unix time (seconds since the “epoch”), and you parse your JSON to JavaScript, the range of integers that can accurately be represented is -9007199254740992 to 9007199254740992 (ref: EcmaScript standard, section 8.5).

The year 4000AD starts at unix time 64060588815, which is 9007135194152192 less than the maximum.

The year 1AD started at unix time -2177452800, which is 9007197077288192 more than the minimum.

So there are enough numbers.

Using hexdump to represent a binary file in Java source code

To embed a binary file (e.g. a png image) into Java source code:

$ hexdump -v -e '/1 "%3i, "' myfile.png
-119,  80,  78,  71,  13,  10,  26,  10,   0,   0,   0,  13,  73,  72,  68,  82, ...

Copy and paste the output into Java code like this:

private static final byte[] myfile = { (byte)-119,  80,  78,  71, ... };

Disabling screensaver on LXDE

Caffeine wasn’t working for me. I got an error like this:

dbus.exceptions.DBusException: org.freedesktop.DBus.Error.ServiceUnknown: The name org.freedesktop.ScreenSaver was not provided by any .service files

Bug 1280449 contained the solution for me. Thank you Paulius Vitkus:

sudo apt-add-repository ppa:behda/ppa
sudo apt-get remove caffeine
sudo apt-get update && sudo apt-get install caffeine

Android development – saving state

Series: Setup, Menu, Drawing, non-Android, Working, Saving state.

Android apps like Rabbit Escape need to save their state when asked, and restore themselves later. This happens when you rotate the screen, and could happen at various other times. Here’s how I handled that in Rabbit Escape:

Android development – Rabbit Escape really working on Android

Series: Setup, Menu, Drawing, non-Android, Working, Saving state.

Up until now, you weren’t sure to believe my promises that Rabbit Escape really was going to be an Android game, since I hadn’t actually got it running on Android. Well, the wait is over: