I Joined the Dark Side

Back in 2010 I was really looking forward to the upcoming MeeGo phones by Nokia, but alas, it was not to be. My five-year-old phone started dropping its connection now and then for no apparent reason, so it was time to upgrade. Unfortunately all the phones out there seemed to be either mini-tablets or otherwise not living up to my requirements, but a few weeks after I’d stopped looking I almost accidentally came across the Sony Ericsson xPeria ray. It combined two features very important to me: it is not a small tablet and it has a nice resolution, resulting in nigh 300 PPI. Can I get the latter on desktop monitors please, instead of that paltry 1080p HD that seems to be popular right now?

I intend to document some of the apps I’ve installed and why, and perhaps also why I quickly uninstalled some others. To that extent it’s more of a public note to self, but who knows — it might just help to someone else.

Sense Analog Clock Widget
Because none of the other clock widgets were big enough. Call me old-fashioned, but I like a big clock to be the first thing I see. The weather, system info and configurable click actions are a nice touch.
K-9 Mail
The default e-mail client was alright, but not really any better than what my old SE s500i gave me over half a decade ago. Besides, it’s mostly just the default client with some bells and whistles.
K9 Mail Unread Count Icon
Unlike the default e-mail client, K-9 Mail doesn’t display the number of unread messages in its icon. This widget takes care of that.
Keyboard from Android 2.3
I like the default Android 2.3 keyboard better than the one Sony Ericsson included. You can choose your preferred keyboard by long-pressing on a text-input field. Among the advantages are that it’s easier to type symbols and you can change languages by a simple swipe on the space bar. Besides, it has a speech recognition button built-in so you don’t necessarily have to type on the screen.
AndFTP
I tried a few FTP programs. Most were lacking in the SFTP department. However, I think it may not ask before it overwrites files.
Dropbox
Heck, it’s useful. Besides, they give you 500MB of extra free storage.
ArchiDroid
I need to extract files sometimes. Duh.
OI File Manager and Open Manager
I haven’t decided which one I like better, but it’s preposterous that something like this wasn’t included by default. Did I mention my feature phone came with a basic file manager?
Barcode Scanner
Very straightforward. It scans those funky QR code blocks without any fluff.
QR Bookmarklet
This one actually isn’t for my phone, but for my regular browse. I saved it among my bookmarklets and gave it the nickname “qr”. Now if I want to open any page on my phone, I can just type “qr” and use Barcode Scanner.
Opera Mobile and Opera Mini
Are any other browsers even in the same league? Mobile for Wi-Fi, Turbo for when a real browser might be required on the go, and Mini for true data saving. Also consider Firefox. The default Webkit browser is bearable, but basically awful. Note that while Opera Mobile supports options like site preferences, adding them is a bit of a pain due to the lack of a simple interface.
Battery Widget
I like a big battery indicator — and the little one it adds to the notification bar has an actual number so you know what’s going on.
Screebl Beta
The best argument for those motion sensors yet. It disables or holds back the screen timeout while the phone is in your hand and can speed it up when you lay it down.
Timeriffic
Again, it seems like this should be included by default. Set your phone up to stfu at night and whenever else you don’t want it to ring. You can also change some other settings if you want, but for me it makes more sense to turn e.g. Wi-Fi on manually.
OpenOffice Document Reader
LibreOffice is my preferred office application after HTML + CSS rendered to PDF with Prince. I may want to look up something in one of my documents on the go.
wifi AutoSyncAutoToggle widget
I don’t really want my phone wasting CPU or data on syncing unless I’m on WLAN. This takes care of that. Don’t forget to tell your applications to obey this setting. Other applications, most notably Google Play Store, don’t necessarily live by this setting, but sport options like “update or sync over Wi-Fi only.”
SD Tools
I don’t know if I’d recommend installing it per se, but benchmarking the speed might interesting for comparison.
Maps With Me
It’s a lot like Google Maps, except it’s based on OpenStreetMaps and offline. There are more OSM apps out there, but most I’ve tried seem to be less fluid, uglier, or default to turning the GPS on. I’m just looking at having a decent 2D map just in case — I’ve got an actual GPS with a bigger screen (albeit sadly with a much lower PPI value) for driving. Surprisingly, although I also gave a few commercial applications a try, their 2D maps didn’t seem nearly as usable as the Google Maps or Maps With Me varieties. The commercial apps have loads of POIs though, which might sometimes be useful.

Aard Dictionary
In a similar vein, I’ve now got The Collaborative International Dictionary of English and the entirety of Wikipedia on my phone. It’s not only useful for when you don’t want to use data: it’s actually really, really fast. There are more dictionaries available, or you can make your own. The only downside I can think of is that SVGs (which presumably shouldn’t take too much extra space) are missing from the files.

