Natural Selection in the Fossil Record

table.figure {
background-color: #f0f0f0;
}
table.figure caption {
caption-side: bottom;
font-size: 90%;
padding: 1em;
background-color: #f0f0f0;
}

For quite some time now, I’ve had a question:

We can see evolution in the present.
And we can see natural selection in the present.
And we can see lots of evolution in the fossil record.
But can we see natural selection in the fossil record?

Continue reading “Natural Selection in the Fossil Record”

“Avowed”

The New York Times ran a piece about the David Mabus affair (tl;dr version: he’s a mentally-ill troll who’d been sending death threats to people for years, and was finally arrested after enough people complained to the police).

It begins:

Over the years, someone writing as David Mabus made himself known to scientists and avowed atheists across North America in thousands of threatening e-mails and violently profane messages on Twitter.

The phrase “avowed atheists” annoyed me, because I see it a lot. I even twatted about it:

The phrase “avowed atheist” still annoys me, though. When’s the last time someone was an “avowed Baptist”?

Then I realized that with an entire browserful of Internet at my disposal, I could answer that question.
Continue reading ““Avowed””

Using snoop/tcpdump as a Filter

Okay, this is kinda cool. Yesterday, I ran snoop (Sun’s version of tcpdump) to help the network folks diagnose a problem we’ve been seeing. Unfortunately, I let it run a bit too long, and wound up with a 1.5Gb file. And the guy who’s going to be looking at this is at a conference, and would rather not download files that big.

Now, I’d known that snoop can dump packets to a file with -o filename and that that file can be read with -i filename; and of course that you can give an expression to say what kinds of packets you want to scan for. But until now, it never occurred to me to put the three of them together. And it turns out that not only does snoop support that, it Does The Right Thing to boot.

Now, one of the reasons I wound up with 1.5Gb worth of packets is that we didn’t know which port the process we were trying to debug would run on, until it ran. (That, and the fact that I started scanning early because I wasn’t sure when it would run. And ending late because the Internet dangled shiny things in front of me.)

At any rate, I was able to run

# snoop -i old-snoop-log -o new-snoop-log host thehost.dom.ain port 50175

and wind up with a packet capture file of manageable size.

And a bit of experimentation showed that tcpdump does the same thing (adjust arguments as appropriate). I’ll have to remember this.

Subjective/Objective

This was originally posted at Secular Perspectives.

Here’s something that occurred to me recently. It’s nearly-trivial, but I found it interesting.

The reason a subjective statement, like “Beethoven’s ninth is his best symphony” is subjective is that a) it refers mental state, and b) that mental state can vary from person to person.

But it can be turned into an objective statement by simply saying whose mind it refers to: “Smith thinks that Beethoven’s ninth symphony is his best”. This is an objective statement, and its truth or falsehood can be ascertained simply by asking Smith. In a few years, maybe we’ll even have scanners that can read the answer in Smith’s brain.

Or instead of specifying a particular subject to whom the statement applies, we can specify a class of people, e.g., “Most music critics think that Beethoven’s ninth is his best”, or “Nobody likes being humiliated” (vs. “humiliation is bad”).

One consequence of this is that it helps put morality on a reality-based footing: a question like “should the US intervene in the Ivory Coast?” seems hopelessly subjective, but we can at least ask questions like, “how many Americans think the US should intervene?” and “how many Ivorians want the US to intervene?”. These questions, and their answers, are called polls, and they’re used all the time. (I’m not saying that complex moral questions should be decided by polling. But polls can provide an objective underpinning to moral arguments. For instance, if 98% of Ivorians hated Americans and wanted the US to stay the hell away, that would undercut arguments like “we should move in: we’ll be greeted as liberators”.)

Secular morality is often attacked for being too subjective. I hope the above helps correct that perception. The whole point of having a system of morality is, presumably, to improve the universe in some way, and hopefully allow us to be happier and get along with each other in the process. What “better” means, above, is subjective, but at the very least we can see what people think, and what most of us can agree on.

Cheap Signaling

I talked about appropriating the biological concept of costly signaling for general skepticism, and it occurred to me to wonder whether there’s such a thing as cheap signaling.

Costly signaling is when the investment required to transmit a message, like “trust me” or “have sex with me” is so high that only the worthy applicant (a trustworthy source, or a good mate) can send it.

Indiana driver's license, 1940
Cheap signaling, in contrast, would then be when the cost of transmitting a message is low enough that unworthy senders can afford it. So for instance, if your state’s driver’s licenses have a simple design, then anyone with a printer and a laminator can fake one, which allows sixteen-year-olds get into bars.

Or, more generally, are there any cheap tricks that someone can use to sell you something you don’t want?

