Monday, August 30, 2010

WPF, TextBox and currency

Getting data to look right in WPF can be a bit tricky. I wanted integers to appear as currency, but without any decimal points. After a bit of stuffing around I went from:
<TextBox Text="StringFormat=C}" />
to
<TextBox Text="StringFormat=\{0:$###\,##0\}}" />

Friday, August 27, 2010

Metaheuristic

I was trying to explain the sorts of algorithms I use at work to a friend the other night. In general, they're called metaheuristics (in particular, I have experience with simulated annealing and genetic algorithms.) I used an analogy of an ordinary heuristic like one that tries to find the shortest path between to points.

Shortest path: Imagine you want to find X marks the spot on a map. However, there are all these barriers in the way and you can't really be sure if the route you're taking will 1) get you there; or 2) get you there with the least steps. However, so long as there is someone/something telling you how far away you are from the X, you should always be able to find the shortest route - if there is one. That's A*.

To describe when to use a metaheuristic, however, I said "well, imagine you don't actually know where X marks the spot is." But it's much worse than that. Imagine you don't really know where it is and no matter which direction you take you don't necessarily or reliably get any closer to X. For example, you start a long way from X; you go ten metres north and you're close; then go twenty metres south and you're just as close. But, actually, the closest you could ever get to X might be five metres east from the start! It just doesn't make any sense. Like someone calling out "hotter" or "colder" seemingly at random when you're trying to find something. They aren't lying to you, it's just really hard to find. If you have a situation like that, use a metaheuristic, or punch them.

Monday, August 23, 2010

WorkChoices and Fair Work Australia

Being a little ignorant of IR policy differences between the ALP and the Liberals, I thought I'd dot-point the similarities and differences they had/have.

Similarities:
  • Can only strike during a bargaining period;
  • Industry-wide (pattern) bargaining is banned;
  • Secret ballot required before industrial action;
  • A single, national industrial relations system;
Differences:
There are more differences - even less significant - however, all the differences are minor compared with the similarities.

The non-voters

I am part of the millions of Australians who don't vote. About 8% of people living in Australia aren't on the electoral roll. There are also about a million overseas who don't vote. Add to that the informal votes, up from 4% to 6% for the 2010 election and you have about 20% of the population eligible to vote who don't.

For a country that rushed in compulsory voting after the massive drop-out 1922 election (60% turnout), I am proud to announce that we're back!

Not that not voting changes anything. How can it? Voting doesn't change anything. Nevertheless, one should not encourage them. It's poor form.

Wednesday, August 11, 2010

Watts Riots started today, 1965


The Situationists had a little to say about the riots.
Let the economists fret over the $27 million lost, and the city planners sigh over one of their most beautiful supermarkets gone up in smoke, and McIntyre blubber over his slain deputy sheriff. Let the sociologists bemoan the absurdity and intoxication of this rebellion.

[...]

Until the Watts explosion, black civil rights demonstrations had been kept by their leaders within the limits of a legal system that tolerates the most appalling violence on the part of the police and the racists [...]

[...]

Looting is a natural response to the unnatural and inhuman society of commodity abundance. It instantly undermines the commodity as such, and it also exposes what the commodity ultimately implies: the army, the police and the other specialized detachments of the state’s monopoly of armed violence. What is a policeman? He is the active servant of the commodity, the man in complete submission to the commodity, whose job is to ensure that a given product of human labor remains a commodity [...]

[...]

The rational world produced by the Industrial Revolution has rationally liberated individuals from their local and national limitations and linked them on a global scale; but it irrationally separates them once again, in accordance with a hidden logic that finds its expression in insane ideas and grotesque values. Estranged from their own world, people are everywhere surrounded by strangers.

Kick Ass

Kick Ass: Clever combination of Watchmen and The Professional. Excellent, ironic portrayal of vigilante fascism. Love the controversy and critical response sections on wikipedia. E.g.
Roger Ebert gave the film one out of four stars. He called the film "morally reprehensible", appalled by the violent scenes in which an 11-year-old girl murders dozens of gang members and is then almost beaten to death by an adult man. "When kids in the age range of this movie's home video audience are shooting one another every day in America, that kind of stops being funny."
Does it Robert? Does it really? 'Cause, you know, I was laughing quite a bit through those scenes.

Friday, August 6, 2010

Genetic Algorithms

There is something a little bit creepy about writing genetic algorithms. I'm not quite sure what it is...


// Run selected breeding program
while (stopWatch.Elapsed < _parameters.SimulationExecutionTime)
{
population = Selection(population).ToList();

var children = Breed(population);

Mutate(children);

population.AddRange(children);
}

Wednesday, August 4, 2010

Subversion

I have decided to hide subversive quotes in the software I am working on.

If you find them all, you unlock "The Revolution Complete" achievement.

Food Inc.

One of the best documentaries about the food industry I've seen. A US bias, but most of it applies to Australia (feed lots, GM soy, production houses for broilers, etc.). The annoying organic farmers and family farmers don't dominate.

This doco beats, by a long margin, anything Michael Moore could ever do. Really interesting.