<?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"
	xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Andy Skelton</title>
	<atom:link href="http://andy.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://andy.wordpress.com</link>
	<description>Just another WordPress hacker</description>
	<pubDate>Fri, 09 May 2008 17:36:48 +0000</pubDate>
	<generator>http://wordpress.org/?v=MU</generator>
	<language>en</language>
			<item>
		<title>Bash equivalent for PHP realpath()</title>
		<link>http://andy.wordpress.com/2008/05/09/bash-equivalent-for-php-realpath/</link>
		<comments>http://andy.wordpress.com/2008/05/09/bash-equivalent-for-php-realpath/#comments</comments>
		<pubDate>Fri, 09 May 2008 17:36:48 +0000</pubDate>
		<dc:creator>Andy</dc:creator>
		
		<category><![CDATA[Coding]]></category>

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

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

		<guid isPermaLink="false">http://andy.wordpress.com/?p=174</guid>
		<description><![CDATA[For all you PHP hackers trying to write a BASH script and looking for an equivalent for PHP&#8217;s realpath function, try readlink. It can expand symbolic links and resolve relative paths like &#8220;./&#8221; and &#8220;../&#8221;. In a shell script, try this:
MY_PATH=$(readlink -f $0)
Thanks to Barry.
       ]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>For all you PHP hackers trying to write a BASH script and looking for an equivalent for PHP&#8217;s realpath function, try readlink. It can expand symbolic links and resolve relative paths like &#8220;./&#8221; and &#8220;../&#8221;. In a shell script, try this:</p>
<p><code>MY_PATH=$(readlink -f $0)</code></p>
<p>Thanks to <a href="http://barry.wordpress.com/">Barry</a>.</p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/andy.wordpress.com/174/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/andy.wordpress.com/174/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/andy.wordpress.com/174/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/andy.wordpress.com/174/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/andy.wordpress.com/174/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/andy.wordpress.com/174/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/andy.wordpress.com/174/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/andy.wordpress.com/174/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/andy.wordpress.com/174/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/andy.wordpress.com/174/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/andy.wordpress.com/174/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/andy.wordpress.com/174/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=andy.wordpress.com&blog=155&post=174&subd=andy&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://andy.wordpress.com/2008/05/09/bash-equivalent-for-php-realpath/feed/</wfw:commentRss>
	
		<media:content url="http://a.wordpress.com/avatar/andy-128.jpg" medium="image">
			<media:title type="html">Andy</media:title>
		</media:content>
	</item>
		<item>
		<title>Attachment Stats</title>
		<link>http://andy.wordpress.com/2008/04/12/attachment-stats/</link>
		<comments>http://andy.wordpress.com/2008/04/12/attachment-stats/#comments</comments>
		<pubDate>Sat, 12 Apr 2008 23:53:17 +0000</pubDate>
		<dc:creator>Andy</dc:creator>
		
		<category><![CDATA[Stats]]></category>

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

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

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

		<guid isPermaLink="false">http://andy.wordpress.com/?p=173</guid>
		<description><![CDATA[WordPress 2.5 with its new uploader results in a lot more post attachments. Until now, the Stats plugin didn&#8217;t keep track of which attachments were viewed. Stats 1.2.1 contains a minor change that lets us show you which of your attachments are most popular.
Remember, attachment views are only counted if you link to the attachment&#8217;s [...]]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>WordPress 2.5 with its new uploader results in a lot more post attachments. Until now, the <a href="http://wordpress.org/extend/plugins/stats/">Stats</a> plugin didn&#8217;t keep track of which attachments were viewed. Stats 1.2.1 contains a <a href="http://dev.wp-plugins.org/changeset/40064/stats/trunk/stats.php">minor change</a> that lets us show you which of your attachments are most popular.</p>
<p>Remember, attachment views are only counted if you link to the attachment&#8217;s Post URL when inserting from the uploader.</p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/andy.wordpress.com/173/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/andy.wordpress.com/173/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/andy.wordpress.com/173/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/andy.wordpress.com/173/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/andy.wordpress.com/173/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/andy.wordpress.com/173/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/andy.wordpress.com/173/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/andy.wordpress.com/173/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/andy.wordpress.com/173/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/andy.wordpress.com/173/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/andy.wordpress.com/173/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/andy.wordpress.com/173/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=andy.wordpress.com&blog=155&post=173&subd=andy&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://andy.wordpress.com/2008/04/12/attachment-stats/feed/</wfw:commentRss>
	
		<media:content url="http://a.wordpress.com/avatar/andy-128.jpg" medium="image">
			<media:title type="html">Andy</media:title>
		</media:content>
	</item>
		<item>
		<title>Cache with Versioned Tags</title>
		<link>http://andy.wordpress.com/2008/03/01/cache-with-versioned-tags/</link>
		<comments>http://andy.wordpress.com/2008/03/01/cache-with-versioned-tags/#comments</comments>
		<pubDate>Sun, 02 Mar 2008 02:00:25 +0000</pubDate>
		<dc:creator>Andy</dc:creator>
		
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://andy.wordpress.com/?p=172</guid>
		<description><![CDATA[A couple of years ago I had an idea: a tagged cache with versioned tags. It works just like an associative array but with an added hidden layer in the cache interface that salts the key with any tags provided and their version numbers. This facilitates classified mass extinctions by the simple act of incrementing [...]]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>A couple of years ago I had an idea: a tagged cache with versioned tags. It works just like an associative array but with an added hidden layer in the cache interface that salts the key with any tags provided and their version numbers. This facilitates classified mass extinctions by the simple act of incrementing a tag version. The entire cache or any tagged subset can be &#8220;flushed&#8221; in this way. I call it extinction because although the items are dead (irretrievable by a normal read operation) they are not removed and may still be exhumed&#8212;Jurassic Park-style&#8212;until an expiration or eviction takes them out.</p>
<p>WordPress.com depends largely on <a href="http://www.danga.com/memcached/">memcached</a> clusters so I modified the <a href="http://dev.wp-plugins.org/browser/memcached/trunk">WordPress memcached client</a> to operate with versioned tags and it did work as planned. It is not operating today because the core changes needed to make the benefits of the new cache outweigh the performance cost never happened. WordPress does use a &#8220;cache group&#8221; concept and we have used it successfully to create different cache scopes but it does not use a multi-tagging cache and it does not have a mechanism to flush groups of items. However, let&#8217;s keep WordPress in mind because the basic data structures of a blog are simple and thus good example fodder.</p>
<p>For one usage example, there could be a &#8220;posts&#8221; tag indicating that the cached resource derives from data in the posts table and you would increment the &#8220;posts&#8221; version every time you changed that table. When you ask the cache for items tagged &#8220;posts&#8221;, it will only find resources that were stored since the last time the &#8220;posts&#8221; tag was incremented by a flush. Any operation that changes the table&#8217;s structure or its contents would trigger a flush of the &#8220;posts&#8221; tag.</p>
<p>To add another degree of utility, you can apply any number of tags when storing a resource in the cache. Thus if you stored a rendered page, you could tag it with every table queried while generating that resource and rely on tag flushes instead of specifically deleting the item from the cache. For finer-grained control, tags could be specified for individual table rows (e.g. &#8220;posts:142&#8243;) but the detrimental effects of increased version array size would have to be outweighed by the benefits of excluding the rest of the &#8220;posts&#8221; items from an extinction.</p>
<p>The central idea behind this scheme is that you should have multiple paths to remove a key or set of keys without knowing which keys are stored in the cache. If your caching substrate has a good eviction scheme this works. If you can reliably determine the generating factors (tables queried, etc.) for every cached resource, you can forget about cache expirations and let the tags do all the work.</p>
<p>There is also the concept of &#8220;tag scope&#8221;. It is not universally applicable but in WordPress MU, where each blog has its own tables, each blog must also have its own array of tag versions so that extinctions are not unnecessarily applied out of context. There are also certain global keys that never vary between blogs. By specifying the scope of some tags as local to the blog and others as global, and storing global and local versions separately, we can specify whether to increment a tag version on one or all blogs.</p>
<p>Each blog would have a local array version that can be incremented to flush all tags in the local scope, making it easy to clear out one blog&#8217;s poisoned cache. A global array version allows us to trigger a universal cache extinction. With many dedicated memcached servers, this would be a neat time-saver.</p>
<p>Metaversions are the cherry on top: a global &#8220;metaversion&#8221; for any local tag can be stored in local as well as global version arrays. The local metaversion is checked against the global metaversion and if they differ, the local version and the local metaversion are incremented. Thus when the &#8220;posts&#8221; tag metaversion is incremented in the global array, each local &#8220;posts&#8221; version will be incremented. This way, we can trigger mass extinctions of any tag across all scopes.</p>
<p>My experimental client did all of this but it increased page generation times by 5-10%. I am still sure that if the software made smart use of cache tags we could have seen great benefits. Unfortunately, with a package as large as WordPress, the time to improve cache utilization would be many times longer than the two weekends I spent hacking the cache client.</p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/andy.wordpress.com/172/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/andy.wordpress.com/172/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/andy.wordpress.com/172/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/andy.wordpress.com/172/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/andy.wordpress.com/172/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/andy.wordpress.com/172/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/andy.wordpress.com/172/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/andy.wordpress.com/172/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/andy.wordpress.com/172/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/andy.wordpress.com/172/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/andy.wordpress.com/172/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/andy.wordpress.com/172/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=andy.wordpress.com&blog=155&post=172&subd=andy&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://andy.wordpress.com/2008/03/01/cache-with-versioned-tags/feed/</wfw:commentRss>
	
		<media:content url="http://a.wordpress.com/avatar/andy-128.jpg" medium="image">
			<media:title type="html">Andy</media:title>
		</media:content>
	</item>
		<item>
		<title>Austin WordPress users, mark your calendars!</title>
		<link>http://andy.wordpress.com/2008/02/12/austin-wordpress-users-mark-your-calendars/</link>
		<comments>http://andy.wordpress.com/2008/02/12/austin-wordpress-users-mark-your-calendars/#comments</comments>
		<pubDate>Wed, 13 Feb 2008 04:33:37 +0000</pubDate>
		<dc:creator>Andy</dc:creator>
		
		<category><![CDATA[Austin]]></category>

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

		<guid isPermaLink="false">http://andy.wordpress.com/?p=171</guid>
		<description><![CDATA[Today at the GeekAustin/Dorkbot happy hour I met up with LinearB who said that on the second third Tuesday in May GeekAustin would like to co-host a social event with WordPress. I know Austin has a lot of WordPress users and consultants that don&#8217;t typically come out for the social events so I&#8217;m putting the [...]]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Today at the GeekAustin/Dorkbot happy hour I met up with LinearB who said that on the <del datetime="2008-02-15T22:27:05+00:00">second</del> <ins datetime="2008-02-15T22:27:05+00:00">third</ins> Tuesday in May GeekAustin would like to co-host a <a href="http://upcoming.yahoo.com/event/433081/">social event with WordPress</a>. I know Austin has a lot of WordPress users and consultants that don&#8217;t typically come out for the social events so I&#8217;m putting the word out early. How about it?</p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/andy.wordpress.com/171/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/andy.wordpress.com/171/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/andy.wordpress.com/171/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/andy.wordpress.com/171/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/andy.wordpress.com/171/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/andy.wordpress.com/171/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/andy.wordpress.com/171/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/andy.wordpress.com/171/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/andy.wordpress.com/171/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/andy.wordpress.com/171/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/andy.wordpress.com/171/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/andy.wordpress.com/171/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=andy.wordpress.com&blog=155&post=171&subd=andy&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://andy.wordpress.com/2008/02/12/austin-wordpress-users-mark-your-calendars/feed/</wfw:commentRss>
	
		<media:content url="http://a.wordpress.com/avatar/andy-128.jpg" medium="image">
			<media:title type="html">Andy</media:title>
		</media:content>
	</item>
		<item>
		<title>Apology: Not Useless Code</title>
		<link>http://andy.wordpress.com/2008/01/11/apology-not-useless-code/</link>
		<comments>http://andy.wordpress.com/2008/01/11/apology-not-useless-code/#comments</comments>
		<pubDate>Fri, 11 Jan 2008 23:38:12 +0000</pubDate>
		<dc:creator>Andy</dc:creator>
		
		<category><![CDATA[Coding]]></category>

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

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

		<guid isPermaLink="false">http://andy.wordpress.com/2008/01/11/apology-not-useless-code/</guid>
		<description><![CDATA[at the top of the main loop, have_posts() and is_404() are mutually exclusive.
Useless Code in WordPress Themes
That is true sometimes, but not always. More specifically, it can be false when a non-permalink URL seeks a non-existent post. For example, /?p=-1.
Issue a 404 if a permalink request doesn&#8217;t match any posts.  Don&#8217;t issue a 404 [...]]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><blockquote><p>at the top of the main loop, have_posts() and is_404() are mutually exclusive.</p>
<p><cite><a href="http://andy.wordpress.com/2006/08/13/useless-code-in-wordpress-themes/">Useless Code in WordPress Themes</a></cite></p></blockquote>
<p>That is true sometimes, but not always. More specifically, it can be false when a non-permalink URL seeks a non-existent post. For example, <code>/?p=-1</code>.</p>
<blockquote><p>Issue a 404 if a permalink request doesn&#8217;t match any posts.  Don&#8217;t issue a 404 if one was already issued, if the request was a search, or if the request was a regular query string request rather than a permalink request.</p>
<p><cite><a href="http://trac.wordpress.org/browser/tags/2.3.2/wp-includes/classes.php#L278">classes.php</a></cite></p></blockquote>
<p>Now it makes sense that the single.php template file would check <code>have_posts()</code>. Let the healing begin.</p>
<p>(Are there any documented examples of this bug occurring outside of single.php?)</p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/andy.wordpress.com/168/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/andy.wordpress.com/168/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/andy.wordpress.com/168/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/andy.wordpress.com/168/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/andy.wordpress.com/168/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/andy.wordpress.com/168/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/andy.wordpress.com/168/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/andy.wordpress.com/168/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/andy.wordpress.com/168/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/andy.wordpress.com/168/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/andy.wordpress.com/168/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/andy.wordpress.com/168/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=andy.wordpress.com&blog=155&post=168&subd=andy&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://andy.wordpress.com/2008/01/11/apology-not-useless-code/feed/</wfw:commentRss>
	
		<media:content url="http://a.wordpress.com/avatar/andy-128.jpg" medium="image">
			<media:title type="html">Andy</media:title>
		</media:content>
	</item>
		<item>
		<title>Name That Color</title>
		<link>http://andy.wordpress.com/2007/12/28/name-that-color/</link>
		<comments>http://andy.wordpress.com/2007/12/28/name-that-color/#comments</comments>
		<pubDate>Fri, 28 Dec 2007 23:53:52 +0000</pubDate>
		<dc:creator>Andy</dc:creator>
		
		<category><![CDATA[Tech]]></category>

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

		<category><![CDATA[web design]]></category>

		<guid isPermaLink="false">http://andy.wordpress.com/2007/12/28/name-that-color/</guid>
		<description><![CDATA[Have you ever wanted to know the name of a color when all you had was the RGB hex value?
According to Chirag Mehta&#8217;s Name That Color tool, #90a090 is nearest to &#8220;mantle&#8221; (#8B9C90). The same tool has an alphabetical list of over 1,500 colors and a Hue/Saturation/Value (HSV) color picker and it&#8217;s licensed cc-by.
via Google
 [...]]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Have you ever wanted to know the name of a color when all you had was the RGB hex value?</p>
<p>According to <a href="http://chir.ag/phernalia/name-that-color/">Chirag Mehta&#8217;s Name That Color</a> tool, <span style="background-color:#90a090;">#90a090</span> is nearest to &#8220;mantle&#8221; (<span style="background-color:#8B9C90;">#8B9C90</span>). The same tool has an alphabetical list of over 1,500 colors and a Hue/Saturation/Value (HSV) color picker and it&#8217;s licensed cc-by.</p>
<p>via <a href="http://www.google.com/search?q=color+namer">Google</a></p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/andy.wordpress.com/166/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/andy.wordpress.com/166/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/andy.wordpress.com/166/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/andy.wordpress.com/166/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/andy.wordpress.com/166/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/andy.wordpress.com/166/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/andy.wordpress.com/166/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/andy.wordpress.com/166/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/andy.wordpress.com/166/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/andy.wordpress.com/166/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/andy.wordpress.com/166/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/andy.wordpress.com/166/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=andy.wordpress.com&blog=155&post=166&subd=andy&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://andy.wordpress.com/2007/12/28/name-that-color/feed/</wfw:commentRss>
	
		<media:content url="http://a.wordpress.com/avatar/andy-128.jpg" medium="image">
			<media:title type="html">Andy</media:title>
		</media:content>
	</item>
		<item>
		<title>Fast MySQL Range Queries on MaxMind GeoIP Tables</title>
		<link>http://andy.wordpress.com/2007/12/16/fast-mysql-range-queries-on-maxmind-geoip-tables/</link>
		<comments>http://andy.wordpress.com/2007/12/16/fast-mysql-range-queries-on-maxmind-geoip-tables/#comments</comments>
		<pubDate>Sun, 16 Dec 2007 10:47:59 +0000</pubDate>
		<dc:creator>Andy</dc:creator>
		
		<category><![CDATA[Coding]]></category>

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

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

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

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

		<guid isPermaLink="false">http://andy.wordpress.com/2007/12/16/fast-mysql-range-queries-on-maxmind-geoip-tables/</guid>
		<description><![CDATA[A few weeks ago I read Jeremy Cole&#8217;s post on querying MaxMind GeoIP tables but I didn&#8217;t know what all that geometric magic was about so I dropped a comment about how we do it here on WordPress.com. (Actually, Nikolay beat me to it.) Jeremy ran some benchmarks and added them to his post. He [...]]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>A few weeks ago I read <a href="http://jcole.us/blog/archives/2007/11/24/on-efficiently-geo-referencing-ips-with-maxmind-geoip-and-mysql-gis/">Jeremy Cole&#8217;s post on querying MaxMind GeoIP tables</a> but I didn&#8217;t know what all that geometric magic was about so I dropped a <a href="http://jcole.us/blog/archives/2007/11/24/on-efficiently-geo-referencing-ips-with-maxmind-geoip-and-mysql-gis/#comment-1146758">comment</a> about how we do it here on WordPress.com. (Actually, Nikolay <a href="http://jcole.us/blog/archives/2007/11/24/on-efficiently-geo-referencing-ips-with-maxmind-geoip-and-mysql-gis/#comment-1146755">beat me to it</a>.) Jeremy ran some benchmarks and added them to his post. He discovered that my query performed favorably.</p>
<p>Today I saw an article referencing that comment and I wished I had published it here, so here it goes. There is a bonus at the end to make it worth your while if you witnessed the original discussion.</p>
<p>The basic problem is this: you have a MySQL table with columns that define the upper and lower bounds of mutually exclusive integer ranges and you need the row for which a given integer fits within the range and you need it fast.</p>
<p>The basic solution is this: you create an index on the <em>upper bound</em> column and find the first row for which that value is <em>greater than or equal to</em> the given value.</p>
<p>The logic is this: MySQL scans the integer index in ascending order. Every range <em>below</em> the matching range will have an upper bound <em>less than</em> the given value. The first range with an upper bound <em>not less than</em> the given value will include that value <em>if the ranges are contiguous</em>.</p>
<p>Assuming contiguous ranges (no possibility of falling between ranges) this query will find the correct row very quickly:</p>
<p><code>SELECT * FROM ip2loc WHERE ip_to &gt;= 123456789 LIMIT 1</code></p>
<p>The MySQL server can find the row with an index scan, a sufficiently fast operation. I can&#8217;t think of a faster way to get the row (except maybe reversing the scan when the number is known to be in the upper half of the entire range).</p>
<p>The bonus is this: because the time to scan the index is related to the length of the index, you should keep the index as small as possible. <a href="http://jcole.us/blog/archives/2007/11/24/on-efficiently-geo-referencing-ips-with-maxmind-geoip-and-mysql-gis/#comment-1148837">Nikolay found</a> that our GeoIP table had gaps between some ranges and decided to rectify this condition by filling in the gaps with &#8220;no country&#8221; rows, ensuring that the query would return &#8220;no country&#8221; instead of a wrong country. I would advise against doing that because it lengthens the index and adds precious query time. Instead, check that the found range&#8217;s lower bound is <em>less than or equal to</em> the given value after you have retrieved the row.</p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/andy.wordpress.com/165/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/andy.wordpress.com/165/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/andy.wordpress.com/165/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/andy.wordpress.com/165/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/andy.wordpress.com/165/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/andy.wordpress.com/165/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/andy.wordpress.com/165/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/andy.wordpress.com/165/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/andy.wordpress.com/165/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/andy.wordpress.com/165/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/andy.wordpress.com/165/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/andy.wordpress.com/165/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=andy.wordpress.com&blog=155&post=165&subd=andy&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://andy.wordpress.com/2007/12/16/fast-mysql-range-queries-on-maxmind-geoip-tables/feed/</wfw:commentRss>
	
		<media:content url="http://a.wordpress.com/avatar/andy-128.jpg" medium="image">
			<media:title type="html">Andy</media:title>
		</media:content>
	</item>
		<item>
		<title>Free tech gear</title>
		<link>http://andy.wordpress.com/2007/10/07/free-tech-gear/</link>
		<comments>http://andy.wordpress.com/2007/10/07/free-tech-gear/#comments</comments>
		<pubDate>Sun, 07 Oct 2007 19:25:28 +0000</pubDate>
		<dc:creator>Andy</dc:creator>
		
		<category><![CDATA[Gadgets]]></category>

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

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

		<category><![CDATA[free stuff]]></category>

		<guid isPermaLink="false">http://andy.wordpress.com/2007/10/07/free-tech-gear/</guid>
		<description><![CDATA[Here&#8217;s a clever WordPress site: Take My Tech is giving away used gadgets by selecting a random commenter when the number of comments on a gadget reaches one hundred. The site will pay for shipping (and hopefully make the owner a few bucks) with the revenues from advertisements. It is a bit of a gamble [...]]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Here&#8217;s a clever WordPress site: <a href="http://www.takemytech.com/">Take My Tech</a> is giving away used gadgets by selecting a random commenter when the number of comments on a gadget reaches one hundred. The site will pay for shipping (and hopefully make the owner a few bucks) with the revenues from advertisements. It is a bit of a gamble for the owner&#8212;craigslist or ebay would be the more obvious choices&#8212;but I find it clever all the same.</p>
<p>The lottery process, including checking for duplicate comment emails/IP&#8217;s, could be automated with a plugin. I suggested building on top of my own <a href="http://wordpress.org/extend/plugins/cap-comments/">Cap Comments</a> plugin.</p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/andy.wordpress.com/164/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/andy.wordpress.com/164/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/andy.wordpress.com/164/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/andy.wordpress.com/164/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/andy.wordpress.com/164/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/andy.wordpress.com/164/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/andy.wordpress.com/164/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/andy.wordpress.com/164/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/andy.wordpress.com/164/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/andy.wordpress.com/164/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/andy.wordpress.com/164/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/andy.wordpress.com/164/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=andy.wordpress.com&blog=155&post=164&subd=andy&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://andy.wordpress.com/2007/10/07/free-tech-gear/feed/</wfw:commentRss>
	
		<media:content url="http://a.wordpress.com/avatar/andy-128.jpg" medium="image">
			<media:title type="html">Andy</media:title>
		</media:content>
	</item>
		<item>
		<title>wp-hackers</title>
		<link>http://andy.wordpress.com/2007/10/03/wp-hackers/</link>
		<comments>http://andy.wordpress.com/2007/10/03/wp-hackers/#comments</comments>
		<pubDate>Thu, 04 Oct 2007 01:27:15 +0000</pubDate>
		<dc:creator>Andy</dc:creator>
		
		<category><![CDATA[WordPress]]></category>

		<category><![CDATA[wp-hackers]]></category>

		<guid isPermaLink="false">http://andy.wordpress.com/2007/10/03/wp-hackers/</guid>
		<description><![CDATA[There has been much discussion of the &#8220;low signal-to-noise ratio&#8221; on the wp-hackers list of late. Not that we need to move that discussion off wp-hackers, but I wanted to compose some thoughts in my own forum where I can moderate the comments to my heart&#8217;s content. This turns up an unfortunate reversal: you don&#8217;t [...]]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>There has been much discussion of the &#8220;low signal-to-noise ratio&#8221; on the wp-hackers list of late. Not that we need to move that discussion off wp-hackers, but I wanted to compose some thoughts in my own forum where I can moderate the comments to my heart&#8217;s content. This turns up an unfortunate reversal: you don&#8217;t have to read any of the comments I didn&#8217;t like, but I have to read them all. I wish moderation worked in reverse.</p>
<p>The wp-hackers list now serves something near 1,000 email addresses. I don&#8217;t know how big it was when I joined two years ago. I do know that the list traffic has grown to become nearly unbearable. I know that there are busier lists. I am speaking not just about the amount of traffic, but the productivity of the list as a whole.</p>
<p>If productivity is the wrong measure of value for wp-hackers then my nephew is a monkey and I&#8217;ll unsubscribe forthwith. By productivity I mean the production of worthwhile code, whether it be core or themes or plugins, and the dissemination of information leading to same.</p>
<p>I would be overjoyed to wake up tomorrow and find wp-hackers messages flooding my inbox <em>if they were mostly productive</em>. The banter, the academic opinions, the griping and nagging and off-topic fussing, these are the things that turned me from a hopeful reader and a contributor into a pessimistic lurker.</p>
<p>It has been said that wp-hackers has followed the typical evolutionary pattern of an open-source software mailing list community. This is probably true&#8212;I can&#8217;t speak from experience because I have participated little in other OSS projects&#8212;but I&#8217;m not willing to let it go at that.</p>
<p>Today it was proposed during the IRC meetup that we monthly post a set of rules or guidelines and be more strict about curtailing off-topic and counterproductive list activity. Assuming the manifestation of rules can proceed trouble-free, I&#8217;m happy with that.</p>
<p>There is just one thing I want to make clear about wp-hackers: a hacker is not someone who discusses or pays lip service or dissents or casts a vote or says what can or should be done. Hackers aren&#8217;t committee members. Hackers are more interested in proving what can be done than arguing about it.</p>
<p>Many important contributions have been made by people who had no interest in hacking or coding or tweaking. I do not mean to exclude them and I do not mean to glorify the archetypal geek who knows no social graces. All productive contributions are welcomed.</p>
<p>Case in point: this post is far too long-winded and unproductive for wp-hackers. It would be a blatant waste of time to send it to the list. To compound the sin, that waste would be multiplied by each and every response. As if it weren&#8217;t bad enough, I am afraid to think of how much time some people spend composing rubbish like this.</p>
<p>Let the rules say things like &#8220;think before you send&#8221; and &#8220;consider the size of the audience.&#8221; What I want to get across is that sometimes it&#8217;s better to self-publish than to use the list. If anybody has trouble setting up a blog, I&#8217;ll tell you where you can get one&#8230; real cheap.</p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/andy.wordpress.com/163/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/andy.wordpress.com/163/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/andy.wordpress.com/163/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/andy.wordpress.com/163/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/andy.wordpress.com/163/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/andy.wordpress.com/163/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/andy.wordpress.com/163/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/andy.wordpress.com/163/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/andy.wordpress.com/163/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/andy.wordpress.com/163/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/andy.wordpress.com/163/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/andy.wordpress.com/163/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=andy.wordpress.com&blog=155&post=163&subd=andy&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://andy.wordpress.com/2007/10/03/wp-hackers/feed/</wfw:commentRss>
	
		<media:content url="http://a.wordpress.com/avatar/andy-128.jpg" medium="image">
			<media:title type="html">Andy</media:title>
		</media:content>
	</item>
		<item>
		<title>Proposal: Multipart Web Requests</title>
		<link>http://andy.wordpress.com/2007/10/01/proposal-multipart-web-requests/</link>
		<comments>http://andy.wordpress.com/2007/10/01/proposal-multipart-web-requests/#comments</comments>
		<pubDate>Mon, 01 Oct 2007 06:54:19 +0000</pubDate>
		<dc:creator>Andy</dc:creator>
		
		<category><![CDATA[Tech]]></category>

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

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

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

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

		<guid isPermaLink="false">http://andy.wordpress.com/2007/10/01/proposal-multipart-web-requests/</guid>
		<description><![CDATA[Here&#8217;s a little idea that might improve the web for everyone. I don&#8217;t know how to draft or submit a Request For Comments&#8212;I could have read RFC 2026 (BCP 9) but I wasn&#8217;t interested&#8212;but if anyone would like to see this through, I hope you&#8217;ll contact me.
We could improve the overall performance and reduce the [...]]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Here&#8217;s a little idea that might improve the web for everyone. I don&#8217;t know how to draft or submit a Request For Comments&#8212;I could have read <a href="ftp://ftp.rfc-editor.org/in-notes/bcp/bcp9.txt">RFC 2026 (BCP 9)</a> but I wasn&#8217;t interested&#8212;but if anyone would like to see this through, I hope you&#8217;ll contact me.</p>
<p>We could improve the overall performance and reduce the request load on most of the world wide web if servers supported a way of sending in one response some or all of the resources that will certainly or likely be requested (GET) as a result of parsing the requested resource.</p>
<p>A sufficient implementation might be possible using existing RFCs. Perhaps a media range of &#8220;Multipart&#8221; in the Accept request-header field could be used to announce that the client can accept such responses.</p>
<p>The ideal implementation might include optimizations for client and proxy caches, such as a Cached request-header whose value would specify for exclusion from the response any already-cached items and their LastModified, ETag, or other conditional request-header values as appropriate.</p>
<p>Static files served in this manner might be parsed by the web server in order to discover which, if any, other resources (images, audio, stylesheets, DTD&#8217;s, etc.) should be sent. The server might take cues from a saved list, as from a cache of previous results of parsing or from a manually generated list.</p>
<p>Servers generating resources dynamically might take cues from the program state, or the page generation scripts might cue the server by passing data directly or as a value of an Include response-header. When a proxy detects the Include response-header along with a single-part response, it may assume that the server was incapable of providing a multi-part response and convert the response into a multi-part response if the proxy has a valid copy or wishes to pre-fetch a copy of any or all of the resources indicated by Include.</p>
<p>A typical request might proceed in this way:</p>
<ol>
<li>Client requests /index.html from example.com with Accept: Multipart</li>
<li>Server finds index.html and discovers that its display will require a PNG file as a background.</li>
<li>Server responds:<br />
{response-headers}<br />
{body-part (text/html)}<br />
&#8211;boundary<br />
{body-part (image/png)}<br />
&#8211;boundary&#8211;</li>
</ol>
<p>In the preceeding example, there is no explicit request for the background image but the client receives it in the payload of the initial response.</p>
<p>Specialized user agents may use the Accept request-header to specify which types of media they prefer to receive but there ought to be a way for agents to specify which types of media they prefer not to receive in multi-part responses. For example, a screen reader probably would want the server to bundle audio but not images. A Reject request-header could indicate unwanted media types or a zero q-value in the Accept header might serve to prevent the server or any proxies from attaching these types.</p>
<p>A proxy handling a non-multi-part request from a client may request resources in multi-part mode and then cache and serve the individual parts as if each had been requested singly. Proxies may construct multi-part responses from parts retrieved individually and they may append additional parts according to any cue, such as by rendering web pages with the engine of their choice (perhaps taking a hint from the User-Agent request-header).</p>
<p>The existence of an entity in a multi-part response should not cause the user agent to display, execute, or otherwise handle the entity. User agents accepting multi-part responses should not store or execute any part which was not used during the course of rendering or interacting with the requested resource.</p>
<p>Does anybody else think that something like this could be beneficial?</p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/andy.wordpress.com/162/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/andy.wordpress.com/162/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/andy.wordpress.com/162/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/andy.wordpress.com/162/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/andy.wordpress.com/162/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/andy.wordpress.com/162/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/andy.wordpress.com/162/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/andy.wordpress.com/162/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/andy.wordpress.com/162/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/andy.wordpress.com/162/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/andy.wordpress.com/162/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/andy.wordpress.com/162/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=andy.wordpress.com&blog=155&post=162&subd=andy&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://andy.wordpress.com/2007/10/01/proposal-multipart-web-requests/feed/</wfw:commentRss>
	
		<media:content url="http://a.wordpress.com/avatar/andy-128.jpg" medium="image">
			<media:title type="html">Andy</media:title>
		</media:content>
	</item>
	</channel>
</rss>