A home page like many others

Welcome to revis.org, a small and dull website which will probably be of no interest. The tedious items below may help you fill the seconds of you life in which you can think of nothing better to do.

Fiction Index Fiction Index
Linux on Apple Laptops Linux on Apple Laptops
Links Links to web resources
Random Comments Random Comments

Most of the things you will find here are notes I have made while fixing problems because the single most irritating thing in the world is trawling through bad documentation and old mailing list posts in order to find the exact configuration tweak needed to get everything to Just Work (TM)... again.

Lazy? Me?

Someone asked me recently if I had started watching TV or developed a drinking habit, prompted by the fact that I haven't been updating my site. Heck, I haven't even installed the new Ubuntu release and it's been out for over a month.

Well, today I can finally prove that I haven't been spending my evenings at home drinking in front of old episodes of Frasier. Things are much, much worse than that.

[Edit]
Over the last few months I have been putting together in my spare time an online planning application in JavaScript.

...which is currently down for upgrades. Should be live again with a new pretty version later this year.
[/Edit]

Vertical div sizing in Firefox

Before you can give a vertical size in Firefox the parent needs to have a size set. By default the body and html elements have a size of zero, so using only percentages to control a fixed vertical layout doesn't work.

However adding the following CSS restores logical behavior.

body {
height: 100%;
}
html {
height: 100%;
}

As useless as a fish with a bicycle

Ah, another cliché. Sit in a meeting for long enough and a few will come along to mug your faint hope for the human race.

One of the most common clichés at engineering meetings, along with 'oh no not another inflatable dartboard', is 'as useless as a fish with a bicycle'. One key point always remains unanswered; just how useless is a fish with a bicycle? I have never seen anyone attempt to quantify it.

If we do not wish to take the easy option of just giving the fish a normal human bicycle (which seems like cheating) we must first invent a suitable sort of bicycle-like conveyance for a fish. How about this one?

Fish in a bicycle.

Ok so it's not really a bicycle, really more of a tricycle, but I feel that nitpicking has been left rather late at this point in the proceedings. There is directional control, bicycle type wheels and a chain drive. This is a lot closer to spec than most things that come out of a design office.

Can the fish move the device? Well, a quick scan of the internet reveals a power output estimate for a 1kg cruising Euthynnus of 0.009W or roughly 0% of the output of a household light bulb.

Real engineers are encouraged to skip this paragraph: Temporarily ignoring efficiency (and sanity) we will assume that as every action has an equal and opposite reaction the circular motion of the fish will induce a circular motion of the water of a similar magnitude but in the opposite direction. This will drag the turbine around, transferring all 0.009W to the drive chain.

This website has a calculator for working out speed at a given power. It will be horribly inaccurate for this particular device but frankly at this point I'm hoping that the errors sort of cancel out. Assuming that our fish conveyance is a 'Streamlined Trike' with a weight of 3kg (1 for the fish, 1.5kg for water and 0.5kg for the rest) we can expect a speed of 0.037m/sec or 27.8 miles per fortnight.

Hold on! Not so fast! As the unsophisticated steering mechanism supplied to the fish can only direct him at +/- 5 degrees his path will not be straight but rather a meandering path more commonly displayed by those who are as drunk as a, um, fish.

Rather than actually do some real maths we will just approximate this as a zig zag path with instantaneous direction changes of 90 degrees. This would give a forward motion of 1m/sec for each 1.41m/sec of actual speed, or in the case of our intrepid aquatic cyclist a blazing 0.026m/sec. This is far superior to your common or garden racing snail who can only manage 0.013m/sec.

So what use is this? Well, frankly, not much. A fish in a trike is unable to pull even fairly trivial loads at any great pace. It is also likley to be defeated by even the smallest of hills. But at least now we know.

As it turns out with enough ingenuity you can pretty much design a solution to any problem. Just be sure it isn't a fish bicycle kind of problem.

Em floating point errors

Drawing CSS layouts using the 'em' unit of measure is a very good idea, as it allows the browser to flexibly resize the whole page when the user zooms in or out. There is a lot more information about flexible layouts here including an example.

However for a complicated application you may need to compute new locations based on the position of existing page elements. You can get the location of an existing element like this:

var el = document.getElementById('elementname');
var left = el.offsetLeft;
var top = el.offsetTop;

However this returns the position in pixels instead of em. In order to convert this to em you need to know how big an em actually is. The most common technique I have seen recommended for this is to make an empty div 1em high and get it's rendered height like so:

HTML
<div id="fontsizecheck" style="height: 1em; position: absolute;"></div>

JavaScript
var el = document.getElementById('emptydiv');
var elinpx = el.offsetHeight;

This works up to a point, but has a serious limitation. Let's say your users font size is really 9.5 pixels in size. Because pixels are always integers your 'eminpx' variable will now hold 10. This means that if you are trying to position something at 'left: 10em;' your code will put it at 100px rather than 95px. This is a pretty big error if you are trying to get things perfect.

Worse than this, as you zoom in and out, the magnitude and sign of this error will change. This causes some interesting visual bugs.

Fortunately there is a pretty easy way to make the errors so small that you can cheerfully ignore them as they will be less than 0.499 pixels. Simply sample an attribute from a much bigger interval with a known size in em.

HTML
<div id="fontsizecheck" style="left: 50em; position: absolute;"></div>

JavaScript
var el = document.getElementById('emptydiv');
var eminpx = el.offsetLeft/50;

The result from this method is good enough to accurately position across a 1650*1080 screen, but may need to be expanded if you are doing something for huge displays with very small font sizes.

