TextMate shortcuts for HTML and Javascript

August 24th, 2011 by nils

Since I keep forgetting them… here is a list of the shortcuts I find most useful when editing HTML and Javascript documents in TextMate:

Creating a HTML document:

  • type “doctype” and hit tab, you’ll see a dropdown to select the doctype
  • type html and hit ctrl + shift + <
  • inside the html tags, type “head” and hit tab
  • inside the generated “head” element and after the title, type “link” and hit tab to generate a stylesheet reference
  • then type “scriptsrc” and hit tab, this will generate a link to an external script
  • for a regular script tag inside the HTML body, type “script” and hit tab

To be continued…

iPhone location data

April 30th, 2011 by nils

Most of you have probably read about the fact that the iPhone stores location related information in a local file. The file is transferred to the computer every time the iPhone is connected and synced via iTunes. If you’re interested in visualizing the data, there is an application called iPhone tracker available at http://petewarden.github.com/iPhoneTracker. The authors of the software, Alasdair Allan and Pete Warden, didn’t only decide to open source their work, but also wrote up quite a bit of documentation about the data and how to access it. They promise that “none of your data ever leaves your machine” but go on to “recommend inspecting the source code if you’re a developer, or even just relying on the directions that allow you to inspect the data using standard database tools.”

So I thought hey, I’m a developer, so let’s see what I can do with those directions and a bit of java code… I documented the result in the little video below and also created a small google code project at http://code.google.com/p/java-location-data-converter. Right now it is just a JUnit test that generates a CSV file which you can then use to e.g. visualize the data with OpenHeatMap (http://www.openheatmap.com). If you have an iPhone and are curious to inspect your location data, check out the the directions to inspect the data.

And if you’re also a java developer, check out my code as a starting point.

Have fun!

iPhone location data visualized from Nils Preusker on Vimeo.

SVN + OS X + “Umlaute”

March 23rd, 2010 by nils

The Mac OS file system —Mac OS Extended (Journaled)— stores umlaut characters as two separate letters (i.e. ‘a’ and ‘¨’). This is referred to as NFD or Normalization Form D with canonical decomposition (see “Unicode Standard Annex #15 – Unicode Normalization Forms”, http://unicode.org/reports/tr15/#Norm_Forms).

This behavior can have unfortunate side effects in applications. Especially remote applications that work path based and interact with different operating systems can run into problems here.

I came across this when I tried to access a subversion repository that contained file names with German umlauts from my Mac. I am running subversion 1.6.5 and when I check out a file with an umlaut in its name, executing “svn stat” will list the file twice, once as missing (with an ‘!’) and once as unversioned (with a ‘?’). A search in the collabnet discussion forums finally confirmed that this is a know issue. The following links provide some documentation:

However, the subversion issues are just one specific bug. For application developers it is important to know that Unicode equivalence is a term to keep in mind. The wikipedia article (http://en.wikipedia.org/wiki/Unicode_equivalence) mentions a bug in the samba protocol due to different representations of Unicode characters.

So, next time you come across an issue that involves a Mac and umlauts, Unicode equivalence might be the term to look for.


October 2nd, 2009 by nils

Just came across this Lawrence Lessig quote in a really interesting article on sketching in hardware:

Technology is responsible for bringing us back from a Read Only (RO) culture to a Read-Write (RW) one…Human beings have been RW during most of our history. But for some time we stopped creating things and started consuming them instead.

So I decided to switch to read-write mode, post this here, and maybe give you some food for thought for the weekend…

Back me up!

January 18th, 2009 by nils

After having months of sleepless nights because I wasn’t backing up my MacBook Pro, I finally decided that something had to happen. What made me hesitate for a while wasn’t so much the search for the right hardware but rather the fact that what i had in mind would be quite an investment. I didn’t want to go for yet another external hard drive because I thought the best solution would be a NAS that I can connect to the network and then access wirelessly from my laptop. Apart from relieving you from having to worry about dragging USB hard disks along when you move your laptop, a NAS with space for several disks also has the advantage that you can create RAID volumes and mirror your disks.

So after a lot of hesitation I settled for the Qnap TS-409 Pro and decided to start off with two 1TB Western Digital (Caviar Green WD10EACS) hard disks. This setup would allow me to start with a RAID 1 Mirroring Disk Volume configuration, effectively leaving 1 TB for use and mirroring the disks so I can be sure that even if a hard drive fails, my data won’t be lost. Later on I can still add two more disks to extend the capacity and I don’t even have to switch the 409 off for that. Another nice feature is that the TS-409 has three USB ports and supports automatic sharing of attached USB hard drives. This way I can continue using the external hard disks I bought before. So much for the server and hardware side of my NAS backup experiment. Lets look at the Software side.

The main scenario I want to be prepared for is a total system failure that requires me to restore or re-install my OS. So I needed a solution that writes bootable disk images and gives me a way to restore them. Since OS X provides a standard image format and the Disk Utility that you can start from the OS X installation disk and that enables you to mount and restore these image files, all a good backup tool needs to offer is a way to create both full and incremental backups. SuperDuper! does this and it is affordable, so I chose to try it.

It turns out that the free version of SuperDuper! enables you to write fully functional backups that you can mount or restore afterwards. By mounting them, you can browse your backup as if it was an actual physical drive. The only restriction of the free version of SuperDuper! is that it doesn’t support incremental backups. Since you’ll only need these later anyway and I was eager to get started, this was the perfect deal for me.

Up to here, everything went really smooth. But of course I wanted more. Since Leopard has Time Machine built in and it gives you such a nice interface to browse snapshots of your file system, I felt like it would be a good addition to SuperDuper!. In fact, on their web site, the developers of SuperDuper! even call it the perfect companion to Time Machine. The fundamental difference between the two is that SuperDuper! gives you a full backup that you can use to restore your system in case the hard disk fails or you mess up your system in some other way. Time Machine on the other hand creates hourly, daily and monthly snapshots of your files and provides an intuitive and simple user interface to browse them and restore them to previous states. I believe a sensable setup is to exclude all system files and basically only let Time Machine back up your data (Users directory) and leave the responsibility for system backups to SuperDuper!.

So much for the theory, but here comes the problem: Time Machine doesn’t support network drives. Luckily there is a simple solution for this. Open up a Terminal window and execute the following command

$ defaults write com.apple.systempreferences
TMShowUnsupportedNetworkVolumes 1

BTW, in case you are worried about messing up your system with this or not knowing how to revert it… the answer is simple

$ defaults write com.apple.systempreferences
TMShowUnsupportedNetworkVolumes 0

Seems logical, doesn’t it 😉

Afterwards you can open the Time Machine preferences in System Preferences and by choosing “Change Disk…” select your network drive. Unfortunately, that isn’t where the story ends though. After kicking off the first backup by selecting the Time Machine icon in the menu bar and then selecting “Back Up Now”, I got the error message “Time Machine Error – The backup disk image could not be created.” Luckily there is also an easy solution for this. We first need to look at whats happening here though. Time Machine seems to be creating an image file on the network drive. You can actually see the file being created but when Time Machine fails, it removes it. The name of the file that is being created contains the computer name, followed by an under score and the MAC address of the primary ethernet device (en0) without colons. Our workaround will be to manually create this file with the Disk Utility and then copy it over to the network drive we have selected in the Time Machine preferences.

So now you can either look up your MAC address by typing in “ifconfig” in the Terminal, looking for en0 and then checking what it says after ether or you can try to copy the file name while Time Machine temporarily creates the image file. Either way, you should end up with a file named <computer-name>_<mac-address-without-colons>.sparsebundle. Note that the .sparsebundle extension is added automatically by the Disk Utility. Now you just have to open the Disk Utility, click “New Image”, type in the image file name and select “sparse bundle disk image” as image format and set a reasonable volume size. The thing to keep in mind here is that the image file won’t initially have the file size you select here but will be able to grow to a maximum of this size. I actually found a very interesting and useful article about this here. After clicking “Create” and waiting a bit, the image file will be created and we can copy it over to the network drive. After starting a Time Machine backup by selecting “Backup Now” from the menu, I finally ended up with this…

I found quite a lot of discussions and hints about this topic on the internet. Here are the articles that really helped to solve the problem:

A thread in the apple discussion forum suggests that the Time Machine backup might fail when the computer name contains certain characters. According to the post, the following characters are safe to use in the computer name: 0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ

I hope this is useful for some people. Have fun and feel free to comment!