Archives 2011

And Now, the Backpedaling

(Alternate title: Invisible Rapture.)

Harold Camping, who got his fifteen minutes of fame predicting the end of the world this past Saturday, has started the backpedaling.

In a rambling discourse to reporters outside his Family Radio International office, Camping, an 89-year-old retired civil engineer, indicated he had misread the signs in predicting that the faithful would be lifted up to Heaven Saturday, leaving sinners to suffer through five months of disasters until the Earth was consumed in a fireball on the End of Days.

God did “bring judgment on the world,” on Saturday, he said, but there will not be any terrible buildup to the end. When it comes, it will happen quickly, he said.

Funny how a “spiritual” apocalypse looks exactly like an apocalypse that isn’t there. I guess he doesn’t want to consider the alternate possibility: that he’s a superstitious fool who thinks that a many-times translated mishmash of writings from the bronze age has any bearing on the modern world. That would be too simple.

Last time he predicted the end of the world, his excuse was that he’d forgot to carry a two or something. This time, it’s that something happened, but we didn’t see it because it was invisible. I’m disappointed. Both of those are tired old excuses that have been used time and time again by previous prophets of armageddon. Would it have been too much to expect him to spend some time coming up with something new? I suppose it was.

Derp

Maggie Gallagher writes at NOM:

The tiny number of liberal northeastern states that have embraced gay marriage tend to have high per capita incomes, because they are much older, supporting fewer children, and much whiter, and better educated than average. They are older in part because with so little job growth, young adults with families move elsewhere, most likely to a southern state with a marriage amendment that enjoys more robust economic growth.

So, um, yeah. Apparently marriage equality kills jobs, resulting in higher per-capita income and better education. And also somehow whiteness and olditude.

I’d like to say the homophobes are scraping the bottom of the barrel, but as with creationists, every time I’ve thought that, I’ve been proven wrong.

Not Impressed with Right-Wing “Scholarship”

I recently stumbled upon a preview of a video purporting to teach children about the 1980s.

Given that the site is endorsed by Mike Huckabee, who once said that every American should be forced at gunpoint to watch David Barton, and since Barton belongs to the “make stuff up” school of historical research, you can understand why I was a bit suspicious. Read More

A Couple of Shell Quickies

Since I got asked several sh-related questions, I might as well get a post out of them.

One person asks:

I’m writing a portable shell script to download a file from the web, and then compare it to a locally-stored version of the same file, using diff.

My first version of the script used mktemp to download the web-file to temporary file, run the diff command, and then delete the temporary file afterwards. e.g.

TEMPFILE=$(mktemp)
wget -q $ONLINEFILEURL -O $TEMPFILE
diff $TEMPFILE $LOCALFILE
rm $TEMPFILE

However I later discovered that the BSD version of mktemp has an incompatible syntax to the GNU version of mktemp. So then I got rid of the usage of temporary files completely, by using input-redirection, e.g.

diff <(wget -q $ONLINEFILEURL -O -) $LOCALFILE

However while this works fine under bash and ksh, it fails under ash and sh with

Syntax error: "(" unexpected

to which I replied:

