<?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>Stinkbug.net</title>
	<atom:link href="http://www.stinkbug.net/?feed=rss2" rel="self" type="application/rss+xml" />
	<link>http://www.stinkbug.net</link>
	<description>Established in September of 2000, Stinkbug.net become the personal website of me, Justin Thomas.</description>
	<lastBuildDate>Thu, 26 Aug 2010 19:34:38 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Thoughts on Mobile Application Development</title>
		<link>http://www.stinkbug.net/?p=1362</link>
		<comments>http://www.stinkbug.net/?p=1362#comments</comments>
		<pubDate>Thu, 26 Aug 2010 19:34:38 +0000</pubDate>
		<dc:creator>Justin Thomas</dc:creator>
				<category><![CDATA[HiddenWord.org]]></category>
		<category><![CDATA[Mobile]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Web]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[web application]]></category>

		<guid isPermaLink="false">http://www.stinkbug.net/?p=1362</guid>
		<description><![CDATA[I have some thoughts on Mobile Application Development.  There are lots of arguments against web based applications.  However, there are also some benefits to it.  Like develop once and it works everywhere, or at least almost everywhere.  I&#8217;ve been thinking about this a lot of HiddenWord.org.  When the iPhone SDK came out, my thought process [...]]]></description>
			<content:encoded><![CDATA[<p>I have some thoughts on Mobile Application Development.  There are lots of arguments against web based applications.  However, there are also some benefits to it.  Like develop once and it works everywhere, or at least almost everywhere.  I&#8217;ve been thinking about this a lot of <a href="http://www.hiddenword.org/">HiddenWord.org</a>.  When the iPhone SDK came out, my thought process was to develop an iPhone app for <a href="http://www.hiddenword.org/">HiddenWord.org</a>.  I have a couple of problems with this.</p>
<ol>
<li>It would require me to learn another programming language.</li>
<li>I would have multiple applications to maintain instead of just one.</li>
<li>What about other mobile devices (the iPhone isn&#8217;t the only  one)?</li>
</ol>
<p>These questions and some new frameworks have forced me to make a decision.  Being a single developer for <a href="http://www.hiddenword.org/">HiddenWord.org</a>, I just can&#8217;t justify developing multiple applications and maintaining them by myself.  That&#8217;s why I&#8217;ve decided to just keep my web application on the web.  It will be easy enough to make a mobile version of the application that will hopefully work on all mobile devices and I still have one application to maintain.  I plan on testing out <a href="http://jquerymobile.com/">jQuery Mobile</a> to do this.  Check it out.  It looks promising.</p>
<p>This way I have a web application that works in your desktop browser and at the same time is optimized for a number of mobile operating systems.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.stinkbug.net/?feed=rss2&amp;p=1362</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>More Research for HiddenWord.org</title>
		<link>http://www.stinkbug.net/?p=1346</link>
		<comments>http://www.stinkbug.net/?p=1346#comments</comments>
		<pubDate>Tue, 08 Jun 2010 04:49:36 +0000</pubDate>
		<dc:creator>Justin Thomas</dc:creator>
				<category><![CDATA[HiddenWord.org]]></category>
		<category><![CDATA[bible]]></category>
		<category><![CDATA[bible study]]></category>

		<guid isPermaLink="false">http://www.stinkbug.net/?p=1346</guid>
		<description><![CDATA[I have several things on the list that I would like to do for HiddenWord.org.  Before I start any of those though, I would like to know from any of the users of HiddenWord.org what features they would like to see added to the application.  Leave a comment and let me know what you would [...]]]></description>
			<content:encoded><![CDATA[<p>I have several things on the list that I would like to do for <a href="http://www.hiddenword.org">HiddenWord.org</a>.  Before I start any of those though, I would like to know from any of the users of <a href="http://www.hiddenword.org">HiddenWord.org</a> what features they would like to see added to the application.  Leave a comment and let me know what you would like to see.  I&#8217;m trying to plan out the next line of development, so now is the time to speak up.  Thanks.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.stinkbug.net/?feed=rss2&amp;p=1346</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Looking for ways to Encrypt Data</title>
		<link>http://www.stinkbug.net/?p=1340</link>
		<comments>http://www.stinkbug.net/?p=1340#comments</comments>
		<pubDate>Mon, 17 May 2010 13:25:20 +0000</pubDate>
		<dc:creator>Justin Thomas</dc:creator>
				<category><![CDATA[Tid Bits]]></category>

		<guid isPermaLink="false">http://www.stinkbug.net/?p=1340</guid>
		<description><![CDATA[Recently I&#8217;ve been looking into encryption.  I&#8217;ve been looking at ways to encrypt data through my web applications.  I&#8217;ve also been thinking about ways to encrypt data using well known techniques for data right on my system.  I&#8217;m not inventing anything that hasn&#8217;t already been done.  I&#8217;m just looking into doing something my self just [...]]]></description>
			<content:encoded><![CDATA[<p>Recently I&#8217;ve been looking into encryption.  I&#8217;ve been looking at ways to encrypt data through my web applications.  I&#8217;ve also been thinking about ways to encrypt data using well known techniques for data right on my system.  I&#8217;m not inventing anything that hasn&#8217;t already been done.  I&#8217;m just looking into doing something my self just for the fun of it and to understand it better.</p>
<p><span id="more-1340"></span></p>
<h3>Secure Pages in Content Management</h3>
<p>One of the things I&#8217;ve been working on a lot in the last several years is Content Management Systems.  I would like to expand our systems to allow truly secure pages.  In this case if someone needed a secure page they could simply create that through the system.  They would be asked to create a password for the page.  The idea would be that the data itself is encrypted in the database and can only be decrypted if the proper password is entered.  Permissions to the page would also be controlled by an Access Control List, which is something I&#8217;ve already done with the current systems I&#8217;ve worked on.  I&#8217;ve thought about ways to use that data to help encrypt the real data even further.</p>
<h3>Encrypting Data on my System</h3>
<p>One of the other things I would like to do is write a small application that would allow me to encrypt data right on my system.  I&#8217;ve looked into ways to use PHP (something I&#8217;m already familiar with) to write a desktop application.  The application might be a CLI application that could be compiled into machine code, running a sqlite database (not sure if there is way to make that a part of the compiled program or not).  The application would simply let me enter some information, like passwords, and store it all encrypted right on my system.</p>
<p>I thinking about playing around with writing this and when I am done I might release it for free.  Let me know if you would be interested in such a tool.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.stinkbug.net/?feed=rss2&amp;p=1340</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>&#8220;Compass&#8221; the CSS Framework</title>
		<link>http://www.stinkbug.net/?p=1328</link>
		<comments>http://www.stinkbug.net/?p=1328#comments</comments>
		<pubDate>Mon, 15 Feb 2010 21:13:08 +0000</pubDate>
		<dc:creator>Justin Thomas</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Blueprint]]></category>
		<category><![CDATA[Compass]]></category>
		<category><![CDATA[framework]]></category>
		<category><![CDATA[stylesheet]]></category>

		<guid isPermaLink="false">http://www.stinkbug.net/?p=1328</guid>
		<description><![CDATA[I wrote about CSS development and frameworks a while back and someone informed me about Compass.  That was the first time I heard about Compass and decided to check it out.  After watching the demo I was pretty much sold.  I decided to implement Compass into our intranet as a testing ground and see how [...]]]></description>
			<content:encoded><![CDATA[<p>I wrote about<a href="http://www.stinkbug.net/?p=1293"> CSS development and frameworks</a> a while back and someone informed me about <a href="http://compass-style.org/">Compass</a>.  That was the first time I heard about Compass and decided to check it out.  After watching the demo I was pretty much sold.  I decided to implement Compass into our intranet as a testing ground and see how it would work for us.</p>
<p>Compass is a lot like <a href="http://lesscss.org/">Less</a> that I talked about in my previous article.  What I liked about Compass more is that it has different CSS frameworks already built in.  Compass has Blueprint built into it, as well as YUI and others.  Compass makes it really easy to integrate that into your project.</p>
<p><span id="more-1328"></span></p>
<h3>How Does Compass Work</h3>
<p>Compass compiles it&#8217;s style sheets from Sass, which requires Ruby.  When you save you .sass file it will compile the .css file.  In your sass files you can use variables and mixins (which are set of style properties that are applied to basically a variable that can be applied to any other CSS element).</p>
<h3>How does Compass relate to Object Oriented CSS</h3>
<p>Here is where it gets a little tricky.  The idea of re-using styles is totally possible with Compass.  However the actual style sheet that is compiled from source can get really fat, really fast.  For every single page you have a separate set of styles.  It doesn&#8217;t really go along with the idea of keeping you style sheets small for really large sites, like I talked about in my <a href="http://www.stinkbug.net/?p=1293">previous article about CSS development</a>.</p>
<p>What does all this mean?  For each developer it may have different meanings.  The pros of compass is that you are truly keeping your presentation separate from your content, which is the recommended web standard approach.  If you are going to use Compass you will have to find that balance between large websites and keeping your style sheets small.  I like Compass and I&#8217;m going to use it.  However I&#8217;m finding out real fast that my style sheet is growing pretty big.  I can still use the normal class styles in the blueprint framework.  Using those classes for layout can help in keeping my style sheet smaller.  On our intranet we are using the blueprint classes on forms to keep the style sheet smaller, yet building the core page layouts into the style sheet.</p>
<p>I recommend Compass as it&#8217;s an easy way to manage your style sheet source and make global changes.  If you have a large site with a lot of hits, I also recommend finding that balance in keeping your style sheets small.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.stinkbug.net/?feed=rss2&amp;p=1328</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Web Security Revisted</title>
		<link>http://www.stinkbug.net/?p=1314</link>
		<comments>http://www.stinkbug.net/?p=1314#comments</comments>
		<pubDate>Tue, 10 Nov 2009 08:18:43 +0000</pubDate>
		<dc:creator>Justin Thomas</dc:creator>
				<category><![CDATA[CakePHP]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[cross site scripting]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[security]]></category>
		<category><![CDATA[XSS]]></category>

		<guid isPermaLink="false">http://www.stinkbug.net/?p=1314</guid>
		<description><![CDATA[Update: I fixed a bug in the code below.  It should work properly now.
I wrote a couple of articles about a year ago describing an idea I had for implementing security into a CakePHP app to insure that cross site scripting attacks don&#8217;t get though.  Just recently I&#8217;ve been working on it again for [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Update: I fixed a bug in the code below.  It should work properly now.</strong></p>
<p>I wrote a couple of articles about a year ago describing an idea I had for implementing security into a CakePHP app to insure that cross site scripting attacks don&#8217;t get though.  Just recently I&#8217;ve been working on it again for a new app, slightly changing my approach.  Since I&#8217;ve never shared all of my code on how I&#8217;ve fully implemented and configured my set up with the HTML Purifier, I&#8217;m going to do that now.  Of course some of the code I&#8217;ve already shared, but this will be all of it together.</p>
<p>I originally had everything set up as a component.  What I want to do is clean everything up before I actually save it to the database.  And I mean everything.  Any data that can be altered from a form should be run through some sort of clean up process, to ensure it&#8217;s security.  The problem with having it set up in a component is that in Cake that can only be accessed from a controller, right?  So what I really want is for this clean up process to happen in the background for any data that is saved, without me having to write any extra code in a controller.  That&#8217;s when I decided to take my component and move into my AppModel.  I suppose this could be done as a behavior as well, but I&#8217;m not real familiar with writing those.</p>
<p><span id="more-1314"></span></p>
<p>So here is my AppModel:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #339933;">&lt;</span> ?php
<span style="color: #000000; font-weight: bold;">class</span> AppModel <span style="color: #000000; font-weight: bold;">extends</span> Model<span style="color: #009900;">&#123;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">function</span> cleanUp<span style="color: #009900;">&#40;</span><span style="color: #000088;">$html</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		App<span style="color: #339933;">::</span><span style="color: #004000;">import</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'vendor'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'HTMLPurifier'</span><span style="color: #339933;">,</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'file'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'../../vendors/HTMLPurifier.auto.php'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #000088;">$config</span> <span style="color: #339933;">=</span> HTMLPurifier_Config<span style="color: #339933;">::</span><span style="color: #004000;">createDefault</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #666666; font-style: italic;">//The List of Allowed elements and attributes</span>
		<span style="color: #666666; font-style: italic;">//This may be information we want to stick in the database at some point so we can change it on the fly.</span>
		<span style="color: #000088;">$allowed</span> <span style="color: #339933;">=</span> 
			<span style="color: #0000ff;">&quot;strong,&quot;</span>
			<span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;em,&quot;</span>
			<span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;strike,&quot;</span>
			<span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;p[style],&quot;</span>
			<span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;ol,&quot;</span>
			<span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;ul,&quot;</span>
			<span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;li,&quot;</span>
			<span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;br,&quot;</span>
			<span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;sub,&quot;</span>
			<span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;sup,&quot;</span>
			<span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;span[style],&quot;</span>
			<span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;blockquote,&quot;</span>
			<span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;dd,&quot;</span>
			<span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;dl,&quot;</span>
			<span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;dt&quot;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #666666; font-style: italic;">// configuration goes here:</span>
		<span style="color: #000088;">$config</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">set</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Core.Encoding'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'UTF-8'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// replace with your encoding</span>
		<span style="color: #000088;">$config</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">set</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'HTML.Doctype'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'XHTML 1.0 Transitional'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// replace with your doctype</span>
		<span style="color: #000088;">$config</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">set</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'HTML.DefinitionID'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'myset'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$config</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">set</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'HTML.DefinitionRev'</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #666666; font-style: italic;">//$config-&gt;set('Cache', 'DefinitionImpl', null);  //cache disabled for development. remove later!</span>
		<span style="color: #000088;">$config</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">set</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'HTML.Allowed'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$allowed</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #666666; font-style: italic;">//$config-&gt;set('HTML', 'EnableAttrID', true);</span>
&nbsp;
		<span style="color: #666666; font-style: italic;">//CSS configuration</span>
		<span style="color: #000088;">$config</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">set</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'CSS.AllowedProperties'</span><span style="color: #339933;">,</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'text-decoration'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'text-align'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'padding-left'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'color'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #000088;">$purifier</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> HTMLPurifier<span style="color: #009900;">&#40;</span><span style="color: #000088;">$config</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #000088;">$pure_html</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$purifier</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">purify</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$html</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #b1b100;">return</span> <span style="color: #000088;">$pure_html</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">function</span> stripAll<span style="color: #009900;">&#40;</span><span style="color: #000088;">$data</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		App<span style="color: #339933;">::</span><span style="color: #004000;">import</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Sanitize'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">empty</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$data</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #b1b100;">return</span> <span style="color: #000088;">$data</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
&nbsp;
		<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">is_array</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$data</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$data</span> <span style="color: #b1b100;">AS</span> <span style="color: #000088;">$key</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$val</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
				<span style="color: #000088;">$data</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$key</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">stripAll</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$val</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span>
			<span style="color: #b1b100;">return</span> <span style="color: #000088;">$data</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #000088;">$data</span> <span style="color: #339933;">=</span> Sanitize<span style="color: #339933;">::</span><span style="color: #004000;">html</span><span style="color: #009900;">&#40;</span>Sanitize<span style="color: #339933;">::</span><span style="color: #004000;">stripScripts</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$data</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #b1b100;">return</span> <span style="color: #000088;">$data</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #009900;">&#125;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p>The first method (cleanup) contains my HTML Purifier configuration.  After everything is initiated, I simply pass it my html and return the purified version.  The second method (stripAll) is one I&#8217;ve published before.  This is basically for any content that doesn&#8217;t need any html in it.  In my case that&#8217;s almost all of the content.</p>
<p>The next thing I needed to do was decide what content gets passed to which method.  I decided to handle this with the beforeSave method in each model.  Here&#8217;s a couple of different versions.</p>
<p>Here is my Study model:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> beforeSave<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">isset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">data</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'Study'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'description'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$description</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">cleanUp</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">data</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'Study'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'description'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
	<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">data</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">stripAll</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">data</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">isset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">data</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'Study'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'description'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	        <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">data</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'Study'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'description'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$description</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
	<span style="color: #b1b100;">return</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Here is my User model:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> beforeSave<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">data</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">stripAll</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">data</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">return</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>The difference in the two models is based on what content I want passed to what method.  In the case of the Study model, the description field can contain html.  So I check to see if it&#8217;s being passed and if so run it through the purifier, then clean all the data, and place the purified html data back.  In the case of the User model, I don&#8217;t want any of the data to contain html, so strip it all.</p>
<p>The benefits to this approach is that I don&#8217;t have to pass all the data to a component from my controller.  I don&#8217;t have to remember to do anything if I decide to create a new action that writes data to the database.  In fact, the only time I have to worry about it is if I create a new field in the database and want to allow it to contain html.  Then I have to remember to add an if statement for that field.</p>
<p>I would be interested in knowing every one&#8217;s thoughts on performance with this approach.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.stinkbug.net/?feed=rss2&amp;p=1314</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Creating a Smart Deployment Process</title>
		<link>http://www.stinkbug.net/?p=1304</link>
		<comments>http://www.stinkbug.net/?p=1304#comments</comments>
		<pubDate>Tue, 22 Sep 2009 13:14:16 +0000</pubDate>
		<dc:creator>Justin Thomas</dc:creator>
				<category><![CDATA[CakePHP]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[deployments]]></category>

		<guid isPermaLink="false">http://www.stinkbug.net/?p=1304</guid>
		<description><![CDATA[Over the last several days I&#8217;ve been trying to do a deployment to our test server and kept running into all kinds of problems.  We have some shell scripts that handle the bulk of the deployment for us, but I found out that it wasn&#8217;t completely working.  In this particular deployment, I made some database [...]]]></description>
			<content:encoded><![CDATA[<p>Over the last several days I&#8217;ve been trying to do a deployment to our test server and kept running into all kinds of problems.  We have some shell scripts that handle the bulk of the deployment for us, but I found out that it wasn&#8217;t completely working.  In this particular deployment, I made some database changes and an update to the core framework.  When trying to run the scripts I found out that the deployment didn&#8217;t go as smoothly as I would have liked.  First, the core didn&#8217;t update properly and there wasn&#8217;t anything in place to handle the database changes.  After the deployment, I had to go back in and make the database changes manually.  It&#8217;s been all but easy.  We&#8217;ve made a lot of progress at making the deployment process an easy thing, but it&#8217;s just not quite there yet.  So I started thinking of ways to improve this.  I kept thinking if Microsoft and Apple can create complex updates to their OS&#8217;s and it still work almost all of the time, why can&#8217;t we do the same thing with a deployment.  After all, the last thing I want to do is jump through hoops to make a complex deployment, possibly forgetting something and then it not work.</p>
<p><span id="more-1304"></span></p>
<p>After a little thought I came up with the possible scenarios for a deployment.</p>
<ol>
<li>Update the Application code</li>
<li>Update the core framework code</li>
<li>Database change of any type (creating tables, alters, deletes, etc.)</li>
</ol>
<p>So the main idea here is to have a set of update files that will be used to update the application. We already have a deployment script that works great for the application code.  I&#8217;m not going to get into all the details of that, but all it is a Linux shell script that takes a tar file of our application code and unarchives it and replaces the old application code.  The script doesn&#8217;t overwrite certain config files, like the database config file and or our core config file. The script also makes sure that that appropriate users, groups, and permissions are all set correctly for the app.  It&#8217;s a script that we have worked on gradually over a year or so to perfect it.  It&#8217;s pretty solid now and we haven&#8217;t had any problem with it lately.  So now the idea is to take that script and modify it some more to add the core framework upgrade.  It will do the same thing as the application code.  If there is an upgrade tar file available for the core framework, then unarchive it and replace it.</p>
<p>Fairly simple, right?  So with one script and one command at the prompt we can upgrade our application code and our core framework without fail.  This is great!</p>
<p>However, then came the real problem, how to handle database changes.  Some database changes are easy, like creating tables, some are not, requiring complex data manipulation that would require a program to modify the data and check for accuracy.  Luckily for us, the framework we chose to use for our application can take care of this if we want it to.  CakePHP has the console, which would simply be a command at the prompt that we could add to our deployment script, that could execute a program for us and handle any database changes that I can think of.</p>
<p>Any database changes that can be done with just sql are kept in a .sql file in CVS.  So our upgrade program will take the sql file and execute it to make any database changes the file contains.  Since we have a program that is executing we can then do any complex data manipulation to guarantee it&#8217;s integrity.</p>
<p>Some might see a small downside to this.  The fact that we may possible have a upgrade program that has to be modified for every new deployment, could seem unnecessary.  After all, if we just have a few small application code changes with no database changes, why go through the trouble of an upgrade program?  At least 50% of the time that&#8217;s going to be the case for us.  The fact still remains that I don&#8217;t want to jump through hoops to make a deployment, possibly forgetting something.  If we have a program that&#8217;s tested and checked for accuracy we can be more confident that when it comes to time for the real deployment, every thing&#8217;s going to work. The bottom line is that if it&#8217;s well thought out our program can look to see what update files are available, so if there is no .sql, we know there is nothing to be done.  This could be a consistent thing that would never have to change.  So the program would be smart enough to know what to do based on what&#8217;s provided.  If you don&#8217;t need the program to do anything, then it would be programmed to do nothing, which should be easy to do anyway.</p>
<p>Right now some of this is theoretical as I haven&#8217;t finished it yet.  I&#8217;m sure there is still improvements that can be made too.  But thanks to well designed frameworks, like CakePHP, that allow us to make stuff like this easier.  If anyone is interested, I&#8217;ll publish a sample of the deployment code when I&#8217;m done with it to show you how it works in more detail.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.stinkbug.net/?feed=rss2&amp;p=1304</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Screencast of HiddenWord.org 0.2 Beta</title>
		<link>http://www.stinkbug.net/?p=1300</link>
		<comments>http://www.stinkbug.net/?p=1300#comments</comments>
		<pubDate>Tue, 07 Jul 2009 18:00:26 +0000</pubDate>
		<dc:creator>Justin Thomas</dc:creator>
				<category><![CDATA[HiddenWord.org]]></category>

		<guid isPermaLink="false">http://www.stinkbug.net/?p=1300</guid>
		<description><![CDATA[I just published a new screen cast of the new version of HiddenWord.org.  Check it out and let me know what you think.  Please leave any comments, suggestions, or improvements that you might have.
http://screencast.com/t/xQSSdPGBcI
]]></description>
			<content:encoded><![CDATA[<p>I just published a new screen cast of the new version of HiddenWord.org.  Check it out and let me know what you think.  Please leave any comments, suggestions, or improvements that you might have.</p>
<p><a href="http://screencast.com/t/xQSSdPGBcI">http://screencast.com/t/xQSSdPGBcI</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.stinkbug.net/?feed=rss2&amp;p=1300</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Thinking about CSS Development a Little Different</title>
		<link>http://www.stinkbug.net/?p=1293</link>
		<comments>http://www.stinkbug.net/?p=1293#comments</comments>
		<pubDate>Wed, 01 Jul 2009 15:49:18 +0000</pubDate>
		<dc:creator>Justin Thomas</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Blueprint]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[frontend]]></category>
		<category><![CDATA[Less]]></category>
		<category><![CDATA[Object Oriented]]></category>

		<guid isPermaLink="false">http://www.stinkbug.net/?p=1293</guid>
		<description><![CDATA[I mentioned a little about the Blueprint CSS framework a while back.  I&#8217;ve been actively developing a couple of sites using it and thinking about using it on another project.  I have to say that I really like it.  It seems that many people are coming up with new ways to develop their sites with [...]]]></description>
			<content:encoded><![CDATA[<p>I mentioned a little about the Blueprint CSS framework a while back.  I&#8217;ve been actively developing a couple of sites using it and thinking about using it on another project.  I have to say that I really like it.  It seems that many people are coming up with new ways to develop their sites with CSS.  I have come across some ideas from other people on how to develop their sites using CSS.</p>
<p><span id="more-1293"></span></p>
<h3>The BlueprintCSS Framework</h3>
<p>First, there is the <a href="http://www.blueprintcss.org/">Blueprint CSS framework</a>.  It provides a solid grid set up and, for me, has made building pages with different layouts a breeze.  I have a set of reusable classes that I don&#8217;t have to write additional CSS for when I decide I want to change my layout up, or add a new page with a completely different layout.  It also includes reset styles, styling for forms, and IE bug fixes.</p>
<h3>Less</h3>
<p>Second, there is <a href="http://lesscss.org/">Less</a>.  I haven&#8217;t actually tried this out yet, but the idea of developing in this fashion is attractive to say the least.  With Less, you can use variables to hold values and then declare those variables in other places.</p>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;"><span style="color: #a1a100;">@brand_color: #4D926F;</span>
&nbsp;
<span style="color: #cc00cc;">#header</span> <span style="color: #00AA00;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span> <span style="color: #a1a100;">@brand_color;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
h2 <span style="color: #00AA00;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span> <span style="color: #a1a100;">@brand_color;</span>
<span style="color: #00AA00;">&#125;</span></pre></div></div>

<p>This way when the time comes that you decide you want to change colors, all you have to do is change it in one place in your style sheet.  Less also allows nested rules.</p>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;"><span style="color: #cc00cc;">#header</span> <span style="color: #00AA00;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">red</span><span style="color: #00AA00;">;</span>
    a <span style="color: #00AA00;">&#123;</span>
        <span style="color: #000000; font-weight: bold;">font-weight</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">bold</span><span style="color: #00AA00;">;</span>
        <span style="color: #000000; font-weight: bold;">text-decoration</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">none</span><span style="color: #00AA00;">;</span>
  <span style="color: #00AA00;">&#125;</span>
<span style="color: #00AA00;">&#125;</span></pre></div></div>

<p>Less requires Ruby and once your styles are written you have to compile them into browser readable CSS files.  So in the case of the above example, your CSS would be compiled into:</p>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;"><span style="color: #cc00cc;">#header</span> <span style="color: #00AA00;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">red</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #cc00cc;">#header</span> a <span style="color: #00AA00;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">font-weight</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">bold</span><span style="color: #00AA00;">;</span>
    <span style="color: #000000; font-weight: bold;">text-decoration</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">none</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></div></div>

<h3>Object Oriented CSS</h3>
<p>Third, I came across this presentation about <a href="http://developer.yahoo.net/blogs/theater/archives/2009/03/website_and_webapp_performance.html">Object Oriented CSS by Nicole Sullivan</a>.  Nicole Sullivan was a performance guru and Yahoo engineer.  Her job was front end development for high performance sites and applications that would perform well under millions of hits.</p>
<p>OO CSS is an interesting idea where you write code that can be reused over and over again, rather than writing new CSS for every new page that has to be built or every new module that has to be created.  She explains the way we&#8217;re currently developing sites is that our style sheets will continue to grow and grow as the life of the site goes on.  With an OO CSS approach it keeps our style sheets leaner and file sizes smaller.</p>
<p>In conclusion, these are a couple of new ways to look at developing our CSS.  It&#8217;s also worth noting that frameworks like Blueprint and an Object Oriented CSS approach to developing would allow us to reuse our CSS more effectively and keep files sizes down, making download times and performance better.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.stinkbug.net/?feed=rss2&amp;p=1293</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Advanced Finds in CakePHP</title>
		<link>http://www.stinkbug.net/?p=1272</link>
		<comments>http://www.stinkbug.net/?p=1272#comments</comments>
		<pubDate>Tue, 23 Jun 2009 18:41:50 +0000</pubDate>
		<dc:creator>Justin Thomas</dc:creator>
				<category><![CDATA[CakePHP]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[Web]]></category>

		<guid isPermaLink="false">http://www.stinkbug.net/?p=1272</guid>
		<description><![CDATA[I talked briefly in my last post about unexpected functionality in trying to retrieve some related data using CakePHP.  I&#8217;m going to spill the details here in hopes that it will help someone new to the framework understand how to do more customized complex finds and retrieve all of your data in one nice data [...]]]></description>
			<content:encoded><![CDATA[<p>I talked briefly in my last post about unexpected functionality in trying to retrieve some related data using CakePHP.  I&#8217;m going to spill the details here in hopes that it will help someone new to the framework understand how to do more customized complex finds and retrieve all of your data in one nice data array.  I think you will find it&#8217;s easier than expected.</p>
<p><span id="more-1272"></span></p>
<p>For my example, I have two models.   A NewsCategory models and a News model.  NewsCategory hasMany News and News belongsTo NewsCategory.</p>
<h3>My Unexpected Results</h3>
<p>The query I thought would work didn&#8217;t produce the results I expected.  Here is the first find method I had in my NewsCategory Controller.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> index<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
	<span style="color: #000088;">$newsArticles</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">NewsCategory</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">find</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'all'</span><span style="color: #339933;">,</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
		<span style="color: #0000ff;">'contain'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
			<span style="color: #0000ff;">'News'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
				<span style="color: #0000ff;">'order'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'News.created DESC'</span><span style="color: #339933;">,</span>
				<span style="color: #0000ff;">'limit'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">3</span>
			<span style="color: #009900;">&#41;</span>
		<span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">set</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">compact</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'newsArticles'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>I was expecting all of my NewsCategory records with 3 associated News records for each NewsCategory.  What I got was a total of 3 News records, regardless of how many NewsCategory records I had.  So now I had to figure out how I was going to get 3 news records for every returned NewsCategory.</p>
<h3>The Solution</h3>
<p>I don&#8217;t know if this is the best way to achieve me goal, but it worked fine for me.  What I decided to do was create a new method inside my NewsCateogry model.  This model would find my NewsCateogry records then loop through that data and find the News records and merge them back into the data set.  From my controller I just simply called this new method.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> index<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #000088;">$newsItems</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">NewsCategory</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">findNewsPage</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">set</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">compact</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'newsItems'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Now inside my NewsCategory model is the new method.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> findNewsPage<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
	<span style="color: #000088;">$newsCategories</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">find</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'all'</span><span style="color: #339933;">,</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
		<span style="color: #0000ff;">'order'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'sort_order'</span><span style="color: #339933;">,</span>
		<span style="color: #0000ff;">'recursive'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #339933;">-</span><span style="color: #cc66cc;">1</span>
	<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$newsCategories</span> <span style="color: #b1b100;">AS</span> <span style="color: #000088;">$key</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$val</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
		<span style="color: #000088;">$newsArticles</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">find</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'first'</span><span style="color: #339933;">,</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
			<span style="color: #0000ff;">'conditions'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'id'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$val</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'NewsCategory'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'id'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
			<span style="color: #0000ff;">'contain'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
				<span style="color: #0000ff;">'News'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
					<span style="color: #0000ff;">'limit'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">3</span><span style="color: #339933;">,</span>
					<span style="color: #0000ff;">'order'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'News.created DESC'</span>
				<span style="color: #009900;">&#41;</span>
			<span style="color: #009900;">&#41;</span>
		<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #990000;">unset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$newsArticles</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'NewsCategory'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #000088;">$results</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> Set<span style="color: #339933;">::</span><span style="color: #004000;">merge</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$newsArticles</span><span style="color: #339933;">,</span> <span style="color: #000088;">$newsCategories</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$key</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #009900;">&#125;</span>
	<span style="color: #b1b100;">return</span> <span style="color: #000088;">$results</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>And that&#8217;s it!  I now get all of my NewsCategory records with 3 News records for each NewsCategory record.  Its worth mentioning that Cakes Set class was a life saver for this task.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.stinkbug.net/?feed=rss2&amp;p=1272</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The Life, The Word, The Cake</title>
		<link>http://www.stinkbug.net/?p=1262</link>
		<comments>http://www.stinkbug.net/?p=1262#comments</comments>
		<pubDate>Wed, 10 Jun 2009 18:37:00 +0000</pubDate>
		<dc:creator>Justin Thomas</dc:creator>
				<category><![CDATA[CakePHP]]></category>
		<category><![CDATA[HiddenWord.org]]></category>
		<category><![CDATA[Personal]]></category>
		<category><![CDATA[bible]]></category>
		<category><![CDATA[life]]></category>
		<category><![CDATA[religion]]></category>

		<guid isPermaLink="false">http://www.stinkbug.net/?p=1262</guid>
		<description><![CDATA[There&#8217;s been a lot going on with life and work lately and I haven&#8217;t had a lot of time to write about any of it.  Needless to say, they are keeping me busy.  With so much going on and not a lot of detail to share at the same time, I thought I&#8217;d just offer [...]]]></description>
			<content:encoded><![CDATA[<p>There&#8217;s been a lot going on with life and work lately and I haven&#8217;t had a lot of time to write about any of it.  Needless to say, they are keeping me busy.  With so much going on and not a lot of detail to share at the same time, I thought I&#8217;d just offer a little summary of everything going on</p>
<p><span id="more-1262"></span></p>
<h3>The Life</h3>
<p>I don&#8217;t talk about my personal life as much these days, but we just recently had a new baby boy.  He&#8217;s about 7 weeks old now.  That&#8217;s one of the things that&#8217;s obviously been keeping me busy.</p>
<p>I&#8217;ve also been slightly bothered with issues with people&#8217;s religious views, or lack there of.  Some suggesting that Christianity, among other religions, have a &#8220;heard mentality&#8221;.  I would go as far as to say that it&#8217;s quite the opposite.  The ones suggesting this would be the ones with the &#8220;heard mentality&#8221; belief system.  I may talk about this topic more in future posts, but it&#8217;s an issue for another time.</p>
<h3>The Word</h3>
<p>As some of you may have noticed, HiddenWord.org is currently down and it&#8217;s been that way for several weeks now.  The time came for me to renew my hosting service and I decided not to do so.  I&#8217;m currently rebuilding the app from the ground up (and doing so very slowly).  I couldn&#8217;t justify spending more money to keep the old app up and running when the new one is so close to being completed.  I have no time frame for completion, as I&#8217;m trying to finish up some other projects first so I can devote full attention to HiddenWord.org.  So I&#8217;m not sure exactly when it will be done.  Keep an eye on this site and you&#8217;ll here about it when it is released.</p>
<p>Some of the new HiddenWord.org features:</p>
<ul>
<li>More secure</li>
<li>Test before you sign up</li>
<li>You control the organization of your studies</li>
<li>Add multiple verses at once to a study</li>
</ul>
<p>I hope you find these features as exiting as I do.  I&#8217;m also going to be looking for alpha testers soon, so if you&#8217;re interested in testing out the app, <a href="http://www.stinkbug.net/?page_id=1189">let me know</a>.</p>
<h3>The Cake</h3>
<p>As some of you know I&#8217;ve been developing with the <a href="http://cakephp.org/">CakePHP Framework</a> a lot lately.  That&#8217;s the same framework that HiddenWord.org will be built on.  I love it and the more I use it the more I grow to appreciate it even more.  It seems to be heavily tested and pretty solid.  I&#8217;ve been using it now for almost 2 years and I still learn little things here and there.</p>
<p>The other day I was working on a piece of code that I was trying to retrieve some related data and found that one of the methods didn&#8217;t work the way I expected it to.  It&#8217;s not a framework problem, it&#8217;s just not what I expected.  I found that I had to write my own little method to do what I really wanted it to do.  The thing about CakePHP is that sometimes you have to write your own methods for more complicated tasks.  Even when you have to do that though, it&#8217;s still usually fairly easy to accomplish your goal using the tools built into the framework.  I am planning on sharing this information in a later article to demonstrate how easy a more complicated task is to achieve in CakePHP.</p>
<p>That&#8217;s it for this post.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.stinkbug.net/?feed=rss2&amp;p=1262</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
