<?xml version="1.0" encoding="utf-8" ?>
<rdf:RDF 
   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
   xmlns:admin="http://webns.net/mvcb/"
   xmlns:content="http://purl.org/rss/1.0/modules/content/"
   xmlns:dc="http://purl.org/dc/elements/1.1/"
   xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
   xmlns:wfw="http://wellformedweb.org/CommentAPI/">
<channel rdf:about="http://www.sklar.com/blog/rss.php?version=1.0">
    <title>sklar.com/blog</title>
    <link>http://www.sklar.com/blog/</link>
    <description>...composed of an indefinite, perhaps infinite number of hexagonal galleries...</description>
    <dc:language>en</dc:language>
    <admin:errorReportsTo rdf:resource="mailto:web-blog@sklar.com" />

    <image rdf:resource="http://www.sklar.com/blog/templates/sklar-sm/img/s9y_banner_small.png" />

    <items>
      <rdf:Seq>
        <rdf:li resource="http://www.sklar.com/blog/archives/122-guid.html" />
        <rdf:li resource="http://www.sklar.com/blog/archives/36-guid.html" />
        <rdf:li resource="http://www.sklar.com/blog/archives/121-guid.html" />
</rdf:Seq>
    </items>
</channel>

<image rdf:about="http://www.sklar.com/blog/templates/sklar-sm/img/s9y_banner_small.png">
        <url>http://www.sklar.com/blog/templates/sklar-sm/img/s9y_banner_small.png</url>
        <title>RSS: sklar.com/blog - ...composed of an indefinite, perhaps infinite number of hexagonal galleries...</title>
        <link>http://www.sklar.com/blog/</link>
        <width>100</width>
        <height>21</height>
    </image>
<item rdf:about="http://www.sklar.com/blog/archives/122-guid.html">
    <title>Fast Multiple String Replacement in PHP</title>
    <link>http://www.sklar.com/blog/archives/122-Fast-Multiple-String-Replacement-in-PHP.html</link>
    <description>
