<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	>

<channel>
	<title>Il Filosofo</title>
	<atom:link href="http://www.ilfilosofo.com/blog/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.ilfilosofo.com</link>
	<description>A blog about philosophy, Christianity, web development and whatever else I feel like writing about.</description>
	<pubDate>Thu, 08 May 2008 14:43:57 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.6-bleeding</generator>
	<language>en</language>
			<item>
		<title>OpenID Servers: Allow Redundant Means of Access</title>
		<link>http://www.ilfilosofo.com/blog/2008/05/08/openid-servers/</link>
		<comments>http://www.ilfilosofo.com/blog/2008/05/08/openid-servers/#comments</comments>
		<pubDate>Thu, 08 May 2008 14:43:57 +0000</pubDate>
		<dc:creator>filosofo</dc:creator>
		
		<category><![CDATA[Internet]]></category>

		<category><![CDATA[OpenID]]></category>

		<guid isPermaLink="false">http://www.ilfilosofo.com/?p=460</guid>
		<description><![CDATA[That&#8217;s the lesson I take from Kyle Neath&#8217;s critique of OpenID  (HT: Ma.tt),  from his first point, the one that I think has the most traction.  OpenID servers should allow users to associate their account with several OpenID providers, if they want, and/or an email address.
]]></description>
			<content:encoded><![CDATA[<p>That&#8217;s the lesson I take from <a href="http://warpspire.com/features/open-id/">Kyle Neath&#8217;s critique of OpenID </a> (HT: <a href="http://ma.tt/2008/05/kyle-skips-openid/">Ma.tt</a>),  from his first point, the one that I think has the most traction.  <a href="http://openid.net/">OpenID</a> servers should allow users to associate their account with several OpenID providers, if they want, and/or an email address.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ilfilosofo.com/blog/2008/05/08/openid-servers/feed/</wfw:commentRss>
		</item>
		<item>
		<title>sed and Multi-Line Search and Replace</title>
		<link>http://www.ilfilosofo.com/blog/2008/04/26/sed-multi-line-search-and-replace/</link>
		<comments>http://www.ilfilosofo.com/blog/2008/04/26/sed-multi-line-search-and-replace/#comments</comments>
		<pubDate>Sat, 26 Apr 2008 17:21:15 +0000</pubDate>
		<dc:creator>filosofo</dc:creator>
		
		<category><![CDATA[Computers]]></category>

		<category><![CDATA[bash]]></category>

		<category><![CDATA[grep]]></category>

		<category><![CDATA[Linux]]></category>

		<category><![CDATA[regex]]></category>

		<category><![CDATA[sed]]></category>

		<category><![CDATA[shell]]></category>

		<guid isPermaLink="false">http://www.ilfilosofo.com/?p=458</guid>
		<description><![CDATA[I&#8217;ve been experimenting with getting regular expression patterns to match over multiple lines using sed.  For example, one might want to change
&#60;p&#62;previous text&#60;/p&#62;
&#60;h2&#62;
&#60;a href=&#34;http://some-link.com&#34;&#62;A title here&#60;/a&#62;
&#60;/h2&#62;
&#60;p&#62;following text&#60;/p&#62;
to 
&#60;p&#62;previous text&#60;/p&#62;
No title here
&#60;p&#62;following text&#60;/p&#62;
sed cycles through each line of input one line at a time, so the most obvious way to match a pattern that extends [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been experimenting with getting regular expression patterns to match over multiple lines using <a href="http://en.wikipedia.org/wiki/Sed"><code>sed</code></a>.  For example, one might want to change</p>
<div class="filosofo-highlight-light html4strict" style="font-family: monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;p&gt;</span></span>previous text<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/p&gt;</span></span><br />
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;h2&gt;</span></span><br />
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;a</span> <span style="color: #000066;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;http://some-link.com&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>A title here<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/a&gt;</span></span><br />
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/h2&gt;</span></span><br />
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;p&gt;</span></span>following text<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/p&gt;</span></span></div>
<p>to </p>
<div class="filosofo-highlight-light html4strict" style="font-family: monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;p&gt;</span></span>previous text<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/p&gt;</span></span><br />
No title here<br />
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;p&gt;</span></span>following text<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/p&gt;</span></span></div>
<p><code>sed</code> cycles through each line of input one line at a time, so the most obvious way to match a pattern that extends over several lines is to concatenate all the lines into what is called <code>sed</code>&#8217;s &#8220;hold space,&#8221; then look for the pattern in that (long) string.  That&#8217;s what I do in the following lines:</p>
<div class="filosofo-highlight-light bash" style="font-family: monospace;"><span style="color: #808080; font-style: italic;">#!/bin/sh</span><br />
<span style="color: #c20cb9; font-weight: bold;">sed</span> -n <span style="color: #ff0000;">'<br />
# if the first line copy the pattern to the hold buffer<br />
1h<br />
# if not the first line then append the pattern to the hold buffer<br />
1!H<br />
# if the last line then ...<br />
$ {<br />
&nbsp; &nbsp; &nbsp; &nbsp; # copy from the hold to the pattern buffer<br />
&nbsp; &nbsp; &nbsp; &nbsp; g<br />
&nbsp; &nbsp; &nbsp; &nbsp; # do the search and replace<br />
&nbsp; &nbsp; &nbsp; &nbsp; s/&lt;h2.*&lt;/h2&gt;/No title here/g<br />
&nbsp; &nbsp; &nbsp; &nbsp; # print<br />
&nbsp; &nbsp; &nbsp; &nbsp; p<br />
}<br />
'</span> sample.php <span style="color: #000000; font-weight: bold;">&gt;</span> sample-edited.php;</div>
<p>A more compact version: </p>
<div class="filosofo-highlight-light bash" style="font-family: monospace;"><br />
<span style="color: #c20cb9; font-weight: bold;">sed</span> -n <span style="color: #ff0000;">'1h;1!H;${;g;s/&lt;h2.*&lt;/h2&gt;/No title here/g;p;}'</span> sample.php <span style="color: #000000; font-weight: bold;">&gt;</span> sample-edited.php;<br />
&nbsp;</div>
<p>As far as I can tell, that&#8217;s the most efficient way to match general multi-line patterns.  I initially thought it might be more efficient not to keep the complete input in the hold buffer, so I modified the algorithm to print out the string whenever a match is found:</p>
<div class="filosofo-highlight-light bash" style="font-family: monospace;"><br />
<span style="color: #808080; font-style: italic;">#!/bin/sh</span><br />
<span style="color: #c20cb9; font-weight: bold;">sed</span> -n <span style="color: #ff0000;">'1h <br />
1!{<br />
&nbsp; &nbsp; &nbsp; &nbsp; # if the sought-after regex is not found, append the pattern space to hold space<br />
&nbsp; &nbsp; &nbsp; &nbsp; /&lt;h2.*&lt;/h2&gt;/ !H<br />
&nbsp; &nbsp; &nbsp; &nbsp; # copy hold space into pattern space<br />
&nbsp; &nbsp; &nbsp; &nbsp; g<br />
&nbsp; &nbsp; &nbsp; &nbsp; # if the regex is found, then...<br />
&nbsp; &nbsp; &nbsp; &nbsp; /&lt;h2.*&lt;/h2&gt;/ {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; # the regular expression<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; s/&lt;h2.*&lt;/h2&gt;/No title here/g<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; # print <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; p<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; # read the next line into the pattern space<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; n<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; # copy the pattern space into the hold space<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; h<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; # copy pattern buffer into hold buffer<br />
&nbsp; &nbsp; &nbsp; &nbsp; h<br />
}<br />
# if the last line then print<br />
$p<br />
'</span> sample.php <span style="color: #000000; font-weight: bold;">&gt;</span> sample-edited.php;<br />
&nbsp;</div>
<p>In the last example, <code>sed</code> concatenates lines only until it finds a match, and then it prints the line (after substituting the text).  Then, it starts again to concatenate the following lines.  </p>
<p>However, that approach is usually massively inefficient, as the regex work increases logarithmically.  Unless a <code>sed</code> guru can point out a better way, I&#8217;m going to continue using the first approach.  </p>
<p>I&#8217;ve put the following script, which I call &#8220;<code>sedml</code>,&#8221; for <code>sed</code> multi-line, in my bash path.</p>
<div class="filosofo-highlight-light bash" style="font-family: monospace;"><span style="color: #808080; font-style: italic;">#!/bin/sh</span><br />
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">$</span>#&quot;</span> -lt <span style="color: #000000;">2</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span> <br />
<span style="color: #000000; font-weight: bold;">then</span><br />
<span style="color: #7a0874; font-weight: bold;">exit</span>;<br />
<span style="color: #000000; font-weight: bold;">fi</span><br />
<br />
<span style="color: #808080; font-style: italic;"># change the input file if no 3rd argument</span><br />
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> -z <span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">$</span>3&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span><br />
<span style="color: #000000; font-weight: bold;">then</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #007800;">outputfile=</span><span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">$</span>1&quot;</span><br />
<span style="color: #000000; font-weight: bold;">else</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #007800;">outputfile=</span><span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">$</span>3&quot;</span><br />
<span style="color: #000000; font-weight: bold;">fi</span><br />
<span style="color: #c20cb9; font-weight: bold;">sed</span> -n <span style="color: #ff0000;">'<br />
# if the first line copy the pattern to the hold buffer<br />
1h<br />
# if not the first line then append the pattern to the hold buffer<br />
1!H<br />
# if the last line then ...<br />
$ {<br />
&nbsp; &nbsp; &nbsp; &nbsp; # copy from the hold to the pattern buffer<br />
&nbsp; &nbsp; &nbsp; &nbsp; g<br />
&nbsp; &nbsp; &nbsp; &nbsp; # do the search and replace<br />
&nbsp; &nbsp; &nbsp; &nbsp; '</span><span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">$</span>2&quot;</span><span style="color: #ff0000;">'<br />
&nbsp; &nbsp; &nbsp; &nbsp; # print<br />
&nbsp; &nbsp; &nbsp; &nbsp; p<br />
}<br />
'</span> $<span style="color: #000000;">1</span> <span style="color: #000000; font-weight: bold;">&gt;</span> $<span style="color: #000000;">1</span>.tmp;<br />
<span style="color: #c20cb9; font-weight: bold;">mv</span> -f $<span style="color: #000000;">1</span>.tmp <span style="color: #007800;">$outputfile</span>;<br />
&nbsp;</div>
<p>So I can replace multi-line patterns in multiple files like so:</p>
<div class="filosofo-highlight-light bash" style="font-family: monospace;">&nbsp;<span style="color: #c20cb9; font-weight: bold;">grep</span> -rl <span style="color: #ff0000;">'&lt;h2'</span> <span style="color: #000000; font-weight: bold;">*</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #000000; font-weight: bold;">while</span> <span style="color: #c20cb9; font-weight: bold;">read</span> i; <span style="color: #000000; font-weight: bold;">do</span> sedml <span style="color: #007800;">$i</span> <span style="color: #ff0000;">&quot;s/&lt;h2.*&lt;/h2&gt;/No title here/g&quot;</span> <span style="color: #007800;">$i</span>.tmp; <span style="color: #000000; font-weight: bold;">done</span>;</div>
]]></content:encoded>
			<wfw:commentRss>http://www.ilfilosofo.com/blog/2008/04/26/sed-multi-line-search-and-replace/feed/</wfw:commentRss>
		</item>
		<item>
		<title>McDonald&#8217;s Spaced Out</title>
		<link>http://www.ilfilosofo.com/blog/2008/04/16/mcdonalds-and-astrophysics/</link>
		<comments>http://www.ilfilosofo.com/blog/2008/04/16/mcdonalds-and-astrophysics/#comments</comments>
		<pubDate>Wed, 16 Apr 2008 16:31:42 +0000</pubDate>
		<dc:creator>filosofo</dc:creator>
		
		<category><![CDATA[Education]]></category>

		<category><![CDATA[Science]]></category>

		<category><![CDATA[McDonald's]]></category>

		<guid isPermaLink="false">http://www.ilfilosofo.com/?p=445</guid>
		<description><![CDATA[This is McDonald&#8217;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&#8217;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&#8217;s because the [...]]]></description>
			<content:encoded><![CDATA[<p>This is McDonald&#8217;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&#8217;s overlook that.)</p>
<p><img src="http://www.ilfilosofo.com/wp-content/uploads/space_jump.jpg" alt="You can jump 6 times higher in space!" title="You can jump 6 times higher in space!" class="alignnone size-full wp-image-446" /></p>
<p>I think what they mean is that you can jump six times as high on the Moon.  </p>
<p>In case you were wondering, that&#8217;s because the <a href="http://en.wikipedia.org/wiki/Surface_gravity">surface gravity</a> of the Moon is 1/6 that of the Earth&#8217;s.  It&#8217;s <em>not</em> because the moon has 1/6 the mass or the diameter of the Earth, as you might suspect.  In fact, as you can see <a href="http://nssdc.gsfc.nasa.gov/planetary/factsheet/moonfact.html">here</a>, the mass of the Moon is 1.23% of the Earth&#8217;s, and its radius is 27.25%.</p>
<p>Surface gravity can be expressed like so:</p>
<p><code>( Surface gravity of the Moon/Surface gravity of the Earth ) = ( Mass of Moon/Mass of the Earth ) / ( Radius of Moon / Radius of Earth ) <sup>2</sup></code></p>
<p>Plug in the numbers, and you get the following:</p>
<p><code>( Surface gravity of the Moon/Surface gravity of the Earth ) = ( 0.07349 x 10<sup>24</sup> kg/5.9736 x 10<sup>24</sup> kg ) / ( 1738.1 km / 6378.1 km ) <sup>2</sup></code></p>
<p>Which ends up as <code>Surface gravity of the Moon/Surface gravity of the Earth = 0.1656 ~ 1/6</code></p>
]]></content:encoded>
			<wfw:commentRss>http://www.ilfilosofo.com/blog/2008/04/16/mcdonalds-and-astrophysics/feed/</wfw:commentRss>
		</item>
		<item>
		<title>C.S. Lewis on His Dark Materials, Harry Potter, and The Da Vinci Code</title>
		<link>http://www.ilfilosofo.com/blog/2008/04/15/cs-lewis-dangerous-realism-in-fiction/</link>
		<comments>http://www.ilfilosofo.com/blog/2008/04/15/cs-lewis-dangerous-realism-in-fiction/#comments</comments>
		<pubDate>Tue, 15 Apr 2008 15:48:10 +0000</pubDate>
		<dc:creator>filosofo</dc:creator>
		
		<category><![CDATA[Books]]></category>

		<category><![CDATA[C.S. Lewis]]></category>

		<category><![CDATA[Experiment in Criticism]]></category>

		<guid isPermaLink="false">http://www.ilfilosofo.com/?p=444</guid>
		<description><![CDATA[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 &#8216;give a false picture of life&#8217;&#8212;in other words, deceive their readers.
I [...]]]></description>
			<content:encoded><![CDATA[<p>Or whatever certain circles think is the controversial-book-we-need-to-protect-people-from du jour.</p>
<blockquote><p>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 &#8216;give a false picture of life&#8217;&#8212;in other words, deceive their readers.</p>
<p>I trust that what has already been said about egoistic castle-building [i.e. the reader lives vicariously as the hero of the story] forearms us against this error.  Those who wish to be deceived always demand in what they read at least a superficial or apparent realism of content.  To be sure, the show of such realism which deceives the mere castle-builder would not deceive a literary reader.  If he is to be deceived, a much subtler and closer resemblance to real life will be required.  But without some degree of realism in content&#8212;a degree proportional to the reader&#8217;s intelligence&#8212;no deception will occur at all.  No one can deceive you unless he makes you think he is telling the truth.  The unblushingly romantic has far less power to deceive than the apparently realistic.  Admitted fantasy is precisely the kind of literature which never deceives at all.  Children are not deceived by fairy-tales; they are often and gravely deceived by school-stories.  Adults are not deceived by science fiction; they can be deceived by the stories in the women&#8217;s magazines.  None of us are deceived by the <em>Odyssey</em>, the <em>Kalevala</em>, <em>Beowulf</em>, or Malory. the real danger lurks in sober-faced novels where all appears to be very probable but all is in fact contrived to put across some social or ethical or religious or anti-religious &#8216;comment on life&#8217;.  For some at least of such comments must be false.  To be sure, no novel will deceive the best type of reader.  He never mistakes art either for life or for philosophy.  He can enter, while he reads, into each author&#8217;s point of view without either accepting or rejecting it, suspending when necessary his disbelief and (what is harder) his belief.  </p>
<p>C.S. Lewis, <em>An Experiment in Criticism</em> 67-8</p></blockquote>
<p>The last part makes it clear that he does think some literature is dangerous; but it&#8217;s dangerous in ways different from how many people imagine.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ilfilosofo.com/blog/2008/04/15/cs-lewis-dangerous-realism-in-fiction/feed/</wfw:commentRss>
		</item>
		<item>
		<title>A Good Enough addEvent</title>
		<link>http://www.ilfilosofo.com/blog/2008/04/14/addevent-preserving-this/</link>
		<comments>http://www.ilfilosofo.com/blog/2008/04/14/addevent-preserving-this/#comments</comments>
		<pubDate>Tue, 15 Apr 2008 03:48:00 +0000</pubDate>
		<dc:creator>filosofo</dc:creator>
		
		<category><![CDATA[Web development]]></category>

		<category><![CDATA[addEvent]]></category>

		<category><![CDATA[addEventListener]]></category>

		<category><![CDATA[attachEvent]]></category>

		<category><![CDATA[JavaScript]]></category>

		<guid isPermaLink="false">http://www.ilfilosofo.com/?p=441</guid>
		<description><![CDATA[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&#8217;s attachEvent with the W3C&#8217;s addEventListener.  Both addEventListener and attachEvent allow you to attach [...]]]></description>
			<content:encoded><![CDATA[<p>Several years ago, PPK of Quirksmode sponsored <a href="http://www.quirksmode.org/blog/archives/2005/10/_and_the_winner_1.html">a contest to come up with a new version of the trusty JavaScript addEvent function</a>.  The original addEvent was <a href="http://www.scottandrew.com/weblog/articles/cbs-events">created by Scott Andrew LePera in 2001</a> as a way to merge Internet Explorer&#8217;s <code>attachEvent</code> with the W3C&#8217;s <code>addEventListener</code>.  Both <code>addEventListener</code> and <code>attachEvent</code> allow you to attach a JavaScript event to a DOM object, but they differ in important ways.  In particular, IE&#8217;s <code>attachEvent</code> doesn&#8217;t maintain the scope of the <code>this</code> keyword: <code>this</code> refers to the <code>window</code> object instead of the object on which you&#8217;re attaching the event, as in the case of <code>addEventListener</code>.  </p>
<p>PPK&#8217;s contest itself ended up falling flat, as even the winner, John Resig (who later created the <a href="http://jquery.com/">jQuery library</a>),  later <a href="http://my.opera.com/hallvors/blog/2007/03/28/a-problem-with-john-resigs-addevent#comment2703457">repudiated it himself</a>. That&#8217;s probably because PPK&#8217;s contest requirements were like asking for all three of good, fast, and cheap.</p>
<p>So seven years later, there&#8217;s no widely-adopted replacement to the original addEvent that:</p>
<ol>
<li>Is short</li>
<li>Maintains the <code>this</code> scope in IE</li>
<li>Has a corresponding removeEvent</li>
</ol>
<p>The various libraries do a good job of 2 and 3, but not 1, and since I often find myself needing 1 and 2 but not 3, I came up with my own good-enough version of addEvent:</p>
<div class="filosofo-highlight-light javascript" style="font-family: monospace;"><span style="color: #003366; font-weight: bold;">var</span> addEvent = <span style="color: #003366; font-weight: bold;">function</span><span style="color: #66cc66;">&#40;</span> obj, type, fn <span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #66cc66;">&#40;</span>obj.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; obj.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span>type, fn, <span style="color: #003366; font-weight: bold;">false</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #66cc66;">&#40;</span>obj.<span style="color: #006600;">attachEvent</span><span style="color: #66cc66;">&#41;</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; obj.<span style="color: #006600;">attachEvent</span><span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">'on'</span> + type, <span style="color: #003366; font-weight: bold;">function</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span> <span style="color: #000066; font-weight: bold;">return</span> fn.<span style="color: #006600;">apply</span><span style="color: #66cc66;">&#40;</span>obj, <span style="color: #003366; font-weight: bold;">new</span> Array<span style="color: #66cc66;">&#40;</span>window.<span style="color: #006600;">event</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;<span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
<span style="color: #66cc66;">&#125;</span><br />
&nbsp;</div>
<p>It&#8217;s short, which is just what I need when I&#8217;m trying to keep the JavaScript size low.  (Whenever size isn&#8217;t so much of an issue, such as on the administrative side of a website, I&#8217;m more likely to use a library which will have a much more robust way of assigning events to objects.)  And my addEvent also makes <code>this</code> refer to object in question, even for IE.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ilfilosofo.com/blog/2008/04/14/addevent-preserving-this/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Restoring Your WordPress 2.5 Password in the Database</title>
		<link>http://pressedwords.com/restore-wordpress-user-password-in-database/</link>
		<comments>http://pressedwords.com/restore-wordpress-user-password-in-database/#comments</comments>
		<pubDate>Tue, 15 Apr 2008 03:39:31 +0000</pubDate>
		<dc:creator>Austin Matzko</dc:creator>
		
		<category><![CDATA[Pressed Words]]></category>

		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://pressedwords.com/restore-wordpress-user-password-in-database/</guid>
		<description><![CDATA[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 [...]]]></description>
			<content:encoded><![CDATA[<p>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 put it directly in the wp_users table, as described <a href="http://codex.wordpress.org/Resetting_Your_Password">here</a>.</p>
<p>The good news&#8212;surprisingly&#8212;is that you can still do that in 2.5, as <a href="http://comox.textdrive.com/pipermail/wp-hackers/2008-April/019484.html">DD32 pointed out on the WordPress hackers mailing list</a>.  You can thank <code>wp_check_password()</code>, which checks to see if your stored password is still in md5 form, and if so, it lets you log in and then converts it.</p>
]]></content:encoded>
			<wfw:commentRss>http://pressedwords.com/restore-wordpress-user-password-in-database/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Plato and Unreasonable Mathematicians</title>
		<link>http://www.ilfilosofo.com/blog/2008/04/12/plato-mathematician-quote/</link>
		<comments>http://www.ilfilosofo.com/blog/2008/04/12/plato-mathematician-quote/#comments</comments>
		<pubDate>Sun, 13 Apr 2008 02:06:26 +0000</pubDate>
		<dc:creator>filosofo</dc:creator>
		
		<category><![CDATA[Mathematics]]></category>

		<category><![CDATA[Philosophy]]></category>

		<category><![CDATA[Plato]]></category>

		<guid isPermaLink="false">http://www.ilfilosofo.com/?p=439</guid>
		<description><![CDATA[
A friend today sent me this picture from the Boston Museum of Science.  It&#8217;s especially funny to me, because I have formal education in both mathematics and philosophy.  And anyone who&#8217;s read Plato&#8217;s Republic is bound to think it odd.
It&#8217;s odd because Plato&#8217;s good society, the republic, requires its citizens to study mathematics [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.ilfilosofo.com/wp-content/uploads/mathematician_plato.jpg" alt="" title="I have hardly ever known a mathematician who was capable of reasoning" class="alignnone size-full wp-image-440" /></p>
<p>A friend today sent me this picture from the Boston Museum of Science.  It&#8217;s especially funny to me, because I have formal education in both mathematics and philosophy.  And anyone who&#8217;s read Plato&#8217;s <i>Republic</i> is bound to think it odd.</p>
<p>It&#8217;s odd because Plato&#8217;s good society, the republic, requires its citizens to study mathematics for <em>ten</em> years.  So it&#8217;s not like Plato takes math lightly.  This quotation arises during Socrates&#8217; and Glaucon&#8217;s conversation about education (the character of Socrates speaks in the first person). </p>
<blockquote><p>[Socrates:] Now, when all these studies reach the point of inter-communion and connection with one another, and come to be considered in their mutual affinities, then, I think, but not till then, will the pursuit of them have a value for our objects; otherwise there is no profit in them.</p>
<p>[Glaucon:] I suspect so; but you are speaking, Socrates, of a vast work.</p>
<p>What do you mean? I said; the prelude or what? Do you not know that all this is but the prelude to the actual strain which we have to learn? For you surely would not regard the skilled mathematician as a dialectician?</p>
<p>Assuredly not, he said; I have hardly ever known a mathematician who was capable of reasoning.</p>
<p>But do you imagine that men who are unable to give and take a reason will have the knowledge which we require of them?</p>
<p>Neither can this be supposed.</p>
<p><em>Source: <strong>Republic</strong> 531e, translated by B. Jowett</em>
</p></blockquote>
<p>Jowett translated the <i>Republic</i> in the 19th Century, so having entered the public domain it&#8217;s well-distributed, if perhaps not as clear as it could be.  Here are the same lines from a couple of other translations:</p>
<blockquote><p> Surely you would not regard experts in mathematics as masters of dialectic. </p>
<p>Certainly not, except a very few of those I have met.</p>
<p><em>trans. F.M. Cornford</em></p></blockquote>
<blockquote><p>&#8216;The subjects we&#8217;ve described are only a prelude to the main theme we have to learn.  For you don&#8217;t think that people who are good at them are skilled in dialectic, do you?&#8217;</p>
<p>&#8216;Heavens, no, though I have come across a few exceptions.&#8217;</p>
<p><em>trans. Desmond Lee</em></p></blockquote>
<p>When Jowett&#8217;s translation talks about being &#8220;capable of reasoning,&#8221; it&#8217;s referring to &#8220;dialectic,&#8221; which for Plato is a special way of reasoning, not just reasoning in general.  &#8220;Dialectic&#8221; is the capstone of Plato&#8217;s proposed education; after training in it for five years, the leaders of his republic should begin to understand philosophical issues.  </p>
<p>So we can let mathematicians off the hook a little bit: Plato&#8217;s not saying they&#8217;re unreasonable, just that they generally haven&#8217;t achieved the heights of thinking made available by dialectic.  Why this is so comes out a little bit later in the next book:</p>
<blockquote><p>The detached studies in which they were educated as children will now be brought together in a comprehensive view of their connexions with one another and with reality.</p>
<p>Certainly that is the only kind of knowledge which takes firm root in the mind.  </p>
<p>Yes, and the chief test of a natural gift for Dialectic, which is the same thing as the ability to see the connexions of things.<br />
&#8230;<br />
When they reach thirty they will be promoted to still higher privileges and tested by the power of Dialectic, to see which can dispense with sight and the other senses and follow truth into the region of pure reality.  </p>
<p><em>Source: <strong>Republic</strong> 537, trans. Cornford</em></p></blockquote>
<p>In other words, dialectic brings everything together.  Referring to his famous <a href="http://en.wikipedia.org/wiki/Allegory_of_the_cave">allegory of the cave</a>, Plato is saying that dialectic is like the last step, where the former prisoners are no longer seeing shadows or indirect images, but are looking at the &#8220;sun&#8221; of truth.  The problem with mathematics by itself is that it doesn&#8217;t provide the big picture; it&#8217;s limited to a particular discipline, so it&#8217;s merely a shadow of the form of the Good.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ilfilosofo.com/blog/2008/04/12/plato-mathematician-quote/feed/</wfw:commentRss>
		</item>
		<item>
		<title>The Right Way to Use JavaScript in Your WordPress Plugin</title>
		<link>http://pressedwords.com/wordpress-javascript-compatibility/</link>
		<comments>http://pressedwords.com/wordpress-javascript-compatibility/#comments</comments>
		<pubDate>Fri, 11 Apr 2008 14:27:32 +0000</pubDate>
		<dc:creator>Austin Matzko</dc:creator>
		
		<category><![CDATA[Pressed Words]]></category>

		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://pressedwords.com/wordpress-javascript-compatibility/</guid>
		<description><![CDATA[Ozh explains how to properly use JavaScript in your WordPress plugins.  There are two key parts:

Use wp_enqueue_script() to load external libraries and standalone scripts, instead of generating your own script header tags.
On admin pages, use the admin_print_scripts-[mypage] action hook to register the code on only your plugin&#8217;s page, not every admin page.

Both of those [...]]]></description>
			<content:encoded><![CDATA[<p>Ozh explains how to <a href="http://planetozh.com/blog/2008/04/how-to-load-javascript-with-your-wordpress-plugin/">properly use JavaScript in your WordPress plugins</a>.  There are two key parts:</p>
<ol>
<li>Use <code>wp_enqueue_script()</code> to load external libraries and standalone scripts, instead of generating your own script header tags.</li>
<li>On admin pages, use the <code>admin_print_scripts-[mypage]</code> action hook to register the code on only your plugin&#8217;s page, not every admin page.</li>
</ol>
<p>Both of those techniques have been available since WordPress 2.1, so plugin authors can be pretty confident that there will be no backwards-compatibility issues in employing them.  (Despite the fact that WordPress is <a href="http://wordpress.org/download/legacy/">maintaining the 2.0.x version line until 2010</a>, my research suggests that the <a href="http://pressedwords.com/how-many-bloggers-use-each-version-of-wordpress/">number of users of that branch is insignificant</a>.) </p>
<p>I would add one more tip to Ozh&#8217;s: don&#8217;t pollute the global JavaScript namespace, especially with the over-used &#8220;$&#8221;.  A number of JavaScript libraries use the dollar sign in different ways, so you can run into problems if, for example, you&#8217;re using jQuery but another plugin has loaded Prototype. </p>
<p>Fortunately, jQuery makes it easy to <a href="http://docs.jquery.com/Using_jQuery_with_Other_Libraries">use &#8220;$&#8221; in a friendly way with other libraries</a>. My favorite is to wrap jQuery-based code in something like the following, which employs <code>$</code> outside of the global namespace <em>and</em> waits to execute the script until after the DOM has loaded. </p>
<p><code>jQuery(function($) { /* some code that uses $ */ });</code></p>
]]></content:encoded>
			<wfw:commentRss>http://pressedwords.com/wordpress-javascript-compatibility/feed/</wfw:commentRss>
		</item>
		<item>
		<title>WordPress Database Errors and the Post Hoc Fallacy</title>
		<link>http://pressedwords.com/instapundit-on-wordpress/</link>
		<comments>http://pressedwords.com/instapundit-on-wordpress/#comments</comments>
		<pubDate>Thu, 10 Apr 2008 20:48:46 +0000</pubDate>
		<dc:creator>Austin Matzko</dc:creator>
		
		<category><![CDATA[Pressed Words]]></category>

		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://pressedwords.com/instapundit-on-wordpress/</guid>
		<description><![CDATA[Glenn Reynolds at Instapundit mentioned WordPress today in not-so-flattering terms (emphasis added):
LIEBERMAN CAMPAIGN CRASHED OWN WEBSITE: &#8220;The server that hosted the joe2006.com Web site failed because it was overutilized and misconfigured.&#8221; That&#8217;s like when people send me a link to their underpowered WordPress blog, then it produces a &#8220;Database Error&#8221; message when too many people [...]]]></description>
			<content:encoded><![CDATA[<p>Glenn Reynolds at <a href="http://instapundit.com/archives2/017681.php">Instapundit mentioned WordPress today</a> in not-so-flattering terms (emphasis added):</p>
<blockquote><p>LIEBERMAN CAMPAIGN <a href="http://www.stamfordadvocate.com/localnews/ci_8859029">CRASHED OWN WEBSITE</a>: &#8220;The server that hosted the joe2006.com Web site failed because it was overutilized and misconfigured.&#8221; That&#8217;s like when people send me a link to their underpowered WordPress blog, then it produces a &#8220;Database Error&#8221; message when too many people try to actually read it. I hate that. (<em>Yeah, this happens elsewhere sometimes, but low-power WordPress blogs seem particularly susceptible.</em>)</p>
</blockquote>
<p>Until WordPress version 2.5, a failed database would generate error screens like the one below:</p>
<p><img src="http://pressedwords.com/blog/uploads/2008/04/db_error.jpg" alt="" width="500" height="282" class="alignnone size-full wp-image-46" /></p>
<p>Note the nifty WordPress branding that appears at the top.  Thanks to that, <a href="http://en.wikipedia.org/wiki/Slashdot_effect">countless Diggers, Slashdotters, and the like</a> began to associate WordPress with failure.  This is a <a href="http://en.wikipedia.org/wiki/Post_hoc_ergo_propter_hoc">post hoc fallacy</a> of course: plenty of sites that buckle under the loads brought by Digg are not powered by WordPress, and many WordPress sites that survive a slashdotting are powered by WordPress.  But in both of those cases, it&#8217;s not obvious; no giant logo greets you to say &#8220;WordPress powers this site, which is staying up just fine!&#8221;</p>
<p>In my opinion, WordPress version 2.5 solved this problem the right way, by adding a non-branded database error message:</p>
<p><img src="http://pressedwords.com/blog/uploads/2008/04/db_error_new.jpg" alt="" width="500" height="92" class="alignnone size-full wp-image-47" /></p>
<p>Other people, including both WordPress <a href="http://technosailor.com/2008/04/10/solving-the-wordpress-traffic-overload-problem/">proponents</a> and <a href="http://www.movabletype.com/blog/2008/03/a-wordpress-25-upgrade-guide.html">opponents</a>, think WordPress lacks something by not allowing all of its users to handle heavy database stress.  I&#8217;m not so sure.  </p>
<p>Flexibility is a large part of what makes WordPress such a great application to write  code for.  If you let plugins do just about anything imaginable on every page load, there&#8217;s a good chance that a small host&#8217;s database won&#8217;t be able to handle all of that in the face of a slashdotting.  And that&#8217;s okay.  The vast majority of WordPress users won&#8217;t ever be slashdotted, and so they don&#8217;t need the extra complication, potential server problems, and plugin incompatibilities that built-in caching would produce.  </p>
<p>If yours is the type of site that&#8217;s going to suffer under the Digg effect, then you can install one of the caching plugins to help you endure, or you can count on superior server resources.  Everyone else will be just fine.</p>
]]></content:encoded>
			<wfw:commentRss>http://pressedwords.com/instapundit-on-wordpress/feed/</wfw:commentRss>
		</item>
		<item>
		<title>How I Rip and Encode MP3s on the Ubuntu Linux Command Line</title>
		<link>http://www.ilfilosofo.com/blog/2008/04/10/shell-mp3-encoding/</link>
		<comments>http://www.ilfilosofo.com/blog/2008/04/10/shell-mp3-encoding/#comments</comments>
		<pubDate>Thu, 10 Apr 2008 11:00:03 +0000</pubDate>
		<dc:creator>filosofo</dc:creator>
		
		<category><![CDATA[Computers]]></category>

		<category><![CDATA[Music]]></category>

		<category><![CDATA[cdparanoia]]></category>

		<category><![CDATA[command line]]></category>

		<category><![CDATA[Linux]]></category>

		<category><![CDATA[lltag]]></category>

		<category><![CDATA[mp3]]></category>

		<category><![CDATA[Ubuntu]]></category>

		<guid isPermaLink="false">http://www.ilfilosofo.com/?p=438</guid>
		<description><![CDATA[I like to know how to use the command line for everything I can.  Here are the tools and commands I use to make mp3s.
First, I rip from the CDROM to a wav file.  
cdparanoia 1 prokofiev1.wav
cdparanoia lets me specify the input device, but I don&#8217;t need to, since the default&#8212;/dev/cdrom&#8212;is what I [...]]]></description>
			<content:encoded><![CDATA[<p>I like to know how to use the command line for everything I can.  Here are the tools and commands I use to make mp3s.</p>
<p>First, I rip from the CDROM to a <code>wav</code> file.  </p>
<p><code>cdparanoia 1 prokofiev1.wav</code></p>
<p><code>cdparanoia</code> lets me specify the input device, but I don&#8217;t need to, since the default&#8212;<code>/dev/cdrom</code>&#8212;is what I want.  The line above just says to rip the first track to a <code>wav</code> file named <code>prokofiev1.wav</code>.</p>
<p><code>lame -h prokofiev1.wav prokofiev1.mp3</code></p>
<p>Encode the <code>wav</code> file to a <code>mp3</code> file, in high quality (128 kb).</p>
<p><code>lltag --cddb prokofiev1.mp3</code></p>
<p><code>lltag</code> helps me look up the <a href="http://en.wikipedia.org/wiki/Cddb">CDDB</a> data about the track and then add it to the mp3. I&#8217;m first prompted to make a CDDB query:</p>
<p><strong><code>Enter CDDB query [<query>q] (no default, h for help) ?</code></strong></p>
<p>I&#8217;ve tried entering the hexadecimal strings I get from <code>cd-discid</code>, but I&#8217;ve never gotten it to return any results.  Instead, I enter &#8220;prokofiev violinsonaten&#8221; verbatim from the CD&#8217;s title.  I get one matching result, which I select, and then I choose the appropriate track and save the CDDB data. </p>
<p><code>id3ed -i prokofiev1.mp3</code> and <code>id3v2 -l prokofiev1.mp3</code> let me verify that the data has been saved. </p>
<p>Now I&#8217;m all set to import the mp3 to Banshee and then to my iPod.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ilfilosofo.com/blog/2008/04/10/shell-mp3-encoding/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>

<!-- Dynamic Page Served (once) in 7.925 seconds -->
<!-- Cached page served by WP-Cache -->
<!-- Compression = gzip -->