<?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>rootsmith blog</title>
	<atom:link href="http://blog.rootsmith.ca/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.rootsmith.ca</link>
	<description>random technology ramblings</description>
	<lastBuildDate>Fri, 30 Sep 2011 05:19:01 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>WordPress on nginx</title>
		<link>http://blog.rootsmith.ca/php/wordpress-on-nginx/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=wordpress-on-nginx</link>
		<comments>http://blog.rootsmith.ca/php/wordpress-on-nginx/#comments</comments>
		<pubDate>Fri, 30 Sep 2011 05:19:01 +0000</pubDate>
		<dc:creator>kevin</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://blog.rootsmith.ca/?p=169</guid>
		<description><![CDATA[So I finally got around to moving my sandbox type stuff and my blog off of slicehost and onto linode. I rarely touch my blog and do anything with wordpress so it is always a bit of a chore to upgrade etc. &#8217;cause I&#8217;m treading on unfamiliar ground. Anyway, I thought I would give myself <a href='http://blog.rootsmith.ca/php/wordpress-on-nginx/'>[...]</a>]]></description>
			<content:encoded><![CDATA[<p>So I finally got around to moving my sandbox type stuff and my blog off of slicehost and onto linode.  I rarely touch my blog and do anything with wordpress so it is always a bit of a chore to upgrade etc. &#8217;cause I&#8217;m treading on unfamiliar ground.</p>
<p>Anyway, I thought I would give myself a challenge and run wordpress behind <code>nginx</code>.  The formula is to proxy <code>nginx</code> to <code>php-cgi</code>.  This worked fine but was horribly unstable as the <code>php-cgi</code> process goes down quite often.  The problem was running <code>spawn-fcgi</code> from <code>init.d</code>.  It needed to be run from a proper process manager.  As luck would have it, I had <code>supervisord</code> already running to monitor <code>uwsgi</code>.</p>
<p>I wish I would have stumbled across <a href="http://agiletesting.blogspot.com/2010/06/setting-up-php5fastcgi-with-nginx.html" title="Setting Up php5-cgi" target="_blank">this post</a> from Grig Gheorghiu, as it would have saved me a lot of effort.  Funny how he is also a python guy.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.rootsmith.ca/php/wordpress-on-nginx/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>British Columbia Marijuana Grow Operations</title>
		<link>http://blog.rootsmith.ca/python/british-columbia-marijuana-grow-operations/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=british-columbia-marijuana-grow-operations</link>
		<comments>http://blog.rootsmith.ca/python/british-columbia-marijuana-grow-operations/#comments</comments>
		<pubDate>Thu, 29 Sep 2011 05:15:32 +0000</pubDate>
		<dc:creator>kevin</dc:creator>
				<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://blog.rootsmith.ca/?p=162</guid>
		<description><![CDATA[Andy McKay linked to a bit of interesting data from his twitter account. I wanted to be able to visualize the data so I used it as an excuse to try out flask, a python micro web framework, and some other stuff. It was all a bit of a yack shave because I could have <a href='http://blog.rootsmith.ca/python/british-columbia-marijuana-grow-operations/'>[...]</a>]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.agmweb.ca/blog/andy/" title="Andy McKay's Blog" target="_blank">Andy McKay</a> linked to a bit of interesting data from his <a href="https://twitter.com/#!/andymckay/status/117774833143660544" title="Surrey is a good place for a grow op" target="_blank">twitter account</a>.  I wanted to be able to visualize the data so I used it as an excuse to try out <a href="http://flask.pocoo.org/" title="Flask - A python micro framework" target="_blank">flask</a>, a python micro web framework, and some other stuff.  It was all a bit of a yack shave because I could have done the whole thing as a static page but what the hell.  It also led me to finally moving my blog off of slicehost and over to linode which of course led to an upgrade of wordpress which led to trying wordpress behind nginx and so on and so forth.  Such is the life of a techie.</p>
<p>Anyway without further ado, click through to see <a href="http://pystol.com">all locations in BC where a marijuana grow operation was found</a> by the police in the last year.  And here is the <a href="http://www.rcmp-grc.gc.ca/drugs-drogues/mgi-ircm/bc-eng.htm" title="Marihuana Grow Operations - British Columbia" target="_blank">raw data</a>.</p>
<p>The visualization shows a circle at the location and the size is proportional to how many plants were seized.  A scaling factor was applied to the circles so that they are still visible, and proportional, at all zoom levels.</p>
<p>Also, don&#8217;t be surprised if the whole thing comes crashing down because this was thrown together as an experiment.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.rootsmith.ca/python/british-columbia-marijuana-grow-operations/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ImportError: cannot import name fixtag</title>
		<link>http://blog.rootsmith.ca/linux/importerror-cannot-import-name-fixtag/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=importerror-cannot-import-name-fixtag</link>
		<comments>http://blog.rootsmith.ca/linux/importerror-cannot-import-name-fixtag/#comments</comments>
		<pubDate>Tue, 27 Sep 2011 20:33:41 +0000</pubDate>
		<dc:creator>kevin</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://blog.rootsmith.ca/?p=159</guid>
		<description><![CDATA[Installing supervisor on Natty Nat will undoubtedly throw the error ImportError: cannot import name fixtag The root cause of this error is the python-meld3 library and the following import statement: from xml.etree.ElementTree import fixtag The problem has been fixed in version 0.6.7 of python-meld3. Therefore, before you install supervisor, do the following on the command <a href='http://blog.rootsmith.ca/linux/importerror-cannot-import-name-fixtag/'>[...]</a>]]></description>
			<content:encoded><![CDATA[<p>Installing supervisor on Natty Nat will undoubtedly throw the error <code>ImportError: cannot import name fixtag</code></p>
<p>The root cause of this error is the <code>python-meld3</code> library and the following import statement:</p>
<p><code>from xml.etree.ElementTree import fixtag</code></p>
<p>The problem has been fixed in version 0.6.7 of python-meld3.  Therefore, before you install supervisor, do the following on the command line as root:</p>

<div class="wp_syntax"><div class="code"><pre class="shell" style="font-family:monospace;">aptitude install python-meld3
pip install meld3==0.6.7</pre></div></div>

<p>The above will install version 0.6.5 of python-meld3 and then pip will upgrade it to the latest.  You can then install supervisor without any problems.</p>
<p>If you want you can <a href="https://bugzilla.redhat.com/show_bug.cgi?id=652890" title="Bug 652890" target="_blank">read the gory details</a> of the problem in python-meld3.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.rootsmith.ca/linux/importerror-cannot-import-name-fixtag/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>mouseOver events in Selenium and jQuery hover</title>
		<link>http://blog.rootsmith.ca/javascript/mouseover-events-in-selenium-and-jquery-hover/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=mouseover-events-in-selenium-and-jquery-hover</link>
		<comments>http://blog.rootsmith.ca/javascript/mouseover-events-in-selenium-and-jquery-hover/#comments</comments>
		<pubDate>Thu, 30 Jun 2011 21:28:26 +0000</pubDate>
		<dc:creator>kevin</dc:creator>
				<category><![CDATA[javascript]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[selenium]]></category>
		<category><![CDATA[testing]]></category>

		<guid isPermaLink="false">http://articles.rootsmith.ca/uncategorized/mouseover-events-in-selenium-and-jquery-hover</guid>
		<description><![CDATA[If you have created some client functionality that is triggered when the user moves the mouse over an element, you may run into trouble testing with Selenium&#8217;s mouseOver method. I recently implemented such a feature using jQuery&#8217;s hover event handler and pulled my hair out trying to test the functionality with Selenium. I went down <a href='http://blog.rootsmith.ca/javascript/mouseover-events-in-selenium-and-jquery-hover/'>[...]</a>]]></description>
			<content:encoded><![CDATA[<p>If you have created some client functionality that is triggered when the user moves the mouse over an element, you may run into trouble testing with Selenium&#8217;s <code>mouseOver</code> method.</p>
<p>I recently implemented such a feature using jQuery&#8217;s <code>hover</code> event handler and pulled my hair out trying to test the functionality with Selenium.  I went down a complete rat hole trying trigger the event within selenium using the <code>getEval</code> method and passing in custom javascript code.  What a nightmare.  That is, until I really sat down and thought about it.</p>
<p>Remember that Selenium doesn&#8217;t actually control the pointer in the browser but drives the browser through javascript.  Therefore, unlike a true mouse event that may trigger a number of events, Selenium&#8217;s <code>mouseOver</code> just triggers <code>mouseover</code> on the element.  Now, if you have used jQuery&#8217;s <code>hover</code> then you are binding your functionality to <code>mouseenter</code> and <code>mouseleave</code> not <code>mouseover</code> and <code>mouseout</code>.</p>
<p>Therefore, if you wish to test with Selenium, do not use jQuery&#8217;s <code>hover</code> method and bind your functionality to <code>mouseover</code> and <code>mouseout</code>.</p>
<p>Note that many older browsers do not support <code>mouseenter</code> and <code>mouseleave</code> as this was introduced by Microsoft and was not immediately adopted by the others.  There is also a big difference in their behaviour and propagation in the event model.  <code>mouseover</code> and <code>mouseout</code> bubble up whereas <code>mouseenter</code> and <code>mouseleave</code> do not bubble up.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.rootsmith.ca/javascript/mouseover-events-in-selenium-and-jquery-hover/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Corporate Lawyer Bullshit Double Speak</title>
		<link>http://blog.rootsmith.ca/uncategorized/corporate-lawyer-bullshit-double-speak/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=corporate-lawyer-bullshit-double-speak</link>
		<comments>http://blog.rootsmith.ca/uncategorized/corporate-lawyer-bullshit-double-speak/#comments</comments>
		<pubDate>Tue, 22 Mar 2011 06:08:37 +0000</pubDate>
		<dc:creator>kevin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://articles.rootsmith.ca/?p=131</guid>
		<description><![CDATA[Well, it looks like the final nail in Microsoft&#8217;s coffin is not far off. They are now resorting to suing their competition rather than say, oh, out-competing. Brian Proffitt&#8217;s article on IT World offers up the gory details. I loved this quote from one of Microsoft&#8217;s weasels councils: Their refusals to take licenses leave us <a href='http://blog.rootsmith.ca/uncategorized/corporate-lawyer-bullshit-double-speak/'>[...]</a>]]></description>
			<content:encoded><![CDATA[<p>Well, it looks like the final nail in Microsoft&#8217;s coffin is not far off.  They are now resorting to suing their competition rather than say, oh, out-competing.  <a href="http://www.itworld.com/open-source/140916/android-sued-microsoft-not-linux">Brian Proffitt&#8217;s article on IT World</a> offers up the gory details.</p>
<p>I loved this quote from one of Microsoft&#8217;s <del>weasels</del> councils:</p>
<blockquote><p>Their refusals to take licenses leave us no choice but to bring legal action to defend our innovations and fulfill our responsibility to our customers, partners, and shareholders to safeguard the billions of dollars we invest each year to bring great software products and services to market.</p></blockquote>
<p>I took the liberty to translate the double-speak into English:</p>
<blockquote><p>Their refusals to be extorted into buying meaningless licenses leaves us no choice but to use our ill gotten gains from years of monopoly rule to financially punish them by dragging out meaningless legal claims in the courts until such time that they relent into paying us for nothing or we bankrupt them.  We must defend our lack of innovation so that we can continue to stifle technological advances and continue to sell our shitty software under long-since-dead per-seat pricing models to the unsuspecting corporate yes-men and slack-jawed middle managers that are our life&#8217;s blood.</p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://blog.rootsmith.ca/uncategorized/corporate-lawyer-bullshit-double-speak/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to use a D-Link DNS 323 as a TimeMachine</title>
		<link>http://blog.rootsmith.ca/uncategorized/how-to-dlink-dns323-timemachine/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=how-to-dlink-dns323-timemachine</link>
		<comments>http://blog.rootsmith.ca/uncategorized/how-to-dlink-dns323-timemachine/#comments</comments>
		<pubDate>Sun, 15 Aug 2010 05:15:41 +0000</pubDate>
		<dc:creator>kevin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://articles.rootsmith.ca/?p=125</guid>
		<description><![CDATA[The D-Link DNS 323 is an extremely affordable SAN solution for a home or small business network.  And since Bonjour support has been cooked into firmware version 1.09 it is now even more useful for Mac users.  However, out of the box it still cannot be recognized by TimeMachine as a valid backup drive.  Infuriating <a href='http://blog.rootsmith.ca/uncategorized/how-to-dlink-dns323-timemachine/'>[...]</a>]]></description>
			<content:encoded><![CDATA[<p>The D-Link DNS 323 is an extremely affordable SAN solution for a home or small business network.  And since Bonjour support has been cooked into firmware version 1.09 it is now even more useful for Mac users.  However, out of the box it still cannot be recognized by TimeMachine as a valid backup drive.  Infuriating to say the least, however, with a bit of time and perceverance it is possible.</p>
<p>Firstly, you will need to fun plug your DNS 323.  <a href="http://wiki.dns323.info/howto:fun_plug" target="_blank">Excellent instructions</a> are found at the <a href="http://wiki.dns323.info/start" target="_blank">DNS323 Wiki</a> site which is an excellent resource for all your DNS 323 hackery needs.</p>
<p>Secondly, you need to <a href="http://wiki.dns323.info/howto:appletalk?s=afp" target="_blank">add AFP support</a>.</p>
<p>Lastly, do the following command on the command line to get TimeMachine to recognize network drives which it does not do by default (really Apple?  Why?!?):</p>
<p><code><br />
defaults write com.apple.systempreferences TMShowUnsupportedNetworkVolumes 1<br />
</code></p>
<p>That&#8217;s it.  You should be able to point TimeMachine at your DNS 323 and you are good to go!</p>
<p>Note that you used to have to trick the Mac into using the SAN as a backup drive but I did not find this to be the case with my latest setup, but if you are having trouble, read <a href="http://www.horto.ca/?p=12" target="_blank">A Poor Man&#8217;s Apple Time Capsule</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.rootsmith.ca/uncategorized/how-to-dlink-dns323-timemachine/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>How To Save Common Searches in GMail</title>
		<link>http://blog.rootsmith.ca/productivity/how-to-save-common-searches-in-gmail/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=how-to-save-common-searches-in-gmail</link>
		<comments>http://blog.rootsmith.ca/productivity/how-to-save-common-searches-in-gmail/#comments</comments>
		<pubDate>Sat, 15 May 2010 17:21:40 +0000</pubDate>
		<dc:creator>kevin</dc:creator>
				<category><![CDATA[productivity]]></category>

		<guid isPermaLink="false">http://articles.rootsmith.ca/?p=122</guid>
		<description><![CDATA[I just stumbled across this little recipe to save common searches in gmail. If you turn your search into an URL you can then bookmark it. For example, if you want to search for anything with the label, funny, you would put the following into the search box: label:funny Instead just create an URL as <a href='http://blog.rootsmith.ca/productivity/how-to-save-common-searches-in-gmail/'>[...]</a>]]></description>
			<content:encoded><![CDATA[<p>I just stumbled across this little recipe to save common searches in gmail.  If you turn your search into an URL you can then bookmark it.  For example, if you want to search for anything with the label, <em>funny</em>, you would put the following into the search box:</p>
<p><code>label:funny</code></p>
<p>Instead just create an URL as follows:</p>
<p><code>https://mail.google.com/mail/#label/funny</code></p>
<p>bookmark it and TADA, you now have a saved search!</p>
<p>I haven&#8217;t experimented with other types of searches but all keywords could conceivably  be prepended with the hash symbol and work similarly.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.rootsmith.ca/productivity/how-to-save-common-searches-in-gmail/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How To Email From A Custom Module In Magento</title>
		<link>http://blog.rootsmith.ca/magento/how-to-email-from-a-custom-module-in-magento/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=how-to-email-from-a-custom-module-in-magento</link>
		<comments>http://blog.rootsmith.ca/magento/how-to-email-from-a-custom-module-in-magento/#comments</comments>
		<pubDate>Fri, 30 Apr 2010 05:51:53 +0000</pubDate>
		<dc:creator>kevin</dc:creator>
				<category><![CDATA[Magento]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://articles.rootsmith.ca/?p=116</guid>
		<description><![CDATA[Magento seemingly makes the most mundane development tasks an exercise in patience. The over engineered PHP beast makes you do more XML situps than the most anal of Java app environments all with zero documentation of its convoluted naming conventions. Therefore, when I wanted to email from within a custom Magento module I found myself <a href='http://blog.rootsmith.ca/magento/how-to-email-from-a-custom-module-in-magento/'>[...]</a>]]></description>
			<content:encoded><![CDATA[<p>Magento seemingly makes the most mundane development tasks an exercise in patience. The over engineered PHP beast makes you do more XML situps than the most anal of Java app environments all with zero documentation of its convoluted naming conventions. Therefore, when I wanted to email from within a custom Magento module I found myself back in the Magento source and forums to try and figure it out. I was just about to go down <a href="http://magentocookbook.wordpress.com/2009/06/26/magento-email/">Asad Rahman&#8217;s approach</a> or <a href="http://inchoo.net/ecommerce/magento/magento-custom-emails/">Branko Ajzele&#8217;s</a> but digging around in Magento&#8217;s source led me to believe there was an easier way. Please note, however, if you want to take a template approach to emailing then you are probably left with the aforementioned approaches and I wish you luck. This approach is very straight forward and about as simple as it gets in Magento. The following function probably doesn&#8217;t need a lot of explanation:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> notify<span style="color: #009900;">&#40;</span><span style="color: #000088;">$sendToName</span><span style="color: #339933;">,</span> <span style="color: #000088;">$sendToEmail</span><span style="color: #339933;">,</span> <span style="color: #000088;">$subject</span><span style="color: #339933;">,</span> <span style="color: #000088;">$msg</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
    Mage<span style="color: #339933;">::</span><span style="color: #990000;">log</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Sending email to <span style="color: #006699; font-weight: bold;">$sendTo</span>&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #000088;">$mail</span> <span style="color: #339933;">=</span> Mage<span style="color: #339933;">::</span><span style="color: #004000;">getModel</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'core/email'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$mail</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>setToName<span style="color: #009900;">&#40;</span><span style="color: #000088;">$sendToName</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$mail</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>setToEmail<span style="color: #009900;">&#40;</span><span style="color: #000088;">$sendToEmail</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$mail</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>setBody<span style="color: #009900;">&#40;</span><span style="color: #000088;">$msg</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$mail</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>setSubject<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'=?utf-8?B?'</span><span style="color: #339933;">.</span><span style="color: #990000;">base64_encode</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$subject</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'?='</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$mail</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>setFromEmail<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;support@example.com&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$mail</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>setFromName<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Your Friendly Neighbourhood Support&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$mail</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>setType<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'text'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    try <span style="color: #009900;">&#123;</span>
        <span style="color: #000088;">$mail</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>send<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
    catch <span style="color: #009900;">&#40;</span>Exception <span style="color: #000088;">$e</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        Mage<span style="color: #339933;">::</span><span style="color: #004000;">logException</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$e</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;">false</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <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>

]]></content:encoded>
			<wfw:commentRss>http://blog.rootsmith.ca/magento/how-to-email-from-a-custom-module-in-magento/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>The New Facebook Open Source Javascript API &#8211; Verifying the Signature</title>
		<link>http://blog.rootsmith.ca/facebook-development/the-new-facebook-open-source-javascript-api-verifying-the-signature/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=the-new-facebook-open-source-javascript-api-verifying-the-signature</link>
		<comments>http://blog.rootsmith.ca/facebook-development/the-new-facebook-open-source-javascript-api-verifying-the-signature/#comments</comments>
		<pubDate>Sun, 14 Mar 2010 07:09:42 +0000</pubDate>
		<dc:creator>kevin</dc:creator>
				<category><![CDATA[Facebook Development]]></category>
		<category><![CDATA[javascript]]></category>

		<guid isPermaLink="false">http://articles.rootsmith.ca/?p=110</guid>
		<description><![CDATA[If you are using the new, alpha version of the Facebook Connect JavaScript SDK you have no doubt scratched your head on how to verify the session signature. The biggest problem is that the documentation of how to validate the signature is completely wrong for the new open-source javascript API. The methodology described in the <a href='http://blog.rootsmith.ca/facebook-development/the-new-facebook-open-source-javascript-api-verifying-the-signature/'>[...]</a>]]></description>
			<content:encoded><![CDATA[<p>If you are using the new, alpha version of the <a href="http://github.com/facebook/connect-js" target="_blank">Facebook Connect JavaScript SDK</a> you have no doubt scratched your head on how to verify the session signature.  The biggest problem is that the <a href="http://wiki.developers.facebook.com/index.php/Verifying_The_Signature" target="_blank">documentation of how to validate the signature</a> is completely wrong for the new open-source javascript API.</p>
<p>The methodology described in the documentation is still correct but there is a new parameter, <code>base_domain</code>, that throws people for a loop.  As well, a number of the parameters have changed names.  Anyway, here are the parameters that you should be able to retrieve from the cookie <code>fbs_[your API key]</code> if you set the <code>cookie</code> option to <code>true</code> in your call to <code>FB.init</code> or they can be retrieved off of the object returned from a call to <code>FB.getSession()</code>:</p>
<p><code>base_domain=somedomain.com<br />
expires=1221157773<br />
secret=HUvxPvYA_7Hvt2gZ3ndw_T__<br />
session_key=2.s_eeketB6Ed9m5qgz64hYw__.3600.1238553600-327212630<br />
uid=2901279<br />
</code></p>
<p>Concatenate all of the above, append your application secret, which you can retrieve from <a href="http://www.facebook.com/developers">http://www.facebook.com/developers</a>, and take the <code>md5</code> of the string.  The result should match the <code>sig</code> parameter.  (Note: that the values of the parameters above are made up but should resemble your values.)</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.rootsmith.ca/facebook-development/the-new-facebook-open-source-javascript-api-verifying-the-signature/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Handling The Return of jQuery AJAX form POSTs</title>
		<link>http://blog.rootsmith.ca/jquery/handling-the-return-of-jquery-ajax-form-posts/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=handling-the-return-of-jquery-ajax-form-posts</link>
		<comments>http://blog.rootsmith.ca/jquery/handling-the-return-of-jquery-ajax-form-posts/#comments</comments>
		<pubDate>Thu, 04 Feb 2010 05:40:59 +0000</pubDate>
		<dc:creator>kevin</dc:creator>
				<category><![CDATA[jquery]]></category>
		<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://articles.rootsmith.ca/?p=102</guid>
		<description><![CDATA[The discussion on stackoverflow about handling different dataType returns from AJAX calls really got me thinking about the best pattern for POSTing form data to the server. This really ties in nicely to my previous blog post about Patterns of Organization when mixing MVC frameworks with javascript. If you are using your own RESTful API <a href='http://blog.rootsmith.ca/jquery/handling-the-return-of-jquery-ajax-form-posts/'>[...]</a>]]></description>
			<content:encoded><![CDATA[<p>The discussion on <a href="http://stackoverflow.com">stackoverflow</a> about <a href="http://stackoverflow.com/questions/850113/jquery-ajax-and-handling-different-datatypes">handling different <code>dataType</code> returns from AJAX calls</a> really got me thinking about the best pattern for POSTing form data to the server.</p>
<p>This really ties in nicely to my previous blog post about <a href="http://articles.rootsmith.ca/python/jquery-ajax-json-html-and-code-patterns-of-organization">Patterns of Organization</a> when mixing MVC frameworks with javascript.  If you are using your own RESTful API when creating a new object in your domain (a.k.a. POSTing some form to create a new foobar) what is the best pattern to follow?</p>
<p>Let&#8217;s first assume that you are POSTing your form via AJAX because you just popped up a lightbox that contained the form rather than doing a whole round trip to render a whole new page with the form.  Therefore you have some code that looks like this:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;form#foobar&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">submit</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    $.<span style="color: #660066;">ajax</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>type<span style="color: #339933;">:</span> <span style="color: #3366CC;">'POST'</span><span style="color: #339933;">,</span>
            url<span style="color: #339933;">:</span> <span style="color: #3366CC;">'/foobar'</span><span style="color: #339933;">,</span>
            data<span style="color: #339933;">:</span> $<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">serializeArray</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
            success<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>data<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                <span style="color: #006600; font-style: italic;">// do something with data;</span>
            <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Under the old MVC pattern you probably re-rendered the form if the user gave you bad data or forgot to fill out a field and then on success, you either re-directed them to the new page showing them their new data or immediately rendered that new page in the POST controller.  However, in the javascript example above it becomes quite cumbersome to expect multiple possible returns.  We do not want to be parsing the returned HTML to figure out if it is a re-rendered form because of a validation failure or if it is the HTML of our new item.  The obvious solution is to return JSON which is easy to inspect.  But I really like the idea of sending back an error HTTP response code if validation fails.</p>
<p>Firstly, if I am within my own application and retrieving data I do not want to write code to turn JSON into HTML.  I know how I want my data to look on the page so why not just return it straight away into HTML.  This allows me to keep my markup in templates where it should be.  By returning validation failures as, well, failures, it allows me to instantly handle two different return types &#8211; JSON for an error code return, and HTML for a new item return.  If JSON is returned I can easily pick out the error message and update the DOM of the form to display the erred fields.  But if my POST was successful, I then kill the form and slide in my new HTML to update my existing list of data all nicely formatted.</p>
<p>Now my javascript looks something like this:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;form#foobar&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">submit</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    $.<span style="color: #660066;">ajax</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>type<span style="color: #339933;">:</span> <span style="color: #3366CC;">'POST'</span><span style="color: #339933;">,</span>
            url<span style="color: #339933;">:</span> <span style="color: #3366CC;">'/foobar'</span><span style="color: #339933;">,</span>
            data<span style="color: #339933;">:</span> $<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">serializeArray</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
            dataType<span style="color: #339933;">:</span> <span style="color: #3366CC;">'html'</span><span style="color: #339933;">,</span>
            success<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>html<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;div#data&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">append</span><span style="color: #009900;">&#40;</span>html<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
            error<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>XMLHttpRequest<span style="color: #339933;">,</span> textStatus<span style="color: #339933;">,</span> errorThrown<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                <span style="color: #003366; font-weight: bold;">var</span> errorObject <span style="color: #339933;">=</span> JSON.<span style="color: #660066;">parse</span><span style="color: #009900;">&#40;</span>XMLHttpRequest.<span style="color: #660066;">responseText</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                <span style="color: #006600; font-style: italic;">// update form with stuff in errorObject</span>
            <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://blog.rootsmith.ca/jquery/handling-the-return-of-jquery-ajax-form-posts/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