The first obvious problem here is that “(wget -q $ONLINEFILEURL -O -)” isn’t a filename, it’s a subprocess. So the shell sees “<” and expects a filename, but finds “(” instead.

It looks as though the way to get diff to read from stdin is the standard way: specify “-” as the filename, and give it input on stdin. Since you’re feeding it the output from a process, you want to use a pipe:

wget -q $ONLINEFILEURL -O - | diff - $LOCALFILE

I also suggested that he could try to figure out which version of mkfile he was using:

# Wrapper function for GNU mktemp
gnu_mktemp() {
	mktemp /tmp/tmpfile.XXXXXX "$@"
}

# Wrapper function for BSD mktemp
bsd_mktemp() {
	mktemp -t /tmp/tmpfile.XXXXXX "$@"
}

# Try to figure out which wrapper to use
if mktemp -V | grep version >/dev/null 2>&1; then
	MKTEMP=gnu_mktemp
else
	MKTEMP=bsd_mktemp
fi

mytmpfile=`$MKTEMP`

And, of course, if race conditions and security aren’t a big concern, there’s always

mytmpfile=/tmp/myprogramname.$$

Another person wanted to write a bash script that would do one thing when run by him or root, and another thing if run by anyone else (basically, die with an error message about insufficient privileges and/or grooviness).

He asked whether the following two expressions were equivalent:

  • if [[ ( `whoami` != "root" ) || ( `whoami` != "coolguy" ) ]]
  • if [[ ! ( `whoami` = "root" ) || ( `whoami` = "coolguy" ) ]]

They’re not, but maybe not for obvious reasons, because propositional logic is a harsh mistress.

In the first expression,

if [[ ( `whoami` != "root" ) || ( `whoami` != "coolguy" ) ]]

let’s say that the user is joeblow. In this case, “`whoami` != "root"” is true, and so the shell can short-circuit the rest of the “||“, because the entire expression is true.

If the user is root, then the first part, “( `whoami` != "root" )” is false. However, the second part, “( `whoami` != "coolguy" )” is true (because rootcoolguy), and so the entire expression is “false || true”, which is true.

The second expression,

if [[ ! ( `whoami` = "root" ) || ( `whoami` = "coolguy" ) ]]

is closer to what he wanted, but doesn’t work because of operator precedence: “!” binds more tightly than “||“, so the expression is equivalen tto “(whoami ≠ root) || (whoami = coolguy)”.

In this case, if the user is joeblow, the first clause, “whoami ≠ root“, is true, and so the entire expression is true.

Worse yet, if the user is root, then neither the first nor second clause is true, so the entire clause is false.

What he really wanted was something like:

if [[ ( `whoami` = "root" ) || ( `whoami` = "coolguy" ) ]]; then
	# Do nothing
	:
else
	# Do something
	echo "Go away"
	exit 1
fi

Except, of course, that since the if-clause is empty, it can be cut out entirely. Then all we need to do is to negate the condition and only keep the code in the else-clause:

if [[ ! ((`whoami` = "root" ) || ( `whoami` = "coolguy" )) ]]

Note the extra pair of parentheses, to make sure that the “!” applies to the whole thing.

(Update, May 18: Fixed HTML entities.)

Craziness Loves Company

Recently Kent Hovind’s International House of Lunacy offered to send out free DVDs to anyone who asked. So naturally, I had to take them up. Yesterday, it was delivered to my… let’s say “imaginary roommate”, with the oh-so-subtle name “Sevil Natas” (thanks to Fez for suggesting that).

I haven’t watched the DVD yet. But it came with bunch of ads for God and related products, including a CSE Ministries catalog. And that’s what I want to talk about. But I need to preface that with a bit of non-snark:

The insidious thing about HIV is that it doesn’t kill you. At least, not directly, by dissolving your cell walls or anything like that. Rather, it weakens your immune system. This makes your body less able to fight off HIV itself, and also leaves you vulnerable to other diseases. So what kills you is not AIDS per se, but something unrelated, that you normally would have been able to fight off easily.

I suspect that something similar goes on with woo: if you’re prone to hold one kind of irrational belief, then you’re probably prone to believing other kinds of irrational beliefs. If you don’t have the mental toolkit to recognize why astrology is bogus, then you might not recognize that dowsing or feng shui are also bogus.

But the thing about religion — certainly Christianity as it is widely practiced in the US and Europe — is that, like HIV, it actively attacks people’s mental defenses against bullshit, by teaching people that believing things without evidence is a virtue, or that religious ideas should be immune from criticism.

And now, on to the woo! Read More

GDMF Exchange!

Yet more reason to hate MS Exchange. Here are the relevant headers and MIME lines from a meeting notification I got recently:

Header:

Subject: XXX Staff Meeting
Content-Type: multipart/alternative;
	boundary="_000_A32122FBAE23C145ABBEFDEA852187CE01E77A1505B7BLADEBLA03V_"
MIME-Version: 1.0

Body:

--_000_A32122FBAE23C145ABBEFDEA852187CE01E77A1505B7BLADEBLA03V_
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: base64

…
--_000_A32122FBAE23C145ABBEFDEA852187CE01E77A1505B7BLADEBLA03V_
Content-Type: text/html; charset="utf-8"
Content-Transfer-Encoding: base64

…
--_000_A32122FBAE23C145ABBEFDEA852187CE01E77A1505B7BLADEBLA03V_
Content-Type: text/calendar; charset="utf-8"; method=REQUEST
Content-Transfer-Encoding: base64

…

--_000_A32122FBAE23C145ABBEFDEA852187CE01E77A1505B7BLADEBLA03V_--

At first glance, all might look normal: there’s a calendar entry with a note attached.

So first we have the plain text version of the note, followed by the HTML version of the note, followed by the vCalendar file describing the meeting itself.

But a closer look at the header shows that the message as a whole has Content-Type: multipart/alternative.

RFC 1521 says:

The multipart/alternative type is syntactically identical to multipart/mixed, but the semantics are different. In particular, each of the parts is an “alternative” version of the same information.

Systems should recognize that the content of the various parts are interchangeable. Systems should choose the “best” type based on the local environment and preferences, in some cases even through user interaction.

In other words, any standards-compliant mail reader should see those three MIME chunks as three different versions of the same information. So if it decides to (or you tell it to) display the HTML version of the note, it shouldn’t display the calendar file. And if it displays the calendar entry, it shouldn’t show the attached note.

Clearly somebody at Microsoft needs to be slapped. Hard.

(And in case you’re wondering, the proper way to do what they’re trying to do would be for the message as a whole to be multipart/mixed with a multipart/alternative chunk for the note, and a text/calendar chunk for the calendar entry. The note chunk would be further subdivided into a text/plain chunk and a text/html chunk.)

I think that when people are first told that Exchange is both a mail server and a calendar server, they think it’s kind of like a goose — something that can competently walk, swim, and fly, even though it may not excel at any of those — but in reality, it’s more like a crocoduck: massive fail at every level, no matter how you look at it.

Numbers Mean Things

So I saw this headline in The Washington Post:

UN envoy says $5 billion malaria fight has saved several thousand lives in recent years

My first thought was, “$5 billion divided by, let’s say 5000 people, that comes out to a million bucks per person saved. A noble result, to be sure, but isn’t there a more cost-effective way of achieving the same result?”

Then I read the first paragraph:

UNITED NATIONS — The U.N. chief’s envoy for malaria says a $5 billion campaign has saved several hundred thousand lives in recent years, keeping international efforts on track to virtually end deaths from the mosquito-borne disease by 2015.

(emphasis added) and now the cost per person drops two orders of magnitude, from $1 million to $10,000. Much more reasonable (though it’d still be nice if it were even cheaper).

But I suspect that either the reporter, or someone at AP or WaPo decided that the word “hundred” didn’t change the meaning enough to make it worth taking up valuable headline space. I’m sorry, but it does.

Then again, what’s two orders of magnitude among friends?

(Cross-posted at UMDSI.)

Answer to the Saturday Puzzle

On Saturday, I gave the following puzzle:

Can you make the following equation correct by moving just one number?:

45 – 46 = 1

Answer below the jump. Read More

Saturday Puzzle

I love Richard Wiseman’s Friday Puzzles. So as a tribute of sorts to this one, here’s one of my own:

Can you make the following equation correct by moving just one number?:

45 – 46 = 1

I’ll post the answer on Monday.

Inexplicably-Elected Official Recommends Magic Spell

From the office of the governor of Texas, Rick Perry:

WHEREAS, the state of Texas is in the midst of an exceptional drought, with some parts of the state receiving no significant rainfall for almost three months, matching rainfall deficit records dating back to the 1930s; …

NOW, THEREFORE, I, RICK PERRY, Governor of Texas, under the authority vested in me by the Constitution and Statutes of the State of Texas, do hereby proclaim the three-day period from Friday, April 22, 2011, to Sunday, April 24, 2011, as Days of Prayer for Rain in the State of Texas. I urge Texans of all faiths and traditions to offer prayers on that day for the healing of our land, the rebuilding of our communities and the restoration of our normal and robust way of life.

Yup, magic. An elected official of a populous state in an allegedly advanced country is using his office to tell his constituents to use rain magic.

Notice that Perry’s proclamation, like a well-crafted ad for a magnetic bracelet or an herbal boner pill, tries to give the impression that the product works, without actually making any actionable claims:

WHEREAS, throughout our history, both as a state and as individuals, Texans have been strengthened, assured and lifted up through prayer; it seems right and fitting that the people of Texas should join together in prayer to humbly seek an end to this devastating drought and these dangerous wildfires;

Shorter Perry: “We have a drought, with the ensuing wildfires and crop failure. Here, have a pacifier!”

(Via ThinkProgress.)