<?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>OhRyan.ca &#187; programming</title>
	<atom:link href="http://ohryan.ca/blog/tag/programming/feed/" rel="self" type="application/rss+xml" />
	<link>http://ohryan.ca/blog</link>
	<description>Canadian Tech News, Hacks &#38; How To</description>
	<lastBuildDate>Mon, 06 Sep 2010 19:19:08 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>How To Detect Mobile Visitors Using .htaccess Rewrite Rules, Simplified</title>
		<link>http://ohryan.ca/blog/2010/04/10/how-to-detect-mobile-visitors-using-htaccess-rewrite-rules-simplified/</link>
		<comments>http://ohryan.ca/blog/2010/04/10/how-to-detect-mobile-visitors-using-htaccess-rewrite-rules-simplified/#comments</comments>
		<pubDate>Sat, 10 Apr 2010 13:00:27 +0000</pubDate>
		<dc:creator>RyanN</dc:creator>
				<category><![CDATA[HowTo]]></category>
		<category><![CDATA[Tips]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[mobile browser]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[rewrite rule]]></category>
		<category><![CDATA[server]]></category>

		<guid isPermaLink="false">http://ohryan.ca/blog/?p=559</guid>
		<description><![CDATA[Since my original posts on mobile redirection in .htaccess files I&#8217;ve gotten some comments and emails asking for step-by-step guidance on exactly how to &#8220;install&#8221; these rules. I hope this post will answer some of those questions. Before you continue reading, if you have php installed on your server, you may want to consider Andy Moore&#8217;s php [...]]]></description>
			<content:encoded><![CDATA[<div>
<p>Since my <a href="http://ohryan.ca/blog/2007/10/29/htaccess-mobile-browser-redirect/" target="_blank">original</a> <a href="http://ohryan.ca/blog/2009/02/18/revisiting-mobile-redirection-using-htaccess-rewrite-rules/" target="_blank">posts</a> on mobile redirection in .htaccess files I&#8217;ve gotten some comments and emails asking for step-by-step guidance on exactly how to &#8220;install&#8221; these rules. I hope this post will answer some of those questions.</p>
<p>Before you continue reading, if you have php installed on your server, you may want to consider <a href="http://detectmobilebrowsers.mobi/" target="_blank">Andy Moore&#8217;s php based detection solution</a>.</p>
<h3>The Basics</h3>
<p>First off, some basic requirements. You&#8217;ll need:</p>
<ul>
<li><strong>Apache/Linux Hosting</strong>. Microsoft&#8217;s IIS has a completely different method for handling this sort of thing.</li>
<li><strong>FTP access.</strong></li>
<li><a href="http://httpd.apache.org/docs/1.3/mod/mod_rewrite.html" target="_blank"><strong>Apache mod_rewrite</strong></a><strong> enabled</strong>. Depending on the type of hosting you have, it may be difficult to determine if you have this module installed and it may be impossible to enable if you don&#8217;t. If the steps below simply don&#8217;t seem to work, there is a good chance you don&#8217;t have mod_rewrite installed. Ask your tech support.</li>
<li><strong>Mobile site in a subdirectory</strong>, eg. www.yourdomain.com/m/. This set of rules I&#8217;ve posted will not work with a mobile subdomain.</li>
</ul>
<h3>The Steps</h3>
<ol>
<li>Download <a href="http://ohryan.ca/blog/wp-content/uploads/mobilerules2.1.txt" target="_blank">mobilerules2.1.txt</a>.</li>
<li>Open the file in your favorite text editor, replace the 2 instances of &#8220;mobiledirectoryhere&#8221; (without quotes) with the directory name you are using for your mobile site. Save it.</li>
<li>Open FTP client, enable &#8216;view hidden files&#8217; &#8211; files beginning with a dot are hidden on linux. This option is typically buried in a &#8220;view&#8221; menu or something to that effect. Results may vary.</li>
<li>Navigate to your site&#8217;s webroot (probably &#8216;htdocs&#8217; or &#8216;www&#8217;).</li>
<li>
<ul>
<li>If there is already a .htaccess file present in the directory. Download it, open it in your favorite text editor. Copy &amp; paste the contents of<a href="http://ohryan.ca/blog/wp-content/uploads/mobilerules2.1.txt" target="_blank">mobilerules2.1.txt</a> into the file. Save it, upload it.</li>
<li>If there is no .htaccess file present. Upload <a href="http://ohryan.ca/blog/wp-content/uploads/mobilerules2.1.txt" target="_blank">mobilerules2.1.txt</a> as is, rename it to .htaccess.</li>
</ul>
</li>
<li>Your Done. Test it from a mobile device.</li>
</ol>
<p>If you have any questions please leave a comment.</p>
<p><strong>Note:</strong> This script treats all opera mini, iphone and android the same as other phones and browsers. Leave some comments if you&#8217;d like me to address this.</p>
</div>
]]></content:encoded>
			<wfw:commentRss>http://ohryan.ca/blog/2010/04/10/how-to-detect-mobile-visitors-using-htaccess-rewrite-rules-simplified/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>DIGG: 4000% PERFORMANCE INCREASE BY SORTING IN PHP RATHER THAN MYSQL</title>
		<link>http://ohryan.ca/blog/2010/03/26/digg-4000-performance-increase-by-sorting-in-php-rather-than-mysql/</link>
		<comments>http://ohryan.ca/blog/2010/03/26/digg-4000-performance-increase-by-sorting-in-php-rather-than-mysql/#comments</comments>
		<pubDate>Fri, 26 Mar 2010 20:37:27 +0000</pubDate>
		<dc:creator>RyanN</dc:creator>
				<category><![CDATA[Random]]></category>
		<category><![CDATA[digg]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://ohryan.ca/blog/?p=573</guid>
		<description><![CDATA[To scale at Digg they followed a set of practices very similar to those used at eBay. No joins, no foreign key constraints (to scale writes), primary key look-ups only, limited range queries, and joins were done in memory. When implementing the comment feature a 4,000 percent increase in performance was created by sorting in [...]]]></description>
			<content:encoded><![CDATA[<blockquote><p>To scale at Digg they followed a set of practices very similar to those used at eBay. No joins, no foreign key constraints (to scale writes), primary key look-ups only, limited range queries, and joins were done in memory. When implementing the comment feature a 4,000 percent increase in performance was created by sorting in PHP instead of MySQL. All this effort required to make a relational database scale basically meant you were using a non-relational database anyway. So why not just use a non-relational database from the start?</p>
<p>[via <a href="http://highscalability.com/blog/2010/3/23/digg-4000-performance-increase-by-sorting-in-php-rather-than.html" target="_blank">High Scalability</a>]</p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://ohryan.ca/blog/2010/03/26/digg-4000-performance-increase-by-sorting-in-php-rather-than-mysql/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How To: Exclude Words Like &#8220;An, A, The&#8221; From Alphabetized MySQL ORDER</title>
		<link>http://ohryan.ca/blog/2009/07/17/how-to-exclude-words-like-an-a-the-from-alphabetized-mysql-order/</link>
		<comments>http://ohryan.ca/blog/2009/07/17/how-to-exclude-words-like-an-a-the-from-alphabetized-mysql-order/#comments</comments>
		<pubDate>Fri, 17 Jul 2009 15:10:42 +0000</pubDate>
		<dc:creator>RyanN</dc:creator>
				<category><![CDATA[HowTo]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://ohryan.ca/blog/?p=419</guid>
		<description><![CDATA[When ordering lists of names or titles it&#8217;s sometimes desirable to exclude articles or other words from the order clause (eg. you want &#8220;The Burning Hell&#8221; to show up before &#8220;Great Lake Swimmers&#8221; in a list ordered by name). Early on in my career I must have assumed it was not possible and never bothered [...]]]></description>
			<content:encoded><![CDATA[<p>When ordering lists of names or titles it&#8217;s sometimes desirable to exclude articles or other words from the order clause (eg. you want &#8220;The Burning Hell&#8221; to show up before &#8220;Great Lake Swimmers&#8221; in a list ordered by name). Early on in my career I must have assumed it was not possible and never bothered to look into again because I don&#8217;t recall ever ordering a list like this.<br />
Anyways. Here&#8217;s how you do it:</p>
<p><code>SELECT name FROM artists ORDER BY TRIM( LEADING "a " FROM TRIM( LEADING "an " FROM TRIM( LEADING "the " FROM LOWER( name ) ) ) )</code></p>
<p><small><a href="http://ask.metafilter.com/52434/How-to-get-mySQL-to-ignore-A-An-amp-The-when-presenting-alphabetized-book-titles">[thanks metafilter]</a></small></p>
]]></content:encoded>
			<wfw:commentRss>http://ohryan.ca/blog/2009/07/17/how-to-exclude-words-like-an-a-the-from-alphabetized-mysql-order/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Even Google Makes Mistakes</title>
		<link>http://ohryan.ca/blog/2009/02/25/even-google-makes-mistakes/</link>
		<comments>http://ohryan.ca/blog/2009/02/25/even-google-makes-mistakes/#comments</comments>
		<pubDate>Wed, 25 Feb 2009 18:31:44 +0000</pubDate>
		<dc:creator>RyanN</dc:creator>
				<category><![CDATA[Google]]></category>
		<category><![CDATA[gmail]]></category>
		<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://ohryan.ca/blog/?p=351</guid>
		<description><![CDATA[This is an expert from a Gmail Blog Post re: the recent gmail outage: Unexpected side effects of some new code that tries to keep data geographically close to its owner caused another data center in Europe to become overloaded, and that caused cascading problems from one data center to another. It took us about [...]]]></description>
			<content:encoded><![CDATA[<p>This is an expert from a <a href="http://gmailblog.blogspot.com/2009/02/update-on-todays-gmail-outage.html" target="_blank">Gmail Blog Post re: the recent gmail outage:</a></p>
<blockquote><p>Unexpected side effects of some new code that tries to keep data geographically close to its owner caused another data center in Europe to become overloaded, and that caused cascading problems from one data center to another. It took us about an hour to get it all back under control.</p></blockquote>
<p>This sounds exactly like the types of bugs I create. The fact that Google makes these sorts of mistakes, even though they do a lot more testing and have bigger teams, etc; makes me feel good about my programming skills.</p>
]]></content:encoded>
			<wfw:commentRss>http://ohryan.ca/blog/2009/02/25/even-google-makes-mistakes/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Revisiting Mobile Redirection Using .htaccess ReWrite Rules</title>
		<link>http://ohryan.ca/blog/2009/02/18/revisiting-mobile-redirection-using-htaccess-rewrite-rules/</link>
		<comments>http://ohryan.ca/blog/2009/02/18/revisiting-mobile-redirection-using-htaccess-rewrite-rules/#comments</comments>
		<pubDate>Wed, 18 Feb 2009 20:20:52 +0000</pubDate>
		<dc:creator>RyanN</dc:creator>
				<category><![CDATA[HowTo]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[mobile browser]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[rewrite rule]]></category>
		<category><![CDATA[server]]></category>

		<guid isPermaLink="false">http://ohryan.ca/blog/?p=338</guid>
		<description><![CDATA[Back in 2007 I wrote a post detailing a method for detecting and redirecting mobile browsers using .htaccess. Since then the mobile landscape has changed quite a bit: iPhone and Android have been released, the PDA market is all but dead and phones are better in general. My original post was based on a PHP [...]]]></description>
			<content:encoded><![CDATA[<p>Back in 2007 <a href="http://ohryan.ca/blog/2007/10/29/htaccess-mobile-browser-redirect/" target="_blank">I wrote a post detailing a method for detecting and redirecting mobile browsers using .htaccess</a>. Since then the mobile landscape has changed quite a bit: iPhone and Android have been released, the PDA market is all but dead and phones are better in general.</p>
<p>My original post was based on a PHP script by Andy Moore. It&#8217;s worth noting that he has continued to update his script and now has a fancy little generator to help you create a PHP based redirect ruleset. Check out <a href="http://detectmobilebrowsers.mobi/" target="_blank">detectmobilebrowsers.mobi</a> for more info.</p>
<p>His solution will probably work for a lot of applications, but there are 2 main reasons I prefer using Apache&#8217;s rewrite rules to redirect mobile browsers:<br />
<strong>1) </strong>Application independent. By putting the rules in the root .htaccess file you can easily redirect traffic across multiple directories, independent of any webapp that might or might not be running in those directories.<br />
<strong>2) </strong>Faster. Placing the rewrite rules in apache&#8217;s httpd.conf file is potentially faster, than running the regexp in a php script for every request.</p>
<p>Enough of that, here&#8217;s the updated ruleset.<br />
<code><br />
# don't apply the rules if you're already in the mobile directory, infintine loop<br />
# you'll want to test against the host if you're using a subdomain<br />
RewriteCond %{REQUEST_URI} !^/mobiledirectoryhere/.*$<br />
# if the browser accepts these mime-types, it's definitely mobile, or pretending to be<br />
RewriteCond %{HTTP_ACCEPT} "text\/vnd\.wap\.wml|application\/vnd\.wap\.xhtml\+xml" [NC,OR]<br />
# a bunch of user agent tests<br />
RewriteCond %{HTTP_USER_AGENT} "sony|symbian|nokia|samsung|mobile|windows ce|epoc|opera" [NC,OR]<br />
RewriteCond %{HTTP_USER_AGENT} "mini|nitro|j2me|midp-|cldc-|netfront|mot|up\.browser|up\.link|audiovox"[NC,OR]<br />
RewriteCond %{HTTP_USER_AGENT} "blackberry|ericsson,|panasonic|philips|sanyo|sharp|sie-"[NC,OR]<br />
RewriteCond %{HTTP_USER_AGENT} "portalmmm|blazer|avantgo|danger|palm|series60|palmsource|pocketpc"[NC,OR]<br />
RewriteCond %{HTTP_USER_AGENT} "smartphone|rover|ipaq|au-mic,|alcatel|ericy|vodafone\/|wap1\.|wap2\.|iPhone|android"[NC]<br />
# put your rewrite rules here<br />
</code></p>
<p><a href="/blog/wp-content/uploads/mobilerules20.txt">Text Version</a></p>
<p>As you can see, the user agent list is a fair bit less verbose. I&#8217;ve been testing the ruleset on a very busy site, based on over 250k mobile site hits this set of rules is causing a lot fewer false positives, while not missing any significant number of mobile browsers.</p>
]]></content:encoded>
			<wfw:commentRss>http://ohryan.ca/blog/2009/02/18/revisiting-mobile-redirection-using-htaccess-rewrite-rules/feed/</wfw:commentRss>
		<slash:comments>22</slash:comments>
		</item>
		<item>
		<title>This is why webprogramming sucks&#8230;</title>
		<link>http://ohryan.ca/blog/2007/08/15/this-is-why-webprogramming-sucks/</link>
		<comments>http://ohryan.ca/blog/2007/08/15/this-is-why-webprogramming-sucks/#comments</comments>
		<pubDate>Wed, 15 Aug 2007 16:01:11 +0000</pubDate>
		<dc:creator>RyanN</dc:creator>
				<category><![CDATA[Funny]]></category>
		<category><![CDATA[Random]]></category>
		<category><![CDATA[comic]]></category>
		<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://ohryan.ca/blog/2007/08/15/this-is-why-webprogramming-sucks/</guid>
		<description><![CDATA[Run-time languages don&#8217;t have compilers.]]></description>
			<content:encoded><![CDATA[<p><a href="http://xkcd.com/303/"><img src="http://imgs.xkcd.com/comics/compiling.png" alt="" width="413" height="360" /></a></p>
<p>Run-time languages don&#8217;t have compilers.</p>
]]></content:encoded>
			<wfw:commentRss>http://ohryan.ca/blog/2007/08/15/this-is-why-webprogramming-sucks/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
