<?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>Tom Milewski</title>
	<atom:link href="http://blog.tommilewski.net/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.tommilewski.net</link>
	<description></description>
	<lastBuildDate>Mon, 06 Jul 2009 15:48:19 +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>Testing ActionMailer with RSpec</title>
		<link>http://blog.tommilewski.net/2009/07/testing-actionmailer-with-rspec/</link>
		<comments>http://blog.tommilewski.net/2009/07/testing-actionmailer-with-rspec/#comments</comments>
		<pubDate>Mon, 06 Jul 2009 15:48:19 +0000</pubDate>
		<dc:creator>Tom</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Ruby on Rails]]></category>

		<guid isPermaLink="false">http://blog.tommilewski.net/?p=139</guid>
		<description><![CDATA[This simple tutorial will show you how to test ActionMailer with RSpec.]]></description>
			<content:encoded><![CDATA[<p>Find the file &#8217;spec/spec_helper.rb&#8217; and place the following code into the Spec::Runner.configure method:<br />
<script src="http://gist.github.com/141491.js"></script><br />
This will populate the deliveries array with every sent email and can be accessed in you tests like such:<br />
<script src="http://gist.github.com/141496.js"></script><br />
Test away!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.tommilewski.net/2009/07/testing-actionmailer-with-rspec/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Easily Toggle a Boolean Value with SQL</title>
		<link>http://blog.tommilewski.net/2009/06/easily-toggle-a-boolean-value-with-sql/</link>
		<comments>http://blog.tommilewski.net/2009/06/easily-toggle-a-boolean-value-with-sql/#comments</comments>
		<pubDate>Wed, 24 Jun 2009 18:45:38 +0000</pubDate>
		<dc:creator>Tom</dc:creator>
				<category><![CDATA[MySQL]]></category>

		<guid isPermaLink="false">http://blog.tommilewski.net/?p=133</guid>
		<description><![CDATA[Here's how you can simply and easily toggle a boolean field using only SQL]]></description>
			<content:encoded><![CDATA[<p>Here&#8217;s how you can simply and easily toggle a boolean field using only SQL:</p>
<p>UPDATE [table] SET [field] = 1 XOR [field] WHERE [conditions]</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.tommilewski.net/2009/06/easily-toggle-a-boolean-value-with-sql/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Custom Error Pages in Rails</title>
		<link>http://blog.tommilewski.net/2009/05/custom-error-pages-in-rails/</link>
		<comments>http://blog.tommilewski.net/2009/05/custom-error-pages-in-rails/#comments</comments>
		<pubDate>Tue, 05 May 2009 18:53:12 +0000</pubDate>
		<dc:creator>Tom</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Ruby on Rails]]></category>

		<guid isPermaLink="false">http://blog.tommilewski.net/?p=124</guid>
		<description><![CDATA[The standard error pages in Ruby on Rails do not allow for enough customization and for a framework that advocates DRY (Don't Repeat Yourself) techniques, well, it's somewhat of a problem.]]></description>
			<content:encoded><![CDATA[<p>The standard error pages in Ruby on Rails do not allow for enough customization and for a framework that advocates DRY (Don&#8217;t Repeat Yourself) techniques, well, it&#8217;s somewhat of a problem. You aren&#8217;t able to embed dynamic code and because of this you also have to repeat the code for your layouts.</p>
<p>So how do we fix this?</p>
<h3><strong>The Controller</strong></h3>
<p>In Rails we much override <em>render_optional_error_file</em>.</p>
<p>So, in <em>app/controllers/application_controller.rb </em>we must add the following code:</p>
<p><script src="http://gist.github.com/107123.js"></script> What this does is it recieves the error code and, rather than send out the static error pages to the client, it sends out the new rendered error pages located in the views.</p>
<h3><strong>The Views</strong></h3>
<p>According to the code above we will need to create a folder within <em>views</em> called <em>errors</em>.  We will then create the following views:</p>
<ul>
<li>404.html.erb</li>
<li>422.html.erb</li>
<li>500.html.erb</li>
<li>unknown.html.erb</li>
</ul>
<p>What you put in these views is entirely up to you.</p>
<h3><strong>Testing</strong></h3>
<p><strong></strong> In order to test this on your local machine you must insert the following code also into <em>app/controllers/application_controller.rb</em>:  <script src="http://gist.github.com/107128.js"></script><br />
Just remember to remove this last bit of code before pushing your application to your staging and/or production environments!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.tommilewski.net/2009/05/custom-error-pages-in-rails/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Zend Framework &#8211; Breadcrumb Helper</title>
		<link>http://blog.tommilewski.net/2008/10/zend-framework-breadcrumb-helper/</link>
		<comments>http://blog.tommilewski.net/2008/10/zend-framework-breadcrumb-helper/#comments</comments>
		<pubDate>Wed, 08 Oct 2008 17:00:57 +0000</pubDate>
		<dc:creator>Tom</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Zend Framework]]></category>
		<category><![CDATA[Breadcrumbs]]></category>

		<guid isPermaLink="false">http://blog.tommilewski.net/?p=104</guid>
		<description><![CDATA[A while back I needed a breadcrumb helper for a Zend Framework project I was working on. Not wanting to reinvent the wheel, I went out searching for one on the good ol&#8217; world wide web to no avail. So then went ahead and created one myself.
This is what I have come up with.

In your [...]]]></description>
			<content:encoded><![CDATA[<p>A while back I needed a breadcrumb helper for a Zend Framework project I was working on. Not wanting to reinvent the wheel, I went out searching for one on the good ol&#8217; world wide web to no avail. So then went ahead and created one myself.</p>
<p>This is what I have come up with.</p>
<p><span id="more-104"></span></p>
<p>In your controller, you will create a multi-dimensional array of breadcrumbs in the following format:</p>
<pre>
[0]
    [title] Home
    [url] /
[1]
    [title] Blog
    [url] /blog/
[2]
    [title] Edit
    [url] NULL
</pre>
<p>You will then send this multi-dimensional array to the breadcrumb helper which will format the breadcrumbs and return the result. In this example, I utilize the power of Zend_View which allows me to set up a placeholder within the view or layout and through setting different parameters output the breadcrumbs in a neatly formatted unordered list.</p>
<p><small><br />
Please note that for the sake of this post this is a very basic implementation of said helper class and therefore should be quite easy to extend. For anyone that would like more information please feel free to leave comments and questions and I&#8217;ll get back to you asap.</p>
<p>ALSO, sorry about the formatting. I&#8217;m working on it.</small></p>
<p>Your Helper File:</p>
<pre lang="php"># ---- File: {library_root}/My/Helper/Breadcrumb.php ----
class My_Helper_Breadcrumb
{
  public static function process($crumbs = NULL)
  {
    if (is_array($crumbs))
    {
      $count = count($crumbs);

      for ($i = 0; $i &lt; $count; $i++)
      {
        if ($i != ($count - 1))
          $output[] = '<a title="'. $crumbs[$i]['title'] .'" href="' . $crumbs[$i]['url'] .'">'. $crumbs[$i]['title'] .'</a>';
        else
          $output[] = '<a class="current" title="'. $crumbs[$i]['title'] .'">' . $crumbs[$i]['title'] .'</a>';
      }
    }
    else
    {
      $output = NULL;
    }

    return $output;
  }
}</pre>
<p>Code within your controller:</p>
<pre lang="php">
# Initialize Bread Crumbs Array
$breadcrumbs = array(
    array('title' => 'Home', 'url' => '/'),
    array('title' => 'Blog', 'url' => '/blog/'));

# Add A Bread Crumb (or Two)
$breadcrumbs[] = array('title' => 'Edit', 'url' => '/blog/edit/');
$breadcrumbs[] = array('title' => $post_name, 'url' => NULL);

# Finalize Bread Crumbs
$this->view->placeholder('breadcrumbs')->exchangeArray( My_Helper_Breadcrumb::process($breadcrumbs) );
</pre>
<p>Code within your View or Layout</p>
<pre lang="php">
# Format &#038; Display Bread Crumbs
$bc = $this->placeholder('breadcrumbs');
$bc->setPrefix("
<ul id='breadcrumbs'>\n
<li>")
   ->setSeparator("</li>
<li>\n")
   ->setIndent(4)
   ->setPostfix("</li>
</ul>

\n");

echo $bc;
</pre>
]]></content:encoded>
			<wfw:commentRss>http://blog.tommilewski.net/2008/10/zend-framework-breadcrumb-helper/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Rules of Optimization</title>
		<link>http://blog.tommilewski.net/2008/09/rules-of-optimization/</link>
		<comments>http://blog.tommilewski.net/2008/09/rules-of-optimization/#comments</comments>
		<pubDate>Wed, 03 Sep 2008 15:57:21 +0000</pubDate>
		<dc:creator>Tom</dc:creator>
				<category><![CDATA[Optimization]]></category>

		<guid isPermaLink="false">http://blog.tommilewski.net/?p=77</guid>
		<description><![CDATA[
First rule of optimization &#8211; Don’t
Second rule of optimization &#8211; Don’t
Third rule of optimization &#8211; Profile before optimizing

]]></description>
			<content:encoded><![CDATA[<ol>
<li>First rule of optimization &#8211; <strong>Don’t</strong></li>
<li>Second rule of optimization &#8211; <strong>Don’t</strong></li>
<li>Third rule of optimization &#8211; <strong>Profile before optimizing</strong></li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://blog.tommilewski.net/2008/09/rules-of-optimization/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Fun With Backups</title>
		<link>http://blog.tommilewski.net/2008/08/fun-with-backups/</link>
		<comments>http://blog.tommilewski.net/2008/08/fun-with-backups/#comments</comments>
		<pubDate>Fri, 22 Aug 2008 06:38:54 +0000</pubDate>
		<dc:creator>Tom</dc:creator>
				<category><![CDATA[Unix]]></category>

		<guid isPermaLink="false">http://blog.tommilewski.net/?p=59</guid>
		<description><![CDATA[Everyone should have a backup strategy for their servers but some still don&#8217;t and if you are one of those people then you better act fast. I will suggest a few simple commands for a very basic but useful backup solution that might allow you to rest a little easier knowing that your data is [...]]]></description>
			<content:encoded><![CDATA[<p>Everyone should have a backup strategy for their servers but some still don&#8217;t and if you are one of those people then you better act fast. I will suggest a few simple commands for a very basic but useful backup solution that might allow you to rest a little easier knowing that your data is safe.</p>
<p><span id="more-59"></span><br />
<strong> Mirroring the Data</strong></p>
<p>We will use rsync for its ability to examine files and only transfer files that have been modified. The flags that are set tell rsync to:</p>
<p>Recurse into directories -r<br />
Compress file data -z</p>
<pre lang="bash">rsync -rz user@remote_host /remote/path /local/path/of/copy</pre>
<p>If you are simply trying to mirror your data to another server then that should do it for you. If you wish to take it one step further and retain multiple backups you should keep reading.</p>
<p><strong><br />
</strong><strong>Data</strong><strong> Retention<br />
</strong></p>
<p>Since rsync only transfers files that have changed, what we will do is retain a copy of the server from the last rsync call so that we minimize both bandwidth and time. After every rsync call is complete we will archive and compress the current copy of the server.</p>
<pre lang="bash">cd /path/to/archives
tar -cf 'date +%F'.tar /local/path/of/copy
bzip2 'date +%F'.tar</pre>
<p>That is all. It wasn&#8217;t that hard now was it?</p>
<p><strong><br />
Conclusion</strong></p>
<p>After running these scripts, say, once a week, you will have a mirror of the server (dating back, in this case, at most a week) as well as as many prior backups your backup server can hold from previous weeks.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.tommilewski.net/2008/08/fun-with-backups/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Zend Project Directory Structure</title>
		<link>http://blog.tommilewski.net/2008/08/zend-project-directory-structure/</link>
		<comments>http://blog.tommilewski.net/2008/08/zend-project-directory-structure/#comments</comments>
		<pubDate>Fri, 22 Aug 2008 05:43:35 +0000</pubDate>
		<dc:creator>Tom</dc:creator>
				<category><![CDATA[Zend Framework]]></category>

		<guid isPermaLink="false">http://blog.tommilewski.net/?p=53</guid>
		<description><![CDATA[This is currently the directory structure I use where possible (host limitations) when utilizing the Zend Framework.

libraries/
    Zend/
        1.5.2/

site/
    www/ -&#62; [/site_version/3.5]

site_version/
    2.0/
    3.0/
    3.5/
        application/
 [...]]]></description>
			<content:encoded><![CDATA[<p>This is currently the directory structure I use where possible (host limitations) when utilizing the Zend Framework.</p>
<p><span id="more-53"></span></p>
<pre>libraries/
    Zend/
        1.5.2/

site/
    www/ -&gt; [/site_version/3.5]

site_version/
    2.0/
    3.0/
    3.5/
        application/
            cache/
            config/
            controllers/
            layouts/
            forms/
            views/
    library/
        My/
            Plugin/
        Zend/ -&gt; [/libraries/Zend/1.5.2]
    public/
        css/
        js/
        media/</pre>
]]></content:encoded>
			<wfw:commentRss>http://blog.tommilewski.net/2008/08/zend-project-directory-structure/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MySQL Query Caching</title>
		<link>http://blog.tommilewski.net/2008/08/code-test/</link>
		<comments>http://blog.tommilewski.net/2008/08/code-test/#comments</comments>
		<pubDate>Thu, 21 Aug 2008 19:58:11 +0000</pubDate>
		<dc:creator>Tom</dc:creator>
				<category><![CDATA[MySQL]]></category>
		<category><![CDATA[Optimization]]></category>

		<guid isPermaLink="false">http://blog.tommilewski.net/?p=3</guid>
		<description><![CDATA[MySQL query caching is probably one of the quickest and easiest ways for someone to speed up a sluggish website.
There are many situations where an application will call the database repeatedly with the same queries only to find that they return the exact same data sets time and time again. MySQL Query Caching caches the [...]]]></description>
			<content:encoded><![CDATA[<p>MySQL query caching is probably one of the quickest and easiest ways for someone to speed up a sluggish website.</p>
<p>There are many situations where an application will call the database repeatedly with the same queries only to find that they return the exact same data sets time and time again. MySQL Query Caching caches the result set therefore removing the overhead of having to run through the database each time a specific query is called.</p>
<p><span id="more-3"></span><br />
<strong> Initial Settings</strong></p>
<p>Before you do anything, you will need to set the query cache type.</p>
<p>The settings are as follows:<br />
0 &#8211; <em>Do Not Cache</em><br />
1 &#8211; <em>Cache All</em><br />
2 &#8211; <em>Cache On Demand</em></p>
<p><strong><br />
Cache All</strong><br />
You may disable query caching for a specific query by setting SQL_NO_CACHE.</p>
<pre lang="mysql">SELECT SQL_NO_CACHE * FROM tutorial;</pre>
<p><strong><br />
Cache ON Demand</strong><br />
You may enable query caching for a specific query by setting SQL_CACHE.</p>
<pre lang="mysql">SELECT SQL_CACHE * FROM tutorial;</pre>
<p><strong></strong></p>
<p><strong><br />
Set Up</strong></p>
<p>For this tutorial, I am simply going to utilize <em>Cache All</em> and to do this you must run the following query:</p>
<pre lang="mysql">SET SESSION query_cache_type = 1;</pre>
<p>This will instantaneously start the query cache and you should see the cache start to fill up.</p>
<pre lang="mysql">SHOW STATUS LIKE '%Qcache%';

+-------------------------+----------+
| Variable_name           | Value    |
+-------------------------+----------+
| Qcache_free_blocks      | 11421    |
| Qcache_free_memory      | 82725432 |
| Qcache_hits             | 4467043  |
| Qcache_inserts          | 243158   |
| Qcache_lowmem_prunes    | 2066     |
| Qcache_not_cached       | 4183     |
| Qcache_queries_in_cache | 17831    |
| Qcache_total_blocks     | 47247    |
+-------------------------+----------+
8 rows in set (0.00 sec)</pre>
<p><strong></strong></p>
<p><strong><br />
Query Cache Size</strong><br />
You may set your query cache size by using the following query:</p>
<pre lang="mysql">SET GLOBAL query_cache_size = 52428800;</pre>
<p>(The value is set in bytes. I have it set at 50Mb)</p>
<p><strong><br />
Read / Write Ratio</strong><br />
Make sure that you check up on your query cache because in some cases it might actually be detrimental to your site.</p>
<p>If your <em>Qcache_inserts</em> are close your <em>Qcache_hits</em> you might want to rethink using query caching as this means that you are nearing a 1:1 read/write ratio. Every time you write to the database, MySQL has to update the query cache and if those two numbers are close then Qcache might be doing the complete opposite of what it was designed to do.</p>
<p><strong><br />
Conclusion</strong><br />
With MySQL query caching enabled, you will generally see an increase in page loading times between five and fifteen percent. You will see more dramatic results on query-intensive pages.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.tommilewski.net/2008/08/code-test/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
