Lottery and Flight 1549

23:16 Tue, 31 May 2011

I am watching a TV documentary Lucky about lottery winners and how it changed their lives, and so on.

After the safe landing of US Airways flight 1549 into the Hudson River in New York, the next day so many people playing the state lottery were choosing the numbers 1, 4, 5 and 9 that the state had to close the lottery early because if those numbers won, the lottery would have made an enormous loss.

And which numbers did win? 1, 4, 5 and ...wait for it... 8. Wow, pretty darn close.

By the way, normally, people choose a fairly random set of numbers, so the set of numbers are pretty evenly distributed, but there is a bias towards numbers that can form a date, such as the numbers between 1 and 31. Numbers greater than 31 tend to be chosen less frequently. This is great for us counter-intuitives who value maths and statistics: choose your set of numbers so that all of the numbers are greater than 31 and, if you win, you will win big, because fewer people will also have chosen those numbers.

Categories: general

My Father: Patrick J. Coleman

16:30 Sun, 22 May 2011

My father died today. It was very sudden and very quick. He was about to turn 85.
[continued...]

Categories: general

Const in C

17:58 Wed, 18 May 2011

If you can never remember where to place const in C, I read a handy tip recently.

Const always applies to the type to the left, the prefixed type. That's it. Except, if const is the first keyword then it applies to the following type. That's not really a cause of confusion though, because then it reads naturally.

Thus, these are all valid C:

const int a // const is first keyword int const a // prefixed int is const1 int *const ap // prefixed pointer, not the int, is const int const *const ap // both const const int *const ap // both const

The obvious gotcha is when using it with pointers and inadvertently applying it to the type instead of the pointer. So int const *ap; mean that the int is constant because the int type appears as a prefix to
[continued...]

Categories: programming

Conjunction of the Planets

06:00 Fri, 13 May 2011

Planetary alignment, how and why. With diagrams!

Did you catch the planetary alignment this morning? It was spectacular. I got up early just before 6am and drove to a nearby hill to get a full view, and it was awesome. The sky was crisp and sharp and the three brightest planets seemed to hang there glowing brightly in the low eastern sky. You could easily imagine our early ancestors several thousand years ago being gobsmacked by such a spectacle and wondering what those lights were. Heck, even today, when we know what it is. And all this on Friday the 13th! Marvellous.

Here is the view from the Southern Hemisphere; people in the north probably saw something similar flipped left-to-right.

conjunction sky view
top to bottom: Jupiter, Mercury, Venus and Mars

Venus and Mercury are in the inner Solar System, while Mars and Jupiter are in the outer. How can we see all four when two of them are "behind" us? The answer is that they aren't behind us at all. We all are travelling in a glorified circle around the Sun, so sometimes we can see across the Solar System, past the Sun, all the way across to the outer Solar System. It's obvious when you see the diagram:
[continued...]

Categories: astronomy, science

Ukulele Tuner

19:30 Mon, 09 May 2011

I bought a ukulele about a month ago, to the growing horror of my neighbours. I always wanted to play a musical instrument, even taking piano lessons several years ago, but it always seemed to involve a big expense and a huge time commitment. Then local TV showed The Mighty Uke, a documentary highlighting the often quirky but always fun ukulele. I was hooked. Only four strings and a short neck make for easy chords. And you can buy a cheap one for $30. Done. The next day I drove to a music shop and bought one.

One thing I learnt early is that an out-of-tune uke sounds terrible. Eno tuner I don't have a great ear for tuning so I figured a digital tuner would be the go. The local shop was selling them for $40—more than the price of the uke!—so ebay to the rescue. This little beauty cost US$10, delivered from Hong Kong to Australia. I don't know how they can make money at that price, but, hey, I'm not going to argue.

Four weeks later (I guess it was on the slow boat from China) it has arrived. It's a neat unit, quite tiny, that you clip to the end of the neck. You can swivel the display to see it whether the instrument is on your lap or being held.
[continued...]

Categories: general, music

Vim Alternative to MiniBuf Explorer

08:50 Sun, 08 May 2011

An alternative method of managing Vim's buffers, using just key mappings

There are a couple of plugins to manage Vim's buffers, of which the best known is probably MinuBufExplorer. I use that on a couple of machines and, while it gets the job done, I've never been completely happy with it1 .

I really only use it for a display of the buffer list. It hasn't been maintained for several years, although there is a fork project available (see MiniBufExplorer's home page where the author lists a couple of alternatives).

Since you have to change buffers manually anyway using the :b xcommand, I figured why not just use a couple of key mappings to make life easier.

I never use F1 for help, so I mapped :ls<CR> to F1 like thismap <F1> :ls<CR>. Now, to change buffers, I just press F1 and I am presented with a list of buffers from which I can type :b1 and I am done. However, you can speed that up more if, like me, you find the : key
[continued...]

Categories: programming, unix

OpenBSD Upgrade 'Just Works'

12:28 Thu, 05 May 2011

I'm starting to sound like a fanboi, but the OpenBSD upgrade on my iMac G4 from 4.8 to 4.9 went without a hitch (well, almost).

First prepare the media, a CD with a boot kernel and all the packages. It's a quick 220MB download and burn. Reboot, select Upgrade instead of Install, and away we go. All the previous settings were kept, so no need to recofigure daemons or config files.

Next, run a sysmerge tool that does diffs on any config file in /etc or /var that has changed and asks you what to do. There were only about 10 of them that needed my help, and it took about 10 minutes all up.

Reboot, and we are done. Easy-peasy.

A slight hitch that had me stumbling for a few minutes was that I seemed to have lost command-line history on the arrow keys. Turns out (I think) that the new default on the shell is vi mode. I changed .kshrc to set to emacs mode and things were sweet.

Categories: unix

Timing, It's a Beautiful Thing

09:30 Wed, 04 May 2011

Just four days after installing OpenBSD on an iMac G4, along comes the next version, 4.9! Just after I had a rush of blood to the head and installed a range of packages too.

Oh well, the update procedure is pretty straightforward. And I get Vim 7.3 too, which is a nice bonus.

Categories: unix