Friday, May 28, 2010

Why you shouldn't multitask

Two great articles on why multitasking is not only bad for getting work done, but also damaging to our bodies and brains: here and here (yes, I know one of them is from the Daily Mail, pretend it isn't!). Well worth reading - I'm going to try to stop multitasking as much as possible (no more half-watching TV in the background, reading email/articles, talking, listening to MP3s all at once and so forth).

A couple of choice quotes:

"He found that just being in a situation where you are able to text and email - perhaps sitting at your desk - can knock a whole ten points from your IQ. This is similar to the head-fog caused by losing a night’s sleep."

"An American study reported in the Journal Of Experimental Psychology found that it took students far longer to solve complicated maths problems when they had to switch to other tasks - in fact, they were up to 40 per cent slower.
The same study also found multitasking has a negative physical effect, prompting the release of stress hormones and adrenaline.
This can trigger a vicious cycle, where we work hard at multi-tasking, take longer to get things done, then feel stressed, harried and compelled to multi-task more."

"Using brain-scans he’s found that if we multi-task while studying, the information goes into the striatum, a region of the brain involved in learning new skills, from where it is difficult to retrieve facts and ideas. If we are not distracted, it heads to the hippocampus, a region involved in storing and recalling information."

Thursday, May 20, 2010

Monday, May 17, 2010

Legislators and corporate donations

Was reading the Wikipedia article about a senator with some disturbing views on homosexuality (his office said he "does not hire openly gay staffers due to the possibility of a conflict of agenda"), Israel (that America should base its Israel policy on the text of the Bible, WTF!) and the rights of prisoners (saying he was "outraged by the outrage" over relevations of abuse in Abu Ghraib, and one of nine senators to vote against an act prohibiting "cruel, inhuman or degrading" treatment of individuals in U.S. Government custody).

Then I saw this part. Inhofe is highly sceptical of the climate change, an issue which I'm somewhat undecided about. Fair enough, but surely receiving a $429,950 "donation" from the petroleum industry is a serious conflict of interest?

U.S. senators make huge decisions on bills and treaties, as well as appoint high level government officials and judges. Surely if they can receive donations from any source, then effectively it means the richest corporations and industries can unfairly influence government policy?

Would it not be better (democratically speaking) if there were no such donations and politicians received some fixed amount for their campaigns from government coffers?

Tuesday, May 11, 2010

Automated refactorings... check that they work!

Many modern IDEs provide automatic, context-sensitive refactorings, especially for statically-typed, popular languages like Java. While you should use these wherever it saves time, you should check that they preserve semantics on the code they transform.

For example, in the following test code, Eclipse will offer to "exchange left and right operands for infix expression" when you try a quick fix (cmd-1 on a Mac, ctrl-1 elsewhere) at the '&&' on line 2. The refactoring transforms "(a || b) && c" into "c && a || b".

 boolean a = true, b = true, c = false;
boolean original = (a || b) && c;
boolean swapped = c && a || b;
assertTrue(!original); // ok
assertEquals(original, swapped); // fail


Note that the parentheses have disappeared - at first I assumed that they must therefore be unnecessary and "c && a || b" is therefore equivalent to "c && (a || b)", but figured that the parser should evaluate from left to right (which would produce different results). Being unconvinced one way or the other, I made a simple testcase to verify that both expressions were logically equivalent, which failed.

I'm not sure why Eclipse removed the parentheses, and it doesn't really matter - the point is, keep an eye on what your code transformation utility is doing - don't assume that it must produce correct output. This was one of those cases where the logic bug might not show up for a while, and the existing unit tests wouldn't have caught it, unless I bothered to run a (probably outdated and slow) integration test.

Abandoned locks

When people arrive back to where they locked their bicycle and find it vandalised, they often just abandon them forever, so you find bike racks with a certain percentage of rusting, ruined bikes.
Fair enough but... why do they leave them locked there, if they're never coming back? The locks are sometimes more expensive than the bike (or at least a new wheel). Why not take the lock home? Then a) people can recycle the bike if they want, b) people can use that parking slot and c) the victim at least doesn't have to buy a new lock for €€€ in future!

Saturday, May 08, 2010

Thoughtless showers

(from Wikipedia article on brainstorming)
Some governmental organisations (The Welsh Development Agency and the Department of Enterprise, Trade and Investment in Belfast) have reached the conclusion that the term 'brainstorming' is offensive to people with epilepsy (see political correctness) and have suggested the alternative "thought-showers".

Oh you stupid, stupid people. You hideously moronic, making-reasons-to-get-offended-about-clearly-inoffensive-things obsessive wankers. You waste public tax funds to research what existing terms could be deemed offensive to somebody by reading it in some contrived and obviously unintended context - something which is completely out of your mandate.

Happily, the article continues:
However, research by the National Society for Epilepsy found of those affected by epilepsy questioned, 93% considered the term inoffensive. A specific comment states that changes need not be made since that could promote an undesirable image of epileptics being easily offended.

Here's a tip for (predominantly) UK government-funded organisations: do your job. Don't waste your time and money determining which terms might offend somebody somewhere if viewed in some funny way. That's not your job.

Thursday, May 06, 2010

Vote for against change, or something

Accidentally caught a political ad on BBC between/after snooker the other day, by the DUP/UUP or some-other-wankersUP. The guy went on about how if you let xxx in, they'd let all the Scottish and Welsh nationalists break up "the union", so you should vote him in instead.
Then, immediately after he says his piece, the words "VOTE FOR CHANGE" appear on the screen.

WAT??? Wasn't he just campaigning AGAINST change?

Opera 10.53 on the Mac: Crash central

The latest release builds of Opera for the Mac are atrocious, crashing all the time. All. The. Fucking. Time. And with seemingly random user interactions leading up to the crash, which kind of suggests a race condition, memory allocator or some other effectively random bug, although I have so many damn tabs open, many of which have JS stuff going on in the background, that it's hard to tell.

Another thing which makes it even harder to tell, is the rubbish stack trace provided when it crashes. A major downside to having closed-source software like Opera is that you can neither properly investigate these crashes nor solve them properly. Why not provide at least some kind of assertions or at least filename/line numbering in the stack traces? AFAIK, adding that sort of debug info, even for a shitty language like C++, isn't that big of a performance hit.

And if they're purposely obscuring debug info because Opera is closed source, then WHAT THE FUCK. Nothing "damaging" would be leaked by such information. Blargh!

Sunday, May 02, 2010

Using tor/Vidalia to access BBC iPlayer (etc) outside the UK

There's a decent article explaining how to set up tor/Vidalia to access sites like BBC's iPlayer which only allow connections from certain countries (like England). Not mentioned in the article (although someone added a comment about it) is that now you do not need to manually select exit nodes in the UK - you can specify exitnode countries in your torrc files by putting a two character country code in braces. This makes the process much easier!

I'm running on a Mac with Vidalia, so the setting file (you can find the location of it in the Vidalia settings dialog's advanced tab - but it's probably ~/Library/Vidalia/torrc) ends with:
ExitNodes {GB}
StrictExitNodes 1

Note that the country code is GB and not UK, which a couple of posts/articles online misleadingly state.

There's another problem with the recent Mac builds - the geoip file is in the wrong place, leading to log messages like the following:
[Warning] Failed to open GEOIP file /Applications/Vidalia.app/share/tor/geoip. We've been configured to use (or avoid) nodes in certain countries, and we need GEOIP information to figure out which ones they are.

That was solved like this (from the terminal):
cd /Applications/Vidalia.app/
mkdir -p share/tor/
cp Contents/Resources/geoip share/tor/

Then stop and restart tor.

Update: StrictNodes should now be StrictExitNodes.