Archive for the ‘Tech’ Category

LibreOffice spell check not working in Lubuntu

Wednesday, November 12th, 2014

I installed LibreOffice into Lubuntu, but the spell checking didn’t work.

It turns out I need to install a dictionary for my locale:

sudo apt-get install myspell-en-gb

I needed to restart LibreOffice, and then I got spell checking as I typed.

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

Thursday, November 6th, 2014

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

Wednesday, November 5th, 2014

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

Saturday, October 18th, 2014

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

Friday, October 17th, 2014

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: