Thoughts on HTML5’s <time> element and other semantic info on the web

I just read about the <time> HTML5 element, and how it was introduced, then removed, and then re-introduced. While I think proper syntax, consistency, etc. are important, I am more concerned with what such new “semantic” elements will actually mean for the web and its users. This is not limited to <time>, but here it should be easy to explain my general concern, using an example:

It’s March 2012
Joe from the U.S. writes on his blog: “I’ll be on vacation in Europe starting 5/4/12, looking forward to meeting you there!”
Pierre from France reads the blog, and, knowing Joe is from the U.S., he will have the following thoughts: “Cool, Joe will be around… what’s that date… ah, Americans with their month/day/year format… ok, I interpret this as 4th of May, i.e. 4/5/12 in proper French format”

It’s March 2015, HTML5 and <time> are starting to get used
Joe from the U.S. writes on his blog: “I’ll be on vacation in Europe starting <time>2015-05-04</time>, looking forward to meeting you there!”
Pierre from France reads the blog, and having set his browser language to French, it shows “I’ll be on vacation in Europe starting 4/5/15, looking forward to meeting you there!”. Not knowing about is browser being clever, and showing him the date in the format he is used to, he thinks: “Cool, Joe will be around… what’s that date… ah, Americans with their month/day/year format… ok, I interpret this to 5th of April, i.e. 5/4/15 in proper French format”

Of course, with proper highlighting of automatically localised dates this could be mitigated to some extent, but I can imagine lots of cases where our current assumptions, coupled with technology that is trying to help, will cause even more confusion than we have now. When communicating, lots of information is “out of band” or just assumed known context. Therefore we need to be very careful when programming our machines to help us communicate, otherwise we achieve the opposite.

Transferring large amounts of data over unreliable network connections

Ever wanted to transfer a batch of multi-Gigabyte files through a slow DSL link and had trouble? Then this article may help – it shows how to do this properly, with standard Linux/Unix command line tools and working SSH key-auth between the two hosts.

Lets look at what the problems are one may encounter when attempting to, say, transfer an 8 GiB video file over the Internet, uploading through a slow link:

  • The connection to the destination host may break at any time, due to any network equipment failure in between, or DSL reconnects by the ISP, or your son pulling the plug of your home router, …
  • The data may get corrupted by faulty hardware or software along the way
  • The uploading may clog up your ADSL connection, essentially making it unusable for anything else
  • Transferring the data without encryption would allow the maybe sensitive data to be read by others, e.g. someone at your ISP, or nearby the destination host
  • The transfer may take hours or days, depending on the amount/link speed ratio. Not getting notified when the transfer finishes may be undesirable

Here is my solution to all the above problems, in a couple of commands. Once entered, you don’t need to worry about the transfer – just wait for a notification e-mail:

  1. ssh-agent bash
  2. ssh-add
  3. while ! rsync \
  4.           --bwlimit <KB/s value> \
  5.           -rP \
  6.           /path/to/directory_that_contain_the_data_to_be_transferred \
  7.           user@destination.host:/path/to/target_directory ; \
  8. do sleep 60 ; done && \
  9.  echo "File transfer completed successfully at $(date)." | mail -s "File transfer completed" your@e-mail.address

Quick explanation of the commands:

  1. Start a shell that is ssh-agent enabled, i.e. the SSH key passphrase can be cached within that shell
  2. Unlock the SSH key by entering the passphrase (which is then cached for all following commands in this shell session)
  3. Start a loop that will only end when the ‘rsync’ command (used as the loop’s ending condition) completes successfully, i.e. the file transfer is done.
    rsync is the perfect tool for the job, since it transfers files reliably (through checksums), can resume efficiently, and all traffic is going through an encrypted SSH connection.
  4. The –bwlimit option of rsync throttles the transfer to <KB/s value> – with my 512 KBit/s = 64 KB/s ADSL upload that means I would use a value around 35 or 40, to guarantee there is still some upload bandwidth left for other things.
  5. -r stands for recursive (transfer the whole directory, and all sub-directories), and -P keeps partially transferred files for resuming and shows progress information; for details see ‘man rsync’
  6. Should be self-explanatory, if not, see ‘man rsync’
  7. Should be self-explanatory, if not, see ‘man rsync’
  8. The actual content of the while loop is just “wait for 60 seconds”. So in case there is a connection problem, the ‘rsync’ command will be retried every minute.
  9. Once the whole loop has completed successfully, which equals a successful transfer, send a short e-mail that notifies you about the completed transfer.

(By the way, you can of course make one line out of lines 3 to 9, I just split it up to make it easier to read and explain)

Sync your Android contacts and calendars with your own server

It’s 2012, and there are still people who don’t put all their information onto Google/Facebook/… servers. Call them paranoid control freaks, if you want. 😉

Some of them even run their own e-mail server. Those people would probably prefer to have their address book(s) and calendar(s) stored on their own server as well, which Android cannot do out of the box.

This blog post aims to give a brief overview over my current solution to this problem. It’s not 100% perfect yet, but I am quite satisfied with it already. I have been using this setup for a couple of months now, and did not encounter any problems of relevance. (*)

Software components involved

On the server:

  • DAViCal – a free (GPL licensed) CalDAV/CardDAV server written in PHP; needs PostgreSQL as database server
  • Roundcube Webmail with the CardDAV plugin – to manage your contacts from within any web browser (Roundcube is of course also a decent mail client)

On the desktop / laptop computer:

  • Mozilla Thunderbird with
    • Lightning extension – to manage your calendar(s) from your Linux/Windows/Mac computer
    • SOGo connector extension (this link brings you to a file listing where you can download a nightly snapshot, there is no officially released version for current Thunderbird versions on the SOGo download page, yet) – to manage / lookup your contacts from your Linux/Windows/Mac computer

      A few words on how to get the SOGo connector working (it’s not really straight-forward, in my opinion): After installing the extension by dragging the downloaded .xpi file onto Thunderbird, open the Address book and choose Menu File / New / Remote Address Book. Enter the URL of your DAViCal CardDAV collection, i.e. https://your.server/davical/caldav.php/YOUR_USER/YOUR_COLLECTION. Then right-click on the new address book and choose Synchronize.

On the Android device:

  • CalDAV-Sync app from Market or AndroidPIT for a bit more than 2€

    (Since CalDAV-Sync is just a backend app that facilitates syncing, this is a screenshot of the Android calendar, with the event that can be seen in the Thunderbird-Lightning screenshot above)
  • CardDAV-Sync app from Market or AndroidPIT for a bit less than 1.50€ or free

    (Since CardDAV-Sync is just a backend app that facilitates syncing, this is a screenshot of the Android contact viewer, with the contact that can be seen in the Roundcube CardDAV screenshot above)
  • Contact Editor or Contact Editor Pro app from Market or AndroidPIT (Pro costs a bit more than 2€, the free version lacks a few features)

A few notes regarding the components:

  • Contact Editor is necessary because the default Android contact editor somehow does not work with custom contact sources. It integrates seamlessly once you have set it as default action upon adding/editing a contact for the first time after installation.
  • The SOGo connector extension for Thunderbird is a good start, but in the long run I really hope Thunderbird’s contact handling can be brought to a level that matches the rest of the application. There is hope.
  • There seems to be a calendar plugin for Roundcube as well (as part of the MyRoundcube plugin collection), and it seems to support CalDAV, but I couldn’t get it to work so far (and did not try hard, since I always have a Thunderbird with Lightning around, which is great for calendaring).

I’m planning to write more on how to get everything set up, but I currently don’t have time for that. The hardest part is getting DAViCal and PostgreSQL to work, in my opinion, all the other components basically just need a URL (to the previously set up DAViCal collection – e.g. https://your.server/davical/caldav.php/YOUR_USER/YOUR_COLLECTION), username and password to work.

Update (2012-01-28): Added some screenshots.
By the way, what must be a very recent change in Gentoo’s packaging of PHP causes CalDAV-Sync to fail syncing, and the apache error log contains “[Sat Jan 28 08:30:48 2012] [error] [client x.x.x.x] PHP Fatal error: Call to undefined function cal_days_in_month() in /…/davical/inc/RRule-v2.php on line 906” if you do not enable the ‘calendar’ USE flag for dev-lang/php (which is disabled by default).
Update (2012-01-29): (*) Typical, I write about something, and then it breaks. It seems there is an incompatibility between the newly released DAViCal 1.0.2 and CalDAV-Sync. The CalDAV-Sync developer has confirmed the issue and is working on it.
Update (2012-01-30): The incompatibility – resulting in logged error messages – does not affect functionality (it was just me having set the account to “One-Way-Sync”)
Update (2012-02-09): Great news: There are nightly builds of the SOGo connector Thunderbird extension that provides CardDAV integration for Thunderbird 10 now – I knew that extension before, but development seemed to have stopped at Thunderbird 3.5 or so. I added links and a bit of info above.
Update (2012-02-09/2): I found the first bug with SOGo connector – when saving a contact that has an image, the image gets lost. This doesn’t really matter to me, because I don’t use images in contacts usually, but for people who use images, this could be annoying. Hope they fix it.