Friday, January 23, 2009

Some People Are Idiots

I've been sick for the past week and a half. The whole stay in bed, drink lots of tea, use entire rain-forest's worth of tissue paper deal. It sucks. I've even lost the ability to speak. At least I can still write.

I've tried every remedy conceived by those old hags that live alone in the middle of some dark forest. You know the ones. It turns out that lemon really is a good anti-bacterial substance, and so is garlic. That's science. I happen to have a wife in the chemistry business, you see. The undisputed winner in the "your grandmother says its good" category of medicine is without a doubt a bit of whiskey. Well maybe most grandmothers don't recommend it, but there's nothing like 40% alcohol to burn all the nasty germs. Sure, there might be some collateral damage, but at least the germs will die. As the song goes, "Just a tea-spoon of whiskey helps the cough go away, helps the cough go away, in a most delightful way!".

So I've been thinking about all the idiots who say pearls of wisdom like:

"All You Need is LOVE"

or perhaps:

"Live Every Day As If It Were Your LAST"

You see, people who live everyday as if it were their last would never bother going to school, have children or advance mankind. It's like one of those governments in those democracies which have elections every two years. They never accomplish anything, because they are only thinking about today. Life is great because we don't live each day as it were our last.

Oh, and finally, "The Wind-Up Bird Chronicle" is a great book, right up there with such classics as "Ubik" or "The Three Stigmata of Palmer Eldritch".

Thursday, January 8, 2009

TBB and Non-Integer Ranges

I've been using the Intel Threading Building Blocks (TBB) library for a while now, and I finally figured out how to overcome one of the annoyances I had with it.

All of the examples I've been able to find show how to iterate over a range of integers. I couldn't find how to directly iterate over a range of doubles. I worked around this by iterating over integers and translating back to doubles in the inner operator() function. I finally figured out the answer, after reading the Reference Manual (as they say, rtfm).

The trick is that the blocked_range construct can accept, in addition to integers, random access iterators. So, with a range:


tbb::blocked_range< std::vector<double>::iterator > ( bunch_of_doubles.start(), bunch_of_doubles.end() );

I can now parallelize a group of doubles.

Of course, this assumes that you have a container ready. Luckily, I happened to have one ready. In other cases, it's probably best to continue and shuffle between ints and doubles.

Wednesday, December 31, 2008

Hamas, Israel and Options

Hamas is the democratically elected government of the people of Gaza. Their charter calls for the complete and total destruction of Israel, a view their leaders consistently voice. It refuses to even talk with Israel, an "entity" it doesn't even acknowledge has a right to exist.

In 2005 Israel withdrew, at an enormous price, to the 1967 border. The result was Hamas's election and constant terrorist attacks against Israel. A fragile 6 month long truce ended recently. Since the truce ended, Hamas has continuously bombed civilian population centers, while Israel did nothing but send warnings. Now, Israel is finally fighting back.

Numbers don't lie. More than 80% of those hit by the Israeli Defense Forces are Hamas members. More than 95% percent of those hit by Hamas terrorists are Israeli civilians, Jewish and Muslim alike. Recent targets include a kindergarten and a school, who were targeted courtesy of Google Earth.

I find comments that Israel should seek a diplomatic solution strange, given that Hamas refuses to accept my right to live here, let alone talk to me. In the end, people need to make choices. Not making a choice is a choice in itself, with its own consequences. Right now, Israel is taking the best of the bad choices at its disposal.

People also speak about the root cause of terrorism. The question should then be what this root cause is. The terrorists of 9/11 weren't poor, un-educated or oppressed. The terrorists of Mumbai were not under occupation. But they all thought that they could advance their goals by maiming, murdering and decapitating innocent civilians. This is the definition of terrorism.

Terrorism - the intentional attack on innocent civilians as a means for advancing the goals of a group.

The root of cause of terrorism is that it is an effective means for advancing one's goals. Terrorism can only be defeated if it is made clear that it is not an effective course of action. This is what the current Israeli operation in Gaza is all about - making it crystal clear that murdering children will not advance the goals of Hamas.

We should say no to Terrorism!

Monday, November 24, 2008

Bash: Passing Arguments with Quotes

Today I needed to write a bash script that eventually calls another program, passing all the arguments to it. It seemed like a simple enough task: just use $@. However, the problem was that the program accepts arguments surrounded with quotes, and the $@ stripped the quotes away. I was really surprised that google didn't immediately find an answer.

Finally I reached this forum:
http://www.linuxforums.org/forum/linux-programming-scripting/62564-bash-script-problem-preserving-quotes-arguments.html

And to save you the trouble, here's a script that preserves the quotes:
#!/bin/bash

# blah blah blah

./foo "$@"


For more on posts, see here.

Thursday, November 20, 2008

Brandon Sanderson, The Hero of Ages and Marketing

The story of how I ended up reading The Hero of Ages is an interesting example of successful marketing in the 22'nd century.

I first heard about Brandon Sanderson after hearing that Robert Jordan passed away. I've read most of the Wheel of Time books several years ago, and occasionally checked up on the status of the final book in the series. That's how I learned that Robert Jordan died before being able to complete the last book, and that an author called Brandon Sanderson had been selected to write the book in his place.

A quick google search led me to the surprisingly good website of Brandon Sanderson. There I found a free ebook of the work-in-progress version of the upcoming Warbreaker book. I read this book and liked it, which made me want to read more books by Sanderson. On his website, he also posted the first couple of chapters of The Final Empire, which I also read and liked. I searched for the book on various ebook sites (since shipping to Israel from amazon is expensive and takes a lot of time), and couldn't find it, so I left it alone.

Fast forward several months later. A random check in fictionwise showed me that the Final Empire was finally released in ebook format, so I immediately bought it and downloaded it to my palm. I read the book in a couple of frantic-your-priorities-are-up-side-down days. As soon as I finished reading the book, I ordered the second volume, The Well of Ascension. I just couldn't wait for it to appear in ebook format. Needless to say, I finished reading this book in no time as well.

I was now hooked, and couldn't wait for the third book to come out. I felt like I was 8 again and couldn't wait a whole week for the next episode of The Transformers. That's why I escalated things up, and ordered the hardcover (!) edition of the third and final book as soon as it came out.

The fact that I kept coming back for more, even to the point of ordering hardcover edition, (which is not something I generally do), just shows how good the books are. But the point is that none of this would have happened without plenty of free material on the author's website. At least on my part, this payed of.