<?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>Never Use This Font &#187; Website Development</title>
	<atom:link href="http://neverusethisfont.com/blog/topics/website-development/feed/" rel="self" type="application/rss+xml" />
	<link>http://neverusethisfont.com/blog</link>
	<description>Ramblings of a Designer/Programmer</description>
	<lastBuildDate>Fri, 09 Jul 2010 21:50:35 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Notes on my preferred IDE: Aptana Studio</title>
		<link>http://neverusethisfont.com/blog/2010/05/my-preferred-dev-environment-aptana-studio/</link>
		<comments>http://neverusethisfont.com/blog/2010/05/my-preferred-dev-environment-aptana-studio/#comments</comments>
		<pubDate>Thu, 13 May 2010 18:49:30 +0000</pubDate>
		<dc:creator>aaron</dc:creator>
				<category><![CDATA[Website Development]]></category>

		<guid isPermaLink="false">http://neverusethisfont.com/blog/?p=240</guid>
		<description><![CDATA[]]></description>
			<content:encoded><![CDATA[<p>I haven’t used Dreamweaver since 2002 and don’t regret it for a minute. On the other hand, I’ve been struggling to find a good IDE for PHP/HTML/Javascript development for a very long time.</p>
<p>Komodo on OSX is pretty good, and allows for editing files directly from an SFTP server. That combined with command-line Subversion was my preferred environment for a long time.</p>
<p>In the last year or two I&#8217;ve started using Aptana, on both Windows and OSX. I’ve been extremely happy with it for the most part. I’ve always installed the standalone version and it’s worked without any trouble immediately after installing. As great as Aptana is, it definitely has its quirks. One of which is the obscure way to get “upload on save” to work.</p>
<p>The trick with Aptana is not to download version 2! They took out a lot of the great features for some reason. Use version 1.5.1, which is nearly impossible to find a link to! Save this setup file locally in case you need to reinstall it, and bookmark <a href="http://studio-download.aptana.com/26125/Aptana_Studio_Setup_1.5.1.exe">this link</a> directly to the 1.5.1 installer! </p>
<p>The Subversion integration is fantastic, and another really useful feature is the two-way sync in case you edit files both locally and remotely and need to sync changes between the two sets of files. If you add an SFTP site to Aptana, you will be able to edit files directly on a server without needing the &#8220;upload on save&#8221; script.</p>
<p>After first installing Aptana, you&#8217;ll want to install the PHP plugin. Go to Help -> Install New Software and choose the PHP Update Site under the &#8220;work with&#8221; menu.</p>
<p><img src="http://neverusethisfont.com/blog/wp-content/uploads/2010/05/2010-05-13_1126_Aptana_Install_PHP-300x264.png" alt="2010-05-13_1126_Aptana_Install_PHP" title="2010-05-13_1126_Aptana_Install_PHP" width="300" height="264" class="aligncenter size-medium wp-image-244" /></p>
<p>After that you&#8217;re pretty much ready to go. Check out a project from Subversion by clicking New -> Other -> Checkout projects from SVN.</p>
]]></content:encoded>
			<wfw:commentRss>http://neverusethisfont.com/blog/2010/05/my-preferred-dev-environment-aptana-studio/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Filtering Array Elements in PHP Using an Anonymous Function</title>
		<link>http://neverusethisfont.com/blog/2009/02/filtering-array-elements-in-php-using-an-anonymous-function/</link>
		<comments>http://neverusethisfont.com/blog/2009/02/filtering-array-elements-in-php-using-an-anonymous-function/#comments</comments>
		<pubDate>Mon, 09 Feb 2009 18:35:01 +0000</pubDate>
		<dc:creator>aaron</dc:creator>
				<category><![CDATA[Website Development]]></category>
		<category><![CDATA[anonymous functions]]></category>
		<category><![CDATA[array]]></category>
		<category><![CDATA[filter]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[search]]></category>

		<guid isPermaLink="false">http://neverusethisfont.com/blog/2009/02/filtering-array-elements-in-php-using-an-anonymous-function/</guid>
		<description><![CDATA[Using an anonymous function in PHP's array_filter as a way to search a 2D array.]]></description>
			<content:encoded><![CDATA[<div style="text-align:center; background-color:#eee; border: 1px #bbb solid; padding: 4px;">== UPDATE ==<br />
This is now basically obsolete thanks to PHP 5.3&#8217;s <a href="http://www.php.net/manual/en/functions.anonymous.php">closures</a></div>
<p>I&#8217;ve used PHP&#8217;s <a href="http://php.net/array_filter">array_filter()</a> in the past to filter elements from an array, but occasionally I find that I need to pass an additional value to the function in order to determine whether to keep the element. This just came up in a case where I was using GET variables to filter search results on a large array.</p>
<p>I have a large 2D array of books where each record has some information such as title, author, publisher, ISBN, etc. I include search boxes for each column when I draw the table to the screen, so the user can search a specific column for some text.</p>

<div class="wp_syntax"><div class="code"><pre class="php"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #ff0000">$data</span> <span style="color: #66cc66;">=</span> <span style="color: #000066;">array</span><span style="color: #66cc66;">&#40;</span>
    <span style="color: #cc66cc;">0</span> <span style="color: #66cc66;">=&gt;</span> <span style="color: #000066;">array</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'Title'</span> <span style="color: #66cc66;">=&gt;</span> <span style="color: #ff0000;">&quot;Career and Life Planning&quot;</span><span style="color: #66cc66;">,</span>  <span style="color: #ff0000;">'Author'</span> <span style="color: #66cc66;">=&gt;</span> <span style="color: #ff0000;">&quot;Michel Ozzi&quot;</span><span style="color: #66cc66;">,</span>      <span style="color: #ff0000;">'ISBN'</span> <span style="color: #66cc66;">=&gt;</span> <span style="color: #ff0000;">&quot;978-0-07-284262-3&quot;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">,</span>
    <span style="color: #cc66cc;">1</span> <span style="color: #66cc66;">=&gt;</span> <span style="color: #000066;">array</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'Title'</span> <span style="color: #66cc66;">=&gt;</span> <span style="color: #ff0000;">&quot;Beginning Algebra&quot;</span><span style="color: #66cc66;">,</span>         <span style="color: #ff0000;">'Author'</span> <span style="color: #66cc66;">=&gt;</span> <span style="color: #ff0000;">&quot;Blitzer&quot;</span><span style="color: #66cc66;">,</span>          <span style="color: #ff0000;">'ISBN'</span> <span style="color: #66cc66;">=&gt;</span> <span style="color: #ff0000;">&quot;978-0-555-03971-7&quot;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">,</span>
    <span style="color: #cc66cc;">2</span> <span style="color: #66cc66;">=&gt;</span> <span style="color: #000066;">array</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'Title'</span> <span style="color: #66cc66;">=&gt;</span> <span style="color: #ff0000;">&quot;Primary Flight Briefing&quot;</span><span style="color: #66cc66;">,</span>   <span style="color: #ff0000;">'Author'</span> <span style="color: #66cc66;">=&gt;</span> <span style="color: #ff0000;">&quot;Federal Aviation&quot;</span><span style="color: #66cc66;">,</span> <span style="color: #ff0000;">'ISBN'</span> <span style="color: #66cc66;">=&gt;</span> <span style="color: #ff0000;">&quot;978-1-5602755-7-2&quot;</span><span style="color: #66cc66;">&#41;</span>
<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
&nbsp;
<span style="color: #b1b100;">foreach</span><span style="color: #66cc66;">&#40;</span> <span style="color: #ff0000">$_GET</span> <span style="color: #b1b100;">as</span> <span style="color: #ff0000">$k</span><span style="color: #66cc66;">=&gt;</span><span style="color: #ff0000">$v</span> <span style="color: #66cc66;">&#41;</span>
<span style="color: #66cc66;">&#123;</span>
	<span style="color: #ff0000">$data</span> <span style="color: #66cc66;">=</span> <span style="color: #000066;">array_filter</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000">$data</span><span style="color: #66cc66;">,</span> <span style="color: #000066;">create_function</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'$data'</span><span style="color: #66cc66;">,</span> <span style="color: #ff0000;">'return ( stripos($data[&quot;'</span><span style="color: #66cc66;">.</span><span style="color: #ff0000">$k</span><span style="color: #66cc66;">.</span><span style="color: #ff0000;">'&quot;], &quot;'</span><span style="color: #66cc66;">.</span><span style="color: #ff0000">$v</span><span style="color: #66cc66;">.</span><span style="color: #ff0000;">'&quot;) !== false );'</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
<span style="color: #66cc66;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p>Notice the values of <code lang="php">$k</code> and <code lang="php">$v</code> are actually written into the PHP code, whereas <code lang="php">$data</code> is written to the function as a variable name. If you were to echo the body of the function, it would actually look something like this:</p>

<div class="wp_syntax"><div class="code"><pre class="php"><span style="color: #b1b100;">return</span> <span style="color: #66cc66;">&#40;</span> stripos<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000">$data</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">&quot;ISBN&quot;</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">,</span> <span style="color: #ff0000;">&quot;555&quot;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">!==</span> <span style="color: #000000; font-weight: bold;">false</span> <span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span></pre></div></div>

<p>In each iteration of the loop the function is re-created, and the key/value pair are essentially hard-coded into the function instead of being variables.</p>
<p>So there you go! A real-live use for anonymous functions in PHP!</p>
]]></content:encoded>
			<wfw:commentRss>http://neverusethisfont.com/blog/2009/02/filtering-array-elements-in-php-using-an-anonymous-function/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Automatically linking Twitter @usernames in PHP</title>
		<link>http://neverusethisfont.com/blog/2008/10/automatically-linking-twitter-usernames/</link>
		<comments>http://neverusethisfont.com/blog/2008/10/automatically-linking-twitter-usernames/#comments</comments>
		<pubDate>Wed, 29 Oct 2008 18:30:41 +0000</pubDate>
		<dc:creator>aaron</dc:creator>
				<category><![CDATA[Website Development]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[regular expressions]]></category>
		<category><![CDATA[twitter]]></category>

		<guid isPermaLink="false">http://neverusethisfont.com/blog/2008/10/automatically-linking-twitter-usernames/</guid>
		<description><![CDATA[I keep seeing people writing scripts that embed their Twitter feed into their websites. The &#8220;easy&#8221; way is to use Javascript, which means you don&#8217;t need to have PHP installed on your server. Doing it this way means your tweets will not be visible to visitors with Javascript disabled.
Really, nobody has Javascript disabled in their [...]]]></description>
			<content:encoded><![CDATA[<p>I keep seeing people writing scripts that embed their Twitter feed into their websites. The &#8220;easy&#8221; way is to use Javascript, which means you don&#8217;t need to have PHP installed on your server. Doing it this way means your tweets will not be visible to visitors with Javascript disabled.</p>
<p>Really, nobody has Javascript disabled in their browsers anymore. The web is pretty much inaccessible without it at this point. However there are still some very important &#8220;visitors&#8221; that crawl around the web without javascript. I&#8217;m talking about search engines. Few if any search engines will actually execute Javascript on your site when crawling it for content. This means anything you have hidden inside a &lt;script&gt; tag will be hidden to them. If you want your tweets to be indexed as part of your page, then you&#8217;ll need to use PHP or another server-side scripting language to embed them into your page. This also has the other advantage of making your page load faster to regular visitors as well.</p>
<p>The below diagram should help illustrate the benefit of using PHP to embed your tweets.</p>
<p><img src="http://neverusethisfont.com/blog/wp-content/uploads/2008/10/twitter_php_rss_win.gif" alt="" align="center" /></p>
<p>Now that you&#8217;re convinced that you want to use PHP to embed your Twitter posts, you&#8217;re going to quickly run into the problem that people&#8217;s Twitter usernames are not given as a link in the RSS feed, but just the @username text. You probably want these usernames linked back to twitter.com.</p>
<p>I have seen some solutions involving splitting up the tweet into individual words, and looking at each to see if it begins with an @ sign. This involves a lot of code, and generally looks something like this:</p>
<p><img src="http://neverusethisfont.com/blog/wp-content/uploads/2008/10/twitter_garble.gif" alt="" align="center" /></p>
<p>It is rendered completely unnecessary by using one line of regular expressions!</p>

<div class="wp_syntax"><div class="code"><pre class="php"><span style="color: #ff0000">$tweet</span> <span style="color: #66cc66;">=</span> <span style="color: #000066;">preg_replace</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'/(^|[^a-z0-9_])@([a-z0-9_]+)/i'</span><span style="color: #66cc66;">,</span> <span style="color: #ff0000;">'$1&lt;a href=&quot;http://twitter.com/$2&quot;&gt;@$2&lt;/a&gt;'</span><span style="color: #66cc66;">,</span> <span style="color: #ff0000">$tweet</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span></pre></div></div>

<p>This regular expression is actually pretty simple. <strong>(updated)</strong> The key part is &#8220;(^|[^a-z0-9_])@([a-z0-9_]+)&#8221;, which is a lot less scary than it first looks. The ( ) are used to capture what&#8217;s inside them so that you can access it later (by using the $1 and $2 above). The [ ] match a set of characters, which can be defined as a range or a list of characters. We&#8217;re matching numbers and letters and the underscore. Finally, the + says &#8220;one or more&#8221;. The vertical bar | is used to match either what&#8217;s on the left <b>or</b> what&#8217;s on the right. The caret ^ (if it&#8217;s not inside square brackets) matches the beginning of a line.</p>
<p>So in English, this regular expression is looking for either the start of a line or a character other than a letter or number or underscore, followed by an @ sign, followed by one or more numbers or letters or the underscore, and storing those characters in the variable $2. This string is then replaced with the HTML code you see above, where $2 is set to the username by the regular expression.</p>
<p>Now that you understand the regular expression above, let me further complicate things by showing you how to make text that begins with http:// into a real hyperlink.</p>

<div class="wp_syntax"><div class="code"><pre class="php"><span style="color: #ff0000">$search</span> <span style="color: #66cc66;">=</span> <span style="color: #000066;">array</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'|(http://[^ ]+)|'</span><span style="color: #66cc66;">,</span> <span style="color: #ff0000;">'/(^|[^a-z0-9_])@([a-z0-9_]+)/i'</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
<span style="color: #ff0000">$replace</span> <span style="color: #66cc66;">=</span> <span style="color: #000066;">array</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'&lt;a href=&quot;$1&quot;&gt;$1&lt;/a&gt;'</span><span style="color: #66cc66;">,</span> <span style="color: #ff0000;">'$1&lt;a href=&quot;http://twitter.com/$2&quot;&gt;@$2&lt;/a&gt;'</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
<span style="color: #ff0000">$tweet</span> <span style="color: #66cc66;">=</span> <span style="color: #000066;">preg_replace</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000">$search</span><span style="color: #66cc66;">,</span> <span style="color: #ff0000">$replace</span><span style="color: #66cc66;">,</span> <span style="color: #ff0000">$tweet</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span></pre></div></div>

<p>Trust me, it isn&#8217;t that bad really. The new regular expression is actually simpler than the first, but is looking for http:// instead of @. You may have also noticed that I switched from using // to ||. You can use any character as the bounds for the regular expression. The advantage of using | is that the bar doesn&#8217;t appear inside ever. If I used / as the bounds, then had http:// inside, I&#8217;d have to escape the forward slashes of the http. (It would look like http:\/\/, which is kind of ridiculous).</p>
<p>You might want to check out <a href="http://www.regular-expressions.info">http://www.regular-expressions.info</a> to learn more about regular expressions. Regular expressions are an extremely powerful tool you will want to add to your arsenal when learning PHP.</p>
]]></content:encoded>
			<wfw:commentRss>http://neverusethisfont.com/blog/2008/10/automatically-linking-twitter-usernames/feed/</wfw:commentRss>
		<slash:comments>13</slash:comments>
		</item>
		<item>
		<title>Redundant web &amp; database servers on a budget using Virtual Private Servers</title>
		<link>http://neverusethisfont.com/blog/2008/09/redundant-web-database-servers-on-a-budget-using-virtual-private-servers/</link>
		<comments>http://neverusethisfont.com/blog/2008/09/redundant-web-database-servers-on-a-budget-using-virtual-private-servers/#comments</comments>
		<pubDate>Tue, 23 Sep 2008 03:33:41 +0000</pubDate>
		<dc:creator>aaron</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Server Software]]></category>
		<category><![CDATA[Website Development]]></category>

		<guid isPermaLink="false">http://neverusethisfont.com/blog/?p=55</guid>
		<description><![CDATA[Background
First let me just say that I have been struggling with this problem for quite some time now. The problem is to provide redundancy for a website so that the website continues to run even if there is a problem with one of the servers it&#8217;s running on.
In a typical simple server setup, there is [...]]]></description>
			<content:encoded><![CDATA[<h2>Background</h2>
<p>First let me just say that I have been struggling with this problem for quite some time now. The problem is to provide redundancy for a website so that the website continues to run even if there is a problem with one of the servers it&#8217;s running on.</p>
<p>In a typical simple server setup, there is a single machine running the web and mysql servers. The machine can be either a dedicated server, or as I have been using, a <a href="http://en.wikipedia.org/wiki/Virtual_private_server">VPS</a>. I have been running my websites off of VPSs for several years now, with minimal trouble. This works most of the time, but the having a site on must one machine means a Single Point Of Failure. If something is wrong with that server, the websites are non-functional until it is fixed. The trouble I have run in to falls under a few categories:</p>
<ol>
<li>A problem with the physical host</li>
<li>A problem at the VPS level (operating system, Apache or MySQL errors, etc)</li>
<li>A problem at the network level</li>
</ol>
<h3>Problems with the physical host</h3>
<p>Problems with the physical host do occur. With a VPS, these are completely out of your control, and are the responsibility of the hosting provider. Some examples of things I&#8217;ve encountered include a failed RAID array, a corrupted filesystem on the host, requiring a several-hour-long fsck, or an unplugged power cord. The worst issue I&#8217;ve had was when the provider said they had lost 2 drives in a RAID 5 array, and all the VPSs on that host were completely gone. Luckily I had a backup of the system and was up and running on a new VPS within a couple hours.</p>
<h3>Problems at the application level</h3>
<p>I haven&#8217;t actually run in to many problems at the VPS level compared to the other types of problems. However the latest issue I&#8217;m having does fall in to this category. Apache periodically starts crashing part way through serving a page with the error &#8220;[notice] child pid 21106 exit signal Segmentation fault (11)&#8221;. Visitors see a completely blank page some of the time.</p>
<h3>Problems at the nework level</h3>
<p>By far the most frequently occurring problem I encounter is network-related. These problems are usually out of both my and the hosting provider&#8217;s control. If there is a problem with the network, the downtime can vary greatly, anywhere from 5 minutes to 12 hours. It can be caused by a <a href="http://en.wikipedia.org/wiki/Denial-of-service_attack">Denial of Service</a> attack on a completely different server in the same datacenter, or it could just be a routing issue somewhere along the path from me to the server.</p>
<p>A typical redundant setup will cover both #1 and #2. Typical setups may include one or more load balancers in front of multiple application servers. If a machine goes down, the load balancers can stop sending requests to it. This works great if you&#8217;re trying to protect against servers failing. However if the load balancers are all on the same network, unless the network has multiple redundant paths, the whole system is still vulnerable to network issues.</p>
<h2>My Solution</h2>
<p>Since I most frequently encounter network issues, I can&#8217;t get away with a just a typical load-balancing solution. What I really need is a copy of the entire website in a geographically different location. Here is my solution:</p>
<p>One VPS in Dallas, TX (called triton), and another VPS in Newark, NJ (called proteus). (Yes, I name my servers after Greek mythology.) Triton holds the master copies of the websites&#8217; php files, and proteus gets a copy of them via rsync. If I ever need to update the site, I edit the files on triton and then rsync them to proteus. Here is where the redundancy comes in. My DNS entries point the domain to both IP addresses. This means during normal operation, visitors will be more or less distributed between the two hosts evenly. If one server goes down, I can stop resolving DNS queries to it, and the worst that will happen is some dead pages for as long as the TTL on the domain.</p>
<p>This works as long as you&#8217;re just serving static content. Serving dynamic content, such as from a database, gets a little more complicated. MySQL&#8217;s NDB clusters are apparently only effective when run within a high speed network, with at least a 10 MBPS connection between them. Replication turns out to be more along the lines of what I&#8217;m looking for.</p>
<h2>Replication to the rescue!</h2>
<p>Replication is designed for a one-way sync between a master and slave. However, it is possible to configure two servers to be both a master and a slave. They will both notify each other of changes made to their databases. There is one trick you need to do in order to prevent primary key conflicts if rows are written to both databases while the link is down. It involves setting the auto_increment offset and increment, so that one server will only create even keys, and the other creates only odd keys.</p>

<div class="wp_syntax"><div class="code"><pre class="bash"><span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>my.cnf
    auto_increment_increment = <span style="color: #000000;">2</span>
    auto_increment_offset = <span style="color: #000000;">1</span></pre></div></div>

<p>Here&#8217;s some dry reading on <a href="http://dev.mysql.com/doc/refman/5.0/en/replication.html">replication</a> from the MySQL manual. Here is a <a href="http://www.onlamp.com/pub/a/onlamp/2006/04/20/advanced-mysql-replication.html">slightly clearer guide to replication</a> which sums everything up pretty nicely. Overall, replication was pretty easy to set up. It seems to be pretty robust as well. I simulated network problems by adding firewall rules to block the servers from each other. I was able to continue to interact with each database, and the changes were all carried over when the link came back up.</p>
<p>Feel free to comment if you have any experience or insights into configuring web and database servers! I&#8217;m curious to hear what other people have done.</p>
]]></content:encoded>
			<wfw:commentRss>http://neverusethisfont.com/blog/2008/09/redundant-web-database-servers-on-a-budget-using-virtual-private-servers/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Hiding text from non-registered users in MediaWiki</title>
		<link>http://neverusethisfont.com/blog/2008/09/hiding-text-from-non-registered-users-in-mediawiki/</link>
		<comments>http://neverusethisfont.com/blog/2008/09/hiding-text-from-non-registered-users-in-mediawiki/#comments</comments>
		<pubDate>Wed, 03 Sep 2008 01:10:33 +0000</pubDate>
		<dc:creator>aaron</dc:creator>
				<category><![CDATA[Website Development]]></category>
		<category><![CDATA[mediawiki]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[wiki]]></category>

		<guid isPermaLink="false">http://blog.neverusethisfont.com/2008/09/hiding-text-from-non-registered-users-in-mediawiki/</guid>
		<description><![CDATA[In a semi-private wiki I maintain, we are using whitelisting to make some pages visible to the public but not others. Authentication is done off of an IMAP server, and only registered users have full access tothe wiki. We still run in to the occasional page where most info should be public, but only certain [...]]]></description>
			<content:encoded><![CDATA[<p>In a semi-private wiki I maintain, we are using whitelisting to make some pages visible to the public but not others. Authentication is done off of an IMAP server, and only registered users have full access tothe wiki. We still run in to the occasional page where most info should be public, but only certain bits should not appear to the public. Things like server passwords, or phone numbers should be hidden except to registered users. I created this plugin so that we can hide bits and pieces of pages from non-registered users, while making the rest of the page public. Just add a &lt;private&gt; tag around the text you want hidden, and you&#8217;re good to go.</p>
<p>Copy this code to a &#8220;extensions/PrivateBlocks.php&#8221;, and add the following line to LocalSettings.php:</p>

<div class="wp_syntax"><div class="code"><pre class="php"><span style="color: #b1b100;">require_once</span><span style="color: #66cc66;">&#40;</span> <span style="color: #ff0000;">'extensions/PrivateBlocks.php'</span> <span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span></pre></div></div>

<p><span id="more-53"></span></p>

<div class="wp_syntax"><div class="code"><pre class="php"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
&nbsp;
<span style="color: #ff0000">$wgExtensionFunctions</span><span style="color: #66cc66;">&#91;</span><span style="color: #66cc66;">&#93;</span> <span style="color: #66cc66;">=</span> <span style="color: #ff0000;">&quot;wfPrivateBlocks&quot;</span><span style="color: #66cc66;">;</span>
<span style="color: #ff0000">$wgExtensionCredits</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">'parserhook'</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#91;</span><span style="color: #66cc66;">&#93;</span> <span style="color: #66cc66;">=</span> <span style="color: #000066;">array</span><span style="color: #66cc66;">&#40;</span>
        <span style="color: #ff0000;">'name'</span> <span style="color: #66cc66;">=&gt;</span> <span style="color: #ff0000;">'PrivateBlocks'</span><span style="color: #66cc66;">,</span>
        <span style="color: #ff0000;">'author'</span> <span style="color: #66cc66;">=&gt;</span> <span style="color: #ff0000;">'Aaron Parecki'</span><span style="color: #66cc66;">,</span>
        <span style="color: #ff0000;">'description'</span> <span style="color: #66cc66;">=&gt;</span> <span style="color: #ff0000;">'Adds &lt;nowiki&gt;&lt;private&gt;&lt;/nowiki&gt; tag for hiding text to non-registered users'</span><span style="color: #66cc66;">,</span>
        <span style="color: #ff0000;">'url'</span> <span style="color: #66cc66;">=&gt;</span> <span style="color: #ff0000;">'http://blog.neverusethisfont.com/2008/09/hiding-text-from-non-registered-users-in-mediawiki/'</span>
<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> wfPrivateBlocks<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
    <span style="color: #000066;">global</span> <span style="color: #ff0000">$wgParser</span><span style="color: #66cc66;">;</span>    
    <span style="color: #ff0000">$wgParser</span><span style="color: #66cc66;">-&gt;</span><span style="color: #006600;">setHook</span><span style="color: #66cc66;">&#40;</span> <span style="color: #ff0000;">&quot;private&quot;</span><span style="color: #66cc66;">,</span> <span style="color: #ff0000;">&quot;privateBlock&quot;</span> <span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
<span style="color: #66cc66;">&#125;</span>
&nbsp;
<span style="color: #808080; font-style: italic;"># The callback function for converting the input text to HTML output</span>
<span style="color: #000000; font-weight: bold;">function</span> privateBlock<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000">$input</span><span style="color: #66cc66;">,</span> <span style="color: #ff0000">$args</span><span style="color: #66cc66;">&#41;</span>
<span style="color: #66cc66;">&#123;</span>
	<span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span> <span style="color: #ff0000">$_SESSION</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">'wsUserID'</span><span style="color: #66cc66;">&#93;</span> <span style="color: #66cc66;">==</span> <span style="color: #cc66cc;">0</span> <span style="color: #66cc66;">&#41;</span>
	<span style="color: #66cc66;">&#123;</span>
		<span style="color: #b1b100;">return</span> <span style="color: #ff0000;">&quot;&quot;</span><span style="color: #66cc66;">;</span>
	<span style="color: #66cc66;">&#125;</span> 
	<span style="color: #b1b100;">else</span>
	<span style="color: #66cc66;">&#123;</span>
		<span style="color: #b1b100;">return</span> <span style="color: #ff0000">$input</span><span style="color: #66cc66;">;</span>
	<span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://neverusethisfont.com/blog/2008/09/hiding-text-from-non-registered-users-in-mediawiki/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Sorting a query in MySQL ignoring the word &#8220;The&#8221;</title>
		<link>http://neverusethisfont.com/blog/2008/04/sorting-a-query-in-mysql-ignoring-the-word-the/</link>
		<comments>http://neverusethisfont.com/blog/2008/04/sorting-a-query-in-mysql-ignoring-the-word-the/#comments</comments>
		<pubDate>Sun, 20 Apr 2008 04:50:12 +0000</pubDate>
		<dc:creator>aaron</dc:creator>
				<category><![CDATA[Website Development]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[sorting]]></category>
		<category><![CDATA[SQL]]></category>

		<guid isPermaLink="false">http://blog.neverusethisfont.com/2008/04/sorting-a-query-in-mysql-ignoring-the-word-the/</guid>
		<description><![CDATA[When you have a database of books or movies, some of the titles begin with &#8220;The.&#8221; If you do a regular ORDER BY on the table, all the titles that start with &#8220;the&#8221; get clumped together. One option is running an unsorted query and sorting in PHP, but it would be better to sort at [...]]]></description>
			<content:encoded><![CDATA[<p>When you have a database of books or movies, some of the titles begin with &#8220;The.&#8221; If you do a regular ORDER BY on the table, all the titles that start with &#8220;the&#8221; get clumped together. One option is running an unsorted query and sorting in PHP, but it would be better to sort at the database level. Here is a query I came up with to do that, using an IF function in MySQL!</p>

<div class="wp_syntax"><div class="code"><pre class="sql"><span style="color: #993333; font-weight: bold;">SELECT</span> * <span style="color: #993333; font-weight: bold;">FROM</span> movies
<span style="color: #993333; font-weight: bold;">ORDER</span> <span style="color: #993333; font-weight: bold;">BY</span> <span style="color: #993333; font-weight: bold;">IF</span><span style="color: #66cc66;">&#40;</span>SUBSTRING<span style="color: #66cc66;">&#40;</span>title,<span style="color: #cc66cc;">1</span>,<span style="color: #cc66cc;">4</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;The &quot;</span>,SUBSTRING<span style="color: #66cc66;">&#40;</span>title,<span style="color: #cc66cc;">5</span><span style="color: #66cc66;">&#41;</span>,name<span style="color: #66cc66;">&#41;</span></pre></div></div>

<p>Now create a custom function for that, and it&#8217;s even easier to use!</p>

<div class="wp_syntax"><div class="code"><pre class="sql"><span style="color: #993333; font-weight: bold;">CREATE</span> <span style="color: #993333; font-weight: bold;">FUNCTION</span> SORTNAME <span style="color: #66cc66;">&#40;</span>name VARCHAR<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">255</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> RETURNS VARCHAR<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">255</span><span style="color: #66cc66;">&#41;</span>
	<span style="color: #993333; font-weight: bold;">RETURN</span> <span style="color: #993333; font-weight: bold;">IF</span><span style="color: #66cc66;">&#40;</span> <span style="color: #66cc66;">&#40;</span>LCASE<span style="color: #66cc66;">&#40;</span>SUBSTRING<span style="color: #66cc66;">&#40;</span>name,<span style="color: #cc66cc;">1</span>,<span style="color: #cc66cc;">4</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">=</span> <span style="color: #ff0000;">'the '</span><span style="color: #66cc66;">&#41;</span>, SUBSTRING<span style="color: #66cc66;">&#40;</span>name,<span style="color: #cc66cc;">5</span><span style="color: #66cc66;">&#41;</span>, name <span style="color: #66cc66;">&#41;</span>;</pre></div></div>

<p>Now you can use it in a query like this:</p>

<div class="wp_syntax"><div class="code"><pre class="sql"><span style="color: #993333; font-weight: bold;">SELECT</span> * <span style="color: #993333; font-weight: bold;">FROM</span> movies
<span style="color: #993333; font-weight: bold;">ORDER</span> <span style="color: #993333; font-weight: bold;">BY</span> SORTNAME<span style="color: #66cc66;">&#40;</span>title<span style="color: #66cc66;">&#41;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://neverusethisfont.com/blog/2008/04/sorting-a-query-in-mysql-ignoring-the-word-the/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The Ultimate Web Developer Setup</title>
		<link>http://neverusethisfont.com/blog/2008/01/the-ultimate-web-developer-setup/</link>
		<comments>http://neverusethisfont.com/blog/2008/01/the-ultimate-web-developer-setup/#comments</comments>
		<pubDate>Thu, 10 Jan 2008 21:02:09 +0000</pubDate>
		<dc:creator>aaron</dc:creator>
				<category><![CDATA[Apple/os x]]></category>
		<category><![CDATA[Website Development]]></category>
		<category><![CDATA[Emulators]]></category>
		<category><![CDATA[VMware]]></category>

		<guid isPermaLink="false">http://blog.neverusethisfont.com/2008/01/the-ultimate-web-developer-setup/</guid>
		<description><![CDATA[Using VMware Fusion and Multiple IEs, I set up my iMac to run the four major browsers simultaneously! IE 7, IE6, Firefox and Safari. With a 1920&#215;1200 display, I can get all four to fit on the screen at once.

Click the image for the full-size version.
I no longer need to keep an extra Windows machine [...]]]></description>
			<content:encoded><![CDATA[<p>Using <a href="http://www.vmware.com/products/fusion/">VMware Fusion</a> and <a href="http://tredosoft.com/Multiple_IE">Multiple IEs</a>, I set up my iMac to run the four major browsers simultaneously! IE 7, IE6, Firefox and Safari. With a 1920&#215;1200 display, I can get all four to fit on the screen at once.</p>
<p><a href="/images/4browsers-full.jpg"><img src="/images/4browsers-mini.jpg" height="300" width="480"></a><br />
Click the image for the full-size version.</p>
<p>I no longer need to keep an extra Windows machine around here for debugging websites! &#8220;Multiple IEs&#8221; also can install IE 5.5, 5.1, 4 and 3, although I&#8217;m pretty sure those are almost completely irrelevant at this point.</p>
<p>One problem I did run into was that VMware in &#8220;Unity&#8221; mode didn&#8217;t seem to play well with Spaces. For example, sometimes after switching spaces a Windows app would lose focus and I wouldn&#8217;t be able to click it anymore. Switching to &#8220;Single Window&#8221; mode and then back again seemed to fix it.</p>
<p><b>Useful software:</b>
<ul>
<li><a href="http://www.vmware.com/products/fusion/">VMware Fusion</a></li>
<li><a href="http://tredosoft.com/Multiple_IE">Multiple IEs</a></li>
</ul>
<div id="zemanta-pixie" style="margin: 5px 0pt; width: 100%;"><a id="zemanta-pixie-a" href="http://www.zemanta.com/" title="Zemified by Zemanta"><img id="zemanta-pixie-img" src="http://img.zemanta.com/pixie.png?x-id=61fec7db-d7bc-41ff-b587-9ff576cc8627" style="border: medium none ; float: right;"></a></div>
]]></content:encoded>
			<wfw:commentRss>http://neverusethisfont.com/blog/2008/01/the-ultimate-web-developer-setup/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Stating the obvious: IE is a pain in the butt</title>
		<link>http://neverusethisfont.com/blog/2007/08/stating-the-obvious-ie-is-a-pain-in-the-butt/</link>
		<comments>http://neverusethisfont.com/blog/2007/08/stating-the-obvious-ie-is-a-pain-in-the-butt/#comments</comments>
		<pubDate>Mon, 27 Aug 2007 00:27:02 +0000</pubDate>
		<dc:creator>aaron</dc:creator>
				<category><![CDATA[Troubleshooting]]></category>
		<category><![CDATA[Website Development]]></category>

		<guid isPermaLink="false">http://blog.neverusethisfont.com/2007/08/stating-the-obvious-ie-is-a-pain-in-the-butt/</guid>
		<description><![CDATA[Thank you Brandon K! You just saved me 6 hours apparently:
from http://php.net/header

Brandon K [ brandonkirsch uses gmail ]
26-Apr-2007 01:04
I just lost six hours of my life trying to use the following method to send a PDF file via PHP to Internet Explorer 6:

header&#40;'Content-type: application/pdf'&#41;;
header&#40;'Content-Disposition: attachment; filename=&#34;downloaded.pdf&#34;'&#41;;
readfile&#40;'original.pdf'&#41;;

When using SSL, Internet Explorer will prompt with the Open [...]]]></description>
			<content:encoded><![CDATA[<p>Thank you Brandon K! You just saved me 6 hours apparently:</p>
<p>from <a href="http://php.net/header" >http://php.net/header</a></p>
<blockquote><p>
Brandon K [ brandonkirsch uses gmail ]<br />
26-Apr-2007 01:04<br />
I just lost six hours of my life trying to use the following method to send a PDF file via PHP to Internet Explorer 6:</p>

<div class="wp_syntax"><div class="code"><pre class="php"><span style="color: #000066;">header</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'Content-type: application/pdf'</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
<span style="color: #000066;">header</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'Content-Disposition: attachment; filename=&quot;downloaded.pdf&quot;'</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
<span style="color: #000066;">readfile</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'original.pdf'</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span></pre></div></div>

<p>When using SSL, Internet Explorer will prompt with the Open / Save dialog, but then says &#8220;The file is currently unavailable or cannot be found.  Please try again later.&#8221;  After much searching I became aware of the following MSKB Article titled &#8220;Internet Explorer file downloads over SSL do not work with the cache control headers&#8221; (KBID: 323308)</p>
<p>PHP.INI by default uses a setting: session.cache_limiter = nocache which modifies Content-Cache and Pragma headers to include &#8220;nocache&#8221; options.  You can eliminate the IE error by changing &#8220;nocache&#8221; to &#8220;public&#8221; or &#8220;private&#8221; in PHP.INI &#8212; This will change the Content-Cache header as well as completely remove the Pragma header.  If you cannot or do not want to modify PHP.INI for a site-wide fix, you can send the following two headers to overwrite defaults:</p>

<div class="wp_syntax"><div class="code"><pre class="php"><span style="color: #000066;">header</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'Cache-Control: maxage=3600'</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span> <span style="color: #808080; font-style: italic;">//Adjust maxage appropriately</span>
<span style="color: #000066;">header</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'Pragma: public'</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span></pre></div></div>

<p>You will still need to set the content headers as listed above for this to work.  Please note this problem ONLY effects Internet Explorer, while Firefox does not exhibit this flawed behavior.
</p></blockquote>
<p>Why can&#8217;t IE just play nice?<br />
<img src="/images/ie-devil-40.gif" align="right"></p>
]]></content:encoded>
			<wfw:commentRss>http://neverusethisfont.com/blog/2007/08/stating-the-obvious-ie-is-a-pain-in-the-butt/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