Hm. Put that way, I think it’s obvious that yes, . Even aside from outright lying, there are subtler tricks like acting friendly, offering you free stuff to instill a sense of obligation, and the like. Basically, just look up “sales tricks” (which is all I did).

(And just in passing, I notice that there’s a bit of an industry in sermon stories. I’m guessing that that’s because a story told in the first person is more convincing than one in the third person.)

Hachèlème bouguille

Way back when, when I was converting my tape collection to MP3, I ran across a song by legendary Genevan blues-rockers (don’t laugh) Le Beau lac de Bâle that I couldn’t recognize. It didn’t seem to correspond to any songs in the album track listings I could find. I tried googling the lyrics, but couldn’t find anything (yes, Virginia, there are things even Google can’t find).

Eventually, I stumbled upon this 45 RPM single, and learned that the mystery song was called “Hachèlème bouguille”.

You can listen to it here.

So as a favor to the next person to run into the same problem, here are the lyrics, in a form that Google can track down:

Vous vivez à sept dans un trois-pièces aux Palettes
J’attrape la migraine en y venant une fois par semaine

Ton frère Jean-Paul écoute toute la nuit Sex Pistols
Et ta soeur Yvette écoute du Wagner aux toilettes

Quitte cette maison de fous
Tu ferais mieux de venir avec nous
On est sympa comme tout
On t’offrira tout plein de Sugus et de cachous

Ton père est pervers, il ne joue qu’au strip poker
Il picole en caleçon devant la télévision

Ta mère tous les matins chante la messe en latin
Oui mais tous les soirs elle chante du rock dans sa baignoire

Quitte cette maison de fous…

Le petit Victor fait du ski dans l’corridor
Et la petite Aline, elle est en froc dans la cuisine

Et le grand Raoul qu’est dev’nu maboul à Kaboul
(Choubidoubi choubidoua)
Sur le balcon, il a une drôle de plantation
(Choubidoubi choubidoua)

Quitte cette maison de fous… (bis)

Quitte cette maison de fous
Et on t’offrira tout plein
Tout plein
Tout plein
De quoi?
De Sugus
De Sugus
De Sugus
Et de cachous

Okay, I should probably have posted this in French, shouldn’t I?

Bourne Shell Introspection

So I was thinking about how to refactor our custom Linux and Solaris init scripts at work. The way FreeBSD does it is to have the scripts in /etc/rc.d define variables with the commands to execute, e.g.,

start_cmd='/usr/sbin/foobard'
stop_cmd='kill `cat /var/run/foobar.pid`'

run_rc_command "$1"

where $1 is “start”, “stop”, or whatever, and run_rc_command is a function loaded from an external file. It can check whether $stop_cmd is defined, and if not, take some default action.

This is great and all, but I was wondering whether it would be possible to check whether a given shell function exists. That way, a common file could implement a generic structure for starting and stopping daemons, and the daemon-specific file could just set the specifics by defining do_start and do_stop functions.

The way to do this in Perl is to iterate over the symbol table of the package you’re looking for, and seeing whether each entry is a function. The symbol table for Foo::Bar is %Foo::Bar::; for the main package, it’s %::. Thus:

while (my ($k, $v) = each %::)
{
	if (defined())
	{
		print "$k is a functionn";
	}
}

sub test_x() {}
sub test_y() {}
sub test_z() {}

But I didn’t know how to do it in the Bourne shell.

Enter type, which tells you exactly that:

#!/bin/sh

# List of all known commands
STD_CMDS="start stop restart status verify"
MORE_CMDS="graceful something_incredibly_daemon_specific"

do_start="This is a string, not a function"

do_restart() {
	echo "I ought to restart something"
}

do_graceful() {
	echo "I am so fucking graceful"
}

for cmd in ${STD_CMDS} ${MORE_CMDS}; do
	if type "do_$cmd" >/dev/null 2>&1; then
		echo "* do_$cmd is defined"
	else
		echo "- do_$cmd is not defined"
	fi
done

And yes, this works not just in bash, but in the traditional, bourne-just-once shell, on every platform that I care about.

So yay, it turns out that the Bourne shell has more introspection than
I thought.

Walking in A Winter Wonderland

The snow that was pelting Atlanta earlier has finally made it up here. It’s still at the “ooh, isn’t that pretty!” stage, rather than the “oh, no, not more goddamn snow” stage, so I went for a walk in it.

Yes, the world shrouded in snow and silence was beautiful. But what struck me is that I unconsciously started walking differently.

I usually walk differently in the snow; that part isn’t surprising. What I found surprising is that apparently I’ve internalized my snow gait to the point where I didn’t need to consciously turn it on. Huh.

Normally, when I walk on dry ground, my heel hits the ground first, followed by the ball. My legs don’t bend much.

