<?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>boolean.co.nz &#187; Development</title>
	<atom:link href="http://boolean.co.nz/blog/category/development/feed/" rel="self" type="application/rss+xml" />
	<link>http://boolean.co.nz/blog</link>
	<description>Where there is more to logic than TRUE or FALSE</description>
	<lastBuildDate>Fri, 18 May 2012 09:56:24 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>MySQL datatype for storing IP addresses</title>
		<link>http://boolean.co.nz/blog/mysql-datatype-for-storing-ip-addresses/782/</link>
		<comments>http://boolean.co.nz/blog/mysql-datatype-for-storing-ip-addresses/782/#comments</comments>
		<pubDate>Fri, 18 May 2012 09:56:24 +0000</pubDate>
		<dc:creator>Boolean</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[MySQL]]></category>

		<guid isPermaLink="false">http://boolean.co.nz/blog/?p=782</guid>
		<description><![CDATA[The best way to store a (version 4) IP address in a MySQL database is as an integer. This may sound strange but MySQL has two powerful functions to enable you to store an IP address as an unsigned INT. Searching an integer is much faster than searching a string and additionally integers take up [...]]]></description>
			<content:encoded><![CDATA[<table>
<tr>
<td><img src="http://boolean.co.nz/blog/wp-content/uploads/2009/04/mysql_logo.png" alt="" title="mysql_logo" width="204" height="106" class="aligncenter size-full wp-image-96" /></td>
</tr>
</table>
<p>The best way to store a (version 4) IP address in a MySQL database is as an integer. This may sound strange but MySQL has two powerful <a href="http://dev.mysql.com/doc/refman/5.0/en/miscellaneous-functions.html" title="functions" target="_blank">functions</a> to enable you to store an IP address as an <em>unsigned</em> INT. Searching an integer is much faster than searching a string and additionally integers take up less storage space which is great when working with large datasets.</p>
<div class="codesnip-container" >mysql> SELECT INET_ATON(&#8217;10.0.5.9&#8242;);<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br />
INET_ATON(&#8217;10.0.5.9&#8242;)<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br />
167773449<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br />
1 row in set (0.00 sec)</div>
<p>and the reverse function</p>
<div class="codesnip-container" >mysql> SELECT INET_NTOA(167773449);<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br />
INET_NTOA(167773449)<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br />
10.0.5.9<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br />
1 row in set (0.00 sec)</div>
]]></content:encoded>
			<wfw:commentRss>http://boolean.co.nz/blog/mysql-datatype-for-storing-ip-addresses/782/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Speeding up PHP FOR loops</title>
		<link>http://boolean.co.nz/blog/speeding-up-php-for-loops/762/</link>
		<comments>http://boolean.co.nz/blog/speeding-up-php-for-loops/762/#comments</comments>
		<pubDate>Wed, 11 Apr 2012 06:36:40 +0000</pubDate>
		<dc:creator>Boolean</dc:creator>
				<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://boolean.co.nz/blog/?p=762</guid>
		<description><![CDATA[Refactoring some client code the other day I found a lot of inefficient logic. Whilst this example is written in PHP the concept is applicable in other programming languages. Many people use for loops in the belief that they are faster than a foreach, and while this is often the case it can be slower [...]]]></description>
			<content:encoded><![CDATA[<table>
<tr>
<td><img src="http://boolean.co.nz/blog/wp-content/uploads/2009/03/php-logo.png" alt="" title="php-logo" width="203" height="107" class="aligncenter size-full wp-image-61" /></td>
</tr>
</table>
<p>Refactoring some client code the other day I found a lot of inefficient logic. Whilst this example is written in PHP the concept is applicable in other programming languages.</p>
<p>Many people use for loops in the belief that they are faster than a foreach, and while this is often the case it can be slower and less flexible if you make some simple mistakes. Consider the following:</p>
<p><strong>A slow FOR loop</strong></p>
<div class="codesnip-container" >$text=&#8221;thequickbrownfoxjumpsoverthelazydog&#8221;;<br />
for($i=0; $i &lt; strlen($text); $i++){ // Loop through the characters<br />
echo ( substr($text,$i,1) == &#8216;o&#8217; ) ? &#8220;Its an o&#8221; : &#8220;Not an o&#8221;; // Display true or false as relevant<br />
}</div>
<p><strong>A faster FOR loop</strong></p>
<div class="codesnip-container" >$text=&#8221;thequickbrownfoxjumpsoverthelazydog&#8221;;<br />
$length = strlen($text); // obtain length of the string<br />
for($i=0; $i &lt; $length ; $i++){ // Loop through the characters<br />
    echo ( substr($text,$i,1) == &#8216;o&#8217; ) ? &#8220;Its an o&#8221; : &#8220;Not an o&#8221;; // Display true or false as relevant<br />
}</div>
<p>The second loop is faster because it does not evaluate the string length each time the loop runs <em>strlen($text)</em> as in the first example. Small differences like this can have a large effect on the speed of scripts especially if there are many loops or iterations.</p>
]]></content:encoded>
			<wfw:commentRss>http://boolean.co.nz/blog/speeding-up-php-for-loops/762/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>LinkedIn dynamic button rendering</title>
		<link>http://boolean.co.nz/blog/linkedin-dynamic-button-rendering/752/</link>
		<comments>http://boolean.co.nz/blog/linkedin-dynamic-button-rendering/752/#comments</comments>
		<pubDate>Sun, 11 Mar 2012 01:03:45 +0000</pubDate>
		<dc:creator>Boolean</dc:creator>
				<category><![CDATA[JavaScript]]></category>

		<guid isPermaLink="false">http://boolean.co.nz/blog/?p=752</guid>
		<description><![CDATA[It has become standard to offer sharing functionality via major platforms such as Facebook, Twitter and LinkedIn on websites. Most of the platform providers have multiple options for inserting their sharing features often including the use of an iFrame. LinkedIn is slightly different however choosing only to offer a javascript based solution similar to the [...]]]></description>
			<content:encoded><![CDATA[<p>It has become standard to offer sharing functionality via major platforms such as Facebook, Twitter and LinkedIn on websites. Most of the platform providers have multiple options for inserting their sharing features often including the use of an iFrame.<br />
<a href="http://www.linkedin.com/" title="LinkedIn" target="_blank">LinkedIn</a> is slightly different however choosing only to offer a javascript based solution similar to the following:</p>
<div class="codesnip-container" >&lt;script src=&#8221;//platform.linkedin.com/in.js&#8221; type=&#8221;text/javascript&#8221;&gt;&lt;/script&gt;</div>
<p>Above the inclusion of the required javascript function, and below the addition of sharing functionality where required.</p>
<div class="codesnip-container" >&lt;script type=&#8221;IN/Share&#8221;&gt;&lt;/script&gt;</div>
<p>When asynchronous pagination gets involved however this lack of an iFrame causes an issue: the javascript is not called as the asynchronous load takes place. This issue stumped for for a while until I found the simple solution to call:</p>
<div class="codesnip-container" >IN.init();</div>
<p>Eugene O&#8217;Neill (Web Developer for LinkedIn) has stated:</p>
<blockquote><p>1) IN.Parse() and IN.Init() are here to stay. While we do employ the policy that any undocumented methods may or may not be supported indefinitely, these two are uniquely crucial to the functionality of the framework. The amount of work it would require to remove IN.Parse()&#8230; I don&#8217;t even want to think about it. IN.Init() is our preferred method for loading the framework asynchronously and won&#8217;t be going anywhere. Feel free to use either method.</p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://boolean.co.nz/blog/linkedin-dynamic-button-rendering/752/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MySQL zerofill for numerical types</title>
		<link>http://boolean.co.nz/blog/mysql-zerofill-numerical-types/742/</link>
		<comments>http://boolean.co.nz/blog/mysql-zerofill-numerical-types/742/#comments</comments>
		<pubDate>Tue, 06 Mar 2012 19:36:39 +0000</pubDate>
		<dc:creator>Boolean</dc:creator>
				<category><![CDATA[MySQL]]></category>

		<guid isPermaLink="false">http://boolean.co.nz/blog/?p=742</guid>
		<description><![CDATA[MySQL has a feature for numerical types known as zerofill which effects the display size of numerical types. Unlike string types, the number inside the parentheses is not the storage size in characters for the type. For numerical types the type name itself solely determines storage size. Column Type Bytes On Disk Signed Storage Range [...]]]></description>
			<content:encoded><![CDATA[<table>
<tr>
<td><img src="http://boolean.co.nz/blog/wp-content/uploads/2009/04/mysql_logo.png" alt="" title="mysql_logo" width="204" height="106" class="aligncenter size-full wp-image-96" />
<td></tr>
</table>
<p>MySQL has a feature for <a href="http://dev.mysql.com/doc/refman/5.0/en/numeric-type-overview.html" title="numerical" target="_blank">numerical</a> types known as zerofill which effects the display size of numerical types. Unlike <a href="http://boolean.co.nz/blog/max-length-for-mysql-text-field-types/135/" title="string types" target="_blank">string types</a>, the number inside the parentheses is <em>not</em> the storage size in characters for the type. For numerical types the type name itself solely determines storage size.</p>
<table>
<tr>
<td><strong>Column Type</strong></td>
<td><strong>Bytes On Disk</strong></td>
<td><strong>Signed Storage Range</strong></td>
<td><strong>Unsigned Storage Range</strong></td>
</tr>
<tr>
<td>tinyint</td>
<td>1 byte</td>
<td>-128 to 127</td>
<td>0 to 255</td>
</tr>
<tr>
<td>smallint</td>
<td>2 bytes</td>
<td>-32768 to 32767</td>
<td>0 to 65535</td>
</tr>
<tr>
<td>mediumint</td>
<td>3 bytes</td>
<td>-8388608 to 8388607</td>
<td>0 to 16777215</td>
</tr>
<tr>
<td>int</td>
<td>4 bytes</td>
<td>-2147483648 to 2147483647</td>
<td>0 to 4294967295</td>
</tr>
<tr>
<td>bigint</td>
<td>8 bytes</td>
<td>-9223372036854775808 to 9223372036854775807</td>
<td>0 to 18446744073709551615</td>
</tr>
</table>
<p>So zerofill with default width &#8211; the same as int(10):</p>
<div class="codesnip-container" >mysql> create table test_table (t int zerofill);<br />
Query OK, 0 rows affected (0.02 sec)</p>
<p>mysql> insert into test_table set t = 10;<br />
Query OK, 1 row affected (0.02 sec)</p>
<p>mysql> select * from test_table;<br />
+————+<br />
| t |<br />
+————+<br />
| 0000000010 |<br />
+————+<br />
1 row in set (0.08 sec)</p></div>
<p>And without zerofill:</p>
<div class="codesnip-container" >mysql> create table test_table (t int);<br />
Query OK, 0 rows affected (0.01 sec)</p>
<p>mysql> insert into test_table set t = 10;<br />
Query OK, 1 row affected (0.01 sec)</p>
<p>mysql> select * from test_table;<br />
+——+<br />
| t |<br />
+——+<br />
| 10 |<br />
+——+<br />
1 row in set (0.01 sec)</p></div>
<p>A common usage for is creating invoice ids such as INV00000945.</p>
<p><strong>Notes:</strong><br />
If you do not have zerofill specified there is no difference between int(3) and int(10)<br />
When doing comparisons: if compared as integers then the values are the same; if you compare as strings the values are different.</p>
]]></content:encoded>
			<wfw:commentRss>http://boolean.co.nz/blog/mysql-zerofill-numerical-types/742/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using Google to host jQuery</title>
		<link>http://boolean.co.nz/blog/using-google-host-jquery/733/</link>
		<comments>http://boolean.co.nz/blog/using-google-host-jquery/733/#comments</comments>
		<pubDate>Sat, 11 Feb 2012 06:34:10 +0000</pubDate>
		<dc:creator>Boolean</dc:creator>
				<category><![CDATA[Hardware]]></category>
		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://boolean.co.nz/blog/?p=733</guid>
		<description><![CDATA[Using Google to host your jQuery (or other applicable content) has several advantages over hosting a version on your own server including better caching, decreased latency, and increased parallelism. There are plenty of other articles to discuss the merits of decreased latency benefits of a CDN or the effects of parallelism on browsers so it [...]]]></description>
			<content:encoded><![CDATA[<table>
<tr>
<td><img src="http://boolean.co.nz/blog/wp-content/uploads/2012/02/jquery_logo.png" alt="" title="jquery_logo" width="366" height="134" class="aligncenter size-full wp-image-734" /></td>
</tr>
</table>
<p>Using Google to host your jQuery (or other applicable content) has several advantages over hosting a version on your own server including better caching, decreased latency, and increased parallelism. There are plenty of other articles to discuss the merits of decreased latency benefits of a CDN or the effects of parallelism on browsers so it wont be covered here.</p>
<p><strong>Caching</strong><br />
Perhaps the most compelling reason to use Google to host your jQuery is that your users actually may not need to download it at all. If you’re hosting jQuery locally then your users must download a copy at least once. Your users probably already have multiple identical copies of jQuery in their browsers cache from other sites, but those copies are ignored when they visit your site.<br />
When a browser sees references to a CDN-hosted copy of jQuery it understands they all refer to exactly same file. The browser trusts that those files are identical and wont re-request the file if it&#8217;s already cached.</p>
<p><strong>Execution</strong><br />
So, now that we know that Google is a good place to serve up our jQuery from how are we going to do it? I believe the best way is also the simplest:</p>
<div class="codesnip-container" >&lt;script src=&#8221;//ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js&#8221;&gt;&lt;/script><br />
&lt;script&gt;window.jQuery || document.write(&#8216;&lt;script src=&#8221;js/libs/jquery-1.7.1.min.js&#8221;&gt;&lt;\/script&gt;&#8217;)&lt;/script&gt;</div>
<p>This will point to Google to host the jQuery library, but fall back to local hosting in the event of connectivity issues.</p>
]]></content:encoded>
			<wfw:commentRss>http://boolean.co.nz/blog/using-google-host-jquery/733/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>08/02/2012 Emergency PHP Updates on server</title>
		<link>http://boolean.co.nz/blog/emergency-php-updates/725/</link>
		<comments>http://boolean.co.nz/blog/emergency-php-updates/725/#comments</comments>
		<pubDate>Tue, 07 Feb 2012 21:42:11 +0000</pubDate>
		<dc:creator>Boolean</dc:creator>
				<category><![CDATA[Hosting]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://boolean.co.nz/blog/?p=725</guid>
		<description><![CDATA[EMERGENCY PHP UPDATES We will be applying a PHP update to the servers later this evening. This will take the primary PHP install from v5.3.9 to v5.3.10 and will resolve a vulnerability that has been patched in the 5.3.10 release. The vulnerability present in 5.3.9 allows for the possibility of remote code execution depending on [...]]]></description>
			<content:encoded><![CDATA[<table>
<tr>
<td><img src="http://boolean.co.nz/blog/wp-content/uploads/2009/03/php-logo.png" alt="" title="php-logo" width="203" height="107" class="aligncenter size-full wp-image-61" /></td>
</tr>
</table>
<p><strong>EMERGENCY PHP UPDATES</strong></p>
<p>We will be applying a PHP update to the servers later this evening.</p>
<p>This will take the primary PHP install from v5.3.9 to v5.3.10 and will resolve a vulnerability that has been patched in the 5.3.10 release.</p>
<p>The vulnerability present in 5.3.9 allows for the possibility of remote code execution depending on how large numbers and arrays are used.</p>
<p>As this is a security issue we will be performing emergency maintenance between <strong>midnight and 3am (GMT).</strong></p>
<p>There should be no interruption to service however, as the work is being done on components critical to PHP based sites, this period should be considered at risk.</p>
<p>The work will cause slightly higher than normal load on the servers and may involve a restart of the web server.</p>
<p>In the worst cast scenario (such as a failed compile) the installer will restore a backup of the current working configuration.</p>
<p>No module or configuration changes will be made to the PHP stack and scripts should notice no difference.</p>
<p>You can view the change log on the php.net site: <a href="http://php.net/ChangeLog-5.php" title="here" target="_blank">http://php.net/ChangeLog-5.php</a></p>
]]></content:encoded>
			<wfw:commentRss>http://boolean.co.nz/blog/emergency-php-updates/725/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MySQL not starting in MAMP OSX</title>
		<link>http://boolean.co.nz/blog/mysql-not-starting-mamp/721/</link>
		<comments>http://boolean.co.nz/blog/mysql-not-starting-mamp/721/#comments</comments>
		<pubDate>Tue, 07 Feb 2012 00:32:03 +0000</pubDate>
		<dc:creator>Boolean</dc:creator>
				<category><![CDATA[MySQL]]></category>
		<category><![CDATA[OSX]]></category>

		<guid isPermaLink="false">http://boolean.co.nz/blog/?p=721</guid>
		<description><![CDATA[Sometimes MySQL doesn&#8217;t come up again when attempting to start MAMP, &#8211; it just hangs after starting Apache. If you don&#8217;t want to have to reboot (and shutting down and restarting MAMP hasn&#8217;t helped) then quit MAMP, open a Terminal window and type: ps aux &#124; grep mysql lsof -i killall -9 mysqld]]></description>
			<content:encoded><![CDATA[<table>
<tr>
<td><img src="http://boolean.co.nz/blog/wp-content/uploads/2009/04/mysql_logo.png" alt="" title="mysql_logo" width="204" height="106" class="aligncenter size-full wp-image-96" /></td>
</tr>
</table>
<p>Sometimes MySQL doesn&#8217;t come up again when attempting to start MAMP, &#8211; it just hangs after starting Apache. If you don&#8217;t want to have to reboot (and shutting down and restarting MAMP hasn&#8217;t helped) then quit MAMP, open a Terminal window and type:</p>
<div class="codesnip-container" >ps aux | grep mysql<br />
lsof -i<br />
killall -9 mysqld</div>
]]></content:encoded>
			<wfw:commentRss>http://boolean.co.nz/blog/mysql-not-starting-mamp/721/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Obtain Facebook likes via PHP SDK</title>
		<link>http://boolean.co.nz/blog/facebook-likes-sdk/713/</link>
		<comments>http://boolean.co.nz/blog/facebook-likes-sdk/713/#comments</comments>
		<pubDate>Sun, 29 Jan 2012 03:11:36 +0000</pubDate>
		<dc:creator>Boolean</dc:creator>
				<category><![CDATA[FaceBook]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://boolean.co.nz/blog/?p=713</guid>
		<description><![CDATA[In an update to this post here is another way to obtain the number of likes for a Facebook page. I&#8217;ll assume that you&#8217;ve already registered a Facebook application, have downloaded the PHP SDK and have included for use in your code. require(&#8216;facebook.php&#8217;); Setup an array with your Facebook applications credentials $facebook = new Facebook(array( [...]]]></description>
			<content:encoded><![CDATA[<table>
<tr>
<td><img src="http://boolean.co.nz/blog/wp-content/uploads/2009/03/php-logo.png" alt="" title="php-logo" width="203" height="107" class="aligncenter size-full wp-image-61" /></td>
</tr>
</table>
<p>In an update to this <a href="http://boolean.co.nz/blog/get-facebook-likes-and-shares-via-graph-api/626/" title="post" target="_blank">post</a> here is another way to obtain the number of likes for a Facebook page.</p>
<p>I&#8217;ll assume that you&#8217;ve already registered a Facebook application, have downloaded the PHP SDK and have included for use in your code.</p>
<div class="codesnip-container" >require(&#8216;facebook.php&#8217;);</div>
<p>Setup an array with your Facebook applications credentials</p>
<div class="codesnip-container" >$facebook = new Facebook(array(<br />
&#8216;appId&#8217; => &#8217;000000000&#8242;, // Put appID here<br />
&#8216;secret&#8217; => &#8217;0000c000c000c000c&#8217;, // Put your secret key here<br />
));</div>
<p>Decide which page you wish to obtain the number of likes for</p>
<div class="codesnip-container" >$getRequest = $facebook->api(&#8216;/cocacola&#8217;); // Lets look at the Facebook page for the popular soft drink<br />
echo $getRequests['likes'];</div>
<p>Obviously you can consume, contrast and display this information in more exciting ways than simply echoing it to the screen. Enjoy.</p>
]]></content:encoded>
			<wfw:commentRss>http://boolean.co.nz/blog/facebook-likes-sdk/713/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Force trailing slash with .htaccess</title>
		<link>http://boolean.co.nz/blog/force-trailing-slash-with-htaccess/684/</link>
		<comments>http://boolean.co.nz/blog/force-trailing-slash-with-htaccess/684/#comments</comments>
		<pubDate>Sun, 06 Nov 2011 23:22:18 +0000</pubDate>
		<dc:creator>Boolean</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Hosting]]></category>

		<guid isPermaLink="false">http://boolean.co.nz/blog/?p=684</guid>
		<description><![CDATA[There are a few reasons to force a trailing slash at the end of URLs including SEO A quick snippet for your .htaccess is below: &#60;IfModule mod_rewrite.c&#62; RewriteCond %{REQUEST_URI} /+[^\.]+$ RewriteRule ^(.+[^/])$ %{REQUEST_URI}/ [R=301,L] &#60;/IfModule&#62; And while I&#8217;m here a quick snippet to prevent hotlinking of images. This will redirect all requests to a specified [...]]]></description>
			<content:encoded><![CDATA[<table>
<tr>
<td><img src="http://boolean.co.nz/blog/wp-content/uploads/2011/09/apache_logo.png" alt="" title="apache_logo" width="365" height="57" class="aligncenter size-full wp-image-635" /></td>
</tr>
</table>
<p>There are a few reasons to force a trailing slash at the end of URLs including SEO</p>
<p>A quick snippet for your .htaccess is below:</p>
<div class="codesnip-container" >&lt;IfModule mod_rewrite.c&gt;<br />
 RewriteCond %{REQUEST_URI} /+[^\.]+$<br />
 RewriteRule ^(.+[^/])$ %{REQUEST_URI}/ [R=301,L]<br />
&lt;/IfModule&gt;</div>
<p>And while I&#8217;m here a quick snippet to prevent hotlinking of images. This will redirect all requests to a specified image, simply replace yoursite.com with your own URL, and nohotlinking.jpg with your own image and path.</p>
<div class="codesnip-container" >RewriteEngine On<br />
RewriteCond %{HTTP_REFERER} !^http://(.+\.)?yoursite\.com/ [NC]<br />
RewriteCond %{HTTP_REFERER} !^$<br />
RewriteRule .*\.(jpe?g|gif|bmp|png)$ /images/nohotlinking.jpg [L]</div>
<p>And finally a snippet to put in your image assets folder (you have images stored separately right?) to prevent malicious code execution and prevent directory listing of all your assets.</p>
<div class="codesnip-container" >Options All -Indexes<br />
AddHandler cgi-script .php .php4 .php5 .pl .jsp .asp .sh .cgi<br />
Options -ExecCGI</div>
]]></content:encoded>
			<wfw:commentRss>http://boolean.co.nz/blog/force-trailing-slash-with-htaccess/684/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Firefox cross domain font embedding</title>
		<link>http://boolean.co.nz/blog/firefox-cross-domain-font-embedding/676/</link>
		<comments>http://boolean.co.nz/blog/firefox-cross-domain-font-embedding/676/#comments</comments>
		<pubDate>Mon, 31 Oct 2011 23:24:59 +0000</pubDate>
		<dc:creator>Boolean</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Hosting]]></category>

		<guid isPermaLink="false">http://boolean.co.nz/blog/?p=676</guid>
		<description><![CDATA[Firefox has a limitation for cross domain font embedding in that it does not allow you to embed from another website. This .htaccess snippet allows you to bypass this limitation and embed fonts located on another webserver. &#60;FilesMatch &#8220;\.(ttf&#124;otf&#124;eot&#124;woff)$&#8221;&#62; &#60;IfModule mod_headers.c&#62; Header set Access-Control-Allow-Origin &#8220;http://thedomain.com&#8221; &#60;/IfModule&#62; &#60;/FilesMatch&#62;]]></description>
			<content:encoded><![CDATA[<p>Firefox has a limitation for cross domain font embedding in that it does not allow you to embed from another website. This .htaccess snippet allows you to bypass this limitation and embed fonts located on another webserver.</p>
<div class="codesnip-container" >&lt;FilesMatch &#8220;\.(ttf|otf|eot|woff)$&#8221;&gt;<br />
&lt;IfModule mod_headers.c&gt;<br />
    Header set Access-Control-Allow-Origin &#8220;http://thedomain.com&#8221;<br />
&lt;/IfModule&gt;<br />
&lt;/FilesMatch&gt;</div>
]]></content:encoded>
			<wfw:commentRss>http://boolean.co.nz/blog/firefox-cross-domain-font-embedding/676/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