Android is certainly usable, but ultimately it’s too Apple-ish for my tastes. It’s also a bit annoying that by default everything’s set up to use data all the time. I understand that connectivity is a big factor of the device, but it’s no wonder people complain about low battery life if their phones are synchronizing all kinds of things every few minutes. If I’m on the go I can live with checking for new e-mail manually to conserve both data usage and battery life. Ultimately, while I’m happy with my new phone, I hope real GNU/Linux will be available before I have to buy a new one again.

Comments

Using WordPress Excerpts in Meta Description

For a long time I’ve been aware of the fact that few, if any, WordPress themes seemed to do anything with the META element’s description feature. I never bothered to look into a solution, especially since I never used to add excerpts to my posts half a decade ago. However, I’ve bothered to do so ever since I started notifying people about updates on Twitter. It already makes the search results much more readable if you’re looking for something in the archives of this site, and I figured I should do the same for search engines.

Some uneventful searching later I found what I was looking for, but it definitely wasn’t right for me: I’ve got a huge volume of posts without any excerpts, so printing empty descriptions no matter what would be silly at best, and besides there are more descriptions out there than merely those of posts. After all, categories and even my site itself have a description as well. The comment by Matthew Slyman was much more to my liking, which I then customized as follows:

<?php
$desc;
if ( is_single() ) {
	$desc = get_the_excerpt();
}
elseif ( is_page() ) {
	$desc = get_the_excerpt();
}
elseif ( is_category() ) {
	$desc = category_description();
}
elseif ( is_home() ) {
	$desc = get_bloginfo('description');
}
$desc = trim(strip_tags($desc));
if (!empty($desc)) {
	echo '<meta name="description" content="';
	echo $desc;
	echo '"/>';
}
?>

Add the whole thing anywhere in your HEAD element in header.php. If excerpts seem to be missing from pages, there’s a simple solution. If you want to reuse the code above for some reason, wrap some sort of function around it and stick it in functions.php. Enjoy.

Comments

OCR Text in PDF with Tesseract

Since I had some scanned PDFs which I wanted to change into plain text, I looked into OCR solutions for Linux: as it turns out there are some pretty good options. I decided to go with Tesseract; you’ll need to install one or more language packs along with it. Unfortunately it only handles TIF files as input, so I needed a simple shell script to automatically convert PDFs to TIFs. This is what you’ll need to install:

aptitude install tesseract-ocr tesseract-ocr-eng tesseract-ocr-nld imagemagick

You might notice ImageMagick in there, which is just useful to have. Heck, even if you’re not interested in OCR you should install it right now and read the manual. In any case, it’s used in the shell script I wrote to assist my OCR-ing. I picked up a script from the Ubuntu Forums, but for some reason it was wasting CPU cycles and disk space with useless conversions to an intermediary format: ImageMagick can convert PDF straight to TIF.

#!/bin/bash
#ocrpdftotext
# Simplified implementation of http://ubuntuforums.org/showthread.php?t=880471

# Might consider doing something with getopts here, see http://wiki.bash-hackers.org/howto/getopts_tutorial
DPI=300
TESS_LANG=nld

FILENAME=${@%.pdf}
SCRIPT_NAME=`basename "$0" .sh`
TMP_DIR=${SCRIPT_NAME}-tmp
OUTPUT_FILENAME=${FILENAME}-output@DPI${DPI}

mkdir ${TMP_DIR}
cp ${@} ${TMP_DIR}
cd ${TMP_DIR}

convert -density ${DPI} -depth 8 ${@} "${FILENAME}.tif"
tesseract "${FILENAME}.tif" "${OUTPUT_FILENAME}" -l ${TESS_LANG}

mv ${OUTPUT_FILENAME}.txt ..
rm *
cd ..
rmdir ${TMP_DIR}

This may not suit your needs, but I think as a starting point it’s a step up from what the Ubuntu forums gave me.

Comments

Word Count

Since I wanted to know the actual number of words in a paper in near-MLA format and couldn’t find my previous (simple) PHP script, I reimplemented an equally simplistic word counter in Javascript. It strips out citations between parentheses. Suggestions welcome and use at your own risk.

Comments

Multiple Monitors: Enabling And Disabling With the Aid of nvidia-glx

As I wrote last year, I wish to “automatically output whatever video I’m playing in fullscreen on another monitor.” Because the other monitor isn’t next to my main monitor, most of the time the output doesn’t have any practical purposes. That isn’t the biggest problem, although you might want to consider Mouse Jail. However, I recently changed from Nouveau, the open-source nVidia drivers, to nvidia-glx, the proprietary nVidia drivers that offer all the latest and greatest OpenGL acceleration: I wanted to play Achron.

After extracting the Achron archive, it turned out that the game wanted to spread across the entire virtual space available, i.e., across both of my monitors. Disabling one monitor is easy enough, but it would have to be automated. Besides, figuring out how to automate this would be a fun exercise in itself.