But when I’m walking on snow, my whole foot hits the ground at the same time. I also bend my knees so that my foot comes down straight, rather than at an angle. It’s a bit like an elephant or a Star Wars AT-AT, where the thigh moves the most, and the shin hangs vertically down from there. As you can imagine, my steps are shorter and I don’t walk as quickly.

It all has to do with coefficients of friction. Plural. For those who have forgotten High School physics, there are two coefficients of friction between two given surfaces: the static one, and the dynamic one. Dynamic friction refers to how hard it is to rub the two surfaces against each other. Static friction refers to when the surfaces are motionless, and how hard it is to get one of them moving.

If you’ve ever received a box of equipment (say, a new computer) and tried pushing it across the floor, you may have noticed that pushing it along the floor is easier than getting it to move in the first place. That’s because when it’s just lying there, you have to overcome static friction to get it to move. When it’s already moving, and you want it to keep moving, you have to overcome dynamic friction. And the dynamic friction coefficient is typically lower than the static one.

Normally, when you’re walking, this doesn’t matter a lot: when your sole hits dry pavement, both the static and dynamic coefficients of friction are high enough that you can trust them to hold your foot in place and allow you to push against the ground for the next step. But on snow or ice, there’s a very real danger of slipping, falling into traffic, and having your head squished by a passing car.

In this light, I think my snow gait makes sense: hitting the ground with my entire foot at once means there’s more surface to take advantage of what little friction there is (though on the other hand (foot?), my body weight is distributed over a larger area, so there’s less friction per square centimeter; I don’t know how this affects things).

Putting my foot straight down means that it’s not moving with respect to the ground when it hits, which in turn means that I’m taking advantage of the static friction coefficient, which is higher than the dynamic one, to keep from slipping. And the “elephant walk” bit is just so that I can put my foot down vertically.

So now that you know how to safely walk on slippery surfaces, go out there and enjoy the snow.

Pre-Compressing Web Content

This was definitely a “D’oh!” type of problem.

One thing I’d been meaning to figure out for a while was how to send gzip-compressed files to a browser. That is, if I have a large HTML file, it’d be nice if the server could compress it to save bandwith and transmission time. Yes, Apache has mod_deflate which takes foo.html and gzips it on the fly, setting all the appropriate HTTP headers. But for static content, I should just be able to compress the file in advance. If the browser asked for foo.html, I wanted Apache to see that there’s a foo.html.gz and send that instead, with headers saying that it’s a text/html file that happens to be compressed.

mod_mime seemed like just the thing: just add

AddEncoding x-gzip .gz

to .htaccess. But every time I did that, Apache sent back “Content-Type: application/x-gzip“, so my browser treated it as a random file of unknown type that happened to be compressed.

Then I noticed that my vanilla-ish site-wide Apache config had

AddType application/x-gzip .gz .tgz

so that when Apache saw foo.html.gz, it ignored the .html extension, and saw only the .gz one.

The fix was to add RemoveType to my .htaccess:

RemoveType .gz
AddEncoding x-gzip .gz

And voilà! .gz stops being a file type and becomes an encoding, allowing .html to shine through.

I’ll add that this plays nice with AddLanguage as well. In my test setup, I have foo.html.en.gz, for which Apache returns the headers

Content-Type: text/html
Content-Encoding: x-gzip
Content-Language: en

I.e., it’s an HTML file, it’s gzip-encoded, and it’s in English.

Just as importantly, this works with other file types (e.g., CSS files and JavaScript scripts), and XMLHttpRequest does the Right Thing with them on all of the browsers I care about.

dirvish + MySQL

I’ve been using dirvish to do backups at home. One problem I’ve always had is how to back up MySQL databases, since the backup takes a snapshot of the binary files, so if it happens at the wrong time (e.g., in the middle of a transaction), the backup might wind up being in an unusable, inconsistent state. Much better to use mysqldump to export the database to a file (one which, by the way, can also be manipulated with standard tools like perl and emacs, in case I need to repair anything).

The obvious way to do this was to use the pre-client dirvish directive to export to a file, then let that file be backed up. But I could never get it to work.

Cut to the chase: It turns out that for this to work, the pre-client directive (and post-client, if you want to clean up afterward) needs an extra semicolon:

pre-client: ; /usr/local/bin/mysqldump -a -A -e > $DIRVISH_SRC/mysqldump.%Y-%m-%d.sql
post-client: ; /bin/rm $DIRVISH_SRC/mysqldump.%Y-%m-%d.sql

Without those semicolons, things don’t run correctly. My guess is that the semicolon tricks dirvish into thinking that the command consists of multiple commands, which must therefore be run inside a shell, rather than a single command to be executed with fork()/exec().