Monthly Archives: April 2008

sed and Multi-Line Search and Replace

I’ve been experimenting with getting regular expression patterns to match over multiple lines using sed. For example, one might want to change
<p>previous text</p>
<h2>
<a href="http://some-link.com">A title here</a>
</h2>
<p>following text</p>
to
<p>previous text</p>
No title here
<p>following text</p>
sed cycles through each line of input one line at a time, so the most obvious way to match a pattern that extends [...]

McDonald’s Spaced Out

This is McDonald’s idea of making their Happy Meals educational. (That I took this photograph may also be proof of bad parenting on our part, but let’s overlook that.)

I think what they mean is that you can jump six times as high on the Moon.
In case you were wondering, that’s because the [...]

C.S. Lewis on His Dark Materials, Harry Potter, and The Da Vinci Code

Or whatever certain circles think is the controversial-book-we-need-to-protect-people-from du jour.
There are earnest people who recommend realistic reading for everyone because, they say, it prepares us for real life, and who would, if they could, forbid fairy-tales for children and romances for adults because they ‘give a false picture of life’—in other words, deceive their readers.
I [...]

A Good Enough addEvent

Several years ago, PPK of Quirksmode sponsored a contest to come up with a new version of the trusty JavaScript addEvent function. The original addEvent was created by Scott Andrew LePera in 2001 as a way to merge Internet Explorer’s attachEvent with the W3C’s addEventListener. Both addEventListener and attachEvent allow you to attach [...]

Restoring Your WordPress 2.5 Password in the Database

WordPress 2.5 introduced a much more thorough password-hashing algorithm with PHPass. That is great for security, but I was afraid that it would make restoring your WordPress password in the database almost impossible. You see, prior to 2.5, if you needed to reset your password, you could just hash it using md5 and [...]

Plato and Unreasonable Mathematicians

A friend today sent me this picture from the Boston Museum of Science. It’s especially funny to me, because I have formal education in both mathematics and philosophy. And anyone who’s read Plato’s Republic is bound to think it odd.
It’s odd because Plato’s good society, the republic, requires its citizens to study mathematics [...]