First of all, there were some issues with xorg.conf. nvidia-settings can generate one, but it’s not the greatest and requires some manual modification, if only to make sure your own mouse remaps and what not aren’t left behind. What we’re interested in is the section where it talks about metamodes. I thought I’d need two of them to enable easy switching: one with the second monitor enabled and one where it was disabled. Since I only actually use the second monitor for VLC video output, it should be disabled by default and enabled only for VLC: Option "metamodes" "DFP: nvidia-auto-select +0+0, CRT: NULL; DFP: nvidia-auto-select +0+0, CRT: nvidia-auto-select +1280+0". Alas, if only it were this simple. As it turns out, now the graphics driver creates a gigantic virtual display space in order to accommodate the largest resolution metamode, allowing you to pan around in it. New plan: we disable the second monitor on boot and dynamically add a metamode when starting VLC. The line in xorg.conf now looks only like this: Option "metamodes" "DFP: nvidia-auto-select +0+0, CRT: NULL".

So, how to add metamodes on the fly? Well, the nvidia-glx driver comes with this nice little utility called nv-control-dpy. Based on that I wrote the following shell script to start VLC:

#!/bin/bash

# Check if the desired resolution is available and if not, add it. The check isn't really necessary for proper operation but it keeps down error output.
[[ "`nv-control-dpy --print-metamodes`" !=  *@1920x1200* ]] && nv-control-dpy --add-metamode "DFP-0: nvidia-auto-select @1280x1024 +0+0, CRT-1: nvidia-auto-select @1920x1200 +1280+0"
xrandr -r 51.0 -s 3200x1200

# See http://www.andymillar.co.uk/blog/2010/03/17/limiting-vlc-memory-usage/
source /etc/profile
ulimit -v 1048576

/usr/bin/vlc $@

# Check if there's still an instance of VLC running.
# $$ is the process's own PID; testing the exit code of pgrep vlc for success wouldn't work 'cause this script itself would still cause that to test positive. Incidentally, see how to check for exit codes at http://linuxcommando.blogspot.com/2008/03/how-to-check-exit-status-code.html (Yes, this comment is all based on me testing something and wondering for a minute or so why my script wasn't working correctly.)
# To check that you can try
#somecommand  argument1 argument2
#RETVAL=$?
#[ $RETVAL -eq 0 ] && echo Success
#[ $RETVAL -ne 0 ] && echo Failure
[ "`pgrep vlc`" == $$ ] && xrandr -r 50.0 -s 1280x1024

The nVidia driver plays a little trick on X11 by pretending the different metamodes have different refresh rates. In some future update this should no longer be necessary, but for now that’s how you can easily switch between them with xrandr. The script is named vlc and added to my PATH in such a manner that it overrides the default link to the VLC binary. I think that should be enough information to adjust this to your own personal needs.

Comments

Behind the Scenes

Half a year ago’s post, about why we decided to buy a washing machine two years ago, was actually written back in September or October of 2009. I didn’t post it at the time because it made me aware I had no table styling. I then proceeded to make a testcase for table styling, which I presumably finished before October 2009 was over.

Sadly for the post, however, I then forgot about it till last year, when I found my table styles testcase during my switch from NTFS to ext4. This had the side-effect that I started incorporating various stylesheet upgrades I’d written over the past two or three years, giving you a different default width and fancy schmancy transition effects today — or actually already back in May 2011 because that’s how long it took me to actually publish this. I really do need to stop putting things in drafts for potential revision without ever picking them up again.

Comments

Uw Kinderen — Your Children

I thought this poem by Annie M.G. Schmidt was quite amusing; it also nicely characterizes the prose texts in the bundle from which I took it. The poem’s short, so you’ve got no excuse not to read it — assuming you speak Dutch, of course.

Een sprookje voor het slapen gaan
over de bijtjes en de maan,
over de elfjes teer en fijn,
die Artistiek Verantwoord zijn,
en over ’t zoete bloemenfeetje…
uw kind vindt het wel mooi, een beetje…
maar gooit de elfjes grif terzijde
voor strips met nare blote meiden.
Een kind is al zo gauw tevree:
een overval — een moord of twee.

Kind, huil maar niet, wees maar bedaard:
ik gooi Rie Cramer in de haard.
Hier is de strip, met stromen bloed.
Beng, weer een lijk. Dus wees maar zoet.

From Voeden, verschonen en in de wieg mikken. 2009, Querido.

For the speakers of English among us, I hereby offer you an impromptu translation:

A fairy tale for sleeping soon
about little bees and the moon,
about little elves frail and fine,
of artistically sound design,
and about the sweet flower fairy…
your child thinks it's nice, not very…
but promptly the elves aside it whirls
for comics with nasty naked girls.
A child is easy to entertain:
a robbery — a murder or twain.

