Wednesday, 23 February 2011

Making a favicon for your Blogger/Blogspot blog

As an escape from the PhDemon, I decided I would look at how to make a favicon for this very blog. You may be asking "What's a favicon?" in which case I suggest glancing at the relevant Wikipedia article, it's basically that little icon you see on your browser tab. If you aren't browsing with tabs, I'm presuming your browser predates "Thunder Thighs". More gory, imaged details are over at the Google Chrome Browser blog, from which most of this is drawn.

The first step, obviously, is to actually make a favicon. I quickly put together the one you see here using Inkscape. I'm no design guru (although I find it a fascinating subject), so I just went for a shiny black background and white text, a bit like the blog title. Maybe I can increase the number of magpies that read this. I exported that from Inkscape as a PNG and used GIMP to shrink and convert to an icon file. I rendered the original at 160x160 but shrunk it down to 24x24 because there's possibly an upper limit to the size (36x36). If you're lazy, you can just use an online tool to faviconize an image.

This brings us to the subject of image format. Basically, I can't seem to establish what formats are usable. PNG, GIF or ICO (Microsoft Icon) should all work. Apparently x-icon should too but support isn't as widespread. Your choice of format will correspond to an appropriate specification in the HTML that we're about to add to the template.

Secondly, you need the favicon to be hosted somewhere online. This part is left as an exercise for the reader. Most of the blog posts I found on the matter recommend defunct services. A current example would be ImageShack but, like I said, any service will do.

Now, to add the favicon to the Blogger template. From your blog's homepage, click "Design" and then "Edit HTML". The following code should be entered somewhere in the header block (i.e. between <head> and </head> but not inside any other command)

<link href="" rel="shortcut icon" />

and one of the following (depending on file format).

<link href="" rel="icon" type="image/ />
<link href="" rel="icon" type="image/png />
<link href="" rel="icon" type="image/gif />

where the URL should be replaced with the location of your favicon. That should do it!

A couple of details. The first is that I haven't been able to test extensively for what formats and sizes do and don't work or on what browsers. It seems to work on Firefox 3.6.13 and Chrome 9.0 using a PNG for the second format. If you're testing with Firefox, you might find that the favicon isn't refreshed when you change it. One solution is to load the favicon by entering its URL in the address bar. This appears to flush Firefox's cache and worked for me.

Monday, 21 February 2011

More on bad astro code

Along with my own rant, a large portion of the blogosphere picked up on two articles in Nature regarding the state of scientific programming. Just before Christmas, this article turned up on arXiv. I mentioned it in a comment on AstroCompute and it was promoted into a post there.

