<?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>ThinkRobot &#187; Code</title>
	<atom:link href="http://think-robot.com/category/code/feed/" rel="self" type="application/rss+xml" />
	<link>http://think-robot.com</link>
	<description>Design &#38; Development Blog</description>
	<lastBuildDate>Tue, 09 Aug 2011 16:56:32 +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>Top Level Cookies in Opera for Custom Domain Names</title>
		<link>http://think-robot.com/2011/04/top-level-cookies-in-opera-for-custom-domain-names/</link>
		<comments>http://think-robot.com/2011/04/top-level-cookies-in-opera-for-custom-domain-names/#comments</comments>
		<pubDate>Sat, 02 Apr 2011 23:36:14 +0000</pubDate>
		<dc:creator>Joanna</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[cookies]]></category>
		<category><![CDATA[dns]]></category>
		<category><![CDATA[domain]]></category>
		<category><![CDATA[fix]]></category>
		<category><![CDATA[host]]></category>
		<category><![CDATA[Opera]]></category>
		<category><![CDATA[tip]]></category>
		<category><![CDATA[top level]]></category>

		<guid isPermaLink="false">http://think-robot.com/?p=288</guid>
		<description><![CDATA[For our local development at work we all use the same fake domain &#8211; helps with setting API keys and other things across the board and isn&#8217;t hard to setup whatever system any new developer might have. It also happens to be not a &#8220;.com&#8221;: www.local.bnt &#8211; which is nice for not confusing it with [...]]]></description>
			<content:encoded><![CDATA[<p>For our local development at work we all use the same fake domain &#8211; helps with setting API keys and other things across the board and isn&#8217;t hard to setup whatever system any new developer might have. It also happens to be not a &#8220;.com&#8221;: <strong>www.local.bnt</strong> &#8211; which is nice for not confusing it with real sites.</p>
<p>While developing cross-subdomain authentication we suddenly realised that it didn&#8217;t work on Opera. After a bit of research it turns out that it&#8217;s not the setting of the cookie path (&#8220;.local.bnt&#8221;) that is the problem, but <a target="_blank" href="http://my.opera.com/yngve/blog/show.dml/267415">the way Opera checks which part of the domain name is the top level domain</a>:</p>
<blockquote><p>&#8220;Here at Opera we went for the rule-of-thumb method: When Opera is checking a cookie whose target domain matches certain criteriea (e.g. it is not a .com domain), <strong>we do a DNS name lookup for the target domain, to see if there is an IP address for that domain</strong>. If there is an IP address for the domain (e.g. example.no) we assume that the domain is a normal company domain, not a co.uk like domain, and therefore safe. If there is no IP address we assume that the domain is co.uk-like and therefore unsafe, and only allows the cookie to be set for the server that sent the cookie.&#8221;</p></blockquote>
<p>So that&#8217;s the problem right there and with an easy fix once you know the above&#8230; However the whole article is worth a read as it does shed some light on the multiple problems related to top level domains and cookies.</p>
<p>If you want to keep your random local domain name make sure your <strong>hosts file</strong> contains not only your sub domains, but the main one as well even if it is not used directly.</p>
<pre><code>127.0.0.1    www.local.bnt
<strong>127.0.0.1    local.bnt</strong>
</code></pre>
<div id="crp_related"><h2>Related Articles:</h2><ul><li><a href="http://think-robot.com/2009/05/doctrine-many-to-many-with-extra-fields/" rel="bookmark">Doctrine Many To Many With Extra Fields</a></li><li><a href="http://think-robot.com/2009/02/how-to-use-the-strong-ownership-list/" rel="bookmark">How To Use the Strong Ownership List</a></li><li><a href="http://think-robot.com/2010/03/multiple-changes-and-a-delete-on-same-object-in-doctrine/" rel="bookmark">Multiple changes and a delete on same object in doctrine</a></li><li><a href="http://think-robot.com/2009/12/phpunit-selenium-screenshot-path-problem/" rel="bookmark">PHPUnit & Selenium - screenshot path problem</a></li><li><a href="http://think-robot.com/2009/04/regex-for-autolinking-urls/" rel="bookmark">Regex for Autolinking URLs</a></li></ul></div>]]></content:encoded>
			<wfw:commentRss>http://think-robot.com/2011/04/top-level-cookies-in-opera-for-custom-domain-names/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>jQuery Multiple Events Without Default Behaviour</title>
		<link>http://think-robot.com/2011/03/jquery-multiple-events-without-default-behaviour/</link>
		<comments>http://think-robot.com/2011/03/jquery-multiple-events-without-default-behaviour/#comments</comments>
		<pubDate>Thu, 31 Mar 2011 22:51:34 +0000</pubDate>
		<dc:creator>Joanna</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[events]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[tip]]></category>

		<guid isPermaLink="false">http://think-robot.com/?p=276</guid>
		<description><![CDATA[Sometimes you trip over the little things. With several people working on the same page while we were recreating some JS functionality from scratch I&#8217;ve noticed one of my buttons suddenly stopped working. Scratched my head a bit, and for a minute thought that maybe it&#8217;s not having a &#8220;return false;&#8221; in my jQuery live() [...]]]></description>
			<content:encoded><![CDATA[<p>Sometimes you trip over the little things.</p>
<p>With several people working on the same page while we were recreating some JS functionality from scratch I&#8217;ve noticed one of my buttons suddenly stopped working. Scratched my head a bit, and for a minute thought that maybe it&#8217;s not having a &#8220;return false;&#8221; in my jQuery live() event handler.</p>
<p>Turned out though that it was actually one of the other developers actually putting a &#8220;return false;&#8221; in their event handler that just happened to target the same element&#8230; </p>
<p>Ideally we needed to propagate the event through a variable number of events but prevent the default behaviour of a link kicking in. <strong>preventDefault()</strong> to the rescue! <img src='http://think-robot.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<pre><code>$('#tag').live('click', function(event){
    (...)
    event.preventDefault();
});
</code></pre>
<p>Now, before blindly applying this piece of code I&#8217;d encourage everyone to first read up on <a target="_blank" href="http://fuelyourcoding.com/jquery-events-stop-misusing-return-false/">why &#8220;return false;&#8221; is evil</a>. <img src='http://think-robot.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p>And for a quick reference here&#8217;s a table featured on a related <a target="_blank" href="http://stackoverflow.com/questions/5302903/jquery-event-stopimmediatepropagation-vs-return-false">StackOverflow question</a>:</p>
<table>
<thead>
<tr>
<td>&nbsp;</td>
<th>stop propagation</th>
<th>prevent default action</th>
<th>prevent &#8220;same element&#8221; event handlers</th>
</tr>
</thead>
<tbody>
<tr>
<th>return false</th>
<td>X</td>
<td>X</td>
<td>&nbsp;</td>
</tr>
<tr>
<th>preventDefault</th>
<td>&nbsp;</td>
<td>X</td>
<td>&nbsp;</td>
</tr>
<tr>
<th>stopPropagation</th>
<td>X</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<th>stopImmediatePropagation</th>
<td>X</td>
<td>&nbsp;</td>
<td>X</td>
</tr>
</tbody>
</table>
<div id="crp_related"><h2>Related Articles:</h2><ul><li><a href="http://think-robot.com/2009/06/hitch-object-oriented-event-handlers-with-jquery/" rel="bookmark">Hitch. Object-oriented event handlers with jQuery</a></li><li><a href="http://think-robot.com/2008/11/nested-sortable-using-jtree-clickable-links/" rel="bookmark">Nested sortable using jTree - clickable links</a></li><li><a href="http://think-robot.com/2009/04/zend_db_select-multiple-table-joins-explained/" rel="bookmark">Zend_Db_Select multiple table joins explained</a></li><li><a href="http://think-robot.com/2008/11/wordpress-nextgen-gallery-tweak/" rel="bookmark">WordPress NextGen gallery tweak</a></li><li><a href="http://think-robot.com/2011/01/enable-delayed-messages-in-zend_queue/" rel="bookmark">Enable delayed messages in Zend_Queue</a></li></ul></div>]]></content:encoded>
			<wfw:commentRss>http://think-robot.com/2011/03/jquery-multiple-events-without-default-behaviour/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Enable delayed messages in Zend_Queue</title>
		<link>http://think-robot.com/2011/01/enable-delayed-messages-in-zend_queue/</link>
		<comments>http://think-robot.com/2011/01/enable-delayed-messages-in-zend_queue/#comments</comments>
		<pubDate>Sun, 30 Jan 2011 11:57:52 +0000</pubDate>
		<dc:creator>Joanna</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[classes]]></category>
		<category><![CDATA[examples]]></category>
		<category><![CDATA[fix]]></category>
		<category><![CDATA[library]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[queue]]></category>
		<category><![CDATA[Zend]]></category>
		<category><![CDATA[Zend Framework]]></category>
		<category><![CDATA[Zend_Queue]]></category>

		<guid isPermaLink="false">http://think-robot.com/?p=268</guid>
		<description><![CDATA[The default Zend_Queue DB implementation unfortunately does not allow you to pass a timeout value when saving a message on the queue. However not all is lost and you can easily extend the standard Zend classes to add that functionality. All you need is your own Db adapter and Queue class. For the adapter you [...]]]></description>
			<content:encoded><![CDATA[<p>The default Zend_Queue DB implementation unfortunately does not allow you to <strong>pass a timeout value</strong> when saving a message on the queue. However not all is lost and you can easily extend the standard Zend classes to add that functionality.</p>
<p>All you need is your own <strong>Db adapter</strong> and <strong>Queue class</strong>.</p>
<p>For the adapter you only need to overwrite <strong>the send()</strong> function. The highlighted code below is the only change to the original class (2 lines affected&#8230;). You could actually apply this without extending Zend_Queue, but this way will be easier if you ever need to update your Zend library.</p>
<pre><code>&lt;?php

class TS_Queue_Adapter_Db extends Zend_Queue_Adapter_Db {

    /**
     * Send a message to the queue
     *
     * @param  string     $message Message to send to the active queue
     * @param  Zend_Queue $queue
     * @param  Timestamp $timeout
     * @return Zend_Queue_Message
     * @throws Zend_Queue_Exception - database error
     */
    public function send($message, Zend_Queue $queue = null<strong>, $timeout = null</strong>){
        if ($this->_messageRow === null) {
            $this->_messageRow = $this->_messageTable->createRow();
        }

        if ($queue === null) {
            $queue = $this->_queue;
        }

        if (is_scalar($message)) {
            $message = (string) $message;
        }
        if (is_string($message)) {
            $message = trim($message);
        }

        if (!$this->isExists($queue->getName())) {
            require_once 'Zend/Queue/Exception.php';
            throw new Zend_Queue_Exception('Queue does not exist:' . $queue->getName());
        }

        $msg = clone $this->_messageRow;
        $msg->queue_id = $this->getQueueId($queue->getName());
        $msg->created = time();
        $msg->body = $message;
        $msg->md5 = md5($message);
<strong>        $msg->timeout = $timeout;</strong>

        try {
            $msg->save();
        } catch (Exception $e) {
            require_once 'Zend/Queue/Exception.php';
            throw new Zend_Queue_Exception($e->getMessage(), $e->getCode(), $e);
        }

        $options = array(
            'queue' => $queue,
            'data' => $msg->toArray(),
        );

        $classname = $queue->getMessageClass();
        if (!class_exists($classname)) {
            require_once 'Zend/Loader.php';
            Zend_Loader::loadClass($classname);
        }
        return new $classname($options);
    }
}</code></pre>
<p>Your Queue class only needs to extend the <strong>send()</strong> function again to allow you to pass the timeout through. obviously you can use this class to add other functionality too.</p>
<pre><code>&lt;?php

class TS_Queue extends Zend_Queue {

	/**
	 * Send a message to the queue
	 *
	 * @param  mixed $message message
	 * @return Zend_Queue_Message
	 * @throws Zend_Queue_Exception
	 */
	public function send($message, $timeout = null){
		return $this->getAdapter()->send($message, null, $timeout);
	}
}</code></pre>
<div id="crp_related"><h2>Related Articles:</h2><ul><li><a href="http://think-robot.com/2009/06/hitch-object-oriented-event-handlers-with-jquery/" rel="bookmark">Hitch. Object-oriented event handlers with jQuery</a></li><li><a href="http://think-robot.com/2009/04/zend_db_select-multiple-table-joins-explained/" rel="bookmark">Zend_Db_Select multiple table joins explained</a></li><li><a href="http://think-robot.com/2009/05/doctrine-many-to-many-with-extra-fields/" rel="bookmark">Doctrine Many To Many With Extra Fields</a></li><li><a href="http://think-robot.com/2008/12/using-zend_mail-and-google-smtp-to-send-emails/" rel="bookmark">Using Zend_Mail and Google SMTP to send emails</a></li><li><a href="http://think-robot.com/2010/12/zend-application-resource-plugin-loading-issues/" rel="bookmark">Zend Application Resource Plugin Loading Issues</a></li></ul></div>]]></content:encoded>
			<wfw:commentRss>http://think-robot.com/2011/01/enable-delayed-messages-in-zend_queue/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Zend Application Resource Plugin Loading Issues</title>
		<link>http://think-robot.com/2010/12/zend-application-resource-plugin-loading-issues/</link>
		<comments>http://think-robot.com/2010/12/zend-application-resource-plugin-loading-issues/#comments</comments>
		<pubDate>Sat, 25 Dec 2010 17:27:17 +0000</pubDate>
		<dc:creator>Joanna</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[tip]]></category>
		<category><![CDATA[Zend Framework]]></category>

		<guid isPermaLink="false">http://think-robot.com/?p=256</guid>
		<description><![CDATA[Admittedly thinking while feeling feverish is slightly impaired, but it took me a little while to figure this one out&#8230; Trying to integrate ZF 1.11 with Doctrine2 to as per this article, I was trying to be a smart-ass and use TS_Resource_EntityManager instead of the ugly looking TS_Resource_Entitymanager. Unfortunately all this got me was this [...]]]></description>
			<content:encoded><![CDATA[<p>Admittedly thinking while feeling feverish is slightly impaired, but it took me a little while to figure this one out&#8230; Trying to integrate ZF 1.11 with Doctrine2 to as per <a href="http://www.spiffyjr.me/2010/11/17/zend-framework-1-11-doctrine-2-lets-play-nice-part-1/" class="external">this article</a>, I was trying to be a smart-ass and use TS_Resource_EntityManager instead of the ugly looking TS_Resource_Entitymanager.</p>
<p>Unfortunately all this got me was this very unhelpful error:</p>
<pre><code>Zend_Application_Bootstrap_Exception with message Resource
matching <strong>"entityManager"</strong> not found</code></pre>
<p>It turns out that although the case of the resource name in the application.ini dosn&#8217;t really matter the class name does not like mixed case. So had to settle with <strong>TS_Resource_Entitymanager</strong> as the plugin name.</p>
<div id="crp_related"><h2>Related Articles:</h2><ul><li><a href="http://think-robot.com/2011/06/wordpress-update-permission-issues/" rel="bookmark">WordPress update permission issues</a></li><li><a href="http://think-robot.com/2009/07/redirect-in-controller-plugin-zend-framework-18/" rel="bookmark">Redirect in controller plugin - Zend Framework 1.8</a></li><li><a href="http://think-robot.com/2009/07/autloading-modular-forms-models-in-zend-framework-18/" rel="bookmark">Autloading modular forms & models in Zend Framework 1.8</a></li><li><a href="http://think-robot.com/2011/01/enable-delayed-messages-in-zend_queue/" rel="bookmark">Enable delayed messages in Zend_Queue</a></li><li><a href="http://think-robot.com/2010/12/installing-windows-7-guest-on-vmware-7-on-opensuse-113-host/" rel="bookmark">Installing Windows 7 Guest on VMWare 7 on OpenSuse 11.3 Host</a></li></ul></div>]]></content:encoded>
			<wfw:commentRss>http://think-robot.com/2010/12/zend-application-resource-plugin-loading-issues/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>PHP_AUTH_USER and PHP_AUTH_PW is null</title>
		<link>http://think-robot.com/2010/12/php_auth_user-and-php_auth_pw-is-null/</link>
		<comments>http://think-robot.com/2010/12/php_auth_user-and-php_auth_pw-is-null/#comments</comments>
		<pubDate>Thu, 09 Dec 2010 19:30:41 +0000</pubDate>
		<dc:creator>Joanna</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[authentication]]></category>
		<category><![CDATA[fix]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[tip]]></category>

		<guid isPermaLink="false">http://think-robot.com/?p=249</guid>
		<description><![CDATA[Ok, so you&#8217;re trying to setup password protection on your website using HTTP authentication. Unfortunately despite the request for password working your authentication keeps failing. If you check the output of your script and the password and username variables are not populated as expected it will usually be for one of two reasons. Working code [...]]]></description>
			<content:encoded><![CDATA[<p>Ok, so you&#8217;re trying to setup password protection on your website using HTTP authentication. Unfortunately despite the request for password working your authentication keeps failing. If you check the output of your script and the password and username variables are not populated as expected it will usually be for one of two reasons.</p>
<h2>Working code example</h2>
<pre><code>
$username = "expectedUsername";
$password = "expectedPassword";

if (!isset($_SERVER['PHP_AUTH_USER']) || $_SERVER['PHP_AUTH_USER'] != $username || $_SERVER['PHP_AUTH_PW'] != $password) {
  header('WWW-Authenticate: Basic realm=""');
  header('HTTP/1.0 401 Unauthorized');
  echo '&gt;h2>Authorization failed.&gt;/h2>';
  exit;
} else if($_SERVER['PHP_AUTH_USER'] != $username &#038; $_SERVER['PHP_AUTH_PW'] != $password){
  echo '&gt;h2>Authorization failed.&gt;/h2>';
  exit;
}</code></pre>
<h2>Most common reason for failure</h2>
<p>Firstly if you are using an older book or website as reference you will see <strong>$PHP_AUTH_USER</strong> mentioned instead of <strong>$_SERVER['PHP_AUTH_USER']</strong>. If you are using the former then this could be the reason for not seeing your variables populated.</p>
<h2>The reason that can take you by surprise</h2>
<p>If your code is correct (compare against the example) and you are using the $_SERVER variable format and still getting <strong>NULL</strong> inside both $_SERVER['PHP_AUTH_USER'] and $_SERVER['PHP_AUTH_PW'] it&#8217;s time to check your server settings.</p>
<p>HTTP authentication does not work with the <strong>cgi version of PHP</strong>, so if your hosting allows you will need to switch to PHP as Apache module or look for an alternative solution.</p>
<div id="crp_related"><h2>Related Articles:</h2><ul><li><a href="http://think-robot.com/2008/12/using-zend_mail-and-google-smtp-to-send-emails/" rel="bookmark">Using Zend_Mail and Google SMTP to send emails</a></li><li><a href="http://think-robot.com/2008/08/server-error-500-htaccess-require-valid-user/" rel="bookmark">Server Error 500 - htaccess require valid-user</a></li><li><a href="http://think-robot.com/2009/12/phpunit-selenium-screenshot-path-problem/" rel="bookmark">PHPUnit & Selenium - screenshot path problem</a></li><li><a href="http://think-robot.com/2008/08/opensuse-11-on-lenovo-thinkpad-x61-tablet-pc/" rel="bookmark">openSUSE 11 on Lenovo Thinkpad X61 (tablet pc)</a></li><li><a href="http://think-robot.com/2008/10/how-to-convert-pdt-projects-into-phpeclipse-projects/" rel="bookmark">How to convert PDT projects into PHPEclipse projects</a></li></ul></div>]]></content:encoded>
			<wfw:commentRss>http://think-robot.com/2010/12/php_auth_user-and-php_auth_pw-is-null/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using TextMate for easier CSS3</title>
		<link>http://think-robot.com/2010/09/using-textmate-for-easier-css3/</link>
		<comments>http://think-robot.com/2010/09/using-textmate-for-easier-css3/#comments</comments>
		<pubDate>Sun, 05 Sep 2010 19:54:15 +0000</pubDate>
		<dc:creator>Andrew</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[HTML/CSS]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[filter]]></category>
		<category><![CDATA[os x]]></category>
		<category><![CDATA[textmate]]></category>
		<category><![CDATA[transform]]></category>

		<guid isPermaLink="false">http://think-robot.com/?p=236</guid>
		<description><![CDATA[Over the past couple of years Webkit has popularised many fancy new CSS tricks. Amongst these the ability to rotate an element is certainly one of the most useful. Fortunately it&#8217;s also widely supported in other browsers, even in lowly old IE right back to version 5.5. The &#8216;modern&#8217; browsers support this with a reasonably [...]]]></description>
			<content:encoded><![CDATA[<p>Over the past couple of years Webkit has popularised many fancy new CSS tricks. Amongst these the ability to rotate an element is certainly one of the most useful. Fortunately it&#8217;s also widely supported in other browsers, even in lowly old IE right back to version 5.5. The &#8216;modern&#8217; browsers support this with a reasonably simple syntax</p>
<p><span id="more-236"></span></p>
<pre><code>[-vendor-prefix-]transform: rotate([angle]deg);</code></pre>
<p>so to use this to rotate an element by 15 degrees in Webkit (e.g. Safari, Chrome), Mozilla and Opera you&#8217;d use</p>
<pre><code>-moz-transform: rotate(15deg);
-o-transform: rotate(15deg);
-webkit-transform: rotate(15deg);
transform: rotate(15deg); </code></pre>
<p>We include the rule without a vendor prefix so that once browsers start to implement this without requiring the use of it our CSS will be ready.</p>
<p>Sadly the syntax for Internet Explorer is a little more cumbersome. It uses the	DXImageTransform.Microsoft.Matrix filter which is a little cryptic, but fortunately quite well documented on <a href="http://msdn.microsoft.com/en-us/library/ms533014(VS.85).aspx">MSDN</a>. We also need 2 variations of this filter, one for IE &lt; 8 and another for IE ≥ 8.</p>
<p>To use the filter the first thing we need to do is convert our angle into radians (angle in radians = angle in degrees * π / 180) then we work with the sine and cosine of this angle:</p>
<pre><code>DXImageTransform.Microsoft.Matrix(sizingMethod='auto expand',M11=[cos(angle)],M12=[-sin(angle)],M21=[sin(angle)],M22=[cos(angle)]);</code></pre>
<p>So if we take our rotate by 15 degrees example from above we&#8217;d end up with the following to cover all IE versions:</p>
<pre><code>filter:progid:DXImageTransform.Microsoft.Matrix(sizingMethod='auto expand',M11=0.965925826289068,M12=-0.258819045102521,M21=0.258819045102521,M22=0.965925826289068);
-ms-filter:"progid:DXImageTransform.Microsoft.Matrix(SizingMethod='auto expand',M11=0.965925826289068,M12=-0.258819045102521,M21=0.258819045102521,M22=0.965925826289068)";</code></pre>
<p>Obviously we don&#8217;t really want to have to whip out a calculator and type 6 lines of CSS every time we want to rotate an element. To save myself a little time I created a <a href="http://www.macromates.com">TextMate</a> bundle that simplifies the process a bit. This bundle allows me to type the standard syntax.</p>
<pre><code>transform:rotate(-10deg)</code></pre>
<p>Then hit a keyboard shortcut to have TextMate fill in the rest.</p>
<p>To add this bundle go to Bundles &gt; Bundle Editor &gt; Show Bundle Editor</p>
<p>Select CSS from the list on the left and side of the editor and select Add new command from the buttons at the bottom. Paste the following into the Command(s) field</p>
<pre><code>#!/usr/bin/env ruby
line = $stdin.read
if line =~ /(\s*)transform\s*:\s*rotate\s*\(\s*(-?[0-9]+)\s*deg\s*\)/i
	rad = $2.to_i * Math::PI / 180
	cos = Math.cos(rad)
	sin = Math.sin(rad)

	print $`
	print $1 + "-moz-transform:rotate(" + $2 + "deg);\n"
	print $1 + "-o-transform:rotate(" + $2 + "deg);\n"
	print $1 + "-webkit-transform:rotate(" + $2 + "deg);\n"
	print $1 + "transform:rotate(" + $2 + "deg);\n"
	print $1 + "filter:progid:DXImageTransform.Microsoft.Matrix(sizingMethod='auto expand',M11=" + 	cos.to_s + ",M12=" + (sin * -1).to_s + ",M21=" + sin.to_s + ",M22=" + cos.to_s + ");\n"
	print $1 + "-ms-filter:\"progid:DXImageTransform.Microsoft.Matrix(SizingMethod='auto expand',M11=" + cos.to_s + ",M12=" + (sin * -1).to_s + ",M21=" + sin.to_s + ",M22=" + cos.to_s + ")\";\n"
	print $'
else
	print line
end</code></pre>
<p>Then select Save: Nothing, Input: Selected text or Line and Output: Replace Selected Text. Now you need to setup how you&#8217;ll trigger this. Select Activation: Key Equivalent and then enter the keyboard shortcut you&#8217;d like &#8211; I&#8217;m using <kbd>Shift + Cmd + R</kbd></p>
<p><img class="alignleft size-medium wp-image-237" style="margin-right: 1em; margin-bottom: 1em;" title="bundle-editor" src="http://think-robot.com/wp-content/uploads/2010/09/bundle-editor-300x180.png" alt="bundle-editor" width="300" height="180" /></p>
<p>Finally close the bundle editor and select Bundle &gt; Bundle Editor &gt; Reload Bundles and you should be good to go.</p>
<p>Of course there are many other CSS3 properties that up until now have been implemented using vendor prefixes in some browsers. We can simplify creating these with some more TextMate snippets. I&#8217;ll include a couple of examples here, firstly box-shadow. Webkit and Mozilla support this using a vendor prefix, Opera and Internet Explorer 9 use the standard property. The syntax is:</p>
<pre><code>[-vendor-prefix-]box-shadow: [x offset] [y offset] [blur radius] [color];</code></pre>
<p>So to create a drak grey shadow just offset slightly below an element we might use something like this:</p>
<pre><code>-moz-box-shadow: 0 2px 5px #333;
-webkit-box-shadow: 0 2px 5px #333;
box-shadow: 0 2px 5px #333;</code></pre>
<p>For the TextMate snippet we&#8217;ll use tab triggers and placeholders &#8211; this let you type a keyword and hit the tab key to insert the text of the snippet with placeholder values inserted with the first placeholder selected so you can fill in a value, tabbing again moves onto the next placeholder and so on. Open up the bundle editor from Bundles &gt; Bundle Editor &gt; Show Bundle Editor and select to add a new snippet under the CSS section. Paste the following into the snippet window:</p>
<pre><code>-moz-box-shadow: ${1:x offset} ${2:y offset} ${3:blur radius} ${4:color};
-webkit-box-shadow: ${1:x offset} ${2:y offset} ${3:blur radius} ${4:color};
box-shadow: ${1:x offset} ${2:y offset} ${3:blur radius} ${4:color};</code></pre>
<p>Select Activation: Tab Trigger and type in the word box as the trigger. Name this snippet box-shadow and exit the bundle editor. Relaod bundles to give it a try. In a CSS file now type box and hit the tab key. The following should be inserted:</p>
<pre><code>-moz-box-shadow: x offset y offset spread color;
-webkit-box-shadow: x offset y offset spread color;
box-shadow: x offset y offset spread color;</code></pre>
<p>with the x offset text highlighted. Starting to type will overwrite all the x offset placeholders, hitting tab again will move onto the y offset. Easy. You could add another snippet that provided box shadows using the inset modifier.</p>
<pre><code>[-vendor-prefix-]box-shadow: inset [x offset] [y offset] [blur radius] [color];</code></pre>
<p>border-radius might also be a good candidate for a time-saving snippet. Probably the most common use of this is where we want to specify equally rounded corners on all round our box. We could use the same style of tab triggered snippet as with the box-shadow example. The snippet would be very simple with just a single placeholder &#8211; something like this:</p>
<pre><code>-moz-border-radius: ${1:1em};
-webkit-border-radius: ${1:1em};
border-radius: ${1:1em};</code></pre>
<p>TextMate is a wonderful editor and snippets really do make this stuff a breeze.</p>
<div id="crp_related"><h2>Related Articles:</h2><ul><li><a href="http://think-robot.com/2011/06/wordpress-update-permission-issues/" rel="bookmark">WordPress update permission issues</a></li><li><a href="http://think-robot.com/2008/10/display-meetings-from-entourage-using-geektool/" rel="bookmark">Display Meetings From Entourage Using GeekTool</a></li><li><a href="http://think-robot.com/2008/11/wordpress-nextgen-gallery-tweak/" rel="bookmark">WordPress NextGen gallery tweak</a></li><li><a href="http://think-robot.com/2008/08/opensuse-11-on-lenovo-thinkpad-x61-tablet-pc/" rel="bookmark">openSUSE 11 on Lenovo Thinkpad X61 (tablet pc)</a></li><li><a href="http://think-robot.com/2010/08/mantis-theme-mock-up/" rel="bookmark">Mantis theme mock-up</a></li></ul></div>]]></content:encoded>
			<wfw:commentRss>http://think-robot.com/2010/09/using-textmate-for-easier-css3/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Multiple changes and a delete on same object in doctrine</title>
		<link>http://think-robot.com/2010/03/multiple-changes-and-a-delete-on-same-object-in-doctrine/</link>
		<comments>http://think-robot.com/2010/03/multiple-changes-and-a-delete-on-same-object-in-doctrine/#comments</comments>
		<pubDate>Sat, 06 Mar 2010 20:58:13 +0000</pubDate>
		<dc:creator>Joanna</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[doctrine]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[solution]]></category>
		<category><![CDATA[tip]]></category>

		<guid isPermaLink="false">http://think-robot.com/?p=219</guid>
		<description><![CDATA[If you want to make several different changes to a doctrine record object you might find yourself slightly puzzled when it comes to deleting related objects. $user['Address']->delete(); $user['Address']->state(Doctrine_Record::STATE_LOCKED); (...) $user->save(); It seems that unless you set the state the save later on still sees an initialized (though empty!) relation. Related Articles:Top Level Cookies in Opera [...]]]></description>
			<content:encoded><![CDATA[<p>If you want to make several different changes to a doctrine record object you might find yourself slightly puzzled when it comes to deleting related objects.</p>
<pre><code>$user['Address']->delete();
$user['Address']->state(Doctrine_Record::STATE_LOCKED);
(...)
$user->save();</code></pre>
<p>It seems that unless you set the state the save later on still sees an initialized (though empty!) relation.</p>
<div id="crp_related"><h2>Related Articles:</h2><ul><li><a href="http://think-robot.com/2011/04/top-level-cookies-in-opera-for-custom-domain-names/" rel="bookmark">Top Level Cookies in Opera for Custom Domain Names</a></li><li><a href="http://think-robot.com/2008/08/server-error-500-htaccess-require-valid-user/" rel="bookmark">Server Error 500 - htaccess require valid-user</a></li><li><a href="http://think-robot.com/2009/06/hitch-object-oriented-event-handlers-with-jquery/" rel="bookmark">Hitch. Object-oriented event handlers with jQuery</a></li><li><a href="http://think-robot.com/2009/05/doctrine-many-to-many-with-extra-fields/" rel="bookmark">Doctrine Many To Many With Extra Fields</a></li><li><a href="http://think-robot.com/2011/06/wordpress-update-permission-issues/" rel="bookmark">WordPress update permission issues</a></li></ul></div>]]></content:encoded>
			<wfw:commentRss>http://think-robot.com/2010/03/multiple-changes-and-a-delete-on-same-object-in-doctrine/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Zend_Date time part and GMT</title>
		<link>http://think-robot.com/2009/12/zend_date-time-part-and-gmt/</link>
		<comments>http://think-robot.com/2009/12/zend_date-time-part-and-gmt/#comments</comments>
		<pubDate>Wed, 16 Dec 2009 21:06:04 +0000</pubDate>
		<dc:creator>Joanna</dc:creator>
				<category><![CDATA[Articles]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[GMT]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[tip]]></category>
		<category><![CDATA[UK]]></category>
		<category><![CDATA[Zend Framework]]></category>
		<category><![CDATA[Zend_Date]]></category>
		<category><![CDATA[ZF]]></category>

		<guid isPermaLink="false">http://think-robot.com/?p=215</guid>
		<description><![CDATA[If you live in the UK you might have a surprise waiting in store for you if you use Zend_Date for the time part only. For a while I even thought this was a bug, however digging deeper has shown that actually it&#8217;s Zend_Date that is right, in a way at least. When setting a [...]]]></description>
			<content:encoded><![CDATA[<p>If you live in the UK you might have a surprise waiting in store for you if you use Zend_Date for the time part only. For a while I even thought this was a bug, however digging deeper has shown that actually it&#8217;s Zend_Date that is right, in a way at least.</p>
<p>When setting a time before 1972 &#8211; this is 1970 and 1971 the time part will not be shifted in the UK locale as DST was only introduced in 1972!</p>
<p>This means if you are only calculating times and need the appropriate time adjustment you will need to set a date as no date part in Zend_Date means 1st Jan 1970.</p>
<div id="crp_related"><h2>Related Articles:</h2><ul><li><a href="http://think-robot.com/2008/10/display-meetings-from-entourage-using-geektool/" rel="bookmark">Display Meetings From Entourage Using GeekTool</a></li><li><a href="http://think-robot.com/2009/04/week-of-the-month-in-mysql/" rel="bookmark">Week of the Month in Mysql</a></li><li><a href="http://think-robot.com/2008/08/opensuse-11-on-lenovo-thinkpad-x61-tablet-pc/" rel="bookmark">openSUSE 11 on Lenovo Thinkpad X61 (tablet pc)</a></li><li><a href="http://think-robot.com/2008/12/strong-ownership-list-approach/" rel="bookmark">Strong ownership list approach</a></li><li><a href="http://think-robot.com/2009/02/how-to-use-the-strong-ownership-list/" rel="bookmark">How To Use the Strong Ownership List</a></li></ul></div>]]></content:encoded>
			<wfw:commentRss>http://think-robot.com/2009/12/zend_date-time-part-and-gmt/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHPUnit &amp; Selenium &#8211; screenshot path problem</title>
		<link>http://think-robot.com/2009/12/phpunit-selenium-screenshot-path-problem/</link>
		<comments>http://think-robot.com/2009/12/phpunit-selenium-screenshot-path-problem/#comments</comments>
		<pubDate>Tue, 15 Dec 2009 23:04:46 +0000</pubDate>
		<dc:creator>Joanna</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[error]]></category>
		<category><![CDATA[path]]></category>
		<category><![CDATA[phpunit]]></category>
		<category><![CDATA[screenshot]]></category>
		<category><![CDATA[selenium]]></category>
		<category><![CDATA[selenium rc]]></category>
		<category><![CDATA[testing]]></category>

		<guid isPermaLink="false">http://think-robot.com/?p=207</guid>
		<description><![CDATA[PHPUnit_Framework_Exception: Response from Selenium RC server for testComplete(). ERROR: Command execution failure. Please search the forum at http://clearspace.openqa.org for error details from the log window. The error message is: Component returned failure code: 0x80520001 (NS_ERROR_FILE_UNRECOGNIZED_PATH) [nsILocalFile.initWithPath] Setting up Selenium RC server together with PHPUnit has proven surprisingly easy&#8230; Well most of it. Every now and [...]]]></description>
			<content:encoded><![CDATA[<pre><code>PHPUnit_Framework_Exception: Response from Selenium RC server for testComplete().
ERROR: Command execution failure. Please search the forum at http://clearspace.openqa.org for error details from the log window.
The error message is: Component returned failure code: 0x80520001 (NS_ERROR_FILE_UNRECOGNIZED_PATH) [nsILocalFile.initWithPath]
</code></pre>
<p>Setting up Selenium RC server together with PHPUnit has proven surprisingly easy&#8230; Well most of it. Every now and then as a beginner you might run into monster errors like the one above. No fear, what Selenium is trying to tell you is just that your path is wrong.</p>
<p>For me it happened when trying to setup the  error screenshot variables:</p>
<pre><code>protected $captureScreenshotOnFailure = TRUE;
<strong>protected $screenshotPath = '/var/www/localhost/htdocs/screenshots';</strong>
protected $screenshotUrl = 'http://localhost/screenshots';
</code></pre>
<p>In case you wonder the path relates to the <strong>browser&#8217;s host</strong> not the Selenium RC host (if they are different), In my case the browsers are run on a windows box, with the Selenium RC setup on a Linux machine. Thus the error about the inapropriate <strong>$screenshotPath</strong>.</p>
<div id="crp_related"><h2>Related Articles:</h2><ul><li><a href="http://think-robot.com/2010/12/installing-windows-7-guest-on-vmware-7-on-opensuse-113-host/" rel="bookmark">Installing Windows 7 Guest on VMWare 7 on OpenSuse 11.3 Host</a></li><li><a href="http://think-robot.com/2009/07/autloading-modular-forms-models-in-zend-framework-18/" rel="bookmark">Autloading modular forms & models in Zend Framework 1.8</a></li><li><a href="http://think-robot.com/2008/08/server-error-500-htaccess-require-valid-user/" rel="bookmark">Server Error 500 - htaccess require valid-user</a></li><li><a href="http://think-robot.com/2011/04/top-level-cookies-in-opera-for-custom-domain-names/" rel="bookmark">Top Level Cookies in Opera for Custom Domain Names</a></li><li><a href="http://think-robot.com/2010/12/zend-application-resource-plugin-loading-issues/" rel="bookmark">Zend Application Resource Plugin Loading Issues</a></li></ul></div>]]></content:encoded>
			<wfw:commentRss>http://think-robot.com/2009/12/phpunit-selenium-screenshot-path-problem/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Autloading modular forms &amp; models in Zend Framework 1.8</title>
		<link>http://think-robot.com/2009/07/autloading-modular-forms-models-in-zend-framework-18/</link>
		<comments>http://think-robot.com/2009/07/autloading-modular-forms-models-in-zend-framework-18/#comments</comments>
		<pubDate>Thu, 30 Jul 2009 21:55:00 +0000</pubDate>
		<dc:creator>Joanna</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[autload]]></category>
		<category><![CDATA[examples]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[Zend Framework]]></category>

		<guid isPermaLink="false">http://think-robot.com/?p=200</guid>
		<description><![CDATA[It&#8217;s not really obvious with the error messages you get, but using a thing like Form_Login does not work out of the box with a modular structure. Which is slightly surprising considering that it&#8217;s inside the default module. I have found examples like the second one below, but no one mentions that you actually declare [...]]]></description>
			<content:encoded><![CDATA[<p>It&#8217;s not really obvious with the error messages you get, but using a thing like Form_Login does not work out of the box with a modular structure. Which is slightly surprising considering that it&#8217;s inside the default module.</p>
<p>I have found <a href="http://forums.zend.com/viewtopic.php?f=69&#038;t=1288&#038;start=0" class="external">examples like the second one below</a>, but no one mentions that you actually declare the default namespace too for everything to work.</p>
<pre><code>$autoloader = new Zend_Application_Module_Autoloader(array(
	'namespace' => '',
	'basePath'  => APPLICATION_PATH .'/modules/default',
	'resourceTypes' => array (
		'form' => array(
		'path' => 'forms',
		'namespace' => 'Form',
    ),
	'model' => array(
		'path' => 'models',
		'namespace' => 'Model',
    	),
    )
));

$autoloader = new Zend_Application_Module_Autoloader(array(
	'namespace' => 'Admin_',
	'basePath'  => APPLICATION_PATH .'/modules/admin',
	'resourceTypes' => array (
		'form' => array(
		'path' => 'forms',
		'namespace' => 'Form',
    ),
	'model' => array(
		'path' => 'models',
		'namespace' => 'Model',
    	),
    )
));</code></pre>
<div id="crp_related"><h2>Related Articles:</h2><ul><li><a href="http://think-robot.com/2009/02/zend-framework-decorators-labels-and-checkboxes/" rel="bookmark">Zend Framework Decorators - Labels and Checkboxes</a></li><li><a href="http://think-robot.com/2009/05/doctrine-many-to-many-with-extra-fields/" rel="bookmark">Doctrine Many To Many With Extra Fields</a></li><li><a href="http://think-robot.com/2009/04/zend_db_select-multiple-table-joins-explained/" rel="bookmark">Zend_Db_Select multiple table joins explained</a></li><li><a href="http://think-robot.com/2008/11/wordpress-nextgen-gallery-tweak/" rel="bookmark">WordPress NextGen gallery tweak</a></li><li><a href="http://think-robot.com/2011/08/edit-bios-in-lenovo-thinkpad-x220t/" rel="bookmark">Edit BIOS in Lenovo ThinkPad x220t</a></li></ul></div>]]></content:encoded>
			<wfw:commentRss>http://think-robot.com/2009/07/autloading-modular-forms-models-in-zend-framework-18/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
	</channel>
</rss>

