<?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:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Indirecthit &#187; Web Development</title>
	<atom:link href="http://www.indirecthit.com/category/web-development/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.indirecthit.com</link>
	<description>A Discussion on PHP, AJAX and Other Web Tools with a bit of startup talk</description>
	<lastBuildDate>Tue, 02 Mar 2010 14:34:41 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Media, Cookies &amp; Domains</title>
		<link>http://www.indirecthit.com/2010/03/02/media-cookies-domains/</link>
		<comments>http://www.indirecthit.com/2010/03/02/media-cookies-domains/#comments</comments>
		<pubDate>Tue, 02 Mar 2010 14:34:41 +0000</pubDate>
		<dc:creator>clong</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Tips]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[cookies]]></category>
		<category><![CDATA[domains]]></category>
		<category><![CDATA[media]]></category>
		<category><![CDATA[static]]></category>

		<guid isPermaLink="false">http://www.indirecthit.com/?p=57</guid>
		<description><![CDATA[With all the brilliant tools (Google Page Speed, YSlow, etc.) out there, web professionals can now easily see a few basic things to improve page speed performance. One suggestion is to send static content from a cookieless domain. On most sites I&#8217;ve worked with, we serve static content from a media subdomain and then the [...]]]></description>
			<content:encoded><![CDATA[<p>With all the brilliant tools (<a title="Google Page Speed" href="http://code.google.com/speed/page-speed/">Google Page Speed</a>, <a title="YSlow" href="http://developer.yahoo.com/yslow/">YSlow</a>, etc.) out there, web professionals can now easily see a few basic things to improve page speed performance. One suggestion is to send static content from a cookieless domain. On most sites I&#8217;ve worked with, we serve static content from a media subdomain and then the real content from the main domain (without www). I know with cookies, if the domain is <strong>.indirecthit.com</strong> it would send that cookie to any subdomain on <strong>indirecthit.com</strong>, therefore the media subdomain would have a cookie. An easy change: remove the <strong>.</strong> from the cookie domain. But when I looked at the <a href="http://www.php.net" class="ubernym uttInitialism" onmouseover="domTT_activate(this, event, 'content', 'PHP: Hypertext Preprocessor' );"><abbr class="uttInitialism">PHP</abbr></a> manual for setcookie, I came across the following statement:</p>
<blockquote><p>The        <em>.</em> is not required but makes it compatible        with more browsers.</p></blockquote>
<p>That doesn&#8217;t sound very good, I want it to be compatible with all browsers&#8230;</p>
<p>I couldn&#8217;t find much on it, from what I did find I believe the reason it doesn&#8217;t work with all browsers is for security. If I had the domain <strong>er.com</strong>, and I set a cookie to the domain <strong>er.com</strong> (notice the missing <strong>.</strong>), the browser could match this with <strong>older.com</strong> or <strong>lesser.com</strong>. If the website at <strong>er.com</strong> set the cookie to <strong>er.com </strong>(without the first <strong>.</strong>), the web server on <strong>older.com </strong>or <strong>lesser.com</strong> can access this cookie&#8230;not good. Therefore, even if I remove the <strong>. </strong>from the domain, it still would match <strong>media.indirecthit.com</strong> and that domain wouldn&#8217;t be cookieless.Doesn&#8217;t solve my problem and isn&#8217;t compatible with most browsers.</p>
<p>The solution, is to split out your media server on a different domain such as <strong>indirecthitmedia.com</strong>. This is why when you visit some Google properties it loads media content from <strong>gstatic.com </strong>not<strong> media.google.com</strong> or <strong>google.com</strong>. And obviously you don&#8217;t set any cookies to this new media domain. You will now score a bit higher on <a title="Google Page Speed" href="http://code.google.com/speed/page-speed/">Google Page Speed</a> and <a title="YSlow" href="http://developer.yahoo.com/yslow/">YSlow</a>. Congrats!</p>]]></content:encoded>
			<wfw:commentRss>http://www.indirecthit.com/2010/03/02/media-cookies-domains/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Table Centering Inheritance</title>
		<link>http://www.indirecthit.com/2008/11/10/table-centering-inheritance/</link>
		<comments>http://www.indirecthit.com/2008/11/10/table-centering-inheritance/#comments</comments>
		<pubDate>Tue, 11 Nov 2008 00:31:26 +0000</pubDate>
		<dc:creator>clong</dc:creator>
				<category><![CDATA[Web Development]]></category>
		<category><![CDATA[html]]></category>

		<guid isPermaLink="false">http://www.indirecthit.com/?p=41</guid>
		<description><![CDATA[I recently came across a little cross-browser issue with using the align attribute in tables. The problem was that we had some cells centering in Internet Explorer and Opera but not in Safari and Firefox. The result was how the inheritence of the align attribute is handled by the different browsers.
The first image below is [...]]]></description>
			<content:encoded><![CDATA[<p>I recently came across a little cross-browser issue with using the align attribute in tables. The problem was that we had some cells centering in Internet Explorer and Opera but not in Safari and Firefox. The result was how the inheritence of the align attribute is handled by the different browsers.</p>
<p>The first image below is in Opera, and the second is in Firefox. I wanted it to look like it does in Firefox.</p>
<p style="text-align: center;"><a href="http://www.indirecthit.com/wp-content/uploads/2008/11/picture-3.png"><img title="picture-3"  style="clear:both" src="http://www.indirecthit.com/wp-content/uploads/2008/11/picture-3-300x25.png" alt="" width="300" height="25" /></a></p>
<p style="text-align: center;"><a href="http://www.indirecthit.com/wp-content/uploads/2008/11/picture-4.png"><img title="picture-4" src="http://www.indirecthit.com/wp-content/uploads/2008/11/picture-4-299x25.png" alt="" width="299" height="25" style="clear:both" /></a></p>
<p><br/><br />
<br/><br />
<br/><br />
The <span class="ubernym uttInitialism" onmouseover="domTT_activate(this, event, 'content', 'Link to the spec: (&lt;a href=&quot;http://www.w3.org/MarkUp/&quot;&gt;link&lt;/a&gt;)','caption', 'HyperText Markup Language' );"><abbr class="uttInitialism">HTML</abbr></span> for the above is:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
</pre></td><td class="code"><pre class="html" style="font-family:monospace;">&lt;table width=&quot;550px&quot; border=&quot;1&quot;&gt;
	&lt;tr&gt;
		&lt;td align=&quot;center&quot;&gt;
			&lt;table border=&quot;1&quot; width=&quot;80%&quot;&gt;
				&lt;tr&gt;
					&lt;td&gt;Apple Sauce&lt;/td&gt;
					&lt;td&gt;Pecan Pumpkin Butter&lt;/td&gt;
				&lt;/tr&gt;
			&lt;/table&gt;
		&lt;/td&gt;
	&lt;/tr&gt;
&lt;/table&gt;</pre></td></tr></table></div>

<p>The problem is that the</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">&lt;td align=&quot;center&quot;&gt;</pre></div></div>

<p> is inherited by the tables within that table for IE and Opera but not for Firefox. It&#8217;s an easy fix, just make the next &lt;td&gt; into &lt;td align=&#8221;left&#8221;&gt; to fix it. It&#8217;s nothing major, probably very well known&#8230;but the first time I&#8217;ve come across it.</p>]]></content:encoded>
			<wfw:commentRss>http://www.indirecthit.com/2008/11/10/table-centering-inheritance/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Django Caching Middleware &amp; Login Page</title>
		<link>http://www.indirecthit.com/2008/06/02/django-caching-middleware-login-page/</link>
		<comments>http://www.indirecthit.com/2008/06/02/django-caching-middleware-login-page/#comments</comments>
		<pubDate>Mon, 02 Jun 2008 13:15:48 +0000</pubDate>
		<dc:creator>clong</dc:creator>
				<category><![CDATA[Django]]></category>
		<category><![CDATA[StartupIndex]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[cache]]></category>

		<guid isPermaLink="false">http://www.indirecthit.com/?p=37</guid>
		<description><![CDATA[Recently on StartupIndex.ca, I&#8217;ve noticed a problem where the first time you login it fails, the second time it works. I sat down last night, and spent some time attempting to solve this problem. My search on the greater web didn&#8217;t end up with very many results, I did find one mailing list thread on [...]]]></description>
			<content:encoded><![CDATA[<p>Recently on StartupIndex.ca, I&#8217;ve noticed a problem where the first time you login it fails, the second time it works. I sat down last night, and spent some time attempting to solve this problem. My search on the greater web didn&#8217;t end up with very many results, I did find one mailing list thread on &#8220;<a href="http://groups.google.ca/group/django-users/browse_thread/thread/3d0694201341c205/abf83324933b243f?hl=en&amp;lnk=st&amp;q=django+login+auth+fails+multiple#abf83324933b243f">django.contrib.auth.views.login failing cookie test</a>&#8220;. This wasn&#8217;t exactly what I was looking for, but it set me down the right path.</p>
<p>Django comes with a <a href="http://www.djangoproject.com/documentation/cache/#the-per-site-cache">caching middleware</a> that caches any request made to the site that doesn&#8217;t have a POST or GET. You can set the cache to only cache pages for anonymous (using CACHE_MIDDLEWARE_ANONYMOUS_ONLY). The second piece of the puzzle is that the login view for Django sets a test cookie when a visitor first comes to the page, if this is not there, the login will fail.</p>
<p>What happens is:</p>
<ol>
<li>Make a request to the login page without any GET or POST parameters.</li>
<li>Web server returns the cached page. (Note: this doesn&#8217;t set the cookie because no Python code has been run, the page returned is static)</li>
<li>The user enters in the login information and submits the information. This is sent to the server as a POST.</li>
<li>The server, because of the POST, now runs the login view. This fails because there was no cookie previously set, but it does set the cookie that should have been previously set.</li>
<li>The error message shown to the user is as if it was a failed attempt. If the user reenters the information, the login will now work as the cookie is now set.</li>
</ol>
<p>Hopefully that makes some sense.</p>
<p>What is the solution? Unfortunately, the <a href="http://www.djangoproject.com/documentation/cache/#the-per-site-cache">caching middleware</a> doesn&#8217;t allow you to fine-grain what it caches, it&#8217;s an all or nothing. There are two solutions:</p>
<ol>
<li>Always pass a GET param to the login page. By passing a GET param, the <a href="http://www.djangoproject.com/documentation/cache/#the-per-site-cache">caching middleware</a> will not return the cached page.</li>
<li>Turn off the  <a href="http://www.djangoproject.com/documentation/cache/#the-per-site-cache">caching middleware</a> and instead use the more fine-grained <a href="http://www.djangoproject.com/documentation/cache/#the-per-view-cache">per-view cache</a>.</li>
</ol>
<p>I&#8217;m trying the GET parameter. We&#8217;ll see how it works.</p>]]></content:encoded>
			<wfw:commentRss>http://www.indirecthit.com/2008/06/02/django-caching-middleware-login-page/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>JSR 311 &#8211; Java REST Libraries</title>
		<link>http://www.indirecthit.com/2008/05/29/jsr-311-java-rest-libraries/</link>
		<comments>http://www.indirecthit.com/2008/05/29/jsr-311-java-rest-libraries/#comments</comments>
		<pubDate>Fri, 30 May 2008 01:47:26 +0000</pubDate>
		<dc:creator>clong</dc:creator>
				<category><![CDATA[Web Development]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[rest]]></category>

		<guid isPermaLink="false">http://www.indirecthit.com/?p=35</guid>
		<description><![CDATA[I&#8217;m starting to work on a project at Well.ca using Java and REST. Knowing the amount of REST libraries out there for other languages, I figured there would be a good amount for Java. Wrong!
There is a Java specification currently in draft for REST, it&#8217;s called JSR 311. Now the problem with this is that [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m starting to work on a project at <a href="http://www.well.ca" class="ubernym uttJustLink" onmouseover="domTT_activate(this, event, 'content', 'An online health store, the place I work.','caption', 'Well.ca' );">Well.ca</a> using Java and REST. Knowing the amount of REST libraries out there for other languages, I figured there would be a good amount for Java. Wrong!</p>
<p>There is a Java specification currently in draft for REST, it&#8217;s called <a href="https://jsr311.dev.java.net/">JSR 311</a>. Now the problem with this is that it is still a draft.</p>
<p>There are currently a few implementations of <a href="https://jsr311.dev.java.net/">JSR 311</a>:</p>
<ul>
<li><a href="https://jersey.dev.java.net/">Jersey</a> &#8211; Part of <a href="https://glassfish.dev.java.net/">Glassfish</a> (SUN&#8217;s open source JEE server)</li>
<li><a href="http://cxf.apache.org/">Apache CXF</a> &#8211; This was previously XFire, an implementation of SOAP for Java. It has also started to implement <a href="https://jsr311.dev.java.net/">JSR 311</a>. I think this implementation isn&#8217;t as fully featured as the other implementations.</li>
<li><a href="http://wiki.jboss.org/wiki/RESTeasy">RESTeasy</a> &#8211; JBoss&#8217;s implementation of <a href="https://jsr311.dev.java.net/">JSR 311</a>.</li>
</ul>
<p>There are a few other options for REST and Java. One option that has been around for a while is called <a href="http://www.restlet.org/">Restlet</a>. The creator of <a href="http://www.restlet.org/">Restlet</a> is involved in the writing of <a href="https://jsr311.dev.java.net/">JSR 311</a> but I don&#8217;t believe his project implements <a href="https://jsr311.dev.java.net/">JSR 311</a>. <em>Update[11-Jun-08]: As commented below by <cite><a rel="external nofollow" href="http://blog.noelios.com/">Jerome Louvel</a> and </cite><cite><a rel="external nofollow" href="http://stephankoo.wordpress.com/">Stephan Koops</a> there is an extension to Restlet to implement </cite><a href="https://jsr311.dev.java.net/">JSR 311</a>, more information can be found on the <a href="http://wiki.restlet.org/docs_1.1/g1/13-restlet/28-restlet/57-restlet.html">Restlet Wiki</a>.</em></p>
<p>Currently, I&#8217;m using <a href="http://cxf.apache.org/">Apache CXF</a> for my project. But I&#8217;m hoping to move to <a href="https://jersey.dev.java.net/">Jersey</a> or <a href="http://wiki.jboss.org/wiki/RESTeasy">RESTeasy</a> because they have a more complete implementation.</p>
<p>The problem with <a href="https://jersey.dev.java.net/">Jersey</a> is that it doesn&#8217;t play nice with <a href="http://hibernate.org/">Hibernate</a> and <a href="http://maven.apache.org/">Maven</a>. This is caused by <a href="http://hibernate.org/">Hibernate</a> requiring cglib which requires ASM 1.5.3, while <a href="https://jersey.dev.java.net/">Jersey</a> requires ASM 3. There are a few solutions described on the web, but they haven&#8217;t solved the problem for me. I&#8217;m hoping to work on this at some point, once I find a solution (if I do) then I&#8217;ll post it.</p>]]></content:encoded>
			<wfw:commentRss>http://www.indirecthit.com/2008/05/29/jsr-311-java-rest-libraries/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Two New Tools for Web Dev</title>
		<link>http://www.indirecthit.com/2008/05/29/two-new-tools-for-web-dev/</link>
		<comments>http://www.indirecthit.com/2008/05/29/two-new-tools-for-web-dev/#comments</comments>
		<pubDate>Thu, 29 May 2008 16:17:55 +0000</pubDate>
		<dc:creator>clong</dc:creator>
				<category><![CDATA[JavaScript/Ajax]]></category>
		<category><![CDATA[Jquery]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[ajax]]></category>
		<category><![CDATA[google]]></category>
		<category><![CDATA[internet explorer]]></category>
		<category><![CDATA[microsoft]]></category>

		<guid isPermaLink="false">http://www.indirecthit.com/?p=32</guid>
		<description><![CDATA[
IETester was just released, this tool looks to be incredibly handy. Right now it&#8217;s in Alpha, but I&#8217;m still planning on using it. Previously I used Multiple IE, but I found that to be a little buggy and prone to not work at all at times. I&#8217;m planning on giving it a try sometime today, [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.indirecthit.com/wp-content/uploads/2008/05/ietester-02.png"><img class="alignleft size-full wp-image-33" title="ietester-02" src="http://www.indirecthit.com/wp-content/uploads/2008/05/ietester-02.png" alt="" width="250" height="145" /></a></p>
<p><a href="http://www.my-debugbar.com/wiki/IETester/HomePage">IETester</a> was just released, this tool looks to be incredibly handy. Right now it&#8217;s in Alpha, but I&#8217;m still planning on using it. Previously I used <a href="http://tredosoft.com/Multiple_IE">Multiple IE</a>, but I found that to be a little buggy and prone to not work at all at times. I&#8217;m planning on giving it a try sometime today, maybe it will solve at least some problems on testing with IE.</p>
<p>A little late, but <a href="http://google.com">Google</a> released an <a href="http://code.google.com/apis/ajaxlibs/">API for loading common JS libraries</a> (such as <a href="http://jquery.com/">JQuery</a>, <a href="http://www.prototypejs.org/">Prototype</a>, <a href="http://mootools.net/">Mootools</a>, etc.) from their network of CDNs. This will also increase the chances of someone having the common library cached, instead of having to download an individual copy of JQuery for each site they visit. It&#8217;s not a new idea, <a href="http://aol.com"><span class="ubernym uttInitialism" onmouseover="domTT_activate(this, event, 'content', 'Still the largest internet service provider in the world (&lt;a href=&quot;http://www.aol.com&quot;&gt;link&lt;/a&gt;)','caption', 'America Online' );"><abbr class="uttInitialism">AOL</abbr></span></a> has hosted the <a href="http://dojotoolkit.org/">Dojo JS library</a> on it&#8217;s CDN for the past few years (<a href="http://dev.aol.com/dojo">more details</a>). Still, I&#8217;m glad to see it expand into other libraries. I will probably move <a href="http://startupindex.ca">StartupIndex.ca</a> to load the <a href="http://jquery.com/">JQuery library</a> from <a href="http://google.com">Google</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://www.indirecthit.com/2008/05/29/two-new-tools-for-web-dev/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Django: Difference Between Two Model Instances</title>
		<link>http://www.indirecthit.com/2008/04/29/django-difference-between-two-model-instances/</link>
		<comments>http://www.indirecthit.com/2008/04/29/django-difference-between-two-model-instances/#comments</comments>
		<pubDate>Tue, 29 Apr 2008 18:48:19 +0000</pubDate>
		<dc:creator>clong</dc:creator>
				<category><![CDATA[Django]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://www.indirecthit.com/?p=30</guid>
		<description><![CDATA[Just a quick snippet, I call this code on a site I&#8217;m working on to handle some basic moderation. It finds the difference between the two instances, and returns a dictionary of the changes. The key in the dictionary is the field name, each value in the dictionary is a tuple containing the new and [...]]]></description>
			<content:encoded><![CDATA[<p>Just a quick snippet, I call this code on a site I&#8217;m working on to handle some basic moderation. It finds the difference between the two instances, and returns a dictionary of the changes. The key in the dictionary is the field name, each value in the dictionary is a tuple containing the new and old value of the field.</p>
<p>You can pass it the excludes field to exclude certain fields from being compared. It does not compare AutoField or RelatedField&#8217;s.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
</pre></td><td class="code"><pre class="python" style="font-family:monospace;"><span style="color: #ff7700;font-weight:bold;">from</span> django.<span style="color: black;">db</span>.<span style="color: black;">models</span> <span style="color: #ff7700;font-weight:bold;">import</span> fields
<span style="color: #ff7700;font-weight:bold;">def</span> get_changes_between_models<span style="color: black;">&#40;</span>model1, model2, excludes = <span style="color: black;">&#91;</span><span style="color: black;">&#93;</span><span style="color: black;">&#41;</span>:
    changes = <span style="color: black;">&#123;</span><span style="color: black;">&#125;</span>
    <span style="color: #ff7700;font-weight:bold;">for</span> field <span style="color: #ff7700;font-weight:bold;">in</span> model1._meta.<span style="color: black;">fields</span>:
        <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: #ff7700;font-weight:bold;">not</span> <span style="color: black;">&#40;</span><span style="color: #008000;">isinstance</span><span style="color: black;">&#40;</span>field, <span style="color: black;">&#40;</span>fields.<span style="color: black;">AutoField</span>, fields.<span style="color: black;">related</span>.<span style="color: black;">RelatedField</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span> 
                <span style="color: #ff7700;font-weight:bold;">or</span> field.<span style="color: black;">name</span> <span style="color: #ff7700;font-weight:bold;">in</span> excludes<span style="color: black;">&#41;</span>:
            <span style="color: #ff7700;font-weight:bold;">if</span> field.<span style="color: black;">value_from_object</span><span style="color: black;">&#40;</span>model1<span style="color: black;">&#41;</span> <span style="color: #66cc66;">!</span>= field.<span style="color: black;">value_from_object</span><span style="color: black;">&#40;</span>model2<span style="color: black;">&#41;</span>:
                changes<span style="color: black;">&#91;</span>field.<span style="color: black;">verbose_name</span><span style="color: black;">&#93;</span> = <span style="color: black;">&#40;</span>field.<span style="color: black;">value_from_object</span><span style="color: black;">&#40;</span>model1<span style="color: black;">&#41;</span>,
                                                   field.<span style="color: black;">value_from_object</span><span style="color: black;">&#40;</span>model2<span style="color: black;">&#41;</span><span style="color: black;">&#41;</span>
    <span style="color: #ff7700;font-weight:bold;">return</span> changes</pre></td></tr></table></div>

<p><em>Based off of code from <a href="http://code.google.com/p/django-modelhistory/">Django Modelhistory</a>.</em></p>]]></content:encoded>
			<wfw:commentRss>http://www.indirecthit.com/2008/04/29/django-difference-between-two-model-instances/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Django: Caching Querysets</title>
		<link>http://www.indirecthit.com/2008/04/28/django-caching-querysets/</link>
		<comments>http://www.indirecthit.com/2008/04/28/django-caching-querysets/#comments</comments>
		<pubDate>Mon, 28 Apr 2008 16:40:21 +0000</pubDate>
		<dc:creator>clong</dc:creator>
				<category><![CDATA[Django]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[cache]]></category>
		<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://www.indirecthit.com/?p=28</guid>
		<description><![CDATA[I have just recently started working with Django again, its been a while since I last used it. One thing I was trying to do was cache querysets, which doesn&#8217;t work. Before the recent merge of the queryset refactor branch into trunk, caching querysets appeared to work, in reality it didn&#8217;t. Now with the merge [...]]]></description>
			<content:encoded><![CDATA[<p>I have just recently started working with Django again, its been a while since I last used it. One thing I was trying to do was cache querysets, which doesn&#8217;t work. Before the recent merge of the queryset refactor branch into trunk, caching querysets appeared to work, in reality it didn&#8217;t. Now with the merge of queryset refactor branch, it fails with a Python error. <a href="http://www.pointy-stick.com/blog/">Malcom</a> (the author of the queryset refactor branch) wrote up the reason for this on the django mailing list in <a href="http://groups.google.com/group/django-users/browse_thread/thread/32143d024b17dd00/cc0428d9c520fa1d?lnk=gst&amp;q=cache+queryset#cc0428d9c520fa1d">this thread</a>.</p>
<p>The solution? Force the queryset to a list. For example:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
</pre></td><td class="code"><pre class="python" style="font-family:monospace;">queryset = Widget.<span style="color: black;">objects</span>.<span style="color: #008000;">all</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
wlist = <span style="color: #008000;">list</span><span style="color: black;">&#40;</span>queryset<span style="color: black;">&#41;</span>
cache.<span style="color: #008000;">set</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;allwidgets&quot;</span>, wlist, <span style="color: #ff4500;">3600</span><span style="color: black;">&#41;</span></pre></td></tr></table></div>

<p>This does mean that you can&#8217;t use the cached list as a queryset, so you&#8217;ll have to cache it after all the filtering, ordering, etc. has been done.</p>]]></content:encoded>
			<wfw:commentRss>http://www.indirecthit.com/2008/04/28/django-caching-querysets/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Comparing Code Syntax Highlighters for Wordpress</title>
		<link>http://www.indirecthit.com/2008/03/17/comparing-code-syntax-highlighters-for-wordpress/</link>
		<comments>http://www.indirecthit.com/2008/03/17/comparing-code-syntax-highlighters-for-wordpress/#comments</comments>
		<pubDate>Mon, 17 Mar 2008 18:24:02 +0000</pubDate>
		<dc:creator>clong</dc:creator>
				<category><![CDATA[Web Development]]></category>
		<category><![CDATA[blogs]]></category>
		<category><![CDATA[plugins]]></category>
		<category><![CDATA[syntax highlighting]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://www.indirecthit.com/2008/03/17/comparing-code-syntax-highlighters-for-wordpress/</guid>
		<description><![CDATA[One of the main uses of this blog is for me to post some of the neat things I&#8217;m working on at Well.ca or on my own time. To do this, I need to have a decent syntax highlighter to make all the code I post nice and pretty. I searched the web and came [...]]]></description>
			<content:encoded><![CDATA[<p>One of the main uses of this blog is for me to post some of the neat things I&#8217;m working on at <a href="http://www.well.ca" class="ubernym uttJustLink" onmouseover="domTT_activate(this, event, 'content', 'An online health store, the place I work.','caption', 'Well.ca' );">Well.ca</a> or on my own time. To do this, I need to have a decent syntax highlighter to make all the code I post nice and pretty. I searched the web and came down to 4 syntax highlights that work with Wordpress, this article is a basic attempt at comparing them.</p>
<p>The major differences between these are how they handle the syntax highlighting and the look. To help compare these I&#8217;ve taken screenshots of all the plugins highlighting a piece of code and written up a quick blurb about them.<br />
<span id="more-16"></span></p>
<h3>iG:Syntax Hiliter</h3>
<p><strong>URL:</strong> <a href="http://blog.igeek.info/still-fresh/category/wp-plugins/igsyntax-hiliter/">http://blog.igeek.info/still-fresh/category/wp-plugins/igsyntax-hiliter/</a></p>
<p><strong>Description:</strong></p>
<p>iG:Syntax Hiliter uses <a href="http://qbnz.com/highlighter/">GeSHi</a>, a common code highlighter, and as such supports a good amount of languages. The code appears to be last updated in February of 2006 and uses version 1.0.7.6 of GeSHi which is about 14 versions behind the current release of <a href="http://qbnz.com/highlighter/">GeSHi</a>.Most of the changes to <a href="http://qbnz.com/highlighter/">GeSHi</a> are adding of more language definitions and not a lot of feature changes. <a href="http://qbnz.com/highlighter/">GeSHi</a> generates the code on the server side.</p>
<p>Code is defined in the Wordpress editor by the language name surrounded by square brackets, e.g.: [php]&#8230;[/php].</p>
<p>Some of the more notable features of iG:Syntax Hiliter are:</p>
<ul>
<li>It can highlight code in comments</li>
<li>Can show plain text version of the code</li>
<li>Has an option for fancy line numbers</li>
</ul>
<p><center><br />
<a href="http://www.indirecthit.com/wp-content/uploads/2008/03/igsyntax.png" title="igsyntax.png"><img src="http://www.indirecthit.com/wp-content/uploads/2008/03/igsyntax.png" alt="igsyntax.png" /></a><br />
</center></p>
<h3>SyntaxHighlighter Plus</h3>
<p><strong>URL:</strong> <a href="http://wordpress.org/extend/plugins/syntaxhighlighter-plus/">http://wordpress.org/extend/plugins/syntaxhighlighter-plus/</a></p>
<p><strong>Description:</strong></p>
<p>This is an enhanced version of another plugin called SyntaxHighlighter. It supports a smaller subset of languages then some other plugins but is capable of handling the major ones (<a href="http://www.php.net" class="ubernym uttInitialism" onmouseover="domTT_activate(this, event, 'content', 'PHP: Hypertext Preprocessor' );"><abbr class="uttInitialism">PHP</abbr></a>, Python, Java, JavaScript, etc). To handle the syntax highlighting it uses <a href="http://code.google.com/p/syntaxhighlighter/">SyntaxHighlighter</a> a JavaScript library to highlight code. The library argues that by making it JavaScript there are no dependencies on the server. I don&#8217;t know if this is a major issue with most Wordpress installs, and does add dependencies on the client side that they must have JavaScript.</p>
<p>You define the code by using one of the following tags:</p>
<ul>
<li>[css]&#8230;[/css]</li>
<li>[code lang="css"]...[/code]</li>
<li>[source lang="css"]&#8230;[/source]</li>
<li>And some other variations&#8230;&gt;</li>
</ul>
<p><center><br />
<a href="http://www.indirecthit.com/wp-content/uploads/2008/03/syntaxhighlighterplus.png" title="syntaxhighlighterplus.png"><img src="http://www.indirecthit.com/wp-content/uploads/2008/03/syntaxhighlighterplus.png" alt="syntaxhighlighterplus.png" /></a><br />
</center></p>
<h3>WP-Syntax</h3>
<p><strong>URL:</strong> <a href="http://wordpress.org/extend/plugins/wp-syntax/">http://wordpress.org/extend/plugins/wp-syntax/</a></p>
<p><strong>Description:</strong></p>
<p>WP-Syntax is another plugin that uses the <a href="http://qbnz.com/highlighter/">GeSHi</a> library to handle syntax highlighting. The <a href="http://qbnz.com/highlighter/">GeSHi</a> is 1.0.7.20 which is the latest version and supports a very large set of languages. The formating used by WP-Syntax can be defined through <span class="ubernym uttInitialism" onmouseover="domTT_activate(this, event, 'content', 'Cascading Style Sheets (&lt;a href=&quot;http://www.w3.org/Style/CSS/&quot;&gt;link&lt;/a&gt;)' );"><abbr class="uttInitialism">CSS</abbr></span> (Cascading Style Sheets) or by defining the <a href="http://qbnz.com/highlighter/">GeSHi</a> initialization settings to match the design of your blog. It supposedly does not conflict with any other plugins by pulling out the code early and then placing it back in after other plugins have finished processing the blog text.</p>
<p>The code to be highlighted is specified by surrounding it with &lt;pre lang=&#8221;php&#8221;&gt;&#8230;&lt;/pre&gt;</p>
<p><center><br />
<a href="http://www.indirecthit.com/wp-content/uploads/2008/03/wp-syntax.png" title="wp-syntax.png"><img src="http://www.indirecthit.com/wp-content/uploads/2008/03/wp-syntax.png" style="margin-left: 140px; margin-right: 140px" alt="wp-syntax.png" align="bottom" /></a><br />
</center></p>
<h3>WP-CODEBOX</h3>
<p><strong>URL:</strong> <a href="http://wordpress.org/extend/plugins/wp-codebox/">http://wordpress.org/extend/plugins/wp-codebox/</a></p>
<p><strong>Description:</strong></p>
<p>WP-CODEBOX is a relatively new plugin that uses <a href="http://qbnz.com/highlighter/">GeSHi</a> to handle the highlighting. It comes with an administration interface that you can edit the defaults.</p>
<p>You specify the code by using: &lt;pre lang=&#8221;php&#8221;&gt;&#8230;&lt;/pre&gt;</p>
<p>Some of the major features are:</p>
<ul>
<li>You can specify a file containing the code that a reader can download.</li>
<li>If no file is specified it will have a &#8220;View in Plain Text&#8221; option.</li>
<li>Can collapse a block of code.</li>
</ul>
<p><center><br />
<a href="http://www.indirecthit.com/wp-content/uploads/2008/03/wp-codebox.png" title="wp-codebox.png"><img src="http://www.indirecthit.com/wp-content/uploads/2008/03/wp-codebox.png" alt="wp-codebox.png" align="bottom" /></a><br />
</center></p>
<h3>Conclusion</h3>
<p>As of the writing of this, I&#8217;m going to try out WP-Syntax. I&#8217;m a big fan of the simplicity and believe it will fit in with the overall design of my blog. I played around with all 4 plugins a little bit, but I need to try some real world examples before I come to a final decision. I&#8217;ll update this post or write a new one with what I think after trying out WP-Syntax for a few posts.</p>]]></content:encoded>
			<wfw:commentRss>http://www.indirecthit.com/2008/03/17/comparing-code-syntax-highlighters-for-wordpress/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Google Did you Mean on Search Pages Using PHP 4</title>
		<link>http://www.indirecthit.com/2007/08/24/google-did-you-mean-on-search-pages-using-php-4/</link>
		<comments>http://www.indirecthit.com/2007/08/24/google-did-you-mean-on-search-pages-using-php-4/#comments</comments>
		<pubDate>Fri, 24 Aug 2007 15:48:03 +0000</pubDate>
		<dc:creator>clong</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[aspell]]></category>
		<category><![CDATA[did you mean]]></category>
		<category><![CDATA[google]]></category>
		<category><![CDATA[search]]></category>
		<category><![CDATA[spellcheck]]></category>

		<guid isPermaLink="false">http://www.indirecthit.com/2007/08/24/google-did-you-mean-on-search-pages-using-php-4/</guid>
		<description><![CDATA[What&#8217;s the best way to handle did you mean? It&#8217;s one of the greatest features of Google, I never worry about misspelling search terms because I know Google will always show the error of my ways.
On Well.ca we had previously implemented this feature using Levenshtein, this measures the number of permutations to get from one [...]]]></description>
			<content:encoded><![CDATA[<p>What&#8217;s the best way to handle did you mean? It&#8217;s one of the greatest features of Google, I never worry about misspelling search terms because I know Google will always show the error of my ways.</p>
<p>On <a href="http://www.well.ca" class="ubernym uttJustLink" onmouseover="domTT_activate(this, event, 'content', 'An online health store, the place I work.','caption', 'Well.ca' );">Well.ca</a> we had previously implemented this feature using <a href="http://ca.php.net/levenshtein">Levenshtein</a>, this measures the number of permutations to get from one string to another. The problem with this is that we had the search term &#8220;Obus&#8221; being corrected to &#8220;Burt&#8217;s&#8221;, not exactly the most accurate system. As a result, I&#8217;ve been working with using Pspell/Aspell to handle the &#8220;Did you mean&#8221;. Aspell is a very popular spell checking software, you can find it used in almost any OS application requiring spell checking. <a href="http://www.php.net" class="ubernym uttInitialism" onmouseover="domTT_activate(this, event, 'content', 'PHP: Hypertext Preprocessor' );"><abbr class="uttInitialism">PHP</abbr></a> interfaces with Aspell through Pspell.</p>
<p>One of the requirements we have, is that we want Pspell/Aspell to use a custom dictionary. Being an Ecommerce site, we want the dictionary to consist of brands, product names, categories, and product subtitles. A limitation of Pspell is that it does not allow you to use just a personal dictionary, therefore, I went through the process of creating a custom language dictionary for Pspell/Aspell to use. I have described all the steps below, from the initial install to the actual checking.</p>
<p><span id="more-8"></span></p>
<p><strong>Installing:</strong></p>
<p><em>Note: These are the following steps I used to install Aspell/Pspell on my Macbook Pro running the latest version of OS X. They should work fine for Linux/Unix systems, for Windows there are other resources on the web for installing these tools.</em></p>
<ol>
<li><em>Install Aspell &#8211; </em>Install Aspell using your package manager (I use MacPorts) or from the Aspell website.</li>
<li><em>Compile <a href="http://www.php.net" class="ubernym uttInitialism" onmouseover="domTT_activate(this, event, 'content', 'PHP: Hypertext Preprocessor' );"><abbr class="uttInitialism">PHP</abbr></a> w/ PSpell support </em>
<ol>
<li>First check to see if your <a href="http://www.php.net" class="ubernym uttInitialism" onmouseover="domTT_activate(this, event, 'content', 'PHP: Hypertext Preprocessor' );"><abbr class="uttInitialism">PHP</abbr></a> install already is built w/ Pspell (look at the output of php_info() for the configure flag &#8211;with-pspell)</li>
<li>(If you are using MacPorts look at the bullet below) If not, compile <a href="http://www.php.net" class="ubernym uttInitialism" onmouseover="domTT_activate(this, event, 'content', 'PHP: Hypertext Preprocessor' );"><abbr class="uttInitialism">PHP</abbr></a> with all the options you want including &#8220;&#8211;with-pspell={prefix}&#8221;. Where prefix is the location of your lib and include containing Pspell.
<ul>
<li>If you are using MacPorts, you can add the flag to the Portfile. On my computer, the Portfile was located at &#8220;<em>/opt/local/var/macports/sources/ rsync.macports.org/release/ports /www/php4/Portfile&#8221;. </em>Open that file and add &#8220;&#8211;with-pspell=${prefix}&#8221; to configure.args. You can then uninstall PHP4 and reinstall it, it should now use the modified Portfile to compile <a href="http://www.php.net" class="ubernym uttInitialism" onmouseover="domTT_activate(this, event, 'content', 'PHP: Hypertext Preprocessor' );"><abbr class="uttInitialism">PHP</abbr></a>.</li>
</ul>
</li>
<li>Restart Apache, and check your php_info() for the proper flags.</li>
</ol>
</li>
<li>You should now be capable of using pspell in <a href="http://www.php.net" class="ubernym uttInitialism" onmouseover="domTT_activate(this, event, 'content', 'PHP: Hypertext Preprocessor' );"><abbr class="uttInitialism">PHP</abbr></a>.</li>
</ol>
<p><!--more--><br />
<strong>Creating a Custom Language Dictionary</strong></p>
<p><em>Note: If you don&#8217;t need a custom language dictionary, you can skip straight to the creating &#8220;Did you mean&#8221; section.</em></p>
<ol>
<li> Download the aspell-lang package:<br />
[code]cvs -z3 -d:pserver:anonymous@cvs.savannah.gnu.org:/sources/aspell co aspell-lang[/code]<br />
The remainder of the steps are now based off of the <a href="http://cvs.savannah.gnu.org/viewvc/aspell-lang/README?revision=1.2&amp;root=aspell&amp;view=markup">README</a> file</li>
<li>Head into the aspell-lang directory. Aspell-lang comes with a command for creating the files used to create a new custom dictionary. The command to create these files is:<br />
[code]./pre {lang_name} {char_set}[/code]</p>
<ul>
<li><em>lang_name</em> must follow the ISO language standards. At the simplest, two alphabetical characters.</li>
<li><em>char_set</em> aspell can use a variety of character sets. See the README for a list of them. For English, I used iso-8859-1</li>
<li>The command I used was: ./pre we iso-8859-1</li>
</ul>
</li>
<li>You should now have a directory called the language name selected. CD into that directory.</li>
<li>At this point, you can edit the info file or leave it at the default. It is fairly self explanatory.</li>
<li>You can now create the wordlist in the file {lang_name}.wl. The format is one word per line.</li>
<li>By default, aspell does not allow any non-alphabetical characters in words. To allow other characters you need to modify {lang_name}.dat
<ul>
<li>The line you need to modify starts with <em>special</em>, you might need to uncomment it.</li>
<li>The format of the special line is: <em>special {char} {start}{middle}{end}</em>. <em>char</em> is the character to be included. <em>start, middle, end</em> tells Aspell where the character is allowed. &#8216;*&#8217; means the character is allowed, &#8216;-&#8217; means the character is not.</li>
<li>An example special attribute is <em>&#8216; -*-</em>, the character is <em>&#8216;</em>, and it is not allowed as the first or last character of the word but is allowed in the middle of the word.</li>
</ul>
</li>
<li>When the wordlist is finalized, you need to run the following commands:

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">.<span style="color: #000000; font-weight: bold;">/</span>proc
.<span style="color: #000000; font-weight: bold;">/</span>configure
<span style="color: #c20cb9; font-weight: bold;">make</span>
<span style="color: #c20cb9; font-weight: bold;">make</span> <span style="color: #c20cb9; font-weight: bold;">install</span></pre></div></div>

</li>
<li>Ignoring any problems, you should now have a custom dictionary installed.</li>
</ol>
<p><!--more--><br />
<strong>Creating &#8220;Did you mean&#8221;</strong></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">//Split the search string by spaces</span>
<span style="color: #000088;">$keywords_single</span> <span style="color: #339933;">=</span> <span style="color: #990000;">explode</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">' '</span><span style="color: #339933;">,</span> <span style="color: #000088;">$keywords_string</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;">//Get the number of words they are searching by</span>
<span style="color: #000088;">$sizeof_keywords_single</span> <span style="color: #339933;">=</span> <span style="color: #990000;">sizeof</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$keywords_single</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$pspell_config</span> <span style="color: #339933;">=</span> pspell_config_create<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;we&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$pspell_link</span> <span style="color: #339933;">=</span> pspell_new_config<span style="color: #009900;">&#40;</span><span style="color: #000088;">$pspell_config</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$keywords_single_replacement</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//Create the replacement array</span>
<span style="color: #b1b100;">for</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$i</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> <span style="color: #000088;">$i</span> <span style="color: #339933;">&amp;</span>lt<span style="color: #339933;">;</span> <span style="color: #000088;">$sizeof_keywords_single</span><span style="color: #339933;">;</span> <span style="color: #000088;">$i</span><span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #666666; font-style: italic;">//Loop through the words</span>
	<span style="color: #666666; font-style: italic;">//Check if the word is correctly spelt</span>
	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>pspell_check<span style="color: #009900;">&#40;</span><span style="color: #000088;">$pspell_link</span><span style="color: #339933;">,</span> <span style="color: #000088;">$keywords_single</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$keywords_misspell</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #339933;">;</span>
		<span style="color: #666666; font-style: italic;">//Get the suggestions from Pspell</span>
		<span style="color: #000088;">$suggestions</span> <span style="color: #339933;">=</span> pspell_suggest<span style="color: #009900;">&#40;</span><span style="color: #000088;">$pspell_link</span><span style="color: #339933;">,</span> <span style="color: #000088;">$keywords_single</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #666666; font-style: italic;">//Take the first result (Pspell sorts the result)</span>
		<span style="color: #000088;">$keywords_single_replacement</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$suggestions</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #666666; font-style: italic;">//Set the replacement word back to the original word</span>
		<span style="color: #000088;">$keywords_single_replacement</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$keywords_single</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #666666; font-style: italic;">/*
 * The following code replaces the words with the corrected words above.
 */</span>
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #990000;">isset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$keywords_phrase</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;</span>amp<span style="color: #339933;">;&amp;</span>amp<span style="color: #339933;">;</span> <span style="color: #990000;">isset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$keywords_misspell</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #000088;">$keywords_replacement</span> <span style="color: #339933;">=</span> <span style="color: #990000;">stripslashes</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_GET</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'keyword'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$i</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> <span style="color: #000088;">$i</span> <span style="color: #339933;">&amp;</span>lt<span style="color: #339933;">;</span> <span style="color: #000088;">$sizeof_keywords_single</span><span style="color: #339933;">;</span> <span style="color: #000088;">$i</span><span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$keywords_replacement</span> <span style="color: #339933;">=</span> <span style="color: #990000;">preg_replace</span><span style="color: #009900;">&#40;</span>
					<span style="color: #990000;">sprintf</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'#(?!&amp;lt;.*?)(%s)(?![^&amp;lt;&amp;gt;]*?&amp;gt;)#i'</span><span style="color: #339933;">,</span>
					<span style="color: #990000;">preg_quote</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$keywords_single</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
					<span style="color: #000088;">$keywords_single_replacement</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span>
					<span style="color: #000088;">$keywords_replacement</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #666666; font-style: italic;">//You can now print the Did You Mean $keywords_replacement...</span>
?<span style="color: #339933;">&amp;</span>gt<span style="color: #339933;">;</span></pre></td></tr></table></div>

<p><!--more--></p>
<p><strong>Resources</strong></p>
<ul>
<li>Pspell Manual &#8211; http://www.php.net/manual/en/ref.pspell.php</li>
<li>Aspell Website &#8211; http://aspell.net/</li>
</ul>]]></content:encoded>
			<wfw:commentRss>http://www.indirecthit.com/2007/08/24/google-did-you-mean-on-search-pages-using-php-4/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>IEs 4 Linux</title>
		<link>http://www.indirecthit.com/2007/08/09/ies-4-linux/</link>
		<comments>http://www.indirecthit.com/2007/08/09/ies-4-linux/#comments</comments>
		<pubDate>Thu, 09 Aug 2007 13:34:21 +0000</pubDate>
		<dc:creator>clong</dc:creator>
				<category><![CDATA[Mac]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[internet explorer]]></category>
		<category><![CDATA[linux]]></category>

		<guid isPermaLink="false">http://www.indirecthit.com/2007/08/09/ies-4-linux/</guid>
		<description><![CDATA[At work, me and my boss, Ali, (we&#8217;re the developers) both use Macbook Pros as our development computers. Which is great for most things, I love Macs. The only problem is that we&#8217;re developing an online site, and the reality is that Internet Explorer is still the most dominant browser. Right now, we&#8217;re using Parallels [...]]]></description>
			<content:encoded><![CDATA[<p>At work, me and my boss, <a href="http://aliasaria.ca/blog/" class="ubernym uttJustLink" onmouseover="domTT_activate(this, event, 'content', 'The founder &amp; CEO of Well.ca','caption', 'Ali Asaria' );">Ali</a>, (we&#8217;re the developers) both use Macbook Pros as our development computers. Which is great for most things, I love Macs. The only problem is that we&#8217;re developing an online site, and the reality is that Internet Explorer is still the most dominant browser. Right now, we&#8217;re using Parallels to test our site on IE but it&#8217;s a slow process. Enter&#8230;<a href="http://www.tatanka.com.br/ies4linux/" target="_blank">IEs 4 Linux</a>.</p>
<p>Even with that name it does work with Mac OSX, there is even a <a href="http://www.tatanka.com.br/ies4linux/page/Does_IEs_4_Linux_Work_with_Mac_OSX" target="_blank">FAQ entry</a> for running IEs 4 Linux on OSX. Here is the process I went through to install IEs 4 Linux on my machine:</p>
<p><strong>Requirements:</strong></p>
<ul>
<li>MacPorts &#8211; http://www.macports.org (You can also use Fink)</li>
<li>X11 SDK and X11 User installed (These can be found on your install DVD)</li>
</ul>
<p><strong>Steps:</strong></p>
<p>First, I installed the required packages through MacPorts for Wine:<br />
[cc lang="bash"]sudo port install cabextract wget fontforge  freetype[/cc]<br />
<em>Note: If you have a problem with installing these packages, you might need to run the command &#8220;clean&#8221; with port. This removes all the temporary files created. E.g. &#8220;sudo port clean &#8211;all freetype&#8221;</em></p>
<p>After installing these packages, I then installed Wine:<br />
[cc lang="bash"]sudo port install wine[/cc]</p>
<p>All that&#8217;s left is running the install script for IEs 4 Linux. Then you can run the X11 application installed with X11User and call the command ie, ie55 or ie5 in xterm.</p>
<p>Now that is the way that it was supposed to work, in reality I came across a few problems:</p>
<p><strong>You have an Apple X11 installation already</strong><strong>:</strong></p>
<p>[cc lang="bash"]<br />
You have an Apple X11 installation already.<br />
MacPorts will not overwrite it.</p>
<p>If you really want to use XFree86 instead,<br />
please move it aside first :<br />
[/cc]<br />
This was caused by having X11 SDK installed but not X11 User installed. X11 User is located in  <em>/System/Installation/Packages/X11User.pkg. </em>After installing, make sure to run the &#8220;clean -all&#8221; command.</p>
<p><strong>Wine is not found:</strong></p>
<p>This error message shows up when xterm does not have a properly set up PATH. To correct this,  read this page on <a href="http://trac.macosforge.org/projects/macports/wiki/InstallingMacPorts#OptionsfortheMacPortsshellandX11environment" target="_blank">Options for MacPorts&#8217; shell and X11 Environment.</a></p>
<p>Good luck!</p>]]></content:encoded>
			<wfw:commentRss>http://www.indirecthit.com/2007/08/09/ies-4-linux/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