The basic content agrees on what everyone seems to appreciate. The article gives a broader range of code (including databases and visualization tools) but all the ideas are the same. In fact, their list of common "features" in astronomy codes (Section 2.1) is almost a checklist for how bad said code can be. Compare your favourite code against this:
  • the code is written in Fortran (bonus if it's earlier than Fortran 77);
  • the code includes frequent GOTO statements;
  • compilation instructions are through a terminal script rather than a Makefile (or other standard builder);
  • in release form, code is non-portable;
  • no variable naming convention is adopted;
  • filenames and paths are hardcoded; or
  • standard algorithms (like matrix inversion, list sorting) are re-invented.
STARS doesn't fare too well. I'll give it the benefit of the doubt on portability and it does use a Makefile. That leaves a score of 5/7. We haven't even started on documentation yet...

How does your code compare? What else could be added to the scorecard?

Friday, 11 February 2011

WubEee, or dual-booting an Eee 1015P the easy way

While I was in South Africa over the Christmas break, my Eee 1000 was stolen from my parents' home. I guess it served as a reminder of why I and hundreds of thousands of other South Africans have moved abroad. More to the point, it meant I needed to replace my dearest netbook. Not that I had any other netbook, but you know what I mean.

As I began the quest to find a suitable successor, I realised that much in the market had changed. Firstly, the Eee PC is now only available with Windows 7 Starter on it. This annoys me but at least, in theory, I could reformat and install Ubuntu, as I had done on my last Eee. I ordered a 1015P from Amazon, which arrived, to my astonishment, less than 40 hours later. Now, the plot thickened as I opened the box: there were no disks. Thus, reformatting the drive comes with the risk of never recovering factory settings (if you knock out the recovery partition). Hence, I cursed Microsoft for strong arming the netbook market and, after the blood-haze of my craze lifted, I decided to try Wubi. This is an account of what I did including some of the standard Ubuntu-on-Eee fixes that are required.

Installing Wubi

After removing a large amount of the crapware that Asus decided to bundle with my Eee and installing a few programs I'd like available in Windows (e.g. Chrome, Dropbox, Skype), I navigated to the Ubuntu download page. Windows was detected, so I was automatically taken to the Wubi download. Installing using Wubi is easy enough: just choose the drive where it's to be installed and the amount of space you'd like dedicated to Ubuntu's filesystem. The default (which I used) seems to be 17GB, with the minimum being 3GB and the maximum 31GB. As you'll see a bit further down, this only needs to be for the programs you install in Ubuntu and the corresponding user settings. You can access media that's also available to Windows.

One small alarm came when I noticed Wubi was downloading the Ubuntu distribution for the amd64 architecture. It turns out this covers all 64-bit capable systems, irrelevant of whether you're on an AMD or Intel system, unlike Debian (from which Ubuntu was forked) has a separate ia64 architecture. It's beyond me, so this is just to say don't worry if your 64-bit machine starts installing the amd64 version.

Linking Windows folders

From the start, my intention was to have Ubuntu and Windows access the same documents and media. Since Windows can't see into the Ubuntu filesystem, this has to be done from Ubuntu. Fortunately, it isn't difficult. To be precise, the behaviour I was going for is like this. In my Windows user folder, there are subfolders like "My Pictures" and "My Documents". In Ubuntu, the home folder (i.e. ~) also contains folders like "Pictures" and "Documents". I want these to point to the same place.

The first step I took was renaming the Windows subfolders. The "My..." bit annoys me, so I removed it. Windows doesn't have a problem with this. All the shortcuts in the Start Menu and other places are unaffected.

Next, in Ubuntu, I removed the folders that I planned to link with rmdir. Then I created symbolic links to the Windows folders. The drive that Wubi installs Ubuntu to, in my case C:, is in the Ubuntu filesystem as /host/. Windows stores the user data under C:\Users\(username)\. In Ubuntu, I created the appropriate links with

ln -s /host/Warrick/Documents/ Documents

Obviously, Warrick is my Windows username. You can do the same for Music, Pictures, and Videos. I've linked Downloads too but that's up to you.

Dropbox is a bit more complicated. I don't know how Dropbox would respond to being told to sync a symbolic link, so instead I told Dropbox to sync the Windows Dropbox folder by specifying /host/Users/Warrick/Dropbox/ as the sync directory when I installed. I then made a symbolic link in my home folder. ~/Dropbox is now effectively synced because it links to the folder that Dropbox actively syncs (in both systems).

Adding Wifi hotkey support

The Eee PC has a set of hardware controls on the keyboard along the lines of pressing Fn with some function key. For example, Fn+F5 dims the screen. Fn+F2 toggles the Wifi. From the first day I installed Ubuntu on my 1000, getting these to work has been variably supported. At first (8.04), support required all sorts of trickery, but it improved to the point that everything actually worked out-of-the-box from Ubuntu 10.04 on.

On my new Eee, everything seemed to work, except the Wifi toggle. Bit of a bummer. Disabling the Wifi when not in use is critical for the battery. I first tried installing the Jupiter Applet to no avail. This is a small program that allows Eee users to access hardware controls that Ubuntu doesn't naturally recognize. After enquiring on the ever helpful Eee PC forums, it turns out the solution is to find the line


in /etc/default/grub and append it to read

GRUB_CMDLINE_LINUX_DEFAULT="quiet splash acpi_osi=Linux"

It all now works beautifully. I'm not sure if this requires Jupiter to be installed but I've left it for the time being.

Those darned window controls

Ubuntu 10.04, it would be nice to distinguish Ubuntu as a brand by moving the window controls to the left corner, but leave them in a different order to OS X. So it's not quite Windows or Mac. It is quite annoying but there's an easy fix. Entering

gconftool-2 --set /apps/metacity/general/button_layout --type string menu:minimize,maximize,close

at a terminal will do it. This is one of just a few things I do each time I update (normally by wiping the Ubuntu partition). I expect to make up a script next time to save me the trouble.

Making Ubuntu the default OS in the Windows Boot Loader

Finally, I changed the Windows Boot Loader to automatically load Ubuntu. This is done by going to My Computer/Properties, selecting Advanced System Settings on clicking settings under System Startup and Recovery. There should be a drop down list corresponding to the OSes in the boot loader (and an option for the length of the timeout).


Using Wubi is a pretty lazy way of dual-booting but it does seem suitable for introducing newbies to Ubuntu. With my media linked I'm not worried about disk space at all and if I want to do a clean install of Ubuntu I can backup my user settings and uninstall/delete Wubi.

If I want to do a clean install of Windows 7 Starter, however, Asus haven't left too many options. I may write a further post if I find out how to restore my system after reformatting the whole drive.