Watching a movie with two subtitles

Tools to merge SRT subtitles

SRTMerger – Input: SRT, Output: SRT, Different colors, displays both subtitles at the bottom, on top of each other.

2srt2ass – Input: SRT, Output: ASS. One subtitle on the top of the screen, one subtitles at the bottom (possible because the output format is ASS).

DualSub – Input: SRT, Output: SRT; displays them at the bottom, next to each other. This is essentially a hack, so it requires you to specify the font with which your player will display the subtitles in advance – you are essentially creating subtitles for a particular player, and it can be a bit fiddly. On the plus side, this one has amazing options for keeping subtitles on the screen for longer, when possible, as well as smoothing over small timestamp differences.

Player functionality

Subtitler (VLC plugin)

Dictionaries, APIs and Databases, in German and other languages

Aside from the obvious, like Wiktionary, Duden, there is also:

Attempts to parse Wiktionary (collected from SO)

Part of Speech tagging

Mail-in-a-box on OpenVZ

  • Use export DISABLE_FIREWALL=1 before running install (I think the firewall can be made to work, but I didn’t attempt it).
  • With ubuntu-14.04-x86_64-minimal, I get this message on container start: resolvconf: Error: /run/resolvconf/interface either does not exist or is not a directory. Subsequently, DNS in the machine doe s not work because /etc/resolv.conf is empty, and any OpenVZ –nameserver options are not applied. This is because mail-in-a-box installs the resolv.conf package, and per /etc/vz/dists/scripts/set_dns.sh, if that package is install, it will be used to set the nameservers. Going through dpkg-reconfigure resolvconf there seem to be a bunch of approaches, though the interworkings of the whole system don’t really understand, but what worked for me was making sure that /etc/resolv.conf is a symlink to /run/resolvconf/resolv.conf, and that /etc/resolvconf/resolv.conf.d/tail contained my nameserver x.x.x.x instruction.

Tools for self-hosted email

I’ve been running my own mail server for years, using the ispmail setup, and recently I have been looking into replacing it with a slightly more comprehensive setup (with a modern webmail, admin ui), ideally without putting in all the manual work. Here is what I came up with:

Open Source options

sovereign – ansible based, lots of unrelated stuff, but no admin ui for mail.

mail in a box

iRedmail – seems capable, but no cool factor.

modoboa – Administration only

Webmail Interfaces

Rainloop

Mailpile

Roundcube, or successor

Interesting Commercial Mail solutions

FastMail – uses Sieve for filters.

atmail – provides a self-install version; a web interface I really like; pricing seems unclear

I forgot the PIN on my Nexus 7, and then I reset the lockscreen using the recovery mode

  • Your device has to be unlocked, otherwise you are out of luck, I believe (who knows, maybe something can be done using ADB debugging only). Note how unlocking your device makes it less secure.
  • Power+VolumeDown until in fastboot mode.
  • fastboot flash recovery recovery-clockwork-6.0.4.3-grouper.img
  • Go to recovery mode without rebooting, which may reset recovery.
  • $ adb shell
  • $ mkdir /mnt/d && mount -t ext4 /dev/block/platform/sdhci-tegra.3/by-name/UDA /mnt/d
  • $ rm /mnt/d/system/locksettings.db*
  • $ reboot

It is probably possible to modify the settings in locksettings.db individually, though it didn’t work for me on first attempt.

Note: When profiles are used, the data for other users can be found in /data/user/.

Generating reports and invoices in the 21th century

When it comes to generating a PDF from a web app, too many people seem to just take FPDF and fiddle with a whole lot of write(x,y) and y+10 calls. Ugh. That is just aweful.

Back when we were writing desktop apps, supposedly there were things like Crystal Reports. There seem to be a couple ones that have things like PHP clients for web usage (and most seem to be able to access a database directly) – Pentaho, Jaspersoft, BIRT.
I don’t have experience with any of them, but when I look at YouTube videos, I see things like “Eclipse” plugins generating pretty ugly looking tables.

I suppose it is perfectly feasible to work with them, though I shy away from the complexity and unsexiness.

There is a thing called FO-XML. It seems like pretty sophisticated stuff, but I’m not about to start learning a new XML language.

It seems there is an opportunity to do this by using HTML and CSS for paged media.

WeasyPrint can render such CSS to PDF. It has some limitations (no markup in page margins), as does the official spec. There are competing extensions to the spec by W3C and WhatWG.

Meanwhile, commercial alternatives to WeasyPrint like PrinceXML (also Antenna House](http://www.antennahouse.com/) have their own custom CSS extensions.

DocRaptor provides PrinceXML as a cloud service.

The Android lifecycle

The last time I wrote Android apps was years ago, starting with the ADP1 and Android 1.0. Back then, the big deal was the Activity lifecycle. Mind the life cycle events! To reclaim memory, Android may kill your app or your activities at any time, they said. Being economical with resources was the big concern. There was even an onMemoryLow event you could implement to help the system manage memory.

At the very beginning, there wasn’t even AsyncTask, never mind retained Fragments.

I was always trying my damnedest to fit everything properly into the activity lifecycle. Like rotating my Async tasks along with with the activity. And it was always such a pain. I never quite understood why it had to be such a pain, and I guess in my subconsciousness I always realized I was not understanding something. I was never sure how global state fit into the whole concept, and was uncomfortable using it. I only saw the activity lifecycle. As in, how can there be background thread dangling around outside of an onCreate/onDestroy cycle?

Coming back to Android now, and seeing people use neat things like event buses finally caused be to think it through, and I believe I had a personal epiphany.

Android is killing your process, but the documentation claims even today that Android may destroy activities to save memory (“the system might destroy that activity completely if it needs to recover system memory”). Is Android “killing” your Java objects? How would it even do that? Is the Android SDK in your process doing some kind of object management when instructed by the system? The idea seems strange, and apparently it isn’t really the case.

The trick for me was to forget about the Activity lifecycle as being memory-related. I think of it now as an implementation detail of the UI framework you are using, possible helpful in terms of resetting state, and both useful and cumbersome in terms of configuration/layout loading.

I had to stop thinking of my app as merely a bunch of Android primitives (activities, services, broadcast receivers) into which I have to fit everything. While these primitives admittedly are actual concepts within Android itself, the specific implementation, including the lifecycle stuff, is technically up to your process.

Instead, if I consider my app a holistic, proper process, simply running on a device where it may be regularly killed, then I’m no longer afraid of using global state, background threads, an event bus, or anything else outside of the framework primitives. I just have to remember: The app may be killed once in the background, so for important things, tell the system you are doing service-stuff right now.

Here are some resources I found helpful:

A Recipe for writing responsive REST clients on Android – How to write a modern Android app.

AsyncTask is bad and you should feel bad – Using AsyncTask outside of activities. Why not just use a thread? The AsyncTask will return in the main thread, and cannot return between in-between a configuration change. Still, a sticky event in EventBus, or a producer in otto might make more sense.

Android Priority Job Queue – If you have a lot of background jobs.

Other things I realized: It is time to upgrade to a 100 character right margin. And the right way to use a SQLite database.