At work, we added a &lt;a href=&quot;http://www.sklar.com/blog/exit.php?url_id=433&amp;amp;entry_id=122&quot; title=&quot;http://blog.ning.com/2010/08/language-filter-live.html&quot; onmouseover=&quot;window.status='http://blog.ning.com/2010/08/language-filter-live.html';return true;&quot; onmouseout=&quot;window.status='';return true;&quot;&gt;language filter&lt;/a&gt; to Ning Pro last month. It lets Network Creators have naughty words (for the Network Creator's definition of &quot;naughty&quot;) replaced with * characters.&lt;br /&gt;
&lt;br /&gt;
A straightforward way to do this in PHP is to pass an array of words to look for and their replacements to a function like &lt;a href=&quot;http://www.sklar.com/blog/exit.php?url_id=434&amp;amp;entry_id=122&quot; title=&quot;http://php.net/str_replace&quot; onmouseover=&quot;window.status='http://php.net/str_replace';return true;&quot; onmouseout=&quot;window.status='';return true;&quot;&gt;str_replace()&lt;/a&gt; or &lt;a href=&quot;http://www.sklar.com/blog/exit.php?url_id=435&amp;amp;entry_id=122&quot; title=&quot;http://php.net/str_ireplace&quot; onmouseover=&quot;window.status='http://php.net/str_ireplace';return true;&quot; onmouseout=&quot;window.status='';return true;&quot;&gt;str_ireplace()&lt;/a&gt;. Or, similarly, use a regular expression that gloms the search terms together (and potentially checks word boundaries.) There are assorted &lt;a href=&quot;http://www.sklar.com/blog/exit.php?url_id=436&amp;amp;entry_id=122&quot; title=&quot;http://wordpress.org/extend/plugins/wp-content-filter&quot; onmouseover=&quot;window.status='http://wordpress.org/extend/plugins/wp-content-filter';return true;&quot; onmouseout=&quot;window.status='';return true;&quot;&gt;WordPress plugins&lt;/a&gt; that work like this.&lt;br /&gt;
&lt;br /&gt;
The problem with this approach is that it's really slow. Especially if you have a lot of words you're looking for. The amount of time it takes to do the search and replace grows in proportion to the number of words you're looking for. This is particularly unfortunate because usually, none of the words are ever found!&lt;br /&gt;
&lt;br /&gt;
For our language filter, we took a different approach. We've packaged it up into a PHP extension called &lt;a href=&quot;http://www.sklar.com/blog/exit.php?url_id=438&amp;amp;entry_id=122&quot; title=&quot;http://github.com/ning/boxwood&quot; onmouseover=&quot;window.status='http://github.com/ning/boxwood';return true;&quot; onmouseout=&quot;window.status='';return true;&quot;&gt;Boxwood&lt;/a&gt; and releasing it today as open source. (Find it on github: &lt;a href=&quot;http://www.sklar.com/blog/exit.php?url_id=438&amp;amp;entry_id=122&quot; title=&quot;http://github.com/ning/boxwood&quot; onmouseover=&quot;window.status='http://github.com/ning/boxwood';return true;&quot; onmouseout=&quot;window.status='';return true;&quot;&gt;http://github.com/ning/boxwood&lt;/a&gt;.)&lt;br /&gt;
&lt;br /&gt;
With Boxwood, you can have your list of search terms be as long as you like -- the search and replace algorithm doesn't get slower with more words on the list of words to look for. It works by building a &lt;a href=&quot;http://www.sklar.com/blog/exit.php?url_id=439&amp;amp;entry_id=122&quot; title=&quot;http://en.wikipedia.org/wiki/Trie&quot; onmouseover=&quot;window.status='http://en.wikipedia.org/wiki/Trie';return true;&quot; onmouseout=&quot;window.status='';return true;&quot;&gt;trie&lt;/a&gt; of all the search terms and then scans your subject text just once, walking down elements of the trie and comparing them to characters in your text. It supports US-ASCII and UTF-8, case-sensitive or insensitive matching, and has some English-centric word boundary checking logic.&lt;br /&gt;
&lt;br /&gt;
Take it for a drive and let us know what you think!    </description>
        <dc:publisher>sklar.com/blog</dc:publisher>
    <dc:creator>sklar@sklar.com (David)</dc:creator>
    <dc:subject>software, php, ning</dc:subject>
    <dc:date>2010-09-29T12:10:46Z</dc:date>
    <wfw:comment>http://www.sklar.com/blog/wfwcomment.php?cid=122</wfw:comment>
    <slash:comments>2</slash:comments>
    <wfw:commentRss>http://www.sklar.com/blog/rss.php?version=1.0&amp;type=comments&amp;cid=122</wfw:commentRss>
</item>
<item rdf:about="http://www.sklar.com/blog/archives/36-guid.html">
    <title>Efficiency is not one-dimensional, part MMDXXI</title>
    <link>http://www.sklar.com/blog/archives/36-Efficiency-is-not-one-dimensional,-part-MMDXXI.html</link>
    <description>
In a discussion of the varying levels of efficiency in different web server configurations, &lt;a href=&quot;http://www.sklar.com/blog/exit.php?url_id=431&amp;amp;entry_id=36&quot; title=&quot;http://www.trachtenberg.com/&quot; onmouseover=&quot;window.status='http://www.trachtenberg.com/';return true;&quot; onmouseout=&quot;window.status='';return true;&quot;&gt;Adam Trachtenberg&lt;/a&gt; writes, in part:&lt;br /&gt;
&lt;blockquote&gt;We've long since passed the inflection point where hardware resources&lt;br /&gt;
are more expensive than business objectives and developer costs, yet&lt;br /&gt;
we still persist in undervaluing those two assets. Just because&lt;br /&gt;
hardware has a tangible price doesn't mean that it's the only part of&lt;br /&gt;
the process with a cost.&lt;/blockquote&gt;&lt;br /&gt;
Well put. &lt;a href=&quot;http://www.sklar.com/blog/exit.php?url_id=432&amp;amp;entry_id=36&quot; title=&quot;http://lists.nyphp.org/pipermail/talk/2004-April/009305.html&quot; onmouseover=&quot;window.status='http://lists.nyphp.org/pipermail/talk/2004-April/009305.html';return true;&quot; onmouseout=&quot;window.status='';return true;&quot;&gt;Read Adam's entire message.&lt;/a&gt;    </description>
        <dc:publisher>sklar.com/blog</dc:publisher>
    <dc:creator>sklar@sklar.com (David)</dc:creator>
    <dc:subject>software</dc:subject>
    <dc:date>2004-04-28T18:41:05Z</dc:date>
    <wfw:comment>http://www.sklar.com/blog/wfwcomment.php?cid=36</wfw:comment>
    <slash:comments>6</slash:comments>
    <wfw:commentRss>http://www.sklar.com/blog/rss.php?version=1.0&amp;type=comments&amp;cid=36</wfw:commentRss>
</item>
<item rdf:about="http://www.sklar.com/blog/archives/121-guid.html">
    <title>PHP Microbenchmarking</title>
    <link>http://www.sklar.com/blog/archives/121-PHP-Microbenchmarking.html</link>
    <description>
I just posted on the &lt;a href=&quot;http://www.sklar.com/blog/exit.php?url_id=427&amp;amp;entry_id=121&quot; title=&quot;http://code.ning.com/2010/05/php-microbenchmarking/&quot; onmouseover=&quot;window.status='http://code.ning.com/2010/05/php-microbenchmarking/';return true;&quot; onmouseout=&quot;window.status='';return true;&quot;&gt;Ning code blog&lt;/a&gt; about the PHP microbenchmarking framework we released:&lt;br /&gt;
&lt;br /&gt;
&lt;blockquote&gt;I'm pleased to announce the release of ub, a PHP microbenchmarking framework. You can download it from &lt;a href=&quot;http://www.sklar.com/blog/exit.php?url_id=428&amp;amp;entry_id=121&quot; title=&quot;http://github.com/ning/ub&quot; onmouseover=&quot;window.status='http://github.com/ning/ub';return true;&quot; onmouseout=&quot;window.status='';return true;&quot;&gt;http://github.com/ning/ub&lt;/a&gt;.&lt;br /&gt;
&lt;br /&gt;
The goal is to make it as easy as possible to compare the runtime of alternative approaches to the same problem, such as different regular expressions, or different methods for string or array manipulation.&lt;br /&gt;
&lt;br /&gt;
The source distribution contains a &lt;a href=&quot;http://www.sklar.com/blog/exit.php?url_id=429&amp;amp;entry_id=121&quot; title=&quot;http://github.com/ning/ub/blob/master/README&quot; onmouseover=&quot;window.status='http://github.com/ning/ub/blob/master/README';return true;&quot; onmouseout=&quot;window.status='';return true;&quot;&gt;README&lt;/a&gt; with some documentation and a bunch of &lt;a href=&quot;http://www.sklar.com/blog/exit.php?url_id=430&amp;amp;entry_id=121&quot; title=&quot;http://github.com/ning/ub/tree/master/b/&quot; onmouseover=&quot;window.status='http://github.com/ning/ub/tree/master/b/';return true;&quot; onmouseout=&quot;window.status='';return true;&quot;&gt;sample benchmarks&lt;/a&gt;.&lt;br /&gt;
&lt;br /&gt;
For normal use, it is rare that two similar, but different approaches produce appreciable differences in runtime. (Inefficient regexes and bloated call stacks aside.) The payoff from this kind of benchmarking is really on operations that happen hundreds or thousands of times in a request, or are happening on hundreds or thousands of servers. At that point, shaving off small amounts of runtime performance can really make a difference.&lt;br /&gt;
 &lt;br /&gt;
I am looking forward to beef up the set of included benchmarks -- contributions are welcome!&lt;/blockquote&gt;    </description>
        <dc:publisher>sklar.com/blog</dc:publisher>
    <dc:creator>sklar@sklar.com (David)</dc:creator>
    <dc:subject>php, ning</dc:subject>
    <dc:date>2010-05-04T13:07:53Z</dc:date>
    <wfw:comment>http://www.sklar.com/blog/wfwcomment.php?cid=121</wfw:comment>
    <slash:comments>1</slash:comments>
    <wfw:commentRss>http://www.sklar.com/blog/rss.php?version=1.0&amp;type=comments&amp;cid=121</wfw:commentRss>
</item>
</rdf:RDF>