Child, don’t cry, just be as if in a daze:
I'll throw Rie Cramer1 in the fireplace.
Here's the comic, with streams of blood.
Bang, again a corpse. So be good.

1. Rie Cramer is a Dutch author and illustrator of books aimed at little children.

Comments

Debian: International Fonts

Ubuntu comes with a large swath of international fonts installed by default, but Debian requires a little more attention. Although I can’t read the languages, I can recognize which script is which. Besides, boxes are just ugly.

  • East Asian: apt-get install ttf-arphic-uming ttf-wqy-zenhei ttf-sazanami-mincho ttf-sazanami-gothic ttf-unfonts-core (source)
  • Indic: apt-get install ttf-indic-fonts (source)
  • All together: apt-get install ttf-arphic-uming ttf-wqy-zenhei ttf-sazanami-mincho ttf-sazanami-gothic ttf-unfonts-core ttf-indic-fonts

These are merely the ones that I missed the most. I may update this post in the future.

Comments

Mounting filesystems with fstab

If you’re just switching from Windows and you don’t like to enter passwords every time you want to access your disks, fstab is what you need. Of course it also applies to e.g. ext4 partitions that you didn’t assign a mount point during the installation of your OS, but when you’ve come that far along you probably already know this.

By far the best explanation of fstab I’ve found was on ArchWiki, so I won’t waste my time reiterating what is stated there. I’ll merely try to further clarify a few things that were less immediately obvious to myself and needed a little experimentation.

In many ways fstab is what I always wanted in Windows. For a long, long time I’ve maintained a C partition (dedicated Windows, so I could wipe it without really affecting anything), a D partition (my primary data container), and later, as I added more HDDs, I think I got up to G. There are some hacks available, like NTFS junction points, but they don’t really protect against the fundamental flaw of drive letter assignment compared to the much more sensible mechanism of mount points.

When you mount a partition manually through your GUI, by clicking on it and entering your password, it creates a temporary entry in /etc/mtab; this entry can be used to as a starting point for fstab entries. However, for more reliable partition mounting you need to use UUIDs. You can obtain this using blkid /mnt/sda1, where /mnt/sda1 should be replaced with whatever partition you want to print a UUID for. This command needs to be run as root, i.e. with su or sudo.

# Use 'blkid' to print the universally unique identifier for a
# device; this may be used with UUID= as a more robust way to name devices
# that works even if disks are added and removed. See fstab(5).

If you prefer to use a GUI, there are some options, but I haven’t tried any of them.

Disk Manager
http://flomertens.free.fr/disk-manager/
PySDM
http://pysdm.sourceforge.net/
fwfstab
http://www.diffingo.com/oss/fwfstab

Comments

Why Opera’s XHTML Error Handling Is Superior

I found this old, unfinished post in my drafts. I’m not quite sure when I originally wrote it, but it was over a year ago. Rather than updating the content I decided to publish it as is, as I’m not sure why I didn’t, with a small addendum at the end.


I made a little compilation of the various error messages displayed by browsers upon encountering an XML syntax error. Firefox (Gecko) has the unfriendly looking error on top, Chromium (Webkit) renders the page up to the error, but shows a large error message (albeit not at all useful like in Opera & Fx), and for Opera I included 10.10 and the latest 10.50 pre-alpha build. Note that it’s just the styles behind the error message that changed a bit: the content and helpfulness of the error message is still the same. I’ll run it down a bit more:

  • Firefox displays an error message that’s only useful if you already know sufficiently much about X(HT)ML, whereas Opera’s error message not only highlights more clearly where parsing failed — although ultimately this difference might just be one of preference. More important, its error message might just helpfully link you precisely where you need to go to learn how to avoid it. When I first started messing about with XHTML back in ’03 or so, I probably would’ve appreciated it if Opera had done that. At the time Opera behaved the same as Fx does now.
  • Chromium displays an error message that doesn’t even manage to clearly indicate what’s the problem. This compares negatively to Fx and Opera highlighting the &.
  • Chromium renders the page up to the problem, which may result in a get out of jail free card. The error message doesn’t seem very annoying, but if the error is in the middle of the page it’ll still be in the way. In my sample page it’s at the end, however. (My example page is basically a standard installation of phpGraphy on which I decided to switch to application/xml+xhtml because it claims to be more or less XHTML compliant now — I had to fix all the unclosed meta and link tags first.)
  • Despite rendering the page, you won’t be able to see the page fully in Chromium. You will with Opera’s reparse as HTML function.

I hope that clarifies why I think Opera’s handling is best, both as a user and as an author.


This blog post is now outdated. You can return to the behavior I hailed by disabling the opera:config#UserPrefs|AutomaticallyreparseXHTMLwithparsingerrorsasHTML option.

Comments

Older Entries »