Tuesday, 27 December 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.

Tuesday, 20 December 2011

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.

Wednesday, 14 December 2011

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.

 

Wednesday, 7 December 2011

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, Pakistan
  • AND these drones are piloted out of the suburbs of Las Vegas, Nevada
  • THEN 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.

Tuesday, 6 December 2011

Monday, 21 November 2011

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.

Saturday, 5 November 2011

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.

Wednesday, 19 October 2011

Monday, 17 October 2011

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.

 

Thursday, 13 October 2011

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 co-creator of Unix, the operating system that has morphed into Linux and Mac OS X.

In 1983, Ritchie was co-awarded the Turing Award. This is the Nobel Prize of computing.

 

Thursday, 29 September 2011

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.

Access library lion

Read more ways here.

Wednesday, 28 September 2011

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 Chrome

2) 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 key

It 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.

 

Tuesday, 20 September 2011

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.

http://www.youtube.com/watch?v=3GWJC7tlYck

 

Monday, 19 September 2011

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 7

The rumour is that Google will shortly be announcing a new language that runs in the browser as a replacement for JavaScript. AND runs on the server as a replacement for Java, C#, PHP, etc. In light of typing, it promises optional typing. I look forward to it.

 

 

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.

 

Tuesday, 13 September 2011

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.

 

Tuesday, 6 September 2011

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 javanewsletter.com domain for about $10 from GoDaddy.

I'm using an existing under-utilised "slice" I have at SliceHost to host the single-page website.

To promote the list, I've done little so far. I put a link on the Poker Copilot blog, on my Hacker News profile, and on my StackOverflow profile.

Currently I have 56 subscribers. I hope to see this list grow to thousands of subscribers within a year or so. I'm pretty sure I can achieve this if I'm diligent, persistent, and patient. I'm also keenly reading various articles on how to best run an email newsletter.

 

Monday, 5 September 2011

Throbbin' 84

Throbbin '84. That was the first album I got.

Throbbin84.jpg

For my 12th birthday, to go with my brand new Walkman.

2bb81cd4_sony-walkman-cassette-1.jpg

Friday, 2 September 2011

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.

Wednesday, 31 August 2011

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.

 

Sunday, 7 August 2011

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:

Chile mountain

Saturday, 6 August 2011

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.

Wednesday, 13 July 2011

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.

 

Monday, 11 July 2011

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.

 

Thursday, 30 June 2011

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.

 

Thursday, 23 June 2011

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:

Screen shot 2011 06 23 at 5 21 03 PM

This reflects my intention that Dubbiya be a tool for physical data modelling, not logical data modelling.

 

 

Wednesday, 22 June 2011

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.

 

Monday, 20 June 2011

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 function

}

In Java I like to use the Preconditions class from Google's guava-libraries. I wondered if I could do something similar in JavaScript to avoid this template code for simulated type-checking:

if (typeof dubbiya === 'undefined') {
    dubbiya = {};
}

if (typeof dubbiya.preconditions === 'undefined') {
    dubbiya.preconditions = {};
}

dubbiya.preconditions = {
    checkArgument : function(expression) {
        if (!expression) {
            throw "IllegalArgumentException";
        }
    }
};
I can use it as such:
function createRelationship(type) {
dubbiya.preconditions.checkArgument(
type === 'one_to_one' ||
type === 'many_to_many' ||
type === 'one_to_many' ||
type === 'many_to_one');
    // now do the actual stuff for the function

}
I like this because when I look at the code, I see immediately that this is type checking code, and not business logic.

Thursday, 9 June 2011

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 shown
  • You can toggle the log on and off with Ctrl+L
  • The faded-out effect on the first message is intentional - a little experiment with HTML5 canvas gradients and rgba colours

Screen shot 2011 06 09 at 6 04 17 PM

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 drops will give me the excuse to buy a new one.

Wednesday, 8 June 2011

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.

Saturday, 4 June 2011

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.

 

 

Friday, 3 June 2011

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 attractive

A 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 really is - it treats like just a pretty picture.

What do all these have in common? They are more awkward to use than a white board. It is click-click-click-type-click-drag-type, etc. I do my database design on a whiteboard, then switch to software to make it look good. Dubbiya eliminates the whiteboard step. It eliminates the click-click-click-type-click-drag-type step.

  • Creating a database diagram in Dubbiya is as simple as typing the names of the entities, and indicating the relationships with simple key presses.
  • Sharing a diagram is copying the URL and sending it via email to a colleague.
  • Diagrams are saved "in the cloud" so you can continue editing and viewing from any Internet-connected computer.
  • SQL is generated automatically as you go.
  • Surrogate primary keys are auto-added.
  • Foreign keys are auto-added.
  • Many-many relationships are magically turned into junction tables.
  • It's a tool meant for knocking up a small entity-relationship diagram for a new project, or to be added to a larger design.
  • It's a tool for use by those doing the implementation, as opposed to the analyst. Therefore it always creates physical models instead of logical models.

It solves pains I've often had when I did IT consulting:

  • the computer I was given to use didn't have the database software I needed. I had to beg, work through bureaucracy, use gratis but less able software, or work on my private computer. Hence Dubbiya is in-the-browser install-nothing software.
  • because I wasn't using the ER diagram software every day, there was a learning curve each time I used the software again. Hence ease of use is a heavily-weighted criterium for Dubbiya.

Yes, this is a big undertaking. Yes, there is a long way to go. Like I did with Poker Copilot, I'll develop Dubbiya iteratively, based on feedback.

 

 

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.

Friday, 27 May 2011

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:

Screen shot 2011 05 27 at 12 05 37 PM

into this:

 

Screen shot 2011 05 27 at 12 05 43 PM

 

Try it yourself here. Each time you refresh the page, it'll start again with a new random arrangement.

 

Thursday, 26 May 2011

Dubbiya with popup help

Gmail has a nice popup window that shows keyboard shortcuts. Press '?' in Gmail and you'll see it.

Gmail help

 

I wanted to add something similar to Dubbiya. The jQuery expansion FancyBox gave it to me.

Screen shot 2011 05 26 at 3 17 25 PM

You can click on the help icon next to the "Quick Add" box. Or when the drawing area has the focus, you can press '?':

 

 

Wednesday, 25 May 2011

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 < Student
Student = Subject
Subject - Teacher

Screen shot 2011 05 25 at 3 11 48 PM

 

The 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 with

function doSomething(x, y) {
...
}

A good IDE alerts you to this before it bites you:

Screen shot 2011 05 25 at 11 20 33 AM

 

 

 

 

 

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 = {};
}

Then each function definition is added as such:

dubbiya.geometry.intersectionPointLineLine = function (line1, line2) {
...
};

Now I can call the function as follows:

var pt1 = dubbiya.geometry.intersectionPointLineLine(line1, line2);

It's a bit silly that one needs to artificially create namespaces. Luckily a good IDE makes this style of code readable:

Screen shot 2011 05 25 at 11 18 06 AM

Tuesday, 24 May 2011

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.

Screen shot 2011 05 24 at 4 26 40 PM

Screen shot 2011 05 24 at 4 26 48 PM

Type "Person-Address" into the "Quick Add" box, and you'll get two new entities, and a line between them:

Screen shot 2011 05 24 at 4 29 41 PM

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.

Screen shot 2011 05 24 at 4 30 48 PM

Sunday, 22 May 2011

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)) {
    ...
}

or

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.