Showing posts from 2011

Best Christmas Movie is...

Die Hard?If you want a Christmas classic that's a little more traditional -- but only a little -- you'd best watch "Die Hard." It's the heartwarming story of a man reuniting with his estranged wife on Christmas Eve -- after he disposes of a few terrorists. Now that's productive holiday.

The Inverse of Angry Birds

The pigs have been misunderstood. Save the pigs and their families from disaster by building structures to block the onslaught of incoming projectiles.The game is called Misunderstood Pigs and is available on in iOS App Store.This is reminiscent of The Last Ringbearer, which is Lord of the Rings rewritten from the perspective of Mordor.

Is Piracy in Russia a Problem?

One thing that we have learned is that piracy is not a pricing issue. It’s a service issue. The easiest way to stop piracy is not by putting antipiracy technology to work. It’s by giving those people a service that’s better than what they’re receiving from the pirates. For example, Russia. You say, oh, we’re going to enter Russia, people say, you’re doomed, they’ll pirate everything in Russia. Russia now outside of Germany is our largest continental European market.That's from How Valve experiments with the economics of video games. Read how the today's model of Internet-purchase and -delivery allows much experimentation with pricing.

Terrorism or Warfare

The always interesting, if often paranoid, "War Tard" cites PW Singer:IF armed unmanned drones are used against legitimate military targets in, say, PakistanAND these drones are piloted out of the suburbs of Las Vegas, NevadaTHEN is a Pakistani 'radical' car bomb in the Walmart parking lot outside that Air Force base in Las Vegas an act of terrorism... or a legitimate act of military retaliation?The whole article is worth reading.

Breaking into Banks

Worth watching: a man whose job was to break into banks.

TED Talk on Board Game Design

If, like me, you are a keen player of board games, you'll enjoy this TED Talk about how game design has evolved due to the German "Spiel des Jahres" award.

iTunes songs don't come with lyrics

I buy music often on  iTunes. My most recent purchase was my good friend Michiko's newest track. It puzzles me why lyrics are not included when I purchase a song from iTunes. Instead I have to use the excellent beaTunes to add the lyrics from dodgy sources.

What is the optimal Jewish toenail cutting algorithm?

That's the eye-catching title to a Stack Overflow question.From a comment on the accepted answer I learnt a new word: Polydactyly

The Endor Holocaust

What happens when you detonate a spherical metal honeycomb over five hundred miles wide just above the atmosphere of a habitable world? Regardless of specifics, the world won't remain habitable for long.That's from the Endor Holocaust.  Even though I resent the Ewoks as the most concrete example of the muppet-isation of Star Wars, I am appalled to learn of their most likely fate at the hands of the Rebels.

This time, a Significant Death for IT

Last week Steve Jobs died. From the media, the obituaries, and the person in the street, you'd think we had lost a combination of Martin Luther King, Mahatma Gandhi, and Leonardo Da Vinci. The truth was, he was the CEO of an extremely successful company that feeds consumerism, and the world went gaga. In my opinion it was uncalled for.Today the news is that Dennis Ritchie died. Dennis Ritchie may be unknown to most people, he may not get accolades from politicians, but he was a far more important person in the IT world. He created the C programming language, which is simply the most significant, influential programming language there is. After 40 years (which is a grand epoch in IT time), a variant of C (Objective-C) is still used for most Mac software and iPhone software. Untold IT students and programmers carried around a well-worn copy of a book co-authored by Ritchie, The C Programming Language, which is THE book which got us into C and serious programming.Ritchie also was a c…

Beautiful Clock on a Webpage

Accessing Library Folder in Mac OS X 10.7 (Lion)

By default you can't see your Library folder in Finder in Mac OS X 10.7, also known as Lion. Fortunately there are several ways to access it sill. My favourite is this one:Holding down the Option key will show the “Library” directory as an option in the Finders Go menu. The other nice thing about the Go menu is that after you have accessed ~/Library on multiple occasions, it will start to appear in the “Recent Folders” submenu for easy repeat access.Read more ways here.

Mac + Chrome + Facebook + Writing a Message = Crash

For the last couple of weeks, I couldn't write multi-line messages in Facebook on Google Chrome on Mac OS X. Some other web sites also had this problem. If I persisted in trying too much, then the browser tab would crash.I solved this by deleting my Google Chrome Profile. I did it as follows:1) I closed Google Chrome2) I opened Terminal, by typing Terminal into Spotlight, and opening the "Top Hit".3) In Terminal I typed the following (use copy + paste):rm -rf ~/Library/Application\ Support/Google/Chrome/
4) I pressed the enter keyIt took several seconds to complete. Once it finished, I opened Google Chrome, and it acted like it was opened for the first time. Facebook now lets me enter multi-line messages without crashing.

The McGurk Effect

It sounds like the name of a bad teen comedy. Actually it is the name of a phenomenon whereby what you see can affect what you hear.It's rather cool.

Joke of the Day

Stick through to the end. You won't regret it.

Bad JavaScript Bug and typing

Johan thinks I was unfairly bashing untyped languages in general in this post.Here's how I think JavaScript (or an alternative) language should best handle the following code:var s = '7';
var num = s * 5;The virtual machine should now know that s is of type String. The virtual machine should now halt and report an error. You shouldn't be able to multiple a String by 5. Unfortunately JavaScript automatically tries to turn the string into a number, thereby giving us 35.The following code should be necessary:var s = '7';
var num = parseInt(s)*5;I suggest this not because of one JavaScript problem. I suggest it because I've seen JavaScript continue to negatively surprise programmers for 12 years.Here's my favourite example of the mysterious workings of JavaScript:var s = '7' + 0; // s is a string containing '70'
var t = '7' - 0; // t is a  number containing 7The rumour is that Google will shortly be announcing a new language that runs i…

Ebay…addictive, anarchic, and archaic

I'm caught up in the fun of selling stuff on eBay. But really, some of the people who use it…I advertised a bookshelf with the measurements and colour listed clearly in the product title. Someone asks, "how wide is it? what colour is it? how high is it?"And the user interface…it is like the last decade of web application user interface improvements never happened!I just hit a limit on how much I could sell. AFTER I spent 15 minutes creating a detailed listing for my iMac, eBay informs me I can't sell it for another 90 days because I've sold too many things in certain restricted categories.So I'm going to have to sell my iMac the old-fashioned way. Even more old-fashioned, that is, than eBay.

He Photographs his TV Viewing

Norman Fineman has seen it all.This makes me despair. And laugh.

Bad JavaScript Bug

Here's a great StackOverflow question that demonstrates how easy it is to create bizarre bugs in JavaScript.Give me strongly-typed languages any day.

Java Newsletter

As a side-project, I started The Java Newsletter some time ago. The Java Newsletter is an email newsletter. Subscribers receive weekly tips on the Java programming language.Sign up for the Java Newsletter here.I read sometime ago that the world of blog-followers and RSS feed readers is somewhat a minority of Internet users. Most people - including developers - are best served via newsletters, directly in their email inbox. This got me thinking. Java is something I know well. There are millions of Java developers. I could write on enough Java topics to keep a weekly email list going for at least a year. It takes about an hour per week to create an article, test the code, proof-read it, and to send it. Why not give it a go?I used Wufoo to create a simple sign-up form, for free.I used MailChimp to manage the list of subscribers and to send the weekly email.Topics come from Effective Java, StackOverflow, and my head.I bought the domain for about $10 from GoDaddy.I'm…

Throbbin' 84

Throbbin '84. That was the first album I got.For my 12th birthday, to go with my brand new Walkman.

No TV. Not missing it. Yet.

I sold my television on Monday. It sat there unused except occasionally being hooked up to a computer when I had guests, in order to brutally subject them to a excruciating, long session of the best of my travel photos, going way back to 2004. Digital cameras have bequeathed us new types of suffering.It's now Friday. I don't miss the television at all. Which makes me wonder why I bothered having one for so long. A living room with a television does look somewhat empty, as if to inform visitors that I live a deprived half-life. I think I need to put a plant where the television was. My plants, however, are all unpleasant to look at, suffering from extended bouts of low-water life, in soil that probably lost all nutrients long ago.

Selling on the eBay for the first time

So…for the first time ever I tried creating an auction on eBay. I'm surprised how cumbersome the process is…and buggy. I would have thought after all these years, eBay would have an excellent process. Is this what happens in a natural monopoly?Here's what I'm selling.

Quote of the Day

Well, if it is the quote of the day it is 14 years too late. Steve Jobs, at the WWDC 1997:Mistakes will be made, but that's good because it means decisions are being made.That's my business philosophy. Do. Reflect. Do some more.

When 6.3 mm of rain is too much

A few years ago I passed through the Atacama Desert in Chile, the driest place on earth. Not a blade of grass, not a single shrub, not a single creature, just expanses of dry mountainous valleys. They get rain on one day every decade, roughly.Yesterday was one of those once-a-decade days, and it wreaked havoc.A similarly wet stretch in early July dumped four years' worth of rain in one day on coastal Antofogasta. That was just a quarter of an inch (more than 6.3 millimeters) but it was still enough to cause collapsed or leaking roofs in homes and businesses that usually have no reason to protect themselves against even minimal precipitation.Here's a photo I took near where the Atacama Desert starts:

The Economic Cost of Civil War

Yesterday I crossed the border from reasonably wealthy Costa Rica to dirt-poor Nicaragua. With the power of Google's public data explorer and some World Bank data, I compared historic GDP per capita for the two countries.The 80's were a turbulent time for Nicaragua. Until then the countries had been rather close in economic development and growth.

Cory Doctorow on 21st Century Writing

Cory Doctorow tells us how he manages to write a book a year, half-a-dozen columns a month, plus plus plus, in a world of ever-present Internet distractions.By all means, schedule a chat — voice, text, or video — when it's needed, but leaving your IM running is like sitting down to work after hanging a giant "DISTRACT ME" sign over your desk, one that shines brightly enough to be seen by the entire world.I have the same opinion of coding. When I really need to concentrate on getting some code written, I need to kill Skype, iChat, and facebook, even if for 30 minutes.

Dubbiya News: What Happened?

A friend who reads this blog (Hi Johan!) mentioned that I seem to have stopped on the Dubbiya project (my in-the-browser database entity-relationship design tool).He's right. I'm just taking a summer pause. First I suffered some "analysis paralysis" as I worked out how to handle saving data models "in the cloud". Then I tried to use Dubbiya to design a real-life data model I needed - and found that actually I've got a lot still to do to make it useful. However being the middle of summer it was time to visit people and be visited. For the next month or two, little or nothing will continue to take place on Dubbiya. After summer though, I've got plans. Big plans!

Coding Outside of Large Corps

In the short time I've been outside Google I've created entire apps in Java in the space of a single workday. (Yes, you can program as quickly in Java as in Ruby or Python, if you understand your tools well.) I've gotten prototypes off the ground, shown it to people, or deployed them with hardly any barriers.That's from an ex-Google coder.

Golden Rules of Computer Security

The three golden rules to ensure computer security are: do not own a computer; do not power it on; and do not use it.That's from computer security pioneer Robert Morris, who passed away recently.

Improved Many-to-Many Relationships in Dubbiya

A class has many students. A student has many classes. In data modelling, this is a classic example of a many-to-many relationship. Type "Student = Class" into Dubbiya, my nascent browser-based, HTML5-dependent entity-relationship modelling tool, and until today, you got a Student entity, a Class entity, and a line between them.The problem is, relational databases can't actually have real many-to-many relationships. You need to simulate them using an in-between table. Dubbiya now creates this for you:This reflects my intention that Dubbiya be a tool for physical data modelling, not logical data modelling.