The effect of transfer caps on usage patterns

I moved from an unlimited data plan to a limited plan from the start of January this year. Being a fairly cautious person, in the month before I made the jump I kept track of how much data I used to make sure that I wouldn't go over the limit.

My new monthly limit is 3GB (1), December's usage was 2800MB. Fantastic, time to switch. Just to be sure I was keeping on track throughout January I set up a automatically populated spreadsheet with an output like this (the scale is in MB):

The yellow line shows, assuming remaining data is evenly used, how much I can use on any particular day without going over budget and getting a slap on the wrist from my ISP.

Daily usage as you can see is generally all over the place, but if we add a simple linear regression (2) a pattern shows up:

Generally it trends upwards towards the end of the month. This should be fairly unsurprising:

  • I was low at the start trying to keep under my daily usage limit.

  • This reserve built up pretty fast, especially when I wasn't online for some reason.
  • With excess available at the end of the month I started burning it on discretionary things like video.

Compare this to December, which has a similar total usage, but spread out roughly evenly over the month.

So, why does it matter when I decide to use my bandwidth? Individually it makes no real difference, but it probably gives some insight into why ISPs often don't offer a status page to show how close you are to the fair usage limit.

If everyone knew how much they had left over at the end of the month the resulting download frenzy would put a major strain on their infrastructure, plus there would be another hit at the start of the month when people who were low at month end suddenly gained a new lease of life. Meanwhile, in the middle of the month expensive hardware would sit idle, when everyone was either already running low or hoarding.

(1) By which they probably mean 3000MB.
(2) General warnings about lies, statistics and devious analysts apply.

Please join me in celebrating a numerological milestone of no importance

Back at article number 100 I wrote:

At this rate I will reach 200 articles by January 2007, 1,000 articles by 2009 and 1 entertained reader by the heat death of the universe.

Since then the posting rate has dropped from 6.25 per week to 2.33 per week, I didn't get to 200 articles until January 2008 and the entertained reader has yet to be found.

On the other hand I am slightly amazed that I have kept this up for over one and a half years, that the most popular article has been read over 15,000 (1) times and that 10,000 (1) people a month stop by. Thanks to everyone who has left a comment, and I hope that some of you found something useful here.

(1) Probably half of these are real visits/people.

Dual screen with an ATI card on Kubuntu

Before starting this you should already have set up the ATI fglrx driver and have it working. You can install and configure it from K>System Settings>Advanced>Restricted Drivers.

Once this is working properly we can use aticonfig to add the necessary sections to the X server configuration file to support multiple monitors.

It is a good idea to have a bootable Linux CD (the Kubuntu install disk should work) just in case you mess something up really badly.

# Back up the old config file!
sudo cp /etc/X11/xorg.conf /etc/X11/xorg.conf.working
# Generate a clean configuration file
sudo dpkg-reconfigure xserver-xorg -p high
# Add dual had configuration first
sudo ati-config --initial=dual-head
# Enable Big Desktop mode
sudo aticonfig --dtop=horizontal

You should check that the config file looks ok, and especially that there are no references to PairMode. The default configuration automatically detects the highest resolution possible on both monitors individually, setting PairMode can stop this working.

Your configuration can be tested by spawning a second X server without rebooting.

# You only need to install xterm once
# sudo apt-get install xterm
sudo xinit -- :2

You should see a terminal window and the rest of the area on both screens should be covered in light gray hatching. If not, restore the config file from your backup and check again for errors. The terminal output will contain the X server error log to help you find the problem.

aticonfig --query-monitor will give you a list of displays, and you can enable/disable them with aticonfig --enable-monitor NAME{,NAME,NAME,...}

You can download my configuration file here. It also includes the necessary configuration for an Intuos3 Wacom tablet, but this shouldn't cause any problems if left enabled.

iSight and Cheese on Kubuntu 7.10

My MacBook Pro has a built in iSight web cam. These are now supported under Linux so I thought I would get mine working.

# unload the default non-working driver and disable it
sudo modprobe -r uvcvideo
sudo mv /lib/modules/2.6.22-14-generic/ubuntu/media/usbvideo/uvcvideo.ko \
/lib/modules/2.6.22-14-generic/ubuntu/media/usbvideo/uvcvideo.ko.original
# get the dependencies to build the driver
sudo apt-get install build-essential libusb-0.1-4 libusb-dev
# get the driver
mkdir isightdriver && cd isightdriver
wget http://files.i-nz.net/projects/linux-kernel/isight/uvcvideo-isight.tar.gz
tar -xvf uvcvideo-isight.tar.gz
# build and install the driver
cd against-revision-140
make
sudo make install
sudo modprobe uvcvideo
# make sure it loads on each boot
sudo echo uvcvideo > /etc/modules

The camera should then start working in Kopete with no further configuration, giving you video chat options for most networks. You can configure device settings in the Settings>Configure>Device menu.

In order to get functionality similar to that provided by Apple's Photobooth application (snapshots and videos) you can install Cheese with:

apt-get install gnome-media cheese

As it requires gstreamer and a few other parts of the gnome-media package the download is quite large.

Single mouse button minesweeper

Ever been irritated by the fact that Minesweeper needs a right mouse button, which is painfully absent on a MacBook? No?

I had an hour or two free, so I wrote my own version. In javascript. It's actually a fairly interesting problem as it requires recursion to handle the cascade reveal game mechanic.

When I get a bit more time I'll clean up the graphics, add a top score database and a few other things. But for now it can be played here.

Updated 23/1/08 with a score calculator.