Cake and Healthcare - When Analogies Attack...

A lot of Americans appear to not quite understand how this whole Universal Healthcare thing might work, and don't understand why (a) they should pay for someone else's healthcare (answer below), or (b) how the system could possibly work and be more efficient than, say, paying some kind of company that tries to make a profit (even 501(c) companies in the US are allowed to make a profit; they're just not allowed to keep it and carry the cash forward to the next year).

Allow me to help.

Let's say you go to a really flashy restaurant. That restaurant feeds you exceptionally well, and you can see hundreds of people coming in and out of the door.

You finish your meal, and you're feeling completely stuffed. The waiter comes by with your bill. You look down at it, and there's a line item for a dime - with just one item listed. "Cake", it says.
You, flustered, wave the waiter back over. "Excuse me, but I didn't order cake, and I don't need cake."

"But it's only a dime, sir," the waiter says. "As you leave the restaurant, if you are still hungry, there is a large cake at the coat check. If you don't believe me, you can come back."
So you get up, and you sign the bill (tipping the waiter less 'cos you don't believe his story), and when you get to the coatcheck they say "So, sir, how was your meal? Can I have your ticket, and may I ask if you're still hungry?"

"Actually, yes, I am hungry," you gruffly state, while handing over the ticket.

The coat-check attendant walks into the other room, and comes back with your coat, and a trolley on which lies an immense 4-storey tier cake, covered in sparklers, with ganache all over it, fresh strawberries and a chocolate fountain bubbling up from the top.

"But... but..." you stammer. "How can you afford to do this?"

It's quite simple: The restaurant feeds all of their customers well ahead of time, making sure that most people never leave hungry, and don't get to the point of needing the cake in the first place.

The dime on every bill adds up for all of the people who come into the restaurant, until eventually, 3000 happy customers have gone by with one 1 of them needing the actual cake itself. And they don't try to make a profit on the cake; they charge a dime, because statistically, that's what the cake costs.

The restaurant is a co-op, which each of the diners buy into. Rather than making a profit for the owner, the membership fee allows the diners to lower their rate. Kind of like CostCo. There's still profits to be made, but it's much cheaper for everyone because the shareholders are taking the profits as direct benefits, not as dividends.

So ultimately, I ask you: Why don't you like cake? Sure, you could go buy that cake yourself for $300... but that's a lot to pay for cake. I'd rather pay 10c every time I went to that restaurant. Sure, occasionally other people might get the benefit of the cake I paid for, but when I want it, it'll be there for me.

(Some people point out that Medicaid/Medicare doesn't work... and that's because Old People and Kids PREFER Cake, which is a concept I'll tackle in my next post).

#Health, #healthcare debate
This entry was posted under Politics. Bookmark the permalink.

The Darker Side of Google & Open Source: Taking without Attribution

So, once upon a time (January 2003), I wrote a rather neat little article about an algorithm I invented called a “Bip Buffer”. It’s basically a circular buffer, split into two parts. It makes writing TCP/IP networking code easier and faster, because it allows you to operate on data contiguously as much as possible. This increases throughput.

(And hey, they’re teaching it at Brunel University in the UK – EE2066 - Computer Architecture & Digital Systems has a reference to it in their powerpoints. Yay ego boost!)

I originally invented it while at Intelligent Ion, working on an ultra-fast miniaturized Mass Spectrometer. I needed something that would act as a circular buffer, and I couldn’t find anything available that didn’t write one byte at a time. So a bit of thought later, a few Aha! moments, and hey presto! Something that let me squirt data FAST through our pipes, and that actually was worthy of writing up.

So I wrote a little article and put it up on CodeProject along with full source code. The only requirement for using the code was that you send me an email if you use it, letting me know how it’s being used. Just because I’m curious.

That, by the way, was the only requirement. No, it’s not public domain, but it’s a hell of a light licensing requirement.

Anyway… fast forward to a few years later.

A Few Years Later

By now, I’ve had about 8 emails. Not bad, I thought. Okay, maybe it wasn’t as cool as  I thought, but still, it was worth it. Cool little thing to have in my bag of tricks.

One was from an observatory who were going to use it in their code. They’ve given me a standing offer to come check the place out whenever I’m in town. I love offers like that – I get to meet very cool people along the way, and I’m all about new and exciting experiences.

Fast forward even more years later, to the present day.

Even More Years Later – The Present Day

Just for kicks, I decided to do a search to see where my little chunk o’ code has been used. And that’s where things got interesting.

You see, it’s in the Google Android Source Code now. Don’t believe me? Check this out:;a=blob_plain;f=adb/sysdeps_win32.c

It’s not quite the same code, but it certainly has the same name for the data structure, and uses my algorithm. Here’s a snippet from that page:

* basically, we use two circular buffers, each one corresponding to a given
* direction.
* each buffer is implemented as two regions:
*   region A which is (a_start,a_end)
*   region B which is (0, b_end)  with b_end <= a_start
* an empty buffer has:  a_start = a_end = b_end = 0
* a_start is the pointer where we start reading data
* a_end is the pointer where we start writing data, unless it is BUFFER_SIZE,
* then you start writing at b_end
* the buffer is full when  b_end == a_start && a_end == BUFFER_SIZE
* there is room when b_end < a_start || a_end < BUFER_SIZE
* when reading, a_start is incremented, it a_start meets a_end, then
* we do:  a_start = 0, a_end = b_end, b_end = 0, and keep going on..

And I’ve never had an email from Google so much as telling me they’re using it. This is bad, folks. I had ONE single requirement to use that algorithm & code. Only one. And it was tiny.

On the plus side, however, my algorithm and a variant of my code has now been reused in every Android device out there. Nice kudos.

Or it would be nice kudos if they’d sent me the email. Or even left a link in the code to my original article. To add insult to injury, this is at the top of the source file:

/* Copyright (C) 2007-2008 The Android Open Source Project


** This software is licensed under the terms of the GNU General Public

** License version 2, as published by the Free Software Foundation, and

** may be copied, distributed, and modified under those terms.


** This program is distributed in the hope that it will be useful,

** but WITHOUT ANY WARRANTY; without even the implied warranty of


** GNU General Public License for more details.


Not only do they claim copyright over everything, but they GPL’d it as well. I hate the GPL; I don’t have a problem with the BSD license. But GPL? No, sorry, I gave away my original code for everyone to use – not to virally license it.

Here’s my original copyright, for comparison:

Copyright (c) 2003 Simon Cooke, All Rights Reserved

Licensed royalty-free for commercial and non-commercial
use. All that I ask is that you send me an email
telling me that you're using my code. It'll make me
feel warm and fuzzy inside. emailaddress@here-removed to prevent spam


But boy, that code looks a lot different than mine. I wonder where that came from?

So Where DID It Come From?

Well, Nettee is using the code – but they attribute it to me originally in the docs. So no harm no foul there. (Thanks guys – you rock).

PyroEmu is using it too: – and they attribute the algorithm for me, but claim the code for themselves… personally, I think my version was cleaner. Still at least they attributed it to me.

But Google? Nooooooo.

And yes, I know I’m blowing this up a bit out of proportion. I don’t mind Google using my code – and let me make that very clear yes, google, you can use my code and algorithm. Please don’t take this as any kind of request to remove it. But in this day and age when we can’t all be Donald Knuth any more, it’d be nice to get some credit for my work. Especially because that’s all I asked for it. I didn’t even patent it.

Credit where it’s due, Open Sourceys. Don’t get all giddy about your free culture without giving back to those who make it possible for you.

And stop putting GPL on my code. It’ll give you hives.

#technology, #programming, #algorithms, #legal, #computer science, #circular buffer, #bip buffer
This entry was posted under Software Development. Bookmark the permalink.

Blogger Getting Rid Of FTP

Hmmm... apparently Google/Blogger are getting rid of their FTP publishing service. This sucks, because I use Blogger to publish my... erm... blog.

I would note that Blogger don't seem to have suggested any way to migrate my existing content. Which sucks.

Time to roll up my sleeves and see what I can set up to move my blog wholesale to GoDaddy.

#technology, #internet
This entry was posted under Meta. Bookmark the permalink.

The Second Coming of the Tablet PC

Ever since Apple announced the iPad, its been "Tablet this, tablet that", and people have been jumping up and down saying that this is the best thing since sliced bread, and totally new and innovative to boot. (I suspect that these are the same people who, when Microsoft kick-started the whole TabletPC initiative about a decade or so ago, insisted that Apple had invented it back then too, and it was called the Newton. Revisionist fan-boi history much? I think so).

What amazes me this time though is that On The Media, a radio show which comes out of WNYC (also home to the rather awesome science show RadioLab) were going gaga about this being the first instance of the "Fifth Screen" that tech geeks have been salivating over for centuries.

The screens go like this:

  1. Movie screens
  2. Television screens
  3. PC screens
  4. Cellphone screens
  5. Some kind of intermediate not-quite-a-screen which, like the One Ring, will in the darkness bind them.

(The similarities to the One Ring don't stop quite there... I'm willing to bet that most of the first people to buy the iPad will indeed look a lot like Gollum, only wearing Armani suits).

What amazes me is that this is totally revisionist history. The TabletPC came in several versions, including convertibles which had keyboards and a screen on a pivot that you could fold back over to sketch on. Like, for example, the rather splendid Toshiba Portege M200 which I once had. Unfortunately, Toshiba haven't seen fit to release one with as high a screen resolution as that wonderful little machine, or as good a GPU since - which means that no matter what kind of Tablets they're selling now, I won't be buying one... goddamn Intel Integrated Graphics... grrr.

The other versions are in what is known as Slate format - like Fujitsu's Stylistic ST6012 Tablet PC.

Woah. Wait a minute. This looks like an iPad.

And yes, it does look like an iPad. Except it has an active pen input (using RF sensors, basically) so that you can sketch high fidelity sketches on it. Or write by hand and enter all of your stuff into OneNote, where text recognition will kick in automatically and let you search your handwritten notes.

The iPad, as it happens, does not support handwriting. This should not be a surprise, as its multi-touch display really isn't designed with high enough fidelity for it. Sure, you might be able to get away with using your own nylon stylus on it (maybe steal one from a DS), but it's not going to be a high end user experience.

So yes, the iPad is not the first attempt at being the "5th screen" (heck, not even the Mira was that). Slate form-factor TabletPCs existed a LONG time ago. And they're much much more useful. If Toshiba would deign to release something akin to the M200 again, with dual core CPUs and a nice fast GPU, I'd happily consider buying one.

That's why half of my notes in OneNote from a few years ago are all handwritten. Because Tablet PCs are awesome in meetings.

End rant. Apple didn't invent this. And what they've got doesn't even measure up to what was out there a decade ago. More marketing flim-flap and frip-frappery. But hey, at least it's stylish.


Experiments in WPF… Part 1

Just for the hell of it, I’m learning WPF and Silverlight (I’m sure it’ll be useful for work at some point).

Here’s the result of my second hacky experiment in building UIs. No real code behind this yet; just UI hackery – although it does show up on-screen and you can resize it:

WPF Facebook App

Let’s look at how this is built.

The Window and Border

First, I have a 4-pixel corner, 2-pixel wide on all sides Border element inside the Window and outside the DockPanel which forms the root of the UI layout.

The Window is set to have a transparent (null) background brush. It has a WindowStyle of None, AllowTransparency is set to True, and its ResizeMode is ResizeWithGrip.

You can move the Window by dragging any non-clickable control in the title-bar. This is achieved by adding an event-handler to the MouseDown event, checking if it’s the Left mouse button which is down, and then if it is, calling DragMove on the Window object’s instance from the handler.

Inside the window is a DockPanel, which forms the root of the layout. In the Top, we have the Title Area. In the Bottom, we have the Status Bar. Left as the last item is a ListBox which is going to fill the remaining space. (Although I still need to play around with this and maybe just switch it to a ScrollView; all of the clicking you’ll do on the app is via Hyperlinks as I see it right now).

The Title Area

The Title area is another DockPanel, where the Bottom docking area is filled with the Update Status TextBox and associated buttons (which is, itself another DockPanel).

After this in the file (so that the update status are fills the whole width of the window, but so that the logo stays flush-left instead of taking up the whole left-hand side) is the facebook logo, which is a simple Image element.

Filling the rest of the space, there’s a horizontal StackPanel, which contains the TextBlock containing a Hyperlink (the “more…” text).

The comment, like and share items are all Hyperlink elements inside a WPF TextBlock element.

The sneakiest part here is the use of a BulletDecorator in the “Update your Status” area. The name part – Simon Cooke in the diagram – is the BulletDecorator’s bullet, whereas the TextBox is the BulletDecorator’s content. The reason this is sneaky? Because this gets us the text on the left auto-aligned with the baseline of the text in the textbox. Pure awesomeness :)

The Status Bar Area

The Status Bar area (which will collapse when it’s not doing anything so as to not take up wasted space) is at the bottom of the first DockPanel. It’s literally a StatusBar control, with two StatusBar items; a TextBlock for the text, and a ProgressBar for the progress indicator. The only real trick here is the use of a margin on the ProgressBar of about 10 pixels, so that the sizing grip doesn’t overwrite it. (This should probably be grabbed from the system properties, but it isn’t yet).

The Main Window

The main part of the window (containing the status updates) is a ListBox, filled with a bunch of ListBoxItems. Each of these contains:

A Grid, with a 54-pixel wide column on the left, which the facebook user image goes into. The right-most column fills the available space.

The right-most column then contains a textblock with runs, spans, images, hyperlinks etc to fill in the relevant info for that item.


Well, it looks like the job of doing something that looks nice & stylized in WPF is pretty easy. Next up, I try to find out how hard it is to grab real live data and stash it in. (I’ll post the XAML code up at some point for those who are interested).


subscribe via RSS