skip page navigation Oregon State University

Frédéric Wenzel

Syndicate content
Open Source, The Web, And German-American Oddities
Updated: 34 min 7 sec ago

Firefox on the Coliseum

11/09/2009

This photo is not photoshopped:

Colosseo

The Mozilla Italia team projected a Firefox wordmark onto Rome’s most famous landmark — and on many other places all over the city. Make sure to check out the picture in its full glory over on flickr.

Picture CC by-sa licensed by nois3lab on flickr.

Categories: Planet OSL

Code Cosmetics With Komodo and vim

11/06/2009

The source code for the Mozilla Add-ons project tries to follow the PEAR Coding Standards. One of these standards is to use 4 spaces per level of indentation, and no tabs.

Over time, unfortunately, some files start to contain a significant amount of mixed-up indentation (both from badly set-up IDEs and third-party contributions that came with tab indentation but went un-noticed). That’s both tedious and error-prone to fix by hand.

A similar problem poses trailing whitespace. While it’s just annoying in general, especially in HTML template files, it also increases page size unnecessarily by leading to more bytes transmitted on the wire, with no benefit to neither the users nor the developers.

Luckily, there are two quick fixes for these problems in both the editor vim and my IDE of choice, Komodo:

To remove tabs and replace them with spaces…

  • in Komodo, select a code block, then click Code -> Untabify Region.
  • in vim, type :%s/\t/    /g (those are four spaces) — or, as oremj points out in the comments, you could just to :retab .

And to wipe out trailing whitespace…

  • in Komodo, in Preferences -> Editor / Save Options, activate the option “Clean trailing whitespace and EOL markers”. Then open your document of choice and just save it again. However, when writing patches, you might want to refrain from keeping this option on at all times: It might result in confusion if a lot of lines are touched that do not have anything to do with the current patch. I wish there was a one-time way to run this, instead of a config option.
  • in vim, type :%s/\s\+$//g which the regex-savvy among you have quickly decyphered as: “in the entire document, replace all one or more whitespace characters that are followed by a line ending with the empty string”.

Happy cleaning!

Categories: Planet OSL

Shortcut to Internet

11/03/2009

For work, I have a virtual machine serving one little purpose: To run Microsoft Internet Explorer 6, for the rare instances when I have to test a website with it. To make that a little more convenient and a little less painful, I just created a “desktop shortcut” for it, and look what it showed up as:

Shortcut to Internet

Haha, “Shortcut to Internet” — this is classic.

Categories: Planet OSL

Adding Empty Directories to git-svn

08/18/2009

Just a reminder, because I always forget it: When you use git-svn on an svn repository and your code base contains empty directories (say, for temporary files, or log files), they will be ignored by git unless they contain at least one file.

Paradox? Maybe. There’s a good reason however: git ignores empty directories because it tracks (file) content, not a bunch of directories some of which happen to contain a file (the concept of tracking files might be the only thing git has remotely in common with good ol’ CVS — though git also does not deeply care about file names, only content).

The “common” way to handle this is by adding a .gitignore file to the repository. This won’t harm svn-only clients, but it’ll make git-svn clients pick up the (almost) empty directory properly.

This is what you need to do.

mkdir empty_dir
echo '*' > empty_dir/.gitignore
echo '!.gitignore' >> empty_dir/.gitignore
git add empty_dir
git commit -m 'adding empty directory' empty_dir

The .gitignore file tells git what file names not to track inside the directory in question. The asterisk means, ignore all files, but the second line makes sure the .gitignore file itself is recognized and added to the repository.

Categories: Planet OSL