<?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>David Caunt</title>
	<atom:link href="http://www.davidcaunt.co.uk/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.davidcaunt.co.uk</link>
	<description>Mobile Software Engineer</description>
	<lastBuildDate>Sat, 21 Jan 2012 17:01:28 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1</generator>
		<item>
		<title>Android Gotcha &#8211; Action Bar Home Icon Doesn&#8217;t Work</title>
		<link>http://www.davidcaunt.co.uk/2012/01/21/android-gotcha-action-bar-home-icon-doesnt-work/</link>
		<comments>http://www.davidcaunt.co.uk/2012/01/21/android-gotcha-action-bar-home-icon-doesnt-work/#comments</comments>
		<pubDate>Sat, 21 Jan 2012 16:58:54 +0000</pubDate>
		<dc:creator>David</dc:creator>
				<category><![CDATA[Android]]></category>

		<guid isPermaLink="false">http://www.davidcaunt.co.uk/?p=168</guid>
		<description><![CDATA[Hopefully by now you&#8217;re using the Action Bar in your applications &#8211; it&#8217;s pretty much mandatory unless you&#8217;re making a game or something unusual. I recommend using the excellent ActionBarSherlock to deal with pre-Honeycomb platforms. Jumping straight in with ActionBarSherlock can cause you to skip over the official ActionBar docs, leading to confusion over implementation [...]]]></description>
			<content:encoded><![CDATA[<p>Hopefully by now you&#8217;re using the Action Bar in your applications &#8211; it&#8217;s pretty much <a title="Android Design Patterns - Action Bar" href="http://developer.android.com/design/patterns/actionbar.html" target="_blank">mandatory </a>unless you&#8217;re making a game or something unusual. I recommend using the excellent <a href="http://actionbarsherlock.com/" target="_blank">ActionBarSherlock </a>to deal with pre-Honeycomb platforms.</p>
<p>Jumping straight in with ActionBarSherlock can cause you to skip over the official ActionBar docs, leading to confusion over implementation details. On older devices the ActionBar home icon works fine and yet, on ICS, <a href="http://stackoverflow.com/questions/8953120/clicking-app-icon-doesnt-trigger-onoptionsitemselected/8953148" target="_blank">the button doesn&#8217;t work</a>!</p>
<p>For packages targetting API level 14 onwards, you need to explicitly enable the home button by calling <a rel="nofollow" href="http://developer.android.com/reference/android/app/ActionBar.html#setHomeButtonEnabled%28boolean%29"><code>setHomeButtonEnabled()</code></a></p>
<p>In your onCreate, add the following:</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>Build.<span style="color: #006633;">VERSION</span>.<span style="color: #006633;">SDK_INT</span> <span style="color: #339933;">&amp;</span>gt<span style="color: #339933;">;=</span> Build.<span style="color: #006633;">VERSION_CODES</span>.<span style="color: #006633;">ICE_CREAM_SANDWICH</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    getActionBar<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">setHomeButtonEnabled</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>The moral of the story is to always read the <a href="http://developer.android.com/guide/topics/ui/actionbar.html">official docs</a> and be aware of the differences between a native and compatibility library ActionBar implementation.</p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.davidcaunt.co.uk/2012/01/21/android-gotcha-action-bar-home-icon-doesnt-work/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Galaxy Nexus &#8211; Android 4 ICS Easter Egg</title>
		<link>http://www.davidcaunt.co.uk/2012/01/08/android-4-0-1-ice-cream-sandwich-easter-egg/</link>
		<comments>http://www.davidcaunt.co.uk/2012/01/08/android-4-0-1-ice-cream-sandwich-easter-egg/#comments</comments>
		<pubDate>Sun, 08 Jan 2012 22:16:16 +0000</pubDate>
		<dc:creator>David</dc:creator>
				<category><![CDATA[Android]]></category>

		<guid isPermaLink="false">http://www.davidcaunt.co.uk/?p=162</guid>
		<description><![CDATA[On your Galaxy Nexus, go to Settings -&#62; About phone and tap on the item which displays the version &#8216;Android version 4.0.1&#8242; three times. The settings screen and status bar will disappear and you&#8217;ll see this splash. Long press on the Android to enter a Nyandroid scene!]]></description>
			<content:encoded><![CDATA[<p>On your Galaxy Nexus, go to Settings -&gt; About phone and tap on the item which displays the version &#8216;Android version 4.0.1&#8242; three times.</p>
<p>The settings screen and status bar will disappear and you&#8217;ll see this splash. Long press on the Android to enter a Nyandroid scene!</p>
<p><img class="aligncenter" title="ICS Easter Egg" src="https://lh5.googleusercontent.com/-Ma8uFfrlz8Q/TwcuSOCF64I/AAAAAAAAB8s/_yGZO8PerLw/s512/2012-01-06.png" alt="" width="288" height="512" /></p>
]]></content:encoded>
			<wfw:commentRss>http://www.davidcaunt.co.uk/2012/01/08/android-4-0-1-ice-cream-sandwich-easter-egg/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Android Gotcha &#8211; Unable to instantiate service</title>
		<link>http://www.davidcaunt.co.uk/2011/10/21/android-gotcha-unable-to-instantiate-service/</link>
		<comments>http://www.davidcaunt.co.uk/2011/10/21/android-gotcha-unable-to-instantiate-service/#comments</comments>
		<pubDate>Fri, 21 Oct 2011 14:43:39 +0000</pubDate>
		<dc:creator>David</dc:creator>
				<category><![CDATA[Android]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[android-gotcha]]></category>

		<guid isPermaLink="false">http://www.davidcaunt.co.uk/?p=152</guid>
		<description><![CDATA[If you&#8217;re using Eclipse and create an IntentService class using the IDE&#8217;s correction features you&#8217;ll create a class like this: public class MyService extends IntentService &#123; &#160; public MyService&#40;String name&#41; &#123; super&#40;name&#41;; // TODO Auto-generated constructor stub &#125; &#160; @Override protected void onHandleIntent&#40;Intent intent&#41; &#123; // TODO Auto-generated method stub Log.d&#40;&#34;MyService&#34;, &#34;onHandleIntent (intent=&#34; + intent [...]]]></description>
			<content:encoded><![CDATA[<p>If you&#8217;re using Eclipse and create an IntentService class using the IDE&#8217;s correction features you&#8217;ll create a class like this:</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> MyService <span style="color: #000000; font-weight: bold;">extends</span> IntentService <span style="color: #009900;">&#123;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> MyService<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> name<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000000; font-weight: bold;">super</span><span style="color: #009900;">&#40;</span>name<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #666666; font-style: italic;">// TODO Auto-generated constructor stub</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    @Override
    <span style="color: #000000; font-weight: bold;">protected</span> <span style="color: #000066; font-weight: bold;">void</span> onHandleIntent<span style="color: #009900;">&#40;</span>Intent intent<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #666666; font-style: italic;">// TODO Auto-generated method stub        </span>
        Log.<span style="color: #006633;">d</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;MyService&quot;</span>, <span style="color: #0000ff;">&quot;onHandleIntent (intent=&quot;</span> <span style="color: #339933;">+</span> intent <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot;)&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>I&#8217;ve added a Log call so I can see my service receive intents.</p>
<p>When you trigger the service in your application, you&#8217;ll immediately see this cryptic force close error in your logcat:</p>
<pre>E/AndroidRuntime( 7758): FATAL EXCEPTION: main
E/AndroidRuntime( 7758): java.lang.RuntimeException: Unable to instantiate service com.example.brokenservice.service.MyService: java.lang.InstantiationException: com.example.brokenservice.service.MyService
E/AndroidRuntime( 7758): 	at android.app.ActivityThread.handleCreateService(ActivityThread.java:2177)
E/AndroidRuntime( 7758): 	at android.app.ActivityThread.access$2500(ActivityThread.java:132)
E/AndroidRuntime( 7758): 	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1102)
E/AndroidRuntime( 7758): 	at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime( 7758): 	at android.os.Looper.loop(Looper.java:143)
E/AndroidRuntime( 7758): 	at android.app.ActivityThread.main(ActivityThread.java:4263)
E/AndroidRuntime( 7758): 	at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime( 7758): 	at java.lang.reflect.Method.invoke(Method.java:507)
E/AndroidRuntime( 7758): 	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
E/AndroidRuntime( 7758): 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
E/AndroidRuntime( 7758): 	at dalvik.system.NativeStart.main(Native Method)
E/AndroidRuntime( 7758): Caused by: java.lang.InstantiationException: com.example.brokenservice.service.MyService
E/AndroidRuntime( 7758): 	at java.lang.Class.newInstanceImpl(Native Method)
E/AndroidRuntime( 7758): 	at java.lang.Class.newInstance(Class.java:1409)
E/AndroidRuntime( 7758): 	at android.app.ActivityThread.handleCreateService(ActivityThread.java:2174)
E/AndroidRuntime( 7758): 	... 10 more</pre>
<p>What gives?</p>
<p>The clue is in the java.lang.InstantiationException, which should be the first thing you search for. This suggests an issue with the constructor for MyService. </p>
<p>The problem is that the OS is looking for a constructor with no arguments, while the definition of IntentService has a constructor which takes a String name. This constructor is overridden by Eclipse. The correct definition of MyService looks like this:</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> MyService <span style="color: #000000; font-weight: bold;">extends</span> IntentService <span style="color: #009900;">&#123;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> MyService<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000000; font-weight: bold;">super</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;MyService&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #666666; font-style: italic;">// TODO Auto-generated constructor stub</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    @Override
    <span style="color: #000000; font-weight: bold;">protected</span> <span style="color: #000066; font-weight: bold;">void</span> onHandleIntent<span style="color: #009900;">&#40;</span>Intent intent<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #666666; font-style: italic;">// TODO Auto-generated method stub      </span>
        Log.<span style="color: #006633;">d</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;MyService&quot;</span>, <span style="color: #0000ff;">&quot;onHandleIntent (intent=&quot;</span> <span style="color: #339933;">+</span> intent <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot;)&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Thanks to <a href="http://stackoverflow.com/questions/6176255/why-do-i-get-an-instantiationexception-if-i-try-to-start-a-service/6176611#6176611">ddewaele on Stack Overflow</a> for the correct answer. </p>
]]></content:encoded>
			<wfw:commentRss>http://www.davidcaunt.co.uk/2011/10/21/android-gotcha-unable-to-instantiate-service/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Beyond the SDK &#8211; Improving the Android Development Workflow</title>
		<link>http://www.davidcaunt.co.uk/2011/04/07/beyond-the-sdk-improving-the-android-development-workflow/</link>
		<comments>http://www.davidcaunt.co.uk/2011/04/07/beyond-the-sdk-improving-the-android-development-workflow/#comments</comments>
		<pubDate>Thu, 07 Apr 2011 23:23:54 +0000</pubDate>
		<dc:creator>David</dc:creator>
				<category><![CDATA[Android]]></category>
		<category><![CDATA[docs]]></category>
		<category><![CDATA[logging]]></category>

		<guid isPermaLink="false">http://www.davidcaunt.co.uk/?p=117</guid>
		<description><![CDATA[So you&#8217;ve got the Android SDK installed and Eclipse doesn&#8217;t seem as bad as you remember, but what else is worth setting up before you get stuck into a project? Below are extensions, tools and tips to improve your workflow. Local documentation If you have browsed your local Android sdk folder you may have noticed [...]]]></description>
			<content:encoded><![CDATA[<p>So you&#8217;ve got the Android SDK installed and Eclipse doesn&#8217;t seem as bad as you remember, but what else is worth setting up before you get stuck into a project? Below are extensions, tools and tips to improve your workflow.</p>
<h2>Local documentation</h2>
<p>If you have browsed your local Android sdk folder you may have noticed that there is a docs folder. This folder contains everything you can browse online at developer.android.com and can be accessed locally to avoid network latency and server/network downtime.</p>
<p>Open &#8216;file:///path/to/android-sdk/docs/reference/packages.html&#8217; in your browser, replacing /path/to/android-sdk with your actual SDK path.</p>
<p><strong>Note</strong>: I found that the API level filter doesn&#8217;t work in Google Chrome, probably due to local script execution. Firefox doesn&#8217;t have this problem, but if you will use Google Chrome, creating an Apache vhost for your docs is one workaround. If you know how to fix this, please leave a comment below.</p>
<h2>Android SDK Reference search (Omnibox)</h2>
<p>Android developer Roman Nurik has created a <a href="https://chrome.google.com/webstore/detail/hgcbffeicehlpmgmnhnkjbjoldkfhoin" target="_blank">Google Chrome extension</a> which allows fast Android SDK Reference search including both classes and XML elements. By simple typing &#8216;ad&#8217; followed by your query, e.g. &#8216;ad ViewG&#8217; you&#8217;ll see all classes beginning with &#8216;ViewG&#8217;.</p>
<p>This extension also adds links on class reference pages linking to the source on android.git.kernel.org.</p>
<p><img class="alignnone" title="Google Chrome Omnibox featuring Android SDK search" src="https://chrome.google.com/webstore/img/hgcbffeicehlpmgmnhnkjbjoldkfhoin/1298536812.45/screenshot_cws/2002" alt="Google Chrome Omnibox featuring Android SDK search" width="400" height="275" /></p>
<p>Source code for this extension is available at <a href="http://code.google.com/p/romannurik-code/source/browse/#hg%2Fchrome-extensions%2Fandroid-sdk-reference-search%2Fextension">code.google.com</a> and this extension could easily be customised to link to your local documentation (see above).</p>
<h2>Android sources</h2>
<p>Eclipse displays API documentation and autocompletes code but you can&#8217;t view the source of Android platform code within the IDE. Fortunately there is a <a href="http://code.google.com/p/adt-addons/">plugin</a> which will download and install the sources for you. You can then ctrl/cmd click on any line of code to see how it is actually implemented.  I often find this useful when documentation isn&#8217;t clear, and it&#8217;s a great way to improve your own code.</p>
<h2>Coloured logcat output</h2>
<p><a href="http://jsharkey.org/blog/">Jeff Sharkey</a> has written a great python script for colouring logcat output &#8211; <a href="http://jsharkey.org/blog/2009/04/22/modifying-the-android-logcat-stream-for-full-color-debugging/">colouredlogcat.py</a>. This script simply colours lines from different programs in different colours, making logs more readable. I recommend putting this one on your <a href="http://en.wikipedia.org/wiki/Path_(computing)">PATH</a>.</p>
<p><img class="aligncenter" title="colouredlogcat.py" src="http://jsharkey.org/downloads/colorcat.png" alt="Sample output from colouredlogcat.py" width="660" height="230" /></p>
<h2>Android Asset Studio</h2>
<p>Don&#8217;t have an <a title="I'm fortunate enough to work with Ian Wharton" href="http://ianwharton.com/" target="_blank">awesome in-house designer</a>? Again Roman Nurik has your back with his <a href="http://android-ui-utils.googlecode.com/hg/asset-studio/dist/index.html" target="_blank">Android Asset Studio</a>, a set of web-based tools for generating image assets for your project. These are useful for prototyping but can generate production quality assets without launching Photoshop.</p>
<h2><span style="font-size: 20px; font-weight: bold;">Themes</span></h2>
<p>Roman Nurik&#8217;s Android themes won&#8217;t increase your productivity but they will make your browser more awesome! There&#8217;s a <a href="https://chrome.google.com/webstore/detail/ihhhgnjnpmjaikooiahhhlemccommcml" target="_blank">honeycomb theme</a> and a <a href="https://chrome.google.com/webstore/detail/oeljdmeofcikjblcoehpmdnooimalbmj" target="_blank">traditional Android version</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.davidcaunt.co.uk/2011/04/07/beyond-the-sdk-improving-the-android-development-workflow/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>WebView gradient backgrounds</title>
		<link>http://www.davidcaunt.co.uk/2011/04/05/webview-gradient-backgrounds/</link>
		<comments>http://www.davidcaunt.co.uk/2011/04/05/webview-gradient-backgrounds/#comments</comments>
		<pubDate>Tue, 05 Apr 2011 21:08:41 +0000</pubDate>
		<dc:creator>David</dc:creator>
				<category><![CDATA[Android]]></category>
		<category><![CDATA[android]]></category>
		<category><![CDATA[gotcha]]></category>

		<guid isPermaLink="false">http://www.davidcaunt.co.uk/?p=100</guid>
		<description><![CDATA[One of those easy questions shot up on Stack Overflow where a few people quickly jump in with an answer. How do you set a gradient background on a view? Three answers later and the question poster refines his question: &#8220;What about a WebView?&#8221; While we all assumed the answer to be the same, WebViews [...]]]></description>
			<content:encoded><![CDATA[<p>One of those easy questions shot up on Stack Overflow where a few people quickly jump in with an answer. How do you set a gradient background on a view?</p>
<p>Three answers later and the question poster refines his question: &#8220;What about a WebView?&#8221; While we all assumed the answer to be the same, WebViews ignore any background drawable used while a background colour is set. The default <a href="http://developer.android.com/reference/android/webkit/WebView.html#setBackgroundColor(int)" target="_blank">background colour for a WebView is white</a>, so you need to make it transparent.</p>
<p>Simply specify 0 as your colour and add a drawable in code or via layout XML.</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;">WebView webview <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>WebView<span style="color: #009900;">&#41;</span>findViewById<span style="color: #009900;">&#40;</span>R.<span style="color: #006633;">id</span>.<span style="color: #006633;">wv</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
webview.<span style="color: #006633;">setBackgroundColor</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
webview.<span style="color: #006633;">setBackgroundResource</span><span style="color: #009900;">&#40;</span>R.<span style="color: #006633;">drawable</span>.<span style="color: #006633;">gradient</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>You can view the original discussion on <a href="http://stackoverflow.com/questions/5551957/how-can-i-set-a-gradient-background-on-a-webview/5552052" target="_blank">Stack Overflow</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.davidcaunt.co.uk/2011/04/05/webview-gradient-backgrounds/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Easy command line scripts with Zend Application</title>
		<link>http://www.davidcaunt.co.uk/2010/02/25/easy-command-line-scripts-with-zend-application/</link>
		<comments>http://www.davidcaunt.co.uk/2010/02/25/easy-command-line-scripts-with-zend-application/#comments</comments>
		<pubDate>Thu, 25 Feb 2010 00:46:22 +0000</pubDate>
		<dc:creator>David</dc:creator>
				<category><![CDATA[Zend Framework]]></category>
		<category><![CDATA[cli]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[zend-application]]></category>
		<category><![CDATA[zend-framework]]></category>

		<guid isPermaLink="false">http://www.davidcaunt.co.uk/?p=83</guid>
		<description><![CDATA[As PHP developers, it is convenient to be able to write command line scripts in PHP. In doing so, you will almost certainly want access to Zend Framework components and their configurations as if you are writing a normal MVC app, but without invoking the MVC stack and without loading unnecessary resources. I&#8217;ve seen solutions [...]]]></description>
			<content:encoded><![CDATA[<p>As PHP developers, it is convenient to be able to write command line scripts in PHP. In doing so, you will almost certainly want access to Zend Framework components and their configurations as if you are writing a normal MVC app, but without invoking the MVC stack and without loading unnecessary resources. I&#8217;ve seen solutions where actions are exposed as controller actions and called by wget &#8211; these are counter-intuitive, inefficient, and will suffer from max execution timeouts and other problems.</p>
<h4>Zend_Applicaton to the rescue</h4>
<p>Lets start with our website&#8217;s public/index.php &#8211; the script which sets up and launches an application. It looks roughly like this:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// Define path to application directory</span>
<span style="color: #990000;">defined</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'APPLICATION_PATH'</span><span style="color: #009900;">&#41;</span>
    <span style="color: #339933;">||</span> <span style="color: #990000;">define</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'APPLICATION_PATH'</span><span style="color: #339933;">,</span>
              <span style="color: #990000;">realpath</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">dirname</span><span style="color: #009900;">&#40;</span><span style="color: #009900; font-weight: bold;">__FILE__</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'/../application'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// Define application environment</span>
<span style="color: #990000;">defined</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'APPLICATION_ENV'</span><span style="color: #009900;">&#41;</span>
    <span style="color: #339933;">||</span> <span style="color: #990000;">define</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'APPLICATION_ENV'</span><span style="color: #339933;">,</span>
              <span style="color: #009900;">&#40;</span><span style="color: #990000;">getenv</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'APPLICATION_ENV'</span><span style="color: #009900;">&#41;</span> ? <span style="color: #990000;">getenv</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'APPLICATION_ENV'</span><span style="color: #009900;">&#41;</span>
                                         <span style="color: #339933;">:</span> <span style="color: #0000ff;">'production'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #b1b100;">require_once</span> <span style="color: #0000ff;">'Zend/Application.php'</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$application</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Zend_Application<span style="color: #009900;">&#40;</span>
    APPLICATION_ENV<span style="color: #339933;">,</span>
    APPLICATION_PATH <span style="color: #339933;">.</span> <span style="color: #0000ff;">'/configs/config.php'</span>
<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$application</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">bootstrap</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">run</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>One feature of <a href="http://framework.zend.com/manual/en/zend.application.theory-of-operation.html">Zend Application</a> is that you can choose to bootstrap only certain resources, rather than all of those referenced in your application config and bootstrap (_init methods.) The following assumes that our script needs to use the database, and send an email.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// Define path to application directory</span>
<span style="color: #990000;">defined</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'APPLICATION_PATH'</span><span style="color: #009900;">&#41;</span>
    <span style="color: #339933;">||</span> <span style="color: #990000;">define</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'APPLICATION_PATH'</span><span style="color: #339933;">,</span>
              <span style="color: #990000;">realpath</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">dirname</span><span style="color: #009900;">&#40;</span><span style="color: #009900; font-weight: bold;">__FILE__</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'/../application'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// Define application environment</span>
<span style="color: #990000;">defined</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'APPLICATION_ENV'</span><span style="color: #009900;">&#41;</span>
    <span style="color: #339933;">||</span> <span style="color: #990000;">define</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'APPLICATION_ENV'</span><span style="color: #339933;">,</span>
              <span style="color: #009900;">&#40;</span><span style="color: #990000;">getenv</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'APPLICATION_ENV'</span><span style="color: #009900;">&#41;</span> ? <span style="color: #990000;">getenv</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'APPLICATION_ENV'</span><span style="color: #009900;">&#41;</span>
                                         <span style="color: #339933;">:</span> <span style="color: #0000ff;">'production'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #b1b100;">require_once</span> <span style="color: #0000ff;">'Zend/Application.php'</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$application</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Zend_Application<span style="color: #009900;">&#40;</span>
    APPLICATION_ENV<span style="color: #339933;">,</span>
    APPLICATION_PATH <span style="color: #339933;">.</span> <span style="color: #0000ff;">'/configs/config.php'</span>
<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//only load resources we need for script, in this case db and mail</span>
<span style="color: #000088;">$application</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">bootstrap</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'db'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'mail'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Having bootstrapped the resources, we can retrieve them from the application as follows:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$db</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$application</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getBootstrap</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getResource</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'db'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//do something!</span>
<span style="color: #000088;">$row</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$db</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">fetchRow</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'SELECT * FROM something'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.davidcaunt.co.uk/2010/02/25/easy-command-line-scripts-with-zend-application/feed/</wfw:commentRss>
		<slash:comments>12</slash:comments>
		</item>
		<item>
		<title>Zend Framework Pitfalls Part 2 – Zend_Db Won&#8217;t Use the Query Cache with MySQL</title>
		<link>http://www.davidcaunt.co.uk/2009/11/28/zend-framework-pitfalls-part-2-zend_db-wont-use-the-query-cache-with-mysql/</link>
		<comments>http://www.davidcaunt.co.uk/2009/11/28/zend-framework-pitfalls-part-2-zend_db-wont-use-the-query-cache-with-mysql/#comments</comments>
		<pubDate>Sat, 28 Nov 2009 13:35:26 +0000</pubDate>
		<dc:creator>David</dc:creator>
				<category><![CDATA[Zend Framework]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[performance]]></category>
		<category><![CDATA[pitfalls]]></category>
		<category><![CDATA[zend-framework]]></category>

		<guid isPermaLink="false">http://www.davidcaunt.co.uk/?p=74</guid>
		<description><![CDATA[This one&#8217;s not limited to Zend Framework, but is actually a &#8216;problem&#8217; in MySQL. I think it is worth covering, as the paragraph in the manual is easily missed. From the MySQL manual: Before MySQL 5.1.17, prepared statements do not use the query cache. Beginning with 5.1.17, prepared statements use the query cache under certain [...]]]></description>
			<content:encoded><![CDATA[<p>This one&#8217;s not limited to Zend Framework, but is actually a &#8216;problem&#8217; in MySQL. I think it is worth covering, as the <a href="http://framework.zend.com/manual/en/zend.db.html#zend.db.adapter.other-statements" target="_blank">paragraph in the manual</a> is easily missed.</p>
<p>From the MySQL manual:</p>
<blockquote><p>Before MySQL 5.1.17, prepared statements do <em>not </em>use the query cache. Beginning with 5.1.17, prepared statements use the query cache under certain conditions, which differ depending on the preparation method</p></blockquote>
<p>This means that if you&#8217;re running MySQL 5.0.x, not uncommon at the time of writing, your applications are not going to benefit from the query cache. There&#8217;s a simple workaround, however:</p>
<p>If you&#8217;re using Pdo, set the following driver option:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$pdoParams</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
    PDO<span style="color: #339933;">::</span><span style="color: #004000;">MYSQL_ATTR_USE_BUFFERED_QUERY</span> <span style="color: #339933;">=&gt;</span> <span style="color: #009900; font-weight: bold;">true</span>
<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$params</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
    <span style="color: #0000ff;">'host'</span>           <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'127.0.0.1'</span><span style="color: #339933;">,</span>
    <span style="color: #0000ff;">'username'</span>       <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'webuser'</span><span style="color: #339933;">,</span>
    <span style="color: #0000ff;">'password'</span>       <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'xxxxxxxx'</span><span style="color: #339933;">,</span>
    <span style="color: #0000ff;">'dbname'</span>         <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'test'</span><span style="color: #339933;">,</span>
    <span style="color: #0000ff;">'driver_options'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$pdoParams</span>
<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Zend_Config_Ini [<a href="http://php.net/parse_ini_file" target="_blank">parse_ini_file()</a>] doesn&#8217;t support class constants, so ini users will have to supply the value of PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, 1000, in their configs:</p>

<div class="wp_syntax"><div class="code"><pre class="ini" style="font-family:monospace;">resources.db.adapter         <span style="color: #000066; font-weight:bold;">=</span><span style="color: #660066;"> pdo_mysql</span>
resources.db.params.host     <span style="color: #000066; font-weight:bold;">=</span><span style="color: #660066;"> localhost</span>
resources.db.params.username <span style="color: #000066; font-weight:bold;">=</span><span style="color: #660066;"> webuser</span>
resources.db.params.password <span style="color: #000066; font-weight:bold;">=</span><span style="color: #660066;"> xxxxxxxx</span>
resources.db.params.dbname   <span style="color: #000066; font-weight:bold;">=</span><span style="color: #660066;"> myDb</span>
resources.db.params.driver_options.1000 <span style="color: #000066; font-weight:bold;">=</span><span style="color: #660066;"> true</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.davidcaunt.co.uk/2009/11/28/zend-framework-pitfalls-part-2-zend_db-wont-use-the-query-cache-with-mysql/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Serving gzipped assets from Amazon S3 &amp; Cloudfront</title>
		<link>http://www.davidcaunt.co.uk/2009/10/13/serving-gzipped-assets-from-amazon-s3-and-cloudfront/</link>
		<comments>http://www.davidcaunt.co.uk/2009/10/13/serving-gzipped-assets-from-amazon-s3-and-cloudfront/#comments</comments>
		<pubDate>Tue, 13 Oct 2009 14:58:59 +0000</pubDate>
		<dc:creator>David</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[aws]]></category>
		<category><![CDATA[cloudfront]]></category>
		<category><![CDATA[performance]]></category>

		<guid isPermaLink="false">http://www.davidcaunt.co.uk/?p=64</guid>
		<description><![CDATA[One of the first steps in improving front-end performance is to migrate static assets to a content delivery network, such as Amazon&#8217;s CloudFront or Akamai. CloudFront is particularly attractive with its pay-as-you-go model, tiny upfront investment and ease of use. Your existing web server may already be set up to compress JavaScript and CSS, potentially saving hundreds of kb [...]]]></description>
			<content:encoded><![CDATA[<p>One of the first steps in improving front-end performance is to migrate static assets to a content delivery network, such as Amazon&#8217;s <a href="http://aws.amazon.com/cloudfront/">CloudFront</a> or <a href="http://www.akamai.com/">Akamai</a>. CloudFront is particularly attractive with its pay-as-you-go model, tiny upfront investment and ease of use.</p>
<p>Your existing web server may already be set up to compress JavaScript and CSS, potentially saving hundreds of kb on the wire. In uploading and testing your assets on CloudFront you&#8217;ll soon realise that it doesn&#8217;t perform any gzipping or compression. How to benefit from Amazon&#8217;s superfast edge locations <em>and </em>smaller file sizes?</p>
<p>When your browser requests a page, the headers sent might look like the following:</p>
<pre>Host: www.davidcaunt.co.uk
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.9.1.3) Gecko/20090824 Firefox/3.5.3 (.NET CLR 3.5.30729) FirePHP/0.3
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-US,en;q=0.8,en-gb;q=0.5,en-us;q=0.3
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 300
Connection: keep-alive
Referer: http://www.davidcaunt.co.uk/about/</pre>
<p>The header we&#8217;re interested in here is Accept-Encoding &#8211; this denotes whether the browser can cope with gzipped assets, and is used by Apache to decide whether to compress them. We can use this header in our PHP scripts to reference pre-compressed assets, and here&#8217;s how:</p>
<ol>
<li>Compress asset, e.g. home.css -&gt; home.cssgz</li>
<li>Upload both files, home.css and home.cssgz to S3 (CloudFront)</li>
<li>Add PHP code to link to the compressed file if the browser accepts</li>
</ol>
<p>You can easily compress assets on Linux using the following:</p>
<pre>gzip home.css</pre>
<p>In step 2, you&#8217;ll need to inform S3 that your assets are gzipped. S3 allows you to specify headers that will be sent with your file:</p>
<pre>Content-Encoding: gzip</pre>
<p>All good libraries and gui tools will help with this. It also makes sense to set Expires headers, if your assets are versioned.</p>
<p>Then the following PHP snippet should be all you need:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #009900; font-weight: bold;">false</span> <span style="color: #339933;">!==</span> <span style="color: #990000;">strpos</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'HTTP_ACCEPT_ENCODING'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'gzip'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	<span style="color: #000088;">$path</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'/css/home.cssgz'</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #b1b100;">else</span><span style="color: #009900;">&#123;</span>
	<span style="color: #000088;">$path</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'/css/home.css'</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>You&#8217;ll want to integrate this code into your View Helpers (Zend Framework) or application code for generating asset URLs.</p>
<p><strong><span style="text-decoration: underline;">Note</span></strong></p>
<p>You&#8217;ll notice I&#8217;ve named my file home.cssgz, not home.css.gz. I had problems with Safari PC (and probably Mac) refusing to use these files inline, and being disposed as attachments.</p>
<p><span style="text-decoration: underline;"><strong><br />
</strong></span></p>
]]></content:encoded>
			<wfw:commentRss>http://www.davidcaunt.co.uk/2009/10/13/serving-gzipped-assets-from-amazon-s3-and-cloudfront/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Zend Framework Pitfalls Part 1 &#8211; Zend_Auth</title>
		<link>http://www.davidcaunt.co.uk/2009/10/12/zend-framework-pitfalls-part-1-zend_auth/</link>
		<comments>http://www.davidcaunt.co.uk/2009/10/12/zend-framework-pitfalls-part-1-zend_auth/#comments</comments>
		<pubDate>Mon, 12 Oct 2009 10:12:17 +0000</pubDate>
		<dc:creator>David</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Zend Framework]]></category>
		<category><![CDATA[pitfalls]]></category>
		<category><![CDATA[zend-auth]]></category>
		<category><![CDATA[zend-framework]]></category>

		<guid isPermaLink="false">http://www.davidcaunt.co.uk/?p=51</guid>
		<description><![CDATA[Foreword Zend Framework is excellent; this series of posts entitled &#8216;Zend Framework Pitfalls&#8217; won&#8217;t try and dispute that. There are, however, one or two problems and poorly implemented components that can cause problems. Before using any library component it is important to be aware of any drawbacks and issues. It is then possible to make [...]]]></description>
			<content:encoded><![CDATA[<h3>Foreword</h3>
<p>Zend Framework is excellent; this series of posts entitled &#8216;Zend Framework Pitfalls&#8217; won&#8217;t try and dispute that. There are, however, one or two problems and poorly implemented components that can cause problems. Before using any library component it is important to be aware of any drawbacks and issues. It is then possible to make an objective decision before investing your time, and you can avoid banging your head against the desk understanding a known bug or problem that isn&#8217;t well documented.</p>
<h4><strong>Component</strong></h4>
<p><a href="http://framework.zend.com/manual/en/zend.auth.html">Zend_Auth</a></p>
<h4>Priority</h4>
<p>Minor (<a href="http://framework.zend.com/issues/secure/ShowConstantsHelp.jspa?decorator=popup#PriorityLevels" target="_blank">definition</a>)</p>
<h4>Problem</h4>
<p>Zend_Auth is implemented as a <a href="http://en.wikipedia.org/wiki/Singleton_pattern">singleton</a><strong>. </strong>This singleton references a single instance of Zend_Auth_Storage_Interface, used to persist an identity. This makes management of two or more authentication systems (e.g. frontend and admin) difficult. You must manually set the storage each time you want to query a different identity.</p>
<h4>Solution 1 &#8211; Don&#8217;t use multiple authentication systems</h4>
<p>In most simple web applications, you can use a single user database (table) to store both common users and administrators, and expose administrator privileges as appropriate via Zend_Acl or similar.</p>
<h4>Solution 2 &#8211; Toggle storage</h4>
<p>Zend_Auth has a method for changing storage, setStorage. Calling this method every time before retrieving the identity object is viable, but you have to remember to do so <em>every</em> time or you could read the wrong storage. This can be wrapped up for practicality:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">class</span> My_Auth <span style="color: #000000; font-weight: bold;">extends</span> Zend_Auth <span style="color: #009900;">&#123;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> static <span style="color: #000000; font-weight: bold;">function</span> getInstance<span style="color: #009900;">&#40;</span><span style="color: #000088;">$storageNamespace</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'Zend_Auth'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
&nbsp;
		<span style="color: #666666; font-style: italic;">// set namespace</span>
		<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setStorage</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> Zend_Auth_Storage_Session<span style="color: #009900;">&#40;</span><span style="color: #000088;">$storageNamespace</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #b1b100;">return</span> parent<span style="color: #339933;">::</span><span style="color: #004000;">getInstance</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Remember to use this getInstance method every time you need to access your auth (and namespace) rather than storing a reference to the Zend_Auth instance.</p>
<h4>Solution 3 &#8211; Your own implementation of Zend_Auth</h4>
<p>Zend_Auth doesn&#8217;t actually do much heavy lifting. You could write something that can take advantage of the other Zend_Auth_* components, without implementing the singleton pattern. This is suggested in the <a href="http://framework.zend.com/manual/en/zend.auth.html#zend.auth.introduction.persistence">reference manual</a>.</p>
<h4>Summary</h4>
<p>It is unlikely that Zend_Auth will be re-architected for the 2.0 release of Zend Framework, the earliest opportunity for a break in backwards compatibility. Whether the singleton pattern is appropriate is debatable and a strongly advantageous alternative solution would be necessary to justify any changes.</p>
<p>As always, your comments and solution suggestions are welcomed.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.davidcaunt.co.uk/2009/10/12/zend-framework-pitfalls-part-1-zend_auth/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Avoiding Firefox &#8216;screen jumping&#8217; when scrollbars are displayed</title>
		<link>http://www.davidcaunt.co.uk/2009/09/15/avoiding-firefox-screen-jumping-when-scrollbars-are-displayed/</link>
		<comments>http://www.davidcaunt.co.uk/2009/09/15/avoiding-firefox-screen-jumping-when-scrollbars-are-displayed/#comments</comments>
		<pubDate>Tue, 15 Sep 2009 12:31:27 +0000</pubDate>
		<dc:creator>David</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[firefox]]></category>
		<category><![CDATA[ux]]></category>

		<guid isPermaLink="false">http://www.davidcaunt.co.uk/?p=41</guid>
		<description><![CDATA[I recently discovered a simple way to improve the experience of Firefox users when navigating through a website. When a document is longer than the viewport, Firefox will display a vertical scrollbar, but when the document is shorter the scrollbar is not displayed. Constant toggling of the scrollbar is jarring to users and often gives [...]]]></description>
			<content:encoded><![CDATA[<p>I recently discovered a simple way to improve the experience of Firefox users when navigating through a website. When a document is longer than the viewport, Firefox will display a vertical scrollbar, but when the document is shorter the scrollbar is not displayed. Constant toggling of the scrollbar is jarring to users and often gives the illusion that your pages are not consistently designed.</p>
<p>Fortunately there&#8217;s a fix which means the scrollbar is always displayed. Simply add this to your css:</p>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;">html <span style="color: #00AA00;">&#123;</span>
    overflow-y<span style="color: #00AA00;">:</span><span style="color: #993333;">scroll</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.davidcaunt.co.uk/2009/09/15/avoiding-firefox-screen-jumping-when-scrollbars-are-displayed/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