Why No Alternatives to JavaScript?

This is a question whose answer I can't find.When you put some JavaScript in a web page, you use this syntax:<script type="text/javascript"> document.write("Hello World!") </script>You explicitly state that this is JavaScript.It's been 16 years since JavaScript was invented. Why have no alternative languages been developed and added to HTML? Clearly HTML allows for the possibility. JavaScript is a language created in ten days, launched without time to go through a "are we really doing this a good way" phase. Hence there are several bad things in JavaScript. An more rigorously developed alternative would be valuable.CoffeScript exists. But this must be compiled into JavaScript before adding to a web page.

JavaScript, Type-checking, and Preconditions

So JavaScript doesn't have type-checking. Which was the root source of a bug that took me a while to find.I'm so much more comfortable with strong type-checking. In many languages, I can create a new type, including its allowable values. In Java, for example, here's a type I created:public enum RelationshipType { ONE_TO_ONE, MANY_TO_MANY, ONE_TO_MANY, MANY_TO_ONE } Now I can specify that a function (method, actually) only accepts one of these four values wherever I need a relationship type.In JavaScript, a function parameter can be ANYTHING - number, string, array, or object. You need to manually check the values. Which leads to template code like this:function createRelationship(type) {
    if (!(type === 'one_to_one' ||
type === 'many_to_many' ||
type === 'one_to_many' ||
type === 'many_to_one')) {
throw 'IllegalArgumentException';

// now do the actual stuff for the functi…

Dubbiya with better logging

Having the big window for Dubbiya log messages was ugly. So I took some inspiration from modern computer games and put the log right into the main canvas.The last 20 log messages are shownYou can toggle the log on and off with Ctrl+LThe faded-out effect on the first message is intentional - a little experiment with HTML5 canvas gradients and rgba colours

Dubbiya now sorta working on iPhone

It turns out that Dubbiya, my entity-relationship diagram maker in-the-browser tool, works somewhat on iPhone and Android. But you couldn't move entities around. On a desktop computer in JavaScript you use mousedown, mousemove, and mouseup events to track what the user does with the mouse. Using these I've implemented the moving around of entities. On the iPhone, you don't have a mouse, and therefore these events don't work. However there are touchstart, touchmove, and touchend events. They are similar to the mouse events, but not quite the same. Now you can whip out your iPhone or (hopefully) Android device, or even (again hopefully because I ain't got a) iPad, open Safari, go to Dubbiya, and move the entities around by dragging them. While testing this, I dropped my iPhone YET AGAIN. Another crack opened in the case, another small piece of plastic flew off. I wonder how many more drops my iPhone can survive. The iPhone is roughly two years old, so maybe these…

Dubbiya Layout with Animation

Dubbiya, my fledgling browser-based ER diagram app, now animates the auto-layout. This is less jarring that the sudden jumping around of entities. Watch a demo (best in HD or full-screen):Try it here.

Animation in HTML5 Canvas

A friend pointed me toward an excellent one-hour presentation on creating games in HTML5. I applied the animation techniques I learnt from the presentation to Dubbiya, my experimental browser-based database entity-relationship project. Click the "Animation" button and the background text follows a trigonometric path across the canvas.Clearly this is not so useful yet. It is just a small test to understand the issues with animation in HTML5. I intend to use the technique to animate automatic changes to the diagram layout.

What is Dubbiya? Rethinking Entity-Relationship Diagrams

Dubbiya is the code name. I hope a better name comes to me soon. Suggestions welcome.My vision for Dubbiya:database design in the browser;that works WITH you;that doesn't involve fiddling around with lines and layout;that is as easy to use as drawing on a white board;yet looks damn attractiveA month ago, Dubbiya was nothing more than an itch to try out HTML5's new Canvas feature. Now it has become an embryonic project.I've been creating entity-relationship diagrams for years. First I used ERwin, which was powerful software with a clumsy user interface. It did the job, but you had to fight somewhat to get it done. Then came Visio, which I started using before Microsoft acquired it. This was a big step forward from ERwin for usability. Another product I've used and loved is SQLEditor for Mac OS X. It wins on simplicity and prettiness. The Mac world also has OmniGraffle, which makes pretty diagrams but doesn't have smarts about what an entity-relationship diagram rea…

Dubbiya now with auto-layout

I integrated my JavaScript graph layout code with Dubbiya. Now when you add an entity, the diagram is automatically laid out. At the moment it is a bit annoying because each time you add an entity the whole diagram changes. I think I'll experiment with anchoring some entities or introducing some animation that makes the jumping around less visually distracting.

Automated graph layout

Oh this is fun.I want to add automated graph layout to Dubbiya, my embryonic browser-based database diagramming tool. I've been doing my research (i.e. reading Wikipedia) and have found a way to turn this:into this:Try it yourself here. Each time you refresh the page, it'll start again with a new random arrangement.

Dubbiya with popup help

Gmail has a nice popup window that shows keyboard shortcuts. Press '?' in Gmail and you'll see it.I wanted to add something similar to Dubbiya. The jQuery expansion FancyBox gave it to me.You can click on the help icon next to the "Quick Add" box. Or when the drawing area has the focus, you can press '?':

Dubbiya now has different relationship types

Dubbiya can now do one-to-many, many-to-one, one-to-one, and many-to-many relationships.Here is the result of the following "Quick Add" entries:Form < StudentStudent = SubjectSubject - TeacherThe syntax is:one-to-many: [entity 1] < [entity 2]one-to-one: [entity 1] - [entity 2]many-to-one: [entity 1] > [entity 2]many-to-many  [entity 1] = [entity 2]

Remembering how to do geometry; JavaScript 'namespaces'

To make the lines representing relationships in Dubbiya, I needed to find where a line intersects a rectangle. I was pretty sure I once knew how to do this. But the knowledge was lurking in an inaccessible part of my mind. So I needed to do some relearning.I enjoy these parts of projects like Dubbiya. It is many times more enjoyable than the forms-and-reports programming than most of us software developers have to do in their professional life.Along the way, I learnt that you can't have two functions in JavaScript with the same name, even if the number of arguments differ.function doSomething(x) {
}clashes withfunction doSomething(x, y) {
}A good IDE alerts you to this before it bites you:I also learnt a relatively nice way to emulate namespaces in JavaScript. At the top of each JavaScript file I can have something like this:if (typeof dubbiya === 'undefined') {
dubbiya = {};
}if (typeof dubbiya.geometry === 'undefined') {
    dubbiya.geometry = {};

Dubbiya now with tooltips and relationships

Work continues on Dubbiya, the code-name for an in-browser entity-relationship diagram editor. There's now tooltips and relationships.Let the mouse sit over a shape for a couple of seconds and you'll see a tooltip.Type "Person-Address" into the "Quick Add" box, and you'll get two new entities, and a line between them:Now type "Address-Country" into "Quick Add". Because Address already exists, only a Country entity is made. It is connected to the existing Address entity.

Adding a method to a built-in JavaScript object

I discovered I can easily add my own methods to the String object - or any other built in object. JavaScript is missing a String.startsWith(prefix) method, so let's create one:

String.prototype.startsWith = function (s) {
    return this.length >= s.length  && this.substring(0, s.length) === s;

Now I can write
if (myString.startsWith("foobar)) {


if ("Saturday".startsWith("Sat")) {

So easy...but there is a problem. If I'm using a third-party JavaScript library, it might add an identically-named method to String, overriding my version. Their version will have different bugs than my version, leading to horribly difficult debugging sessions.

I don't yet know a sane solution to this. The best I've come up with is to give my own extra methods a nasty prefix.