<?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>Garrett Bluma &#187; Web Programming</title>
	<atom:link href="http://garrettbluma.com/category/web-programming/feed/" rel="self" type="application/rss+xml" />
	<link>http://garrettbluma.com</link>
	<description>Web Developer</description>
	<lastBuildDate>Wed, 08 Feb 2012 03:23:08 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>What Happened to Aspect-Oriented PHP?</title>
		<link>http://garrettbluma.com/2011/01/18/what-happened-to-aspect-oriented-php/</link>
		<comments>http://garrettbluma.com/2011/01/18/what-happened-to-aspect-oriented-php/#comments</comments>
		<pubDate>Wed, 19 Jan 2011 05:51:45 +0000</pubDate>
		<dc:creator>Garrett Bluma</dc:creator>
				<category><![CDATA[Best Practices]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Web Programming]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://garrettbluma.com/?p=382</guid>
		<description><![CDATA[AOPHP was apparently started in early 2005 as a research project by <a href="http://www.softwareengineeringonline.com/publications.htm">John Stamey</a> and <a href="http://bryansaunders.net/wordpress/">Bryan Saunders</a> but for unknown reasons it did not get popular and was loosely maintained for a number of years.  Since about 2007, the topic hasn't really been talked about much.]]></description>
			<content:encoded><![CDATA[<p><strong>It's not every day that you find a lost branch of a programming language.</strong> However, Aspect-Oriented PHP (AOPHP) is one such artifact.  Borrowing much from the general concept of AOP, it might have become a full-fledged extension of PHP, but for one reason or another, it never took off.</p>
<p><a href="http://en.wikipedia.org/wiki/Aspect-oriented_programming">Wikipedia </a> defines <a href="http://en.wikipedia.org/wiki/Aspect-oriented_programming">Aspect-Oriented Programming</a> (AOP) as:</p>
<blockquote><p>a programming paradigm which isolates secondary or supporting functions from the main program's business logic. It aims to increase modularity by allowing the separation of cross-cutting concerns, forming a basis for aspect-oriented software development.</p></blockquote>
<p>That's pretty dense, but basically AOP tries to solve the problem of fragmented code.  Object-Oriented Programming did the same thing by adding classes and objects. AOP attempts to solve a different problems (cross-cutting concerns) with different constructs, namely Aspects.   Despite the fact that there has been some traction in other languages such as <a href="http://www.voelter.de/data/articles/aop/aop.html">Java</a>, <a href="http://www.aspectc.org/fileadmin/publications/sdj-2005-en.pdf">C++</a> and <a href="http://www.dcl.hpi.uni-potsdam.de/research/loom/">C#</a>, a PHP variant never caught on.</p>
<p>AOPHP was apparently started in early 2005 as a research project by <a href="http://www.softwareengineeringonline.com/publications.htm">John Stamey</a> and <a href="http://bryansaunders.net/wordpress/">Bryan Saunders</a> but for unknown reasons it did not get popular and was loosely maintained for a number of years.  Since about 2007, the topic hasn't really been talked about much —  perhaps among other reasons, because PHP doesn't seem to attract the scholarly computer-science types.</p>
<h3>So what the heck is a Cross-Cutting Concern?</h3>
<p><strong>To explain what it IS, it helps to explain, first, what it's NOT. </strong> The classic example is that if you consider an XML parser in procedural terms you would probably create dozens of functions and each one would take a reference to some data structure.  There isn't any clear boundary or encapsulation between the XML parser code and production code.</p>
<p>If we take that same example and apply Object-Oriented Programming methodologies, you would have an XmlParser class with functions and references attached to it.   With OOP you get clear boundaries defined, and common code related to XML parsing stays in one localized place.</p>
<p>If I tried to explain AOP using the XML parser example, I would fail to do it justice.  AOP actually works very well alongside Object-Oriented programming.  But, a good example is a logging system.  No doubt you've written something like this.</p>
<pre class="php"><span style="color: #333333;">function</span> foo<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>
<span style="color: #66cc66;">&#123;</span>
    customLog<span style="color: #66cc66;">&#40;</span><span style="color: #aa3333;">&quot;starting foo&quot;</span><span style="color: #66cc66;">&#41;</span>;
    <span style="color: #808080; font-style: italic;">// ... do some work</span>
    customLog<span style="color: #66cc66;">&#40;</span><span style="color: #aa3333;">&quot;finished foo&quot;</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #66cc66;">&#125;</span></pre>
<p>The problem is that we repeat too much code.  A cross-cutting concern is one where related code (in this case, logging statements) is found scattered across an application.  Log calls are a good example because they are typically found all over an app.  If we, later, wanted to exchange our logging class for a different one, it would require updating every call (affecting many systems).  This would be a small issue with most websites, but if we're talking about corporate infrastructure code... Well, I wouldn't want to do it.</p>
<h3>How does AOPHP  solve these problems?</h3>
<p>AOP, as a theory, provides some interesting functionality.  For example, consider how difficult it would be to implement the phrase<em> "Wherever we get data from the database log the transaction and inputs." </em>Programming that could take weeks.  Just imagine modifying all of that (functioning) code and inserting the proper log statements for each situation.<strong> Errors would ensue.</strong> If code can smell, this one smells like duplication of effort.</p>
<p>Many programming languages try to simulate natural language with their syntax, and this is where AOP shines (theoretically).  We could produce some pseudocode like the following:</p>
<pre>before each database transaction
    log input parameters and a timestamp</pre>
<p>With AOPHP the implementation would look something like the following — very similar to the pseudocode.</p>
<pre class="php">aspect DatabaseLogging <span style="color: #66cc66;">&#123;</span>
    pointcut databaseAccess = execr<span style="color: #66cc66;">&#40;</span><a href="http://www.php.net/mysql_query"><span style="color: #333399;">mysql_query</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #3333cc;">$sql</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
    before<span style="color: #66cc66;">&#40;</span><span style="color: #3333cc;">$sql</span><span style="color: #66cc66;">&#41;</span>: databaseAccess <span style="color: #66cc66;">&#123;</span>
        customLog<span style="color: #66cc66;">&#40;</span><span style="color: #aa3333;">&quot;Accessing Database: {$sql}&quot;</span><span style="color: #66cc66;">&#41;</span>;
    <span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span></pre>
<p>Remember, this applies to every database call — <strong>and you don't need to write an adapter class! </strong></p>
<p>Okay, so it might not be a stellar example, but think about patching all those oddites of PHP that you already do.  Things like <a href="http://shiflett.org/articles/sql-injection">escaping variables</a>, <a href="http://en.wikipedia.org/wiki/Cross-site_request_forgery">CSRF protection</a>, <a href="http://stackoverflow.com/questions/328/php-session-security">session handling</a>, and various types of <a href="http://simonwillison.net/2003/Jun/17/theHolyGrail/">form validation</a>.  Personally I would love to have these features and not have to think about check every time I need them.</p>
<h3>Does PHP even need it?</h3>
<p>At this point, PHP probably doesn't need AOP.  There are enough Reflection API functions like <tt>__call</tt> and <tt>__get</tt> which allow a programmer to intercept function calls dynamically.  And the PHP developers seem to be having enough difficulty adapting to unicode... So this kind of stuff will probably remain for just language nerds like myself.  (And actually I'm not using, just writing about it.)  But certainly, much of the acclaim made about Ruby is due to it's metaprogramming — which is very AOP-esque.</p>
<h3>Notable attempts at Aspect-Oriented PHP:</h3>
<ul>
<li><a href="http://bryansaunders.net/wordpress/?s=aophp">AOPHP</a> (last updated 2007)</li>
<li><a href="http://www.cs.toronto.edu/~yijun/aspectPHP/">AspectPHP</a> (2005)</li>
<li><a href="http://www.phpclasses.org/package/3215-PHP-PHP-AOP-implementation-based-on-cache-compilation.html">Transparent PHP AOP</a> (2006)</li>
<li><a href="http://code.google.com/p/php-aop/">PHP-AOP</a> (???)</li>
</ul>
<p>(As far as I know, none of these are production ready.)</p>
]]></content:encoded>
			<wfw:commentRss>http://garrettbluma.com/2011/01/18/what-happened-to-aspect-oriented-php/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP Error Suppression Roundup</title>
		<link>http://garrettbluma.com/2010/12/20/php-error-suppression/</link>
		<comments>http://garrettbluma.com/2010/12/20/php-error-suppression/#comments</comments>
		<pubDate>Mon, 20 Dec 2010 22:12:42 +0000</pubDate>
		<dc:creator>Garrett Bluma</dc:creator>
				<category><![CDATA[Best Practices]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Web Programming]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://garrettbluma.com/?p=390</guid>
		<description><![CDATA[One of my personal rules of using PHP is to <strong>Never Suppress Errors</strong> <em>(except in production)</em>.  I follow this rule because it keeps me from shooting myself in the foot, and <em>generally I try to avoid that</em>.

PHP supports a number of different scope models for error suppression, which can be combined to produce sophisticated <em>(or atrocious)</em> use of errors. They seem to fall into a few categories; Per-environment, per-file, and per-command.

<strong>Per-Environment</strong> — Globally configured via PHP.ini, this is imperative for a production environments that you want to hide messy errors from. For example, you wouldn't want to hand out a stack trace to potential hacker or burden a casual user with cryptic error messages.  Error suppression at this level is usually smart and can be part of good security.

<strong>Per-File</strong> — PHP doesn't just enforce a single global rule, but also supports overriding the above environmental setting manually.  Since PHP is stateless, this change only applies to the current page lifespan, or until it is manually turned off — which can be useful for certain scenarios like showing errors. Or vice versa, not showing errors, the choice is yours.  Generally these statements are less than <em>sublime</em>, but all-in-all, they are easy enough to find and do only one thing.

<strong>Per-command</strong> — Finally, PHP supports per-command error suppression in the form of an 'at' symbol "@".  This is the one I have always told myself <strong>NEVER TO USE!</strong>  It's not that I'm paranoid, <strong>it's just impractical to go through ALL of your code</strong> and add/remove these symbols whenever you move to production.]]></description>
			<content:encoded><![CDATA[<p>One of my personal rules of using PHP is to <strong>Never Suppress Errors</strong> <em>(except in production)</em>.  I follow this rule because it keeps me from shooting myself in the foot, and <em>generally I try to avoid that</em>.</p>
<p>PHP supports a number of different scope models for error suppression, which can be combined to produce sophisticated <em>(or atrocious)</em> use of errors. They seem to fall into a few categories; Per-environment, per-file, and per-command.</p>
<p><strong>Per-Environment</strong> — Globally configured via PHP.ini, this is imperative for a production environments that you want to hide messy errors from. For example, you wouldn't want to hand out a stack trace to potential hacker or burden a casual user with cryptic error messages.  Error suppression at this level is usually smart and can be part of good security.</p>
<p><strong>Per-File</strong> — PHP doesn't just enforce a single global rule, but also supports overriding the above environmental setting manually.  Since PHP is stateless, this change only applies to the current page lifespan, or until it is manually turned off — which can be useful for certain scenarios like showing errors. Or vice versa, not showing errors, the choice is yours.  Generally these statements are less than <em>sublime</em>, but all-in-all, they are easy enough to find and do only one thing.</p>
<p><strong>Per-command</strong> — Finally, PHP supports per-command error suppression in the form of an 'at' symbol "@".  This is the one I have always told myself <strong>NEVER TO USE!</strong>  It's not that I'm paranoid, <strong>it's just impractical to go through ALL of your code</strong> and add/remove these symbols whenever you move to production.  These are often used like this:</p>
<pre class="php"><span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>DEBUG<span style="color: #66cc66;">&#41;</span>
    <a href="http://www.php.net/mysql_connect"><span style="color: #333399;">mysql_connect</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #3333cc;">$host</span>,<span style="color: #3333cc;">$user</span>,<span style="color: #3333cc;">$password</span>,<span style="color: #3333cc;">$db</span><span style="color: #66cc66;">&#41;</span> or <a href="http://www.php.net/die"><span style="color: #333399;">die</span></a><span style="color: #66cc66;">&#40;</span> <a href="http://www.php.net/mysql_error"><span style="color: #333399;">mysql_error</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#41;</span>;
<span style="color: #b1b100;">else</span>
    @<a href="http://www.php.net/mysql_connect"><span style="color: #333399;">mysql_connect</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #3333cc;">$host</span>,<span style="color: #3333cc;">$user</span>,<span style="color: #3333cc;">$password</span>,<span style="color: #3333cc;">$db</span><span style="color: #66cc66;">&#41;</span>;</pre>
<p>The danger with this code is that you're duplicating EVERYTHING just to hide an error.  Furthermore, most modules support decent error handling, so... I don't like it.</p>
<p>So, I've never been able to find a good use for it... <em>until, perhaps, now.</em></p>
<p>First, an aside; I've always had some beef with ternary expressions like the following:</p>
<pre class="php"><span style="color: #333333;">&lt;?php</span> <a href="http://www.php.net/echo"><span style="color: #333399;">echo</span></a> <span style="color: #66cc66;">&#40;</span><a href="http://www.php.net/isset"><span style="color: #333399;">isset</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #3333cc;">$dbResult</span>-&gt;<span style="color: #336633;">name</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> ? <span style="color: #3333cc;">$dbResult</span>-&amp;gt;name : <span style="color: #aa3333;">''</span> <span style="color: #333333;">?&gt;</span></pre>
<p>These are particularly odd because despite PHP's dynamic nature <strong>I still need to verify that EVERY variable exists</strong> before using it.  In contrast, in javascript if you access a variable that doesn't exist, you get a return type of <em>undefined</em>.  That's slick, if a bit confusing for newbies.  Beyond that, I've written this literally thousands of times, and I'm getting tired of it.  All for the purpose of avoiding the following error:</p>
<pre>Notice: undefined property $name; ...</pre>
<p>Every time I write this, I tell myself, <strong>Surely, there must be a better way.</strong></p>
<p>I've considered disabling "Notices" on PHP.ini (or even per-file), but truthfully I actually enjoy these errors; they allow me to avoid deprecated features and other little fixes a good developer keep track of.</p>
<p>So '@' fits for use in suppressing this particular Notice, but it doesn't stop there. The @ symbol also suppresses every other type of error and warning where applied.  <strong>It is therefore a dangerous tool.</strong> Much like Spiderman's powers, the @ must be used responsibly.</p>
<p>An example of this danger is <tt>@mysql_query()</tt>.  This can hide a version mismatch warning, an SQL syntax error, or it could hide a fatal error trying to explain that MySQL is not installed.  These are <em>dramatically different problems</em> and I don't trust my code enough to make an assumption about the errors I'm suppressing.</p>
<p>So using @ on a function seems dangerous, too much is happening that can be hidden.  Using @ on a variable however, seems like it should only suppress the error of whether or not it actually exists, which is exactly what I want.</p>
<pre class="php"><span style="color: #333333;">&lt;?php</span> <a href="http://www.php.net/echo"><span style="color: #333399;">echo</span></a> @<span style="color: #3333cc;">$dbResult</span>-&gt;<span style="color: #336633;">name</span>; <span style="color: #333333;">?&gt;</span></pre>
<p>Seems elegant enough. No unnecessary code.  Suppresses asinine notices, and apparently nothing else.</p>
<p>Now, I'm sure there are problems with this; aside from the fact that it's good practice to provide fallbacks.  I expect to see many problems with this choice, but <strong>I'll let you just tell me that I'm wrong.</strong></p>
<p>Thanks.</p>
]]></content:encoded>
			<wfw:commentRss>http://garrettbluma.com/2010/12/20/php-error-suppression/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Disable Mootools in Joomla 1.6</title>
		<link>http://garrettbluma.com/2010/12/18/disable-mootools-in-joomla-1-6/</link>
		<comments>http://garrettbluma.com/2010/12/18/disable-mootools-in-joomla-1-6/#comments</comments>
		<pubDate>Sun, 19 Dec 2010 01:14:38 +0000</pubDate>
		<dc:creator>Garrett Bluma</dc:creator>
				<category><![CDATA[Joomla]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Web Programming]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://garrettbluma.com/?p=404</guid>
		<description><![CDATA[Disabling Mootools in Joomla 1.5 was actually pretty simple.  All you need to to is add the following to your template above your head tag:

<pre lang="php"><?php 
    // at the top of your template
    $headers=$this->getHeadData();
    $headers['scripts'] = array();
    $this->setHeadData($headers);

    // make sure to eliminate any of the following
    //JHTML::_('behavior.framework', true);
    //JHTML::_('behavior.mootools', true);
?></pre>

In Joomla 1.6 this can remain the same if you adjust  a tiny bit of Joomla internals.  Specifically we need to modify the <tt>setHeadData()</tt> function in <tt>joomla16/libraries/joomla/document/html/html.php</tt> (around line 116).  

<pre lang="php">// original version
$this->_scripts = (isset($data['scripts']) &#038;& !empty($data['scripts'])) ? 
                  $data['scripts'] : $this->_scripts;

// updated version ( !empty() replaced with is_arrray() )
$this->_scripts = (isset($data['scripts']) &#038;& is_array($data['scripts'])) ? 
                  $data['scripts'] : $this->_scripts;</pre>

What this does is allow Joomla to accept an empty value for <tt>$headers['scripts']</tt> where it would previously reject it. 

Let me know if you have any questions.

Happy coding!]]></description>
			<content:encoded><![CDATA[<p>Disabling Mootools in Joomla 1.5 was actually pretty simple.  All you need to to is add the following to your template above your head tag:</p>
<pre class="php"><span style="color: #333333;">&lt;?php</span>
    <span style="color: #808080; font-style: italic;">// at the top of your template</span>
    <span style="color: #3333cc;">$headers</span>=<span style="color: #3333cc;">$this</span>-&gt;<span style="color: #336633;">getHeadData</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
    <span style="color: #3333cc;">$headers</span><span style="color: #66cc66;">&#91;</span><span style="color: #aa3333;">'scripts'</span><span style="color: #66cc66;">&#93;</span> = <a href="http://www.php.net/array"><span style="color: #333399;">array</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
    <span style="color: #3333cc;">$this</span>-&gt;<span style="color: #336633;">setHeadData</span><span style="color: #66cc66;">&#40;</span><span style="color: #3333cc;">$headers</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
    <span style="color: #808080; font-style: italic;">// make sure to eliminate any of the following</span>
    <span style="color: #808080; font-style: italic;">//JHTML::_('behavior.framework', true);</span>
    <span style="color: #808080; font-style: italic;">//JHTML::_('behavior.mootools', true);</span>
<span style="color: #333333;">?&gt;</span></pre>
<p>In Joomla 1.6 this can remain the same if you adjust  a tiny bit of Joomla internals.  Specifically we need to modify the <tt>setHeadData()</tt> function in <tt>joomla16/libraries/joomla/document/html/html.php</tt> (around line 116).  </p>
<pre class="php"><span style="color: #808080; font-style: italic;">// original version</span>
<span style="color: #3333cc;">$this</span>-&gt;_scripts = <span style="color: #66cc66;">&#40;</span><a href="http://www.php.net/isset"><span style="color: #333399;">isset</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #3333cc;">$data</span><span style="color: #66cc66;">&#91;</span><span style="color: #aa3333;">'scripts'</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span> &amp;&amp; !<a href="http://www.php.net/empty"><span style="color: #333399;">empty</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #3333cc;">$data</span><span style="color: #66cc66;">&#91;</span><span style="color: #aa3333;">'scripts'</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> ?
                  <span style="color: #3333cc;">$data</span><span style="color: #66cc66;">&#91;</span><span style="color: #aa3333;">'scripts'</span><span style="color: #66cc66;">&#93;</span> : <span style="color: #3333cc;">$this</span>-&gt;_scripts;
&nbsp;
<span style="color: #808080; font-style: italic;">// updated version ( !empty() replaced with is_arrray() )</span>
<span style="color: #3333cc;">$this</span>-&gt;_scripts = <span style="color: #66cc66;">&#40;</span><a href="http://www.php.net/isset"><span style="color: #333399;">isset</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #3333cc;">$data</span><span style="color: #66cc66;">&#91;</span><span style="color: #aa3333;">'scripts'</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span> &amp;&amp; <a href="http://www.php.net/is_array"><span style="color: #333399;">is_array</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #3333cc;">$data</span><span style="color: #66cc66;">&#91;</span><span style="color: #aa3333;">'scripts'</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> ?
                  <span style="color: #3333cc;">$data</span><span style="color: #66cc66;">&#91;</span><span style="color: #aa3333;">'scripts'</span><span style="color: #66cc66;">&#93;</span> : <span style="color: #3333cc;">$this</span>-&gt;_scripts;</pre>
<p>What this does is allow Joomla to accept an empty value for <tt>$headers['scripts']</tt> where it would previously reject it. </p>
<p>Let me know if you have any questions.</p>
<p>Happy coding!</p>
]]></content:encoded>
			<wfw:commentRss>http://garrettbluma.com/2010/12/18/disable-mootools-in-joomla-1-6/feed/</wfw:commentRss>
		<slash:comments>24</slash:comments>
		</item>
		<item>
		<title>NodeJS is (almost) gonna kill PHP</title>
		<link>http://garrettbluma.com/2010/10/14/nodejs-is-almost-gonna-kill-php/</link>
		<comments>http://garrettbluma.com/2010/10/14/nodejs-is-almost-gonna-kill-php/#comments</comments>
		<pubDate>Fri, 15 Oct 2010 00:50:07 +0000</pubDate>
		<dc:creator>Garrett Bluma</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[Web Programming]]></category>
		<category><![CDATA[nodejs]]></category>

		<guid isPermaLink="false">http://garrettbluma.com/?p=361</guid>
		<description><![CDATA[A few weeks back I posted that: NodeJS is gonna kill PHP There are some merits to that statement. NodeJS is moving along quickly, with new modules getting added daily. Many of the web methodologies transition easily to Node Javascript is a strong language with a strong history of development. Asynchronous from the top to the bottom. AWESOME! YOU GET TO USE ALL THE JAVASCRIPT YOU'VE EVER WRITTEN. (emphasis added) Atwood's Law (Anything that can be written in Javascript, will be written in Javascript) PHP is unable to advance. At the same time, I (almost) never consider an argument valid [...]]]></description>
			<content:encoded><![CDATA[<p>A few weeks back I posted that:</p>
<blockquote><p>NodeJS is gonna <strong>kill</strong> PHP</p></blockquote>
<p>There are some merits to that statement.</p>
<ul>
<li>NodeJS is moving along quickly, with new modules getting added daily.</li>
<li>Many of the web methodologies transition easily to Node</li>
<li>Javascript is a strong language with a strong history of development.</li>
<li>Asynchronous from the top to the bottom. AWESOME!</li>
<li>YOU GET TO USE ALL THE JAVASCRIPT YOU'VE EVER WRITTEN. (emphasis added)</li>
<li><a href="http://www.codinghorror.com/blog/2007/07/the-principle-of-least-power.html">Atwood's Law</a> (Anything that <em>can</em> be written in Javascript, <em>will</em> be written in Javascript)</li>
<li>PHP is unable to advance.</li>
</ul>
<p>At the same time, I (almost) never consider an argument valid unless there are counter-examples which help to paint a complete picture. If all I see is perfect, I must not be living in reality. As a side note, this is why if you ever listen to two programmers argue, you'll inevitably find that they will swap roles and start arguing against their original idea. It's really pretty funny if you watch for it. Regardless, I think the same rule is at play. We all want to explore the problem domain.</p>
<p>So what <em>are</em> the downsides to NodeJS (and <em>yes</em>, they do exist):</p>
<ul>
<li><strong>Non-Classical inheritance structure </strong>— It's hard enough teaching someone inheritance, I won't even venture to try to explain prototypes.</li>
<li><strong>Heavy usage of anonymous functions</strong> — Another tricky thing to teach.</li>
<li><strong>Lack of a sponsor company</strong> to direct development in advantageous directions</li>
<li><strong>Will probably never catch on in enterprise environments</strong> (due to last point)</li>
</ul>
<p>The nice thing about these problems that they are all pretty easy to overcome. John Resig has written a handy<a href="http://ejohn.org/blog/simple-javascript-inheritance/"> class that emulates classical inheritance</a>. And anonymous functions can be rewritten to work as named functions, so that's out. What's left is the difficult problem of having a stable platform that can be used by enterprise environments. In the end this is a social problem and it will just take successful companies to take the leap and others to follow.</p>
]]></content:encoded>
			<wfw:commentRss>http://garrettbluma.com/2010/10/14/nodejs-is-almost-gonna-kill-php/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Programming and Practice</title>
		<link>http://garrettbluma.com/2010/07/13/programming-and-practice/</link>
		<comments>http://garrettbluma.com/2010/07/13/programming-and-practice/#comments</comments>
		<pubDate>Wed, 14 Jul 2010 04:00:03 +0000</pubDate>
		<dc:creator>Garrett Bluma</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[Web Programming]]></category>
		<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://garrettbluma.com/?p=290</guid>
		<description><![CDATA[I’ve been thinking about practice lately—and about growth. Here are some thoughts: Programming is a complicated job. Many people see it as a craft, and as craftsmen, programmers must spend countless hours honing their skills and improving their expertise to reach a level to compete at the level they desire to be at. For example: If I want to build web pages at an amateur level, I simply need to know HTML, some CSS, and maybe some jQuery. For every question that might come up, there is usually a hundred answers on Google. If I want to do the same thing [...]]]></description>
			<content:encoded><![CDATA[<p>I’ve been thinking about practice lately—and about growth. Here are some thoughts:</p>
<p>Programming is a complicated job. Many people see it as a craft, and  as craftsmen, programmers must spend countless hours honing their skills  and improving their expertise to reach a level to compete at the level  they desire to be at. For example:</p>
<ul>
<li>If I want to build web pages at an <strong>amateur</strong> level, I  simply need to know HTML, some CSS, and maybe some jQuery. For every  question that might come up, there is usually a hundred answers on  Google.</li>
<li>If I want to do the same thing at an <strong>expert</strong> level, I  must know about usability, cross-browser compatibility, form  validation, race-condition debugging, and a host of other things—most  importantly, however, I should be able to find answers to problems that  are not Google-able.</li>
</ul>
<p>So if you’re shooting for your “A” game, you need to practice, right?.</p>
<p>But there’s a problem too. If <strong>anyone</strong> has an issue  with repetitiveness, it must be programmers. We have actually been  taught that the sole purpose for our job is to <em>reduce</em> repetitiveness. So where does that leave practice and doing things multiple times?</p>
<p>A lot of the programmers I know, who are really good, attribute their  success to the fact that they spend hours at home every night building  cool stuff or researching—I think the same could be said of artists and writers as well.</p>
<p>This is great, but let’s consider the following quote by Geoffrey Colvin (emphasis added).</p>
<blockquote><p>For example: <strong>Simply hitting a bucket of balls is not deliberate practice</strong>, which is why most golfers don’t get better. Hitting an eight-iron 300 times <strong>with a goal</strong> of leaving the ball within 20 feet of the pin 80 percent of the time, <strong>continually observing results</strong> and <strong>making appropriate adjustments</strong>, and doing that <strong>for hours every day</strong> - that’s deliberate practice.</p></blockquote>
<p>So let’s make an assumption—perhaps an incorrect one, but bear with me.</p>
<blockquote><p>Most programmers are not <em>deliberate</em> about <strong>what</strong> they practice or how they grow. They <strong>do not</strong> set clear goals, they <strong>do not</strong> continually measure results, however they <strong>are</strong> spending the necessary time.</p></blockquote>
<p>Why are we just like the golfers?—”simply hitting a bucket of balls.”</p>
<ul>
<li> <strong>Programmers don't get out enough. <span style="font-weight: normal;">In particular with other that practice the same craft.</span></strong><strong> </strong></li>
<li> <strong>It’s still a fairly new craft. </strong>Many <em>outsiders </em>(your family, bosses, etc.) still think  that we just “know computers” and they come to us for everything  relating to computers. To them cleaning viruses and building web-pages  are the same thing. So, to cater to their needs, we are often forced to  become jacks-of-all-trades.</li>
<li> <strong>The web it too noisy</strong>. How do we judge what is important  given the thousands of new articles written every day? The best thing we  can do is probably unplug from the web and go for a walk.</li>
</ul>
<p>Here are some possible solutions. Certainly not an exhaustive list, but something to get started with.</p>
<ul>
<li> <strong>Local user groups.</strong> These allow for interaction, they expose people to higher-level talks and foster an environment for learning beyond amateur.</li>
<li> <strong>Set clear learning goals </strong>like “I want to understand exactly how Object Oriented CSS works” or “Find out mathematically if database XYZ can scale for a certain use-case”.</li>
<li> <strong>Continually measure results</strong>. Progress is important and  it might seem daunting that understanding CSS in 13 browsers is a  huge task, but every time you check one off, you’ll feel good about it.</li>
</ul>
<p>And although I don’t follow my own advice fully yet, I’ve determined to move forward with some of my own goals:</p>
<ul>
<li>Develop a system for building web UI applications that actually simplifies things.</li>
<li>Start a user group to empower other developers and designers.</li>
<li>Build tools that empower people.</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://garrettbluma.com/2010/07/13/programming-and-practice/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Joomla Sphinx Search Plugin</title>
		<link>http://garrettbluma.com/2010/02/16/joomla-sphinx-search-plugin/</link>
		<comments>http://garrettbluma.com/2010/02/16/joomla-sphinx-search-plugin/#comments</comments>
		<pubDate>Wed, 17 Feb 2010 02:26:15 +0000</pubDate>
		<dc:creator>Garrett Bluma</dc:creator>
				<category><![CDATA[Joomla]]></category>
		<category><![CDATA[Web Programming]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[Sphinx]]></category>

		<guid isPermaLink="false">http://garrettbluma.com/?p=212</guid>
		<description><![CDATA[Beware, this is beta quality software. Use at your own risk. As we understand already, Joomla doesn't have relevant searching. It's a shame since everything else is designed well, but this is a problem regarding implementation. This article explains how to setup sphinx to index your Joomla articles and use my plugin to search using Joomla. In my own experiments I built a plugin that accomplished this. It works splendidly, and I had all intention of releasing the code to the public, but got distracted. This process is currently unrefined, but it works. I'm a fan of revision anyway, so [...]]]></description>
			<content:encoded><![CDATA[<p class="dropshadow"><img class="alignnone size-full wp-image-218" title="sphinx-horse" src="http://garrettbluma.com/wp-content/uploads/2010/02/sphinx-horse.jpg" alt="" width="580" height="252" /></p>
<blockquote><p><strong>Beware, this is beta quality software. Use at your own risk.</strong></p></blockquote>
<p>As we understand already, Joomla doesn't have relevant searching. It's a shame since everything else is designed well, but this is a problem regarding implementation. This article explains how to setup sphinx to index your Joomla articles and use my plugin to search using Joomla.</p>
<p>In my own experiments I built a plugin that accomplished this. It works splendidly, and I had all intention of releasing the code to the public, but got distracted. This process is currently unrefined, but it works. I'm a fan of revision anyway, so if you see a way to improve this article, hit me up (email).</p>
<p><strong>So why doesn't Joomla have relevant searching already?</strong> — Unfortunately it doesn't seem like they had much choice about it. Joomla relies on MySQL. MySQL is just now beginning to get some Full-Text searching mechanisms implemented and those that do exist are spotty. For example, it is only available in recent versions of the MyISAM database engine and not at all for InnoDB. Plus, I've heard some complaints about it not even being terribly good at it's own job.</p>
<p>A system like Sphinx can go beyond what MySQL supports anyway. It can use word stems and substitutions, so I could specify <tt>CPP</tt> to be used interchangeably with <tt>C++</tt> in any search query and it doesn't get confused about plural or singular versions of words. It also supports weights, so I can tell Sphinx to prefer matches found in titles and move them higher in the search results.</p>
<h3>Install &amp; Configure Sphinx</h3>
<p>There are a number of good articles on the web about this. I may revisit how to install Sphinx in detail, but for now defer to the follow links:</p>
<ul>
<li><a href="http://www.sphinxsearch.com/docs/current.html#installation">Sphinx Homepage</a> — <em>Obviously the first place to start looking is the Sphinx homepage. Good documentation on Sphinx operation and internals.</em></li>
<li><a href="http://www.ibm.com/developerworks/library/os-php-sphinxsearch/">Build a custom search engine with PHP</a> — <em>IBM has a great article on using Sphinx in-the-field. This article describes setup of Sphinx as well as testing and integration with PHP.</em></li>
</ul>
<p>Here is my configuration I've been using for my Joomla Setup. This is basically the same as any configuration setup on IBM's website, but adapted to Joomla. There are a few things you'll need to edit though:</p>
<ul>
<li><tt>exampleuser</tt> — <em>This should be the username you connect with to search your database</em></li>
<li><tt>examplepass</tt> — <em>This should be the password for the username just described</em></li>
<li><tt>exampledb</tt> — <em>This is the database sphinx will be searching on.</em></li>
<li>Check your paths. I'm making some assumptions here. Your sphinx data should be outside of your web-root and readable/writable by whatever process <tt>searchd</tt> is running as.</li>
</ul>
<p><strong>/var/www/website/sphinx/config.conf:</strong></p>
<pre><code>
source mywebsite_articles
{
    type            = mysql
    sql_host        = localhost
    sql_user        = exampleuser
    sql_pass        = examplepassword
    sql_db          = exampledb
    sql_sock        = /var/run/mysqld/mysqld.sock
    sql_port        = 3306

    # indexer query
    # document_id MUST be the very first field
    # document_id MUST be positive (non-zero, non-negative)
    # document_id MUST fit into 32 bits
    # document_id MUST be unique

    sql_query = \
        SELECT `id`, `title`, `alias`, `introtext`, `fulltext`, `created`, `modified`, `hits` \
        FROM jos_content ;

    # document info query
    # ONLY used by search utility to display document information
    # MUST be able to fetch document info by its id, therefore
    # MUST contain '$id' macro
    #

    sql_query_info = \
        SELECT * \
        FROM jos_content  \
        WHERE id=$id
}
index mywebsite_articles
{
    source                  = mywebsite_articles
    path                    = /var/www/website/data
    morphology              = none

    min_word_len            = 3
    min_prefix_len          = 0
    min_infix_len           = 3
}

searchd
{
    port          = 3312
    log           = /var/www/website/sphinx/search.log
    query_log     = /var/www/website/sphinx/query.log
    pid_file      = /var/www/website/sphinx/searchd.pid
}
</code></pre>
<h3>Testing Sphinx</h3>
<p>How do we know if Sphinx is setup correctly? We test it!</p>
<p>First we need to generate the index. So fire up your terminal and run the following (assuming your sphinx install lives in /usr/local/sphinx):</p>
<pre><code>
/usr/local/sphinx/bin/indexer \
--config /var/www/website/sphinx/config.conf \
--all --rotate
</code></pre>
<p>Second we need to start the search daemon. This will process search requests.</p>
<pre><code>
/usr/local/sphinx/bin/searchd \
--config /var/www/website/sphinx/config.conf
</code></pre>
<p>If you get any errors, I'd recommend going back and reviewing the configuration and re-running the indexer, then start searchd again.</p>
<p>If we don't have any errors, we can run a test outside of Joomla to see if everything is working correctly. For example:</p>
<pre><code>/usr/local/sphinx/bin/search \
--config /var/www/website/sphinx/config.conf \
"Hello world"</code></pre>
<h3>Install &amp; Configure Joomla Plugin</h3>
<p>You can download the plugin here (<a href="http://garrettbluma.com/track.php?file=http%3A%2F%2Fgarrettbluma.com/code/sphinx/plgSphinxContent-v1.zip">Download</a>) or at the bottom of this article.</p>
<p class="dropshadow"><img class="aligncenter size-full wp-image-231" title="Sphinx Plugin Upload" src="http://garrettbluma.com/wp-content/uploads/2010/02/Screen-shot-2010-02-16-at-6.49.47-PM.png" alt="Sphinx Plugin Upload" width="528" height="206" /></p>
<p>Enable the plugin. Be sure to turn off other search modules while you're at it. It is much easier to determine if your search results are isolated to one plugin.</p>
<p class="dropshadow"><img class="aligncenter size-full wp-image-232" title="Enable Plugin" src="http://garrettbluma.com/wp-content/uploads/2010/02/Screen-shot-2010-02-16-at-6.50.51-PM.png" alt="Enable Plugin" /></p>
<p class="dropshadow"><img class="aligncenter size-full wp-image-235" title="Configure Sphinx Plugin" src="http://garrettbluma.com/wp-content/uploads/2010/02/Screen-shot-2010-02-16-at-6.52.43-PM.png" alt="Configure Sphinx Plugin" width="514" height="229" /></p>
<p>If you are hosting Sphinx on the same server as your web service, you'll probably want to keep these similar to what I have. Otherwise, be sure to fill-in the appropriate fields here and configure any firewalls that may be between the web server and the Sphinx server.</p>
<p>You will also want to be careful to use the same name of your index defined in your config file. In my example I'm using <tt>mywebsite_articles</tt>. This is what I fill-in for <em>Resource Name.</em></p>
<h3>Test Sphinx Plugin</h3>
<p>The only thing left to do now is to actually test the thing. Go to your website and do a search!</p>
<h3>Completing the solution</h3>
<p>There are a few things still missing from this setup that I want you to be aware of.</p>
<p>First, if you don't update your index periodically, you will only see the content that you indexed the first time. One solution is to setup a scheduled task (or cron) to re-index your content. Notice as well I put <tt>--rotate</tt> at the end of my indexing operation. Once Sphinx has updated the index, it will begin to use the new index to search with. You don't need to restart your <tt>searchd</tt> process, just update the index.</p>
<p>Second, you should be aware that if your server restarts you'll need <tt>searchd</tt> to start automatically. An init script would work great, even something as simple as this:</p>
<p><strong>/etc/init.d/searchd</strong></p>
<pre><code>
#! /bin/sh
NAME=sphinx
DAEMON=/usr/local/sphinx/bin/searchd
CONFIG=/var/www/website/sphinx/config.conf
[ -x "$DAEMON" ] || exit 0
case "$1" in
  start)
    echo "Stopping any running daemons..."
    $DAEMON --config $CONFIG --stop
    echo "Starting sphinx search daemon..."
    $DAEMON --config $CONFIG
    ;;
  stop)
    echo "Stopping sphinx search daemon..."
    $DAEMON --config $CONFIG --stop
    ;;
  *)
    echo "Usage: $NAME {start|stop}"
    exit 3
    ;;
esac
:
</code></pre>
<p><div class='download-link'>
							<a href='http://garrettbluma.com/track.php?file=http%3A%2F%2Fgarrettbluma.com/code/sphinx/plgSphinxContent-v2.zip'><img alt='Download' class='leftalign' src='http://garrettbluma.com/wp-content/plugins/dBeautifier/icons/tar.png' /></a>
							<h4>
								<a href='http://garrettbluma.com/track.php?file=http%3A%2F%2Fgarrettbluma.com/code/sphinx/plgSphinxContent-v2.zip'>plgSphinxContent-v2.zip (Sphinx Search Plugin)</a>
							</h4><p>Downloads: 162 File Size: 0.0 KB </p>
						</div></p>
]]></content:encoded>
			<wfw:commentRss>http://garrettbluma.com/2010/02/16/joomla-sphinx-search-plugin/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
		<item>
		<title>Caching in Joomla 1.5 with Fault Tolerance</title>
		<link>http://garrettbluma.com/2009/12/20/programmatic-caching-in-joomla-1-5-with-fault-tolerance/</link>
		<comments>http://garrettbluma.com/2009/12/20/programmatic-caching-in-joomla-1-5-with-fault-tolerance/#comments</comments>
		<pubDate>Sun, 20 Dec 2009 18:00:43 +0000</pubDate>
		<dc:creator>Garrett Bluma</dc:creator>
				<category><![CDATA[Joomla]]></category>
		<category><![CDATA[Web Programming]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://www.garrettbluma.com/?p=154</guid>
		<description><![CDATA[If you've used Joomla before, you may be aware that there are built-in caching features which you can activate to reduce the number of expensive database calls needed to render a page. This feature is also available to your own custom code, whether that be in the form of components, modules, or plugins. The actual mileage for this feature may vary due to the speed of the server and what Joomla decides to cache. Personally I think Joomla's use of caching, specifically how they use it for articles, leaves something to be desired. The downsides include content that doesn't get [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align:center"><img src="http://www.garrettbluma.com/images/posts/fault-tolerant-caching-overview.png" alt="Overview" /></p>
<p>If you've used Joomla before, you may be aware that there are built-in caching features which you can activate to reduce the number of expensive database calls needed to render a page. This feature is also available to your own custom code, whether that be in the form of components, modules, or plugins.</p>
<p>The actual mileage for this feature may vary due to the speed of the server and what Joomla decides to cache. Personally I think Joomla's use of caching, specifically how they use it for articles, leaves something to be desired. The downsides include content that doesn't get flushed out once it has changed or content that has too short of a lifetime to prove useful. Because of this, I don't think lot of developers realize that you can use it to cache your own components, plugins, and modules reliably and without affecting the user experience in a negative way, all the while in a modest environment (i.e. a server environment that doesn't have special software like memcached installed.)</p>
<p>You might consider implementing a little caching if:</p>
<ul>
<li>Your code is heavy and slow <em>(Don't take it personally, mine is too sometimes)</em></li>
<li>Your code is high-latency requiring network resources that may or may not actually be available</li>
<li>You have a crazy number of visitors and your database is becoming a significant bottleneck</li>
</ul>
<p>In my own recent project I was able to improve my access times of some SOAP requests by 500% (~1 second/request down to ~200ms/request).</p>
<h3>Let's get our bearings</h3>
<p style="text-align:center"><img src="http://www.garrettbluma.com/images/posts/fault-tolerant-caching-functions.png" alt="Overview" /></p>
<p>Here's a basic example of some code which initializes a JCache object and get's some data using it. You'll notice that there are two functions, one which just generically gets some data <tt>getData</tt> and another function <tt>getDataCached</tt> which instantiates the cache and calls <tt>getData</tt>. We need to do this so that our cache is aware of what the inputs and outputs are, that way it can do a lookup on the cache and return data without ever touching <tt>getData</tt>. </p>
<p><strong>com_cachetest/cachetest.php:</strong></p>
<pre><code class="php">
class CacheTest {
    function getData($url) {
        // ... Get some data

        // in this case, I'm just returning some dummy data instead of
        // downloading a web page which if we plan for the worst case scenario,
        // might not be available.

        $data = $url;

        // send data back
        return $data;
    }
    function getDataCached($url) {

        $group = "cachetest";
        $function = array("CacheTest", "getData");

        // get a cache object and name it something useful
        $cache =&amp; JFactory::getCache( $group );
        $cache->setCaching( 1 ); // enable caching (1 = enabled, 0 = disabled)

        // call our function "getData" through the cache
        $result = $cache->call( $function , $url);

        return $result;
    }
}

$data = CacheTest::getDataCached( "http://example.com" );
var_dump($data); // to see what we actually get
</code></pre>
<h3>Fault Tolerant Caching</h3>
<p>One issue in the above example is that if <tt>getData</tt> returns some bogus data, it's going to be stuck in the cache and you won't realize it until it's too late. This isn't a likely scenario for a quick database call but if you have a network request that is waiting and waiting and eventually reaches timeout, the cached data will possibly be empty. This can be problematic but it's also easily avoided. In the following example we do a quick check to see if the data is invalid, remove the old data and get a fresh copy. </p>
<p><strong>com_cachetest/cachetest.php:</strong></p>
<pre><code class="php">
class CacheTest {
    function getData($url) {
        // ... Get some data

        // in this case, I'm just returning some dummy data instead of
        // downloading a web page which if we plan for the worst case scenario,
        // might not be available.

        $data = $url;

        // send data back
        return $data;
    }

    function getDataCached($url) {

        $group = "cachetest";
        $function = array("CacheTest", "getData");

        // get a cache object and name it something useful
        $cache =&amp; JFactory::getCache( $group );
        $cache->setCaching( 1 ); // enable caching (1 = enabled, 0 = disabled)

        // call our function "getData" through the cache
        $result = $cache->call( $function, $url);

        // Check if we get sane data. Depending on your data this
        // could be more than just an empty check
        if ( empty( $result ) ) {

            // find the id to remove data for
            $id = $cache->_makeId( $function, $url );

            // invalidate this entry in the cache
            $cache->remove( $id, $group );

            // call our function again knowing the cache has been fixed
            $result = $cache->call( $function, $url );
        }
        return $result;
    }
}
$data = CacheTest::getDataCached( "http://example.com" );
var_dump($data); // to see what we actually get
</code></pre>
<h3>In Closing</h3>
<p>Joomla's caching API is simple and, by default, just writes these cache files to disk. Although not the fastest approach the default options are really handy for a less-than-stellar server setup. These caching options are available to even shared hosts. At the same time, I should mention that Joomla has done a fantastic job of integrating support for more advanced caching systems like <a href="http://memcached.org/">memcache</a> and <a href="http://xdebug.org/">xdebug</a> so that the above code can be run even faster without any modifications.</p>
<p><div class='download-link'>
							<a href='http://garrettbluma.com/track.php?file=http%3A%2F%2Fgithub.com/gbluma/joomla-caching-example/tree/master/.git'><img alt='Download' class='leftalign' src='http://garrettbluma.com/wp-content/plugins/dBeautifier/icons/github.png' /></a>
							<h4>
								<a href='http://garrettbluma.com/track.php?file=http%3A%2F%2Fgithub.com/gbluma/joomla-caching-example/tree/master/.git'>joomla-caching-example.git (Programmatic Caching in Joomla 1.5 with Fault Tolerance)</a>
							</h4><p>Downloads: 159 File Size: 0.0 KB </p>
						</div></p>
]]></content:encoded>
			<wfw:commentRss>http://garrettbluma.com/2009/12/20/programmatic-caching-in-joomla-1-5-with-fault-tolerance/feed/</wfw:commentRss>
		<slash:comments>16</slash:comments>
		</item>
		<item>
		<title>IE Caching Ajax Requests When It Shouldn&#8217;t</title>
		<link>http://garrettbluma.com/2009/08/17/ie-caching-ajax-requests-when-it-shouldnt/</link>
		<comments>http://garrettbluma.com/2009/08/17/ie-caching-ajax-requests-when-it-shouldnt/#comments</comments>
		<pubDate>Mon, 17 Aug 2009 17:09:21 +0000</pubDate>
		<dc:creator>Garrett Bluma</dc:creator>
				<category><![CDATA[Web Programming]]></category>
		<category><![CDATA[internet explorer]]></category>
		<category><![CDATA[Javascript]]></category>

		<guid isPermaLink="false">http://www.garrettbluma.com/?p=136</guid>
		<description><![CDATA[I've noticed some difficulty in Ajax controls not working correctly in IE (any version). This may be old news for many of you, but I'm going to post it anyway—hopefully someone will use it. The Problem: Ajax requests don't seem to be working in IE, but there aren't any error messages and nothing fails like you'd expect it to—the only real issue is that the content is not updating. Everything works as expected in Firefox, Safari, Chrome, etc. The Solution: This problem is because IE has aggressive caching in place for Ajax requests. This is bad. Why is this bad? [...]]]></description>
			<content:encoded><![CDATA[<p>I've noticed some difficulty in Ajax controls not working correctly in IE (any version). This may be old news for many of you, but I'm going to post it anyway—hopefully someone will use it.</p>
<p><strong>The Problem:</strong></p>
<p>Ajax requests don't seem to be working in IE, but there aren't any error messages and nothing fails like you'd expect it to—the only real issue is that the content is not updating. Everything works as expected in Firefox, Safari, Chrome, etc.</p>
<p><strong>The Solution:</strong></p>
<p>This problem is because IE has aggressive caching in place for Ajax requests. This is bad. Why is this bad? Because we commonly use Ajax to refresh content and make updates to our data. Unless we make some updates to our code, we will see stale information and mislead our visitors.</p>
<p>We can fix this pretty easily though. Some people claim that by switching our GET requests to POST that we'll solve the problem at hand. I didn't have any luck with that. Instead if you assign a header explicitly telling the browser to invalidate the page after viewing it, you can prevent IE from caching the page.</p>
<p>In PHP you do it like this:</p>
<div>
<div><code><span style="color: #000000;"> <span style="color: #0000bb;">&lt;?php<br />
header</span><span style="color: #007700;">(</span><span style="color: #dd0000;">"Cache-Control: no-cache, must-revalidate"</span><span style="color: #007700;">); </span><span style="color: #ff8000;"><br />
</span><span style="color: #0000bb;">header</span><span style="color: #007700;">(</span><span style="color: #dd0000;">"Expires: Sat, 26 Jul 1997 05:00:00 GMT"</span><span style="color: #007700;">); </span><span style="color: #ff8000;">// Date in the past<br />
</span><span style="color: #0000bb;">?&gt;</span> </span> </code></div>
</div>
]]></content:encoded>
			<wfw:commentRss>http://garrettbluma.com/2009/08/17/ie-caching-ajax-requests-when-it-shouldnt/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Using Cufon for Text Replacement</title>
		<link>http://garrettbluma.com/2009/04/03/using-cufon-for-text-replacement/</link>
		<comments>http://garrettbluma.com/2009/04/03/using-cufon-for-text-replacement/#comments</comments>
		<pubDate>Sat, 04 Apr 2009 03:37:12 +0000</pubDate>
		<dc:creator>Garrett Bluma</dc:creator>
				<category><![CDATA[Web Programming]]></category>
		<category><![CDATA[cufon]]></category>
		<category><![CDATA[text]]></category>
		<category><![CDATA[text replacement]]></category>

		<guid isPermaLink="false">http://www.garrettbluma.com/?p=56</guid>
		<description><![CDATA[A basic example of how to use cufon for font replacement.]]></description>
			<content:encoded><![CDATA[<p>Up until a few days ago I didn't realize that you could use canvas tags for text-replacment, but then I read this article.</p>
<p><a href="http://kilianvalkhof.com/2009/javascript/cufon-vs-typefacejs-which-one-is-better/">http://kilianvalkhof.com/2009/javascript/cufon-vs-typefacejs-which-one-is-better/</a></p>
<p>Since reading about this article I've want to play with Cufón to see how it stacks up. Here's a little example for you.</p>
<h1 id="cufon_example">Using Cufón for Text Replacement, an Example</h1>
<p>and the source (<tt>SF_Foxboro_Script_400.font.js</tt> generated at <a href="http://cufon.shoqolate.com/generate/">http://cufon.shoqolate.com/generate/</a> ):</p>
<pre>&lt;script src="http://cufon.shoqolate.com/js/cufon-yui.js"
    type="text/javascript"&gt;&lt;/script&gt;
&lt;script src="/code/cufon/SF_Foxboro_Script_400.font.js"
    type="text/javascript"&gt;&lt;/script&gt;

&lt;script type="text/javascript"&gt;&lt;!--
    Cufon.replace('h1');
// --&gt;&lt;/script&gt;</pre>
<p>Not the greatest example, but it works.</p>
<p>In conclusion, I like this approach in theory. I'm still not sure if it is a "too fast to notice", so I think I'll stick to the ugly web-fonts—but I love the fact that people are stepping outside of the box and being unconventional. Props for that!</p>
<p><script src="http://cufon.shoqolate.com/js/cufon-yui.js" type="text/javascript"></script> <script src="/code/cufon/SF_Foxboro_Script_400.font.js" type="text/javascript"></script></p>
<p><script type="text/javascript"><!--
    Cufon.replace( document.getElementById('cufon_example') );
// --></script></p>
]]></content:encoded>
			<wfw:commentRss>http://garrettbluma.com/2009/04/03/using-cufon-for-text-replacement/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Page Caching using memcached
Database Caching 9/25 queries in 0.004 seconds using memcached
Object Caching 515/547 objects using memcached

Served from: garrettbluma.com @ 2012-02-08 01:08:43 -->
