<?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>Jim Lam - Project Manager, Technical Team Lead &#38; Senior LAMP/Front End Developer</title>
	<atom:link href="http://jimlam.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://jimlam.com</link>
	<description>PHP, MySQL,  jQuery, HTML, CSS, Javascript, Photoshop, SEO, Linux/Apache, Subversion, Adwords/Analytics, XML</description>
	<lastBuildDate>Sat, 11 Feb 2012 13:16:53 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
<xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" name="robots" content="noindex" />
		<item>
		<title>Check if the start of the month is in X days &#8211; PHP function</title>
		<link>http://jimlam.com/php/check-if-the-start-of-the-month-is-in-x-days-php-function/</link>
		<comments>http://jimlam.com/php/check-if-the-start-of-the-month-is-in-x-days-php-function/#comments</comments>
		<pubDate>Sat, 11 Feb 2012 13:14:51 +0000</pubDate>
		<dc:creator>Jim Lam</dc:creator>
				<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://jimlam.com/?p=640</guid>
		<description><![CDATA[I was working on a project which required a daily cron to run and perform certain operations if it was a specific number of days before the start of the following month. I used this as a class method to &#8230; <a href="http://jimlam.com/php/check-if-the-start-of-the-month-is-in-x-days-php-function/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I was working on a project which required a daily cron to run and perform certain operations if it was a specific number of days before the start of the following month.</p>
<p>I used this as a class method to check both 48hrs and 24hrs before the 1st, as well as on the actual day itself.</p>
<p>Here&#8217;s the simple PHP function I came up with:</p>
<pre class="brush: php; title: ; notranslate">
function isStartOfMonthInXDays( $days )
{

	$day = date( 'j', strtotime( '+'. $days .' day' ) );

	if ( $day == 1 ) {
		return true;
	}
	else {
		return false;
	}

}
</pre>
<p><span id="more-640"></span><br />
If you found this article useful, help me out by leaving a <strong>comment</strong> below and clicking the <strong>Like</strong> button.<br />
<script type="text/javascript"><!--
google_ad_client = "ca-pub-8723168851783984";
/* Blog Rect */
google_ad_slot = "8412103904";
google_ad_width = 300;
google_ad_height = 250;
//-->
</script><br />
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></p>
<div id="fb-root"></div>
<p><script>(function(d, s, id) {
  var js, fjs = d.getElementsByTagName(s)[0];
  if (d.getElementById(id)) {return;}
  js = d.createElement(s); js.id = id;
  js.src = "//connect.facebook.net/en_US/all.js#xfbml=1";
  fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script></p>
<div class="fb-comments" data-href="http://jimlam.com/php/check-if-the-start-of-the-month-is-in-x-days/" data-num-posts="10" data-width="460"></div>
<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fjimlam.com%2Fphp%2Fcheck-if-the-start-of-the-month-is-in-x-days-php-function%2F&amp;layout=standard&amp;show_faces=true&amp;width=450&amp;action=like&amp;colorscheme=light&amp;height=80" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:450px; height:80px;" allowTransparency="true"></iframe>]]></content:encoded>
			<wfw:commentRss>http://jimlam.com/php/check-if-the-start-of-the-month-is-in-x-days-php-function/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP Fatal error: Out of memory &#8211; Prevention better than Cure</title>
		<link>http://jimlam.com/php/php-fatal-error-out-of-memory-prevention-better-than-cure/</link>
		<comments>http://jimlam.com/php/php-fatal-error-out-of-memory-prevention-better-than-cure/#comments</comments>
		<pubDate>Thu, 08 Dec 2011 14:49:02 +0000</pubDate>
		<dc:creator>Jim Lam</dc:creator>
				<category><![CDATA[MySQL]]></category>
		<category><![CDATA[Performance]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://jimlam.com/?p=545</guid>
		<description><![CDATA[While running a PHP script you may encounter the dreaded &#8220;Fatal error: Out of memory&#8221; message. It is usually be accompanied with a few long numbers which represent the number of bytes the script tried to allocate. The obvious fix &#8230; <a href="http://jimlam.com/php/php-fatal-error-out-of-memory-prevention-better-than-cure/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>While running a PHP script you may encounter the dreaded &#8220;<strong>Fatal error: Out of memory</strong>&#8221; message. It is usually be accompanied with a few long numbers which represent the number of bytes the script tried to allocate.</p>
<p>The obvious fix would be to <strong>increase the memory limit</strong> in the php.ini, apache config, .htaccess or at the top of the script itself:</p>
<pre class="brush: php; title: ; notranslate">
ini_set('memory_limit', '64M');
</pre>
<p>Increasing the amount of memory will possibly make the error disappear, but for how long? Really all you are doing is <strong>suppressing</strong> the problem, which will more than likely rear it&#8217;s ugly head again in the future.</p>
<p>The best course of action is to get to the real <strong>root cause</strong> of the problem. Why is the script using so much memory? Can the code be <strong>refactored</strong> to make it more <strong>efficient</strong>?</p>
<p>In order to diagnose <strong>why</strong>, you need to identify <strong>where</strong>. Some strategically placed debug code is required. Using <strong>memory_get_usage()</strong>, a built in PHP function, will return the number of bytes the script is using at that point.  </p>
<pre class="brush: php; title: ; notranslate">
echo memory_get_usage();

// Make it more human-readable. Convert Bytes to MB.
echo intval((memory_get_usage() / 1024) / 1024) . &quot;MB\n&quot;;
</pre>
<p>It can be a little tedious, but working line by line or in areas you think could be symptomatic will quickly highlight where you should concentrate your optimisation efforts.</p>
<p>A common cause is a very <strong>large result set</strong> from a MySQL query. The returned data is read into memory and stored until such time PHP decides it&#8217;s no longer required. <strong>Do you really need to select all fields, or all rows?</strong></p>
<pre class="brush: sql; title: ; notranslate">
SELECT * FROM `tablename`

SELECT `id`,`surname`,`age` FROM `tablename`
</pre>
<p>If you only require 5 of the 10 fields in a table, you consume approximately <strong>50% less memory</strong>. On small result sets it&#8217;s not significant, but when you have 10K plus rows it can really start to add up. Also consider using LIMIT to only retrieve the rows you need.</p>
<p>There is also a minimal saving to be made by returning the results as an <strong>array</strong>, rather than an <strong>object</strong> as can be the case with some Active Record libraries.</p>
<h2>The Takeaway</h2>
<p><strong>Prevention is better than cure</strong>. A quick fix will always come back to <em>byte</em> you!<br />
<span id="more-545"></span><br />
If you found this article useful, help me out by leaving a <strong>comment</strong> below and clicking the <strong>Like</strong> button.<br />
<script type="text/javascript"><!--
google_ad_client = "ca-pub-8723168851783984";
/* Blog Rect */
google_ad_slot = "8412103904";
google_ad_width = 300;
google_ad_height = 250;
//-->
</script><br />
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></p>
<div id="fb-root"></div>
<p><script>(function(d, s, id) {
  var js, fjs = d.getElementsByTagName(s)[0];
  if (d.getElementById(id)) {return;}
  js = d.createElement(s); js.id = id;
  js.src = "//connect.facebook.net/en_US/all.js#xfbml=1";
  fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script></p>
<div class="fb-comments" data-href="http://jimlam.com/php/php-fatal-error-out-of-memory-prevention-better-than-cure/" data-num-posts="10" data-width="460"></div>
<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fjimlam.com%2Fphp%2Fphp-fatal-error-out-of-memory-prevention-better-than-cure%2F&amp;layout=standard&amp;show_faces=true&amp;width=450&amp;action=like&amp;colorscheme=light&amp;height=80" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:450px; height:80px;" allowTransparency="true"></iframe>]]></content:encoded>
			<wfw:commentRss>http://jimlam.com/php/php-fatal-error-out-of-memory-prevention-better-than-cure/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Dynamic object property names in Javascript</title>
		<link>http://jimlam.com/javascript/dynamic-object-property-names-in-javascript/</link>
		<comments>http://jimlam.com/javascript/dynamic-object-property-names-in-javascript/#comments</comments>
		<pubDate>Sun, 04 Dec 2011 16:36:04 +0000</pubDate>
		<dc:creator>Jim Lam</dc:creator>
				<category><![CDATA[Javascript]]></category>

		<guid isPermaLink="false">http://jimlam.com/?p=455</guid>
		<description><![CDATA[Have ever needed to create a Javascript object with dynamic property names? You may have found that your dynamic variable name was actually used literally. eval() is your friend&#8230; If you found this article useful, help me out by leaving &#8230; <a href="http://jimlam.com/javascript/dynamic-object-property-names-in-javascript/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Have ever needed to create a Javascript object with dynamic property names? You may have found that your dynamic variable name was actually used literally. eval() is your friend&#8230;</p>
<pre class="brush: jscript; title: ; notranslate">
// Initialise an object.
var myObj = new Object();

var testValue = 'Jim Lam'; 

// Assign your dynamic property name. e.g. via PHP.
var dynamicPropertyName = 'changeable'; 

// WRONG. Creates a property called 'dynamicPropertyName'.
myObj.dynamicPropertyName = testValue;

// RIGHT. Creates a property called 'changeable'.
eval(&quot;myObj.&quot; + dynamicPropertyName + &quot; = '&quot; + testValue + &quot;' &quot;);

// Check.
alert(myObj.changeable); // Jim Lam
</pre>
<p><span id="more-455"></span><br />
If you found this article useful, help me out by leaving a <strong>comment</strong> below and clicking the <strong>Like</strong> button.<br />
<script type="text/javascript"><!--
google_ad_client = "ca-pub-8723168851783984";
/* Blog Rect */
google_ad_slot = "8412103904";
google_ad_width = 300;
google_ad_height = 250;
//-->
</script><br />
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></p>
<div id="fb-root"></div>
<p><script>(function(d, s, id) {
  var js, fjs = d.getElementsByTagName(s)[0];
  if (d.getElementById(id)) {return;}
  js = d.createElement(s); js.id = id;
  js.src = "//connect.facebook.net/en_US/all.js#xfbml=1";
  fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script></p>
<div class="fb-comments" data-href="http://jimlam.com/javascript/dynamic-object-property-names-in-javascript/" data-num-posts="10" data-width="460"></div>
<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fjimlam.com%2Fjavascript%2Fdynamic-object-property-names-in-javascript%2F&amp;layout=standard&amp;show_faces=true&amp;width=450&amp;action=like&amp;colorscheme=light&amp;height=80" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:450px; height:80px;" allowTransparency="true"></iframe>]]></content:encoded>
			<wfw:commentRss>http://jimlam.com/javascript/dynamic-object-property-names-in-javascript/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Format price with 2 decimal places in PHP</title>
		<link>http://jimlam.com/php/format-price-with-2-decimal-places-in-php/</link>
		<comments>http://jimlam.com/php/format-price-with-2-decimal-places-in-php/#comments</comments>
		<pubDate>Sat, 03 Dec 2011 12:15:23 +0000</pubDate>
		<dc:creator>Jim Lam</dc:creator>
				<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://jimlam.com/?p=442</guid>
		<description><![CDATA[Example usage: If you found this article useful, help me out by leaving a comment below and clicking the Like button.]]></description>
			<content:encoded><![CDATA[<pre class="brush: php; title: ; notranslate">
sprintf(&quot;%01.2f&quot;, $price );
</pre>
<p>Example usage:</p>
<pre class="brush: php; title: ; notranslate">
sprintf(&quot;%01.2f&quot;, 10 ); // 10.00
sprintf(&quot;%01.2f&quot;, 10.5 ); // 10.50
</pre>
<p><span id="more-442"></span><br />
If you found this article useful, help me out by leaving a <strong>comment</strong> below and clicking the <strong>Like</strong> button.<br />
<script type="text/javascript"><!--
google_ad_client = "ca-pub-8723168851783984";
/* Blog Rect */
google_ad_slot = "8412103904";
google_ad_width = 300;
google_ad_height = 250;
//-->
</script><br />
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></p>
<div id="fb-root"></div>
<p><script>(function(d, s, id) {
  var js, fjs = d.getElementsByTagName(s)[0];
  if (d.getElementById(id)) {return;}
  js = d.createElement(s); js.id = id;
  js.src = "//connect.facebook.net/en_US/all.js#xfbml=1";
  fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script></p>
<div class="fb-comments" data-href="http://jimlam.com/php/format-price-with-2-decimal-places-in-php/" data-num-posts="10" data-width="460"></div>
<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fjimlam.com%2Fphp%2Fformat-price-with-2-decimal-places-in-php%2F&amp;layout=standard&amp;show_faces=true&amp;width=450&amp;action=like&amp;colorscheme=light&amp;height=80" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:450px; height:80px;" allowTransparency="true"></iframe>]]></content:encoded>
			<wfw:commentRss>http://jimlam.com/php/format-price-with-2-decimal-places-in-php/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Steve Jobs 1955-2011 </title>
		<link>http://jimlam.com/apple-mac/steve-jobs/</link>
		<comments>http://jimlam.com/apple-mac/steve-jobs/#comments</comments>
		<pubDate>Wed, 05 Oct 2011 16:00:19 +0000</pubDate>
		<dc:creator>Jim Lam</dc:creator>
				<category><![CDATA[Apple Mac]]></category>

		<guid isPermaLink="false">http://jimlam.com/?p=427</guid>
		<description><![CDATA[]]></description>
			<content:encoded><![CDATA[<p><a href="http://jimlam.com/wp-content/uploads/2011/10/stevejobs.jpg"><img class="alignnone size-full wp-image-428" title="Steve Jobs" src="http://jimlam.com/wp-content/uploads/2011/10/stevejobs.jpg" alt="Steve Jobs" width="640" height="428" /></a></p>
<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fjimlam.com%2Fapple-mac%2Fsteve-jobs%2F&amp;layout=standard&amp;show_faces=true&amp;width=450&amp;action=like&amp;colorscheme=light&amp;height=80" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:450px; height:80px;" allowTransparency="true"></iframe>]]></content:encoded>
			<wfw:commentRss>http://jimlam.com/apple-mac/steve-jobs/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Become the fastest programmer in the world</title>
		<link>http://jimlam.com/php/become-the-fastest-programmer-in-the-world/</link>
		<comments>http://jimlam.com/php/become-the-fastest-programmer-in-the-world/#comments</comments>
		<pubDate>Mon, 19 Sep 2011 22:58:34 +0000</pubDate>
		<dc:creator>Jim Lam</dc:creator>
				<category><![CDATA[Performance]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Project Management]]></category>

		<guid isPermaLink="false">http://jimlam.com/?p=403</guid>
		<description><![CDATA[This post was influenced by the film Limitless. &#8220;An action-thriller about a writer who takes an experimental drug that allows him to use 100 percent of his mind. As one man evolves into the perfect version of himself, forces more &#8230; <a href="http://jimlam.com/php/become-the-fastest-programmer-in-the-world/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>This post was influenced by the film Limitless.</p>
<p><em>&#8220;An action-thriller about a writer who takes an <strong>experimental drug that allows him to use 100 percent of his mind</strong>. As one man evolves into the <strong>perfect version of himself</strong>, forces more corrupt than he can imagine mark him for assassination. Out-of-work writer Eddie Morra&#8217;s (Bradley Cooper) rejection by girlfriend Lindy (Abbie Cornish) confirms his belief that he has zero future. That all vanishes the day an old friend introduces Eddie to NZT, a <strong>designer pharmaceutical that makes him laser focused</strong> and more confident than any man alive.&#8221; &#8211;  IMDb</em></p>
<p>I found the film quite inspirational, and immediately began researching methods to improve my productivity.</p>
<h2>Focus is the key.</h2>
<p>Anything which has the potential to break your concentration must be removed from your environment. Close Facebook, Twitter, Skype and your Email. If you have your own office close the door. Position your desk in a direction which minimises passing distractions. Clear your physical and virtual desktop.</p>
<h2>Performance enhancing drugs.</h2>
<p>Caffeine can help stimulate your mind and body. In my case, only a small amount is required otherwise it has the opposite effect, and actually reduces my concentration level.</p>
<h2>Fuel the fire.</h2>
<p>Keep bottles of water and various snacks at arms length. Being well hydrated will keep you alert, whilst the sugar will satisfy the slightest hunger, without having to resort to getting up for something more substancial. Your doctor won&#8217;t be too happy about this, but hey.</p>
<h2>Stay in the zone.</h2>
<p>Listening to music works for me. Tracks without words ideally. The higher the BPM, the better. Drum &amp; Bass is a great choice. This one is very much about personal preference. There are cases both for and against playing music which is familiar, versus new.</p>
<p>Time of day can play a role. If you are a freelancer or work from home, do so when you feel you are the most proactive. For many developers, it is often the night time. Unless you live above a bar, it should be quieter during the small hours. Clients and colleagues are likely to be in bed, so you won&#8217;t be disturbed by emails and phone calls.</p>
<h2>Don&#8217;t touch the mouse.</h2>
<p>Learn all the keyboard shortcuts for the IDE you use.</p>
<h2>Engage Auto Pilot.</h2>
<p>Try using auto code completion and self closing braces. Keep snippets of often used code handy.</p>
<h2>Once you go black&#8230;</h2>
<p>I switched over to having a black background in my text editor, after years on white. Some editors will allow you to simply invert the syntax colouring. I&#8217;ve found that I can look at a darker screen for longer without causing my eyes to fatigue, plus it looks more geeky and matrix-like.</p>
<h2>Get a head start.</h2>
<p>Consider using a framework. For Javascript, jQuery is obviously the go-to library of choice. For PHP, there are an array to choose from: Zend, Cake, Symphony, Fuel and my personal favourite CodeIgniter. Frameworks provide a great foundation on which to build your application with features like MVC  build in for free.</p>
<h3>Summary</h3>
<p>It&#8217;s all about finding out what works for you. Getting in the zone, and then staying there.<br />
<span id="more-403"></span><br />
If you found this article useful, help me out by leaving a <strong>comment</strong> below and clicking the <strong>Like</strong> button.<br />
<script type="text/javascript"><!--
google_ad_client = "ca-pub-8723168851783984";
/* Blog Rect */
google_ad_slot = "8412103904";
google_ad_width = 300;
google_ad_height = 250;
//-->
</script><br />
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></p>
<div id="fb-root"></div>
<p><script>(function(d, s, id) {
  var js, fjs = d.getElementsByTagName(s)[0];
  if (d.getElementById(id)) {return;}
  js = d.createElement(s); js.id = id;
  js.src = "//connect.facebook.net/en_US/all.js#xfbml=1";
  fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script></p>
<div class="fb-comments" data-href="http://jimlam.com/php/become-the-fastest-programmer-in-the-world/" data-num-posts="10" data-width="460"></div>
<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fjimlam.com%2Fphp%2Fbecome-the-fastest-programmer-in-the-world%2F&amp;layout=standard&amp;show_faces=true&amp;width=450&amp;action=like&amp;colorscheme=light&amp;height=80" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:450px; height:80px;" allowTransparency="true"></iframe>]]></content:encoded>
			<wfw:commentRss>http://jimlam.com/php/become-the-fastest-programmer-in-the-world/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>How to get Parent of Parent Post in WordPress</title>
		<link>http://jimlam.com/php/how-to-get-parent-of-parent-post-in-wordpress/</link>
		<comments>http://jimlam.com/php/how-to-get-parent-of-parent-post-in-wordpress/#comments</comments>
		<pubDate>Sun, 14 Aug 2011 22:32:20 +0000</pubDate>
		<dc:creator>Jim Lam</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Wordpress]]></category>

		<guid isPermaLink="false">http://jimlam.com/?p=399</guid>
		<description><![CDATA[If you found this article useful, help me out by leaving a comment below and clicking the Like button.]]></description>
			<content:encoded><![CDATA[<pre class="brush: php; title: ; notranslate">
$parent = get_post($post-&gt;post_parent);
$grandparent = $parent-&gt;post_parent;
</pre>
<p><span id="more-399"></span><br />
If you found this article useful, help me out by leaving a <strong>comment</strong> below and clicking the <strong>Like</strong> button.<br />
<script type="text/javascript"><!--
google_ad_client = "ca-pub-8723168851783984";
/* Blog Rect */
google_ad_slot = "8412103904";
google_ad_width = 300;
google_ad_height = 250;
//-->
</script><br />
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></p>
<div id="fb-root"></div>
<p><script>(function(d, s, id) {
  var js, fjs = d.getElementsByTagName(s)[0];
  if (d.getElementById(id)) {return;}
  js = d.createElement(s); js.id = id;
  js.src = "//connect.facebook.net/en_US/all.js#xfbml=1";
  fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script></p>
<div class="fb-comments" data-href="http://jimlam.com/php/how-to-get-parent-of-parent-post-in-wordpress/" data-num-posts="10" data-width="460"></div>
<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fjimlam.com%2Fphp%2Fhow-to-get-parent-of-parent-post-in-wordpress%2F&amp;layout=standard&amp;show_faces=true&amp;width=450&amp;action=like&amp;colorscheme=light&amp;height=80" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:450px; height:80px;" allowTransparency="true"></iframe>]]></content:encoded>
			<wfw:commentRss>http://jimlam.com/php/how-to-get-parent-of-parent-post-in-wordpress/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Timing is everything</title>
		<link>http://jimlam.com/performance/timing-is-everything/</link>
		<comments>http://jimlam.com/performance/timing-is-everything/#comments</comments>
		<pubDate>Tue, 19 Jul 2011 13:11:18 +0000</pubDate>
		<dc:creator>Jim Lam</dc:creator>
				<category><![CDATA[Performance]]></category>

		<guid isPermaLink="false">http://jimlam.com/?p=390</guid>
		<description><![CDATA[The average internet user has a very short attention span and doesn&#8217;t like waiting, who does? A slow loading website will fustrate potential customers. It gives a poor first impression when compared with your rivals. A misconception may be formed &#8230; <a href="http://jimlam.com/performance/timing-is-everything/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>The average internet user has a very short attention span and doesn&#8217;t like waiting, who does?</p>
<p>A slow loading website will fustrate potential customers. It gives a poor first impression when compared with your rivals.</p>
<p>A misconception may be formed about your business that you are unresponsive and don&#8217;t care for user experience.</p>
<p>Imagine if your website loaded twice as fast as your competition. That would certainly help engage users, resulting in higher conversions.</p>
<p>Just like tuning an F1 racing car, there are many aspects which can be analysed and optimised to give greater performance.</p>
<p>Don&#8217;t let your competitors steal a lead on you.</p>
<p><a title="Improve the performance of your website" href="http://webwings.com">Webwings are experts in tuning the performance of websites</a>.<br />
<span id="more-390"></span><br />
If you found this article useful, help me out by leaving a <strong>comment</strong> below and clicking the <strong>Like</strong> button.<br />
<script type="text/javascript"><!--
google_ad_client = "ca-pub-8723168851783984";
/* Blog Rect */
google_ad_slot = "8412103904";
google_ad_width = 300;
google_ad_height = 250;
//-->
</script><br />
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></p>
<div id="fb-root"></div>
<p><script>(function(d, s, id) {
  var js, fjs = d.getElementsByTagName(s)[0];
  if (d.getElementById(id)) {return;}
  js = d.createElement(s); js.id = id;
  js.src = "//connect.facebook.net/en_US/all.js#xfbml=1";
  fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script></p>
<div class="fb-comments" data-href="http://jimlam.com/performance/timing-is-everything/" data-num-posts="10" data-width="460"></div>
<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fjimlam.com%2Fperformance%2Ftiming-is-everything%2F&amp;layout=standard&amp;show_faces=true&amp;width=450&amp;action=like&amp;colorscheme=light&amp;height=80" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:450px; height:80px;" allowTransparency="true"></iframe>]]></content:encoded>
			<wfw:commentRss>http://jimlam.com/performance/timing-is-everything/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Facebook Like &#8211; small button, BIG marketing potential</title>
		<link>http://jimlam.com/online-marketing/facebook-like-small-button-big-marketing-potential/</link>
		<comments>http://jimlam.com/online-marketing/facebook-like-small-button-big-marketing-potential/#comments</comments>
		<pubDate>Tue, 25 Jan 2011 21:43:13 +0000</pubDate>
		<dc:creator>Jim Lam</dc:creator>
				<category><![CDATA[Online Marketing]]></category>

		<guid isPermaLink="false">http://www.jimlam.com/?p=321</guid>
		<description><![CDATA[When purchasing a product or deciding on a supplier for a service there is an inherent risk, especially online. This risk is reduced significantly if it is in the form of a personal recommendation. No where is the personal recommendation &#8230; <a href="http://jimlam.com/online-marketing/facebook-like-small-button-big-marketing-potential/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>When purchasing a product or deciding on a supplier for a service there is an inherent risk, especially online.</p>
<p>This risk is reduced significantly if it is in the form of a personal recommendation.</p>
<p>No where is the personal recommendation more prevalent than with Facebook&#8217;s Like button.</p>
<p>A &#8216;safety in numbers&#8217; theory can be applied, whereby a large number of like&#8217;s is translated into a perceived acceptance or superiority. In many cases this is justified.</p>
<p>Facebook is built around relationships. The power/weight of a &#8216;like&#8217; is far greater the closer a friend is in your social circle.</p>
<p>The average number of friends a Facebook user has is 150. Use this order of magnitude to your advantage. </p>
<p>If you can get just 1 user to &#8216;like&#8217; your product or service, a recommendation will be posted to their news feed. Potentially, you have increased your audience by 150!</p>
<p>You Like?<br />
<span id="more-321"></span><br />
If you found this article useful, help me out by leaving a <strong>comment</strong> below and clicking the <strong>Like</strong> button.<br />
<script type="text/javascript"><!--
google_ad_client = "ca-pub-8723168851783984";
/* Blog Rect */
google_ad_slot = "8412103904";
google_ad_width = 300;
google_ad_height = 250;
//-->
</script><br />
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></p>
<div id="fb-root"></div>
<p><script>(function(d, s, id) {
  var js, fjs = d.getElementsByTagName(s)[0];
  if (d.getElementById(id)) {return;}
  js = d.createElement(s); js.id = id;
  js.src = "//connect.facebook.net/en_US/all.js#xfbml=1";
  fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script></p>
<div class="fb-comments" data-href="http://jimlam.com/online-marketing/facebook-like-small-button-big-marketing-potential/" data-num-posts="10" data-width="460"></div>
<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fjimlam.com%2Fonline-marketing%2Ffacebook-like-small-button-big-marketing-potential%2F&amp;layout=standard&amp;show_faces=true&amp;width=450&amp;action=like&amp;colorscheme=light&amp;height=80" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:450px; height:80px;" allowTransparency="true"></iframe>]]></content:encoded>
			<wfw:commentRss>http://jimlam.com/online-marketing/facebook-like-small-button-big-marketing-potential/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Generate array with x years before/after the current year</title>
		<link>http://jimlam.com/php/generate-array-with-x-years-before-after-the-current-year/</link>
		<comments>http://jimlam.com/php/generate-array-with-x-years-before-after-the-current-year/#comments</comments>
		<pubDate>Thu, 30 Dec 2010 14:48:42 +0000</pubDate>
		<dc:creator>Jim Lam</dc:creator>
				<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.jimlam.com/?p=305</guid>
		<description><![CDATA[Wrote this PHP date function which can easily be used to populate a drop down in a form. e.g. credit card expiry, or date of birth. Example usage: What about months? It would be more efficient to have this as &#8230; <a href="http://jimlam.com/php/generate-array-with-x-years-before-after-the-current-year/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Wrote this PHP <strong>date</strong> function which can easily be used to populate a drop down in a form.<br />
e.g. credit card expiry, or date of birth.</p>
<pre class="brush: php; title: ; notranslate">
function getDateYears( $start = NULL, $before = NULL, $after = NULL, $sort = NULL ) {
	if ( empty( $start ) || ( empty( $before ) &amp;&amp; empty( $after ) ) ) {
		return false;
	}
	$years = array( $start );
	if ( $before ) {
		for( $i = 1; $i &lt;= $before; $i++ ) {
			$years[] = $start - $i;
		}
	}
	if ( $after ) {
		for( $i = 1; $i &lt;= $after; $i++ ) {
			$years[] = $start + $i;
		}
	}
	asort( $years );
	if ( $sort ) {
		rsort( $years );
	}
	return $years;
}
</pre>
<p><em>Example usage:</em></p>
<pre class="brush: php; title: ; notranslate">
// The next 10 years, starting with the current year.
getDateYears( date('Y'), 0, 10 );

// 10 years either side of 1982, and sort in reverse.
getDateYears( 1982, 10, 10, TRUE );
</pre>
<p><strong>What about months?</strong> <em>It would be more <strong>efficient</strong> to have this as a static array, but where&#8217;s the fun in that. You get month number (with leading zeros) as the key, and the value is the full month (December). Perfect for insertion into a date field in <strong>MySQL</strong></em>.</p>
<pre class="brush: php; title: ; notranslate">
function getDateMonths() {
	$months = array();
	for( $i = 1; $i &lt;= 12; $i++  ) {
		$months[str_pad( $i, 2, '0', STR_PAD_LEFT )] = date( 'F', mktime( 0, 0, 0, $i, 1 ) );
	}
	return $months;
}
</pre>
<p><span id="more-305"></span><br />
If you found this article useful, help me out by leaving a <strong>comment</strong> below and clicking the <strong>Like</strong> button.<br />
<script type="text/javascript"><!--
google_ad_client = "ca-pub-8723168851783984";
/* Blog Rect */
google_ad_slot = "8412103904";
google_ad_width = 300;
google_ad_height = 250;
//-->
</script><br />
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></p>
<div id="fb-root"></div>
<p><script>(function(d, s, id) {
  var js, fjs = d.getElementsByTagName(s)[0];
  if (d.getElementById(id)) {return;}
  js = d.createElement(s); js.id = id;
  js.src = "//connect.facebook.net/en_US/all.js#xfbml=1";
  fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script></p>
<div class="fb-comments" data-href="http://jimlam.com/php/generate-array-with-x-years-before-after-the-current-year/" data-num-posts="10" data-width="460"></div>
<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fjimlam.com%2Fphp%2Fgenerate-array-with-x-years-before-after-the-current-year%2F&amp;layout=standard&amp;show_faces=true&amp;width=450&amp;action=like&amp;colorscheme=light&amp;height=80" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:450px; height:80px;" allowTransparency="true"></iframe>]]></content:encoded>
			<wfw:commentRss>http://jimlam.com/php/generate-array-with-x-years-before-after-the-current-year/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

<!-- Dynamic page generated in 0.739 seconds. -->
<!-- Cached page generated by WP-Super-Cache on 2012-05-17 16:01:52 -->
<!-- Compression = gzip -->
