<?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>Kaiesh.com</title>
	<atom:link href="http://www.kaiesh.com/feed" rel="self" type="application/rss+xml" />
	<link>http://www.kaiesh.com</link>
	<description>Business. Technology. Cool Stuff.</description>
	<lastBuildDate>Tue, 31 Aug 2010 05:37:38 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Facebook and Twitter Integration with WordPress Blogs to help SEO</title>
		<link>http://www.kaiesh.com/143/facebook-and-twitter-integration-with-wordpress-blogs-to-help-seo</link>
		<comments>http://www.kaiesh.com/143/facebook-and-twitter-integration-with-wordpress-blogs-to-help-seo#comments</comments>
		<pubDate>Tue, 31 Aug 2010 05:37:38 +0000</pubDate>
		<dc:creator>Kaiesh</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[SEO]]></category>
		<category><![CDATA[Tip]]></category>

		<guid isPermaLink="false">http://www.kaiesh.com/?p=143</guid>
		<description><![CDATA[A while ago I posted a quick SEO overview guide, and that had a section on how Social Media played an important role. While mentioning these topics at a high level, when it gets down to the nuts and bolts, it can be quite time consuming and effort laden in order to actually get stuff [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.kaiesh.com%2F143%2Ffacebook-and-twitter-integration-with-wordpress-blogs-to-help-seo"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.kaiesh.com%2F143%2Ffacebook-and-twitter-integration-with-wordpress-blogs-to-help-seo&amp;style=normal" height="61" width="50" /><br />
			</a>
		</div>
<p><a href="http://www.kaiesh.com/120/seo-quickstart-guide-in-a-graphic-for-beginners"><img class="left" src="/images/kaiesh_com_seoMedley.png" alt="Search Engine Optimisation through Social Media" /></a> A while ago I posted a <a href="http://www.kaiesh.com/120/seo-quickstart-guide-in-a-graphic-for-beginners">quick SEO overview guide</a>, and that had a section on how Social Media played an important role.</p>
<p>While mentioning these topics at a high level, when it gets down to the nuts and bolts, it can be quite time consuming and effort laden in order to actually get stuff done. Any shortcuts that exists, really go a long way in helping cater to the whole gamut of requirements. So, I&#8217;m going to pick out at some of these topics and share my personal experiences with them to try and help out a little.</p>
<p>To start with &#8211; self hosted <a href="http://www.wordpress.org">WordPress</a> sites (which is what this is) are by far the best combination of ease and flexibility in my opinion. So if you&#8217;re going for a blogging platform, start with <a href="http://www.wordpress.org">WordPress</a>.</p>
<p>Then, the first step for your subsequent Twitter integration, is easy. The plugin you want is &#8220;<a href="http://tweetmeme.com/about/plugins">TweetMeme</a>&#8220;. You can search for it in the WordPress plugin directory, or you can simply download it from their site. Whichever one you choose, once it is installed and activated, it just works. Nothing else required.</p>
<p>To go slightly deeper, and integrate every blog post with your twitter account automatically, you can use <a href="http://feedburner.google.com">FeedBurner</a>. FeedBurner is quite self explanatory to set up, and only requires you to have a Twitter and a Google account to get it working. FeedBurner also has the added advantage of pinging several other blog services everytime it detects a post from you. So that helps in additional link building.</p>
<p>Moving onto Facebook &#8211; there&#8217;s a minefield of plugins for WordPress out there. There are some that throw everything into the plugin including the kitchen sink, but then they become horrendously annoying to configure and very bulky to load. I narrowed down my requirements to two things that Facebook is really useful for today &#8211; &#8220;Liking&#8221; stuff, and &#8220;Comments&#8221;. Both of these get entered as stories into profiles. So this does exactly what you want by hitting newsfeeds. Other features like linking to my Facebook &#8220;Notes&#8221;, or duplicating/synchronising content and comments between the two defeat the purpose of me having a website. So after much hunting, I have found two applications that sort out everything I need:</p>
<ol>
<li><a href="http://www.grahamswan.com/facebook-comments"><strong>Facebook Comments for WordPress</strong></a> by Graham Swan</li>
<li><a href="http://blog.ahmedgeek.com/facebook-like-button-v5-0-major-update"><strong>Facebook Like</strong></a> by Ahmed Hussein</li>
</ol>
<p>They need a little bit of configuration in order to run properly, but they come with comprehensive HowTo guides. They do the fantastic job of seamlessly integrating your blog into people&#8217;s newsfeeds with minimal brain power.</p>
<p>Have you used or made any other plugins that you&#8217;ve found useful?</p>
<a href="http://www.facebook.com/share.php?u=http%3A%2F%2Fwww.kaiesh.com%2F143%2Ffacebook-and-twitter-integration-with-wordpress-blogs-to-help-seo&amp;t=Facebook%20and%20Twitter%20Integration%20with%20Wordpress%20Blogs%20to%20help%20SEO" id="facebook_share_link_143">Share on Facebook</a>
	<script type="text/javascript">
	<!--
	var button = document.getElementById('facebook_share_link_143') || document.getElementById('facebook_share_icon_143') || document.getElementById('facebook_share_both_143') || document.getElementById('facebook_share_button_143');
	if (button) {
		button.onclick = function(e) {
			var url = this.href.replace(/share\.php/, 'sharer.php');
			window.open(url,'sharer','toolbar=0,status=0,width=626,height=436');
			return false;
		}
	
		if (button.id === 'facebook_share_button_143') {
			button.onmouseover = function(){
				this.style.color='#fff';
				this.style.borderColor = '#295582';
				this.style.backgroundColor = '#3b5998';
			}
			button.onmouseout = function(){
				this.style.color = '#3b5998';
				this.style.borderColor = '#d8dfea';
				this.style.backgroundColor = '#fff';
			}
		}
	}
	-->
	</script>
	]]></content:encoded>
			<wfw:commentRss>http://www.kaiesh.com/143/facebook-and-twitter-integration-with-wordpress-blogs-to-help-seo/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Quirks in Mobile Location Technology &#8211; Wifi Errors</title>
		<link>http://www.kaiesh.com/137/quirks-in-mobile-location-technology-wifi-errors</link>
		<comments>http://www.kaiesh.com/137/quirks-in-mobile-location-technology-wifi-errors#comments</comments>
		<pubDate>Wed, 11 Aug 2010 05:05:17 +0000</pubDate>
		<dc:creator>Kaiesh</dc:creator>
				<category><![CDATA[Travel]]></category>

		<guid isPermaLink="false">http://www.kaiesh.com/?p=137</guid>
		<description><![CDATA[So I&#8217;ve been playing with Google Maps and the location technology on my shiny new Xperia X10 Android phone, and I think it is all very cool. But there are some things which need fixing for the future&#8230; in no particular order, here are the results of my findings&#8230; GPS Accuracy: Obviously awesome in accuracy [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.kaiesh.com%2F137%2Fquirks-in-mobile-location-technology-wifi-errors"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.kaiesh.com%2F137%2Fquirks-in-mobile-location-technology-wifi-errors&amp;style=normal" height="61" width="50" /><br />
			</a>
		</div>
<p><a href="http://www.savagechickens.com"><img src="/images/savagechicken-chickengps2.jpg" alt="Chicken GPS - Existential GPS" /></a><br />
So I&#8217;ve been playing with Google Maps and the location technology on my shiny new Xperia X10 Android phone, and I think it is all very cool. But there are some things which need fixing for the future&#8230; in no particular order, here are the results of my findings&#8230;</p>
<p><strong>GPS</strong><br />
<strong>Accuracy:</strong> Obviously awesome in accuracy &#8211; pinpoints your location, but claims to have an error margin of about 20m. I&#8217;ve never had it off any amount that I could notice. If I hang out of my window on one side of the house it detects that window, and if I move to the other, it finds it there too. Very cool. This does depend on if your phone can see the sky, and also on how many high rise buildings are around you though.<br />
<strong>Power:</strong> T3h lame. I guess you have to compromise on accuracy with battery juice. If you leave GPS on without being plugged into something, don&#8217;t try to use your phone for anything else. You&#8217;ll probably run the battery dry once you&#8217;ve finished typing the SMS you wanted to send. On my phone at least &#8211; if you have the map software up, and the GPS on you can see the percentage reading of your battery dropping&#8230;</p>
<p><strong>Network Location</strong><br />
<strong>Accuracy:</strong> The accuracy really depends on how densely packed your area is with mobile cell towers. The fewer towers you have around you, the worse the accuracy. In rural areas I generally see accuracy ranges of around 800m. Which isn&#8217;t too bad when all things are considered. If you&#8217;ve moving, then the software is usually intelligent enough to refine that reading, and reduce the error margin &#8211; so I think this is a pretty reasonable level of detail for not doing much at all.<br />
<strong>Power:</strong> Great usage of power! It doesn&#8217;t stress the phone that much at all. It has to be connected to cell towers, and it&#8217;s effectively performing a fancy variant of triangulation &#8211; so the work is mainly done in the software as opposed to communicating with external devices. So this is a great power saver, and allows you to get a good idea of where you are!</p>
<p><strong>Wifi</strong><br />
<strong>Accuracy:</strong> It appears that either Google, or some database somewhere on the internet ( I have done no research into this and it is purely speculation) has a reference for infrastructure points, and where they are likely to be located. Presumably this database was hugely plumped up when the iPhone frenzy kicked in and everyone was walking around with their phones and wifi on. So the large database owners have attached the Lat+Lng location based on these devices and the corresponding surrounding wifi nodes. This is visible from items like the touch iPods &#8211; which don&#8217;t have GPS, or cellular reception, but do have Wifi &#8211; they can still &#8220;tell you where you are&#8221; on Google maps. Bear in mind though, that this has the potentially to be <b>HUGELY</b> inaccurate. Different continent inaccurate. I had a wifi node set up in my house in the UK, and someone clearly had an iPhone &#8211; because now that I&#8217;ve moved to a different country whenever I walk into range of the wifi node, apparently I am back in the UK! So I find this type of referencing <b>REALLY BAD.</b> In theory though &#8211; it says 75metres should be the accuracy when combined with mobile networks.<br />
<strong>Power:</strong> Wifi sucks power out of these tiny devices &#8211; so I would recommend not using this as a location reference device, and really only for when you actually need to download data!</p>
<p>What about you? What has your experience been with mobile location technology? Either in phones or in-car GPS units?</p>
<a href="http://www.facebook.com/share.php?u=http%3A%2F%2Fwww.kaiesh.com%2F137%2Fquirks-in-mobile-location-technology-wifi-errors&amp;t=Quirks%20in%20Mobile%20Location%20Technology%20-%20Wifi%20Errors" id="facebook_share_link_137">Share on Facebook</a>
	<script type="text/javascript">
	<!--
	var button = document.getElementById('facebook_share_link_137') || document.getElementById('facebook_share_icon_137') || document.getElementById('facebook_share_both_137') || document.getElementById('facebook_share_button_137');
	if (button) {
		button.onclick = function(e) {
			var url = this.href.replace(/share\.php/, 'sharer.php');
			window.open(url,'sharer','toolbar=0,status=0,width=626,height=436');
			return false;
		}
	
		if (button.id === 'facebook_share_button_137') {
			button.onmouseover = function(){
				this.style.color='#fff';
				this.style.borderColor = '#295582';
				this.style.backgroundColor = '#3b5998';
			}
			button.onmouseout = function(){
				this.style.color = '#3b5998';
				this.style.borderColor = '#d8dfea';
				this.style.backgroundColor = '#fff';
			}
		}
	}
	-->
	</script>
	]]></content:encoded>
			<wfw:commentRss>http://www.kaiesh.com/137/quirks-in-mobile-location-technology-wifi-errors/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Installing the Android SDK on Ubuntu</title>
		<link>http://www.kaiesh.com/132/installing-the-android-sdk-on-ubuntu</link>
		<comments>http://www.kaiesh.com/132/installing-the-android-sdk-on-ubuntu#comments</comments>
		<pubDate>Sat, 07 Aug 2010 04:34:20 +0000</pubDate>
		<dc:creator>Kaiesh</dc:creator>
				<category><![CDATA[Development]]></category>

		<guid isPermaLink="false">http://www.kaiesh.com/?p=132</guid>
		<description><![CDATA[Installing the Android SDK on my Ubuntu machine was a bit of a hassle this morning &#8211; especially given that I already had the Eclipse IDE installed from the repository! I was battling all morning with NullPointerExceptions for a reason that was previously unknown to me! So in the event that this makes anyone&#8217;s life [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.kaiesh.com%2F132%2Finstalling-the-android-sdk-on-ubuntu"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.kaiesh.com%2F132%2Finstalling-the-android-sdk-on-ubuntu&amp;style=normal" height="61" width="50" /><br />
			</a>
		</div>
<p><a href="http://www.flickr.com/photos/laihiu/4407976543/"><img src="http://farm5.static.flickr.com/4040/4407976543_e1b10b5154_m.jpg" alt="Android" align="left" style="margin-right: 5px;"></a> Installing the Android SDK on my Ubuntu machine was a bit of a hassle this morning &#8211; especially given that I already had the Eclipse IDE installed from the repository! I was battling all morning with NullPointerExceptions for a reason that was previously unknown to me!</p>
<p>So in the event that this makes anyone&#8217;s life easier, I would recommend following these steps:</p>
<ol>
<li>Get Java1.6 from the repositories &#8211; either using synaptic, or apt-get to download it</li>
<li>Open up a terminal window</li>
<li>Type in <code>sudo update-alternatives --config java</code></li>
<li>Select the option in this list that points to Java 1.6 (or higher)</li>
<li>Download the <a href="http://developer.android.com/sdk/index.html">Android SDK</a> for Ubuntu</li>
<li>Unpack the tgz in a directory of your choice, and run &#8220;tools/android&#8221;</li>
<li>Click &#8220;Available Packages&#8221; and refresh the repository</li>
<li>Download the necessary SDK elements!</li>
</ol>
<p>Doing in that sequence will save you a lot of headache. Of course afterwards you can pick up your preferred IDE &#8211; Android Dev recommends Eclipse &#8211; but not the eclipse from the repository. Instead you need to download the new(er) one from the eclipse website.</p>
<p>P.S. Thanks to <a href="http://www.flickr.com/photos/laihiu/4407976543/">LaiHiu</a> for the entry graphic</p>
<a href="http://www.facebook.com/share.php?u=http%3A%2F%2Fwww.kaiesh.com%2F132%2Finstalling-the-android-sdk-on-ubuntu&amp;t=Installing%20the%20Android%20SDK%20on%20Ubuntu" id="facebook_share_link_132">Share on Facebook</a>
	<script type="text/javascript">
	<!--
	var button = document.getElementById('facebook_share_link_132') || document.getElementById('facebook_share_icon_132') || document.getElementById('facebook_share_both_132') || document.getElementById('facebook_share_button_132');
	if (button) {
		button.onclick = function(e) {
			var url = this.href.replace(/share\.php/, 'sharer.php');
			window.open(url,'sharer','toolbar=0,status=0,width=626,height=436');
			return false;
		}
	
		if (button.id === 'facebook_share_button_132') {
			button.onmouseover = function(){
				this.style.color='#fff';
				this.style.borderColor = '#295582';
				this.style.backgroundColor = '#3b5998';
			}
			button.onmouseout = function(){
				this.style.color = '#3b5998';
				this.style.borderColor = '#d8dfea';
				this.style.backgroundColor = '#fff';
			}
		}
	}
	-->
	</script>
	]]></content:encoded>
			<wfw:commentRss>http://www.kaiesh.com/132/installing-the-android-sdk-on-ubuntu/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Listing methods for all of your PHP objects for quick reference</title>
		<link>http://www.kaiesh.com/124/listing-methods-for-all-of-your-php-objects-for-quick-reference</link>
		<comments>http://www.kaiesh.com/124/listing-methods-for-all-of-your-php-objects-for-quick-reference#comments</comments>
		<pubDate>Fri, 23 Jul 2010 12:52:41 +0000</pubDate>
		<dc:creator>Kaiesh</dc:creator>
				<category><![CDATA[Development]]></category>

		<guid isPermaLink="false">http://www.kaiesh.com/?p=124</guid>
		<description><![CDATA[When managing or developing object orientated programming sites in PHP, I find that I frequently forget the names of methods that belong to classes. Even though I try to have a standard naming format &#8211; my memory still seems to fail So rather than run phpDocs over my objects continually, I knocked together this quick [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.kaiesh.com%2F124%2Flisting-methods-for-all-of-your-php-objects-for-quick-reference"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.kaiesh.com%2F124%2Flisting-methods-for-all-of-your-php-objects-for-quick-reference&amp;style=normal" height="61" width="50" /><br />
			</a>
		</div>
<p><a href="http://www.flickr.com/photos/honou/2936937247/"><img src="http://farm4.static.flickr.com/3021/2936937247_a44e91ca09_m.jpg" align="left" alt="Open Reference Book" /></a>When managing or developing object orientated programming sites in PHP, I find that I frequently forget the names of methods that belong to classes. Even though I try to have a standard naming format &#8211; my memory still seems to fail <img src='http://www.kaiesh.com/wp-includes/images/smilies/icon_sad.gif' alt=':-(' class='wp-smiley' /><br />
So rather than run phpDocs over my objects continually, I knocked together this quick script to list all the methods in all my objects (I store all my objects in one directory). I call this file &#8220;_methodList.php&#8221; and keep it <strong>only</strong> on the <strong>development server</strong>. Here&#8217;s the code!<br />
<code>$dirpath = "/path/to/objects";<br />
$dh = opendir($dirpath);<br />
while (false !== ($file = readdir($dh))) {<br />
 <span style="color: #4f9a4d; font-weight: bold;">//Don't list subdirectories</span><br />
 if (!is_dir("$dirpath/$file")) {<br />
  <span style="color: #4f9a4d; font-weight: bold;">//only grab PHP files</span><br />
  if ((substr($file, -3)=="php")&amp;&amp;($file!="_methodList.php")){<br />
   echo $file."&lt;br/&gt;\n";<br />
   require_once($file);<br />
   $methArr = get_class_methods(substr($file, 0, -4));<br />
   if (sizeof($methArr) &gt; 0){<br />
    foreach ($methArr as $method){<br />
    echo "-&gt; ".$method."&lt;br/&gt;\n";<br />
    }<br />
   }<br />
   echo "&lt;br/&gt;";<br />
  }<br />
 }<br />
}<br />
closedir($dh);</code></p>
<p>Thanks to <a href="http://www.flickr.com/photos/honou/2936937247/">Honou</a> for the opening graphic!</p>
<a href="http://www.facebook.com/share.php?u=http%3A%2F%2Fwww.kaiesh.com%2F124%2Flisting-methods-for-all-of-your-php-objects-for-quick-reference&amp;t=Listing%20methods%20for%20all%20of%20your%20PHP%20objects%20for%20quick%20reference" id="facebook_share_link_124">Share on Facebook</a>
	<script type="text/javascript">
	<!--
	var button = document.getElementById('facebook_share_link_124') || document.getElementById('facebook_share_icon_124') || document.getElementById('facebook_share_both_124') || document.getElementById('facebook_share_button_124');
	if (button) {
		button.onclick = function(e) {
			var url = this.href.replace(/share\.php/, 'sharer.php');
			window.open(url,'sharer','toolbar=0,status=0,width=626,height=436');
			return false;
		}
	
		if (button.id === 'facebook_share_button_124') {
			button.onmouseover = function(){
				this.style.color='#fff';
				this.style.borderColor = '#295582';
				this.style.backgroundColor = '#3b5998';
			}
			button.onmouseout = function(){
				this.style.color = '#3b5998';
				this.style.borderColor = '#d8dfea';
				this.style.backgroundColor = '#fff';
			}
		}
	}
	-->
	</script>
	]]></content:encoded>
			<wfw:commentRss>http://www.kaiesh.com/124/listing-methods-for-all-of-your-php-objects-for-quick-reference/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>SEO QuickStart Guide in a Graphic for Beginners</title>
		<link>http://www.kaiesh.com/120/seo-quickstart-guide-in-a-graphic-for-beginners</link>
		<comments>http://www.kaiesh.com/120/seo-quickstart-guide-in-a-graphic-for-beginners#comments</comments>
		<pubDate>Sat, 17 Jul 2010 18:05:41 +0000</pubDate>
		<dc:creator>Kaiesh</dc:creator>
				<category><![CDATA[SEO]]></category>

		<guid isPermaLink="false">http://www.kaiesh.com/?p=120</guid>
		<description><![CDATA[I&#8217;ve spent the past couple of years continually looking over Search Engine Optimisation (SEO) guides, blogs and tips from so many different sources, and while some have their own twist on the way things should be done, there are several core messages which keep coming through. I&#8217;m no SEO guru, but I try what I [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.kaiesh.com%2F120%2Fseo-quickstart-guide-in-a-graphic-for-beginners"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.kaiesh.com%2F120%2Fseo-quickstart-guide-in-a-graphic-for-beginners&amp;style=normal" height="61" width="50" /><br />
			</a>
		</div>
<p>I&#8217;ve spent the past couple of years continually looking over Search Engine Optimisation (SEO) guides, blogs and tips from so many different sources, and while some have their own twist on the way things should be done, there are several core messages which keep coming through. I&#8217;m no SEO guru, but I try what I can, and I&#8217;ve summed up the core messages in this graphic below. If I&#8217;ve missed anything critical &#8211; then let me know! It&#8217;s a big graphic, but should be worth the wait <img src='http://www.kaiesh.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p><a href="/images/seo-visual-quickstart-guide-for-beginners.jpg" target="_blank"><img src="/images/seo-visual-quickstart-guide-for-beginners.jpg" alt="SEO Visual Quickstart Guide for Beginners with things to do on your site, and off your site!" /></a></p>
<p>Special thanks go to the follow sites that I used information from:</p>
<p><a href="http://www.seomoz.org" target="_blank">SEOMoz.org</a>, <a href="http://thegooglecache.com" target="_blank">TheGoogleCache.com</a>, <a href="http://getclicky.com" target="_blank">GetClicky.com</a>, <a href="http://viktorviktoriashop.com" target="_blank">ViktorViktoriaShop.com</a> (for the great product graphic). If I&#8217;ve used your work and you don&#8217;t want me to, then let me know and I&#8217;ll blur you out of the graphic!</p>
<a href="http://www.facebook.com/share.php?u=http%3A%2F%2Fwww.kaiesh.com%2F120%2Fseo-quickstart-guide-in-a-graphic-for-beginners&amp;t=SEO%20QuickStart%20Guide%20in%20a%20Graphic%20for%20Beginners" id="facebook_share_link_120">Share on Facebook</a>
	<script type="text/javascript">
	<!--
	var button = document.getElementById('facebook_share_link_120') || document.getElementById('facebook_share_icon_120') || document.getElementById('facebook_share_both_120') || document.getElementById('facebook_share_button_120');
	if (button) {
		button.onclick = function(e) {
			var url = this.href.replace(/share\.php/, 'sharer.php');
			window.open(url,'sharer','toolbar=0,status=0,width=626,height=436');
			return false;
		}
	
		if (button.id === 'facebook_share_button_120') {
			button.onmouseover = function(){
				this.style.color='#fff';
				this.style.borderColor = '#295582';
				this.style.backgroundColor = '#3b5998';
			}
			button.onmouseout = function(){
				this.style.color = '#3b5998';
				this.style.borderColor = '#d8dfea';
				this.style.backgroundColor = '#fff';
			}
		}
	}
	-->
	</script>
	]]></content:encoded>
			<wfw:commentRss>http://www.kaiesh.com/120/seo-quickstart-guide-in-a-graphic-for-beginners/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Arricah is born!</title>
		<link>http://www.kaiesh.com/118/arricah-is-born</link>
		<comments>http://www.kaiesh.com/118/arricah-is-born#comments</comments>
		<pubDate>Mon, 12 Jul 2010 08:17:02 +0000</pubDate>
		<dc:creator>Kaiesh</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.kaiesh.com/?p=118</guid>
		<description><![CDATA[My wife gave birth to our beautiful little girl on the 7th of July, and so I have been quite busy the past couple of weeks! I will return to regular posting shortly! Share on Facebook]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.kaiesh.com%2F118%2Farricah-is-born"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.kaiesh.com%2F118%2Farricah-is-born&amp;style=normal" height="61" width="50" /><br />
			</a>
		</div>
<p><a href="http://www.flickr.com/photos/kaiesh/collections/72157624470310152/"><img src="http://farm5.static.flickr.com/4119/4785789164_7a1a228dac_m.jpg" alt="Arricah" align="left" /></a> My wife gave birth to our beautiful little girl on the 7th of July, and so I have been quite busy the past couple of weeks!</p>
<p>I will return to regular posting shortly!</p>
<a href="http://www.facebook.com/share.php?u=http%3A%2F%2Fwww.kaiesh.com%2F118%2Farricah-is-born&amp;t=Arricah%20is%20born%21" id="facebook_share_link_118">Share on Facebook</a>
	<script type="text/javascript">
	<!--
	var button = document.getElementById('facebook_share_link_118') || document.getElementById('facebook_share_icon_118') || document.getElementById('facebook_share_both_118') || document.getElementById('facebook_share_button_118');
	if (button) {
		button.onclick = function(e) {
			var url = this.href.replace(/share\.php/, 'sharer.php');
			window.open(url,'sharer','toolbar=0,status=0,width=626,height=436');
			return false;
		}
	
		if (button.id === 'facebook_share_button_118') {
			button.onmouseover = function(){
				this.style.color='#fff';
				this.style.borderColor = '#295582';
				this.style.backgroundColor = '#3b5998';
			}
			button.onmouseout = function(){
				this.style.color = '#3b5998';
				this.style.borderColor = '#d8dfea';
				this.style.backgroundColor = '#fff';
			}
		}
	}
	-->
	</script>
	]]></content:encoded>
			<wfw:commentRss>http://www.kaiesh.com/118/arricah-is-born/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to migrate contacts from a Palm Treo 680 to a Nokia e71 without Outlook</title>
		<link>http://www.kaiesh.com/116/how-to-migrate-contacts-from-a-palm-treo-680-to-a-nokia-e71-without-outlook</link>
		<comments>http://www.kaiesh.com/116/how-to-migrate-contacts-from-a-palm-treo-680-to-a-nokia-e71-without-outlook#comments</comments>
		<pubDate>Thu, 24 Jun 2010 01:36:09 +0000</pubDate>
		<dc:creator>Kaiesh</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.kaiesh.com/?p=116</guid>
		<description><![CDATA[I recently switched from my Palm Treo 680 to a Nokia e71. It was a painful departure from a decade with Palm, but the phone is now old, and the battery life has begun to become a major issue during the normal working day. The e71 has some great features over the Palm, but a [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.kaiesh.com%2F116%2Fhow-to-migrate-contacts-from-a-palm-treo-680-to-a-nokia-e71-without-outlook"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.kaiesh.com%2F116%2Fhow-to-migrate-contacts-from-a-palm-treo-680-to-a-nokia-e71-without-outlook&amp;style=normal" height="61" width="50" /><br />
			</a>
		</div>
<p>I recently switched from my Palm Treo 680 to a Nokia e71. It was a painful departure from a decade with Palm, but the phone is now old, and the battery life has begun to become a major issue during the normal working day.</p>
<p>The e71 has some great features over the Palm, but a couple of things I&#8217;ll definitely miss are the touch screen and the keyboard!</p>
<p>A hurdle that I came across during migration was my contacts. There didn&#8217;t seem to be a simple way to synchronise the two devices without hacking about with Outlook and some other garbage inbetween. I don&#8217;t run Windows, and so I don&#8217;t have Outlook. Short of spending ages trying to knock together a synchronisation profile in Ubuntu for both devices, I tried to find an easier way. It turns out, there is a very simple way that doesn&#8217;t seem to be well documented.</p>
<p>The process works like this:</p>
<ol>
<li> On the Palm Treo 680, go to your contacts menu, and under the category &#8220;All&#8221; &#8211; press the &#8220;Menu&#8221; button (bottom right key on the keyboard)</li>
<li> Click &#8220;Send Category&#8221;</li>
<li> Select &#8220;Email&#8221; or &#8220;Chatter&#8221;, or some other file transfer method that allows you to get the file to your <strong>Desktop</strong></li>
<li>You will then have a file called &#8220;All.vcf&#8221; on your desktop, this file now needs to be processed through my <a href="http://www.kaiesh.com/box/?package=vcardSplitter">PHP vCardSplitter script</a>. You can do this using PHP5-CLI, or if you don&#8217;t have this on your computer, then drop me a comment below to get in touch, and I&#8217;ll split the files for you</li>
<li>Once your files are split, you then need to connect your Nokia phone to your computer in &#8220;Mass Storage Mode&#8221; and copy all the split VCF files onto the phone under the folder &#8220;/Other/Contacts&#8221;</li>
<li>Safely disconnect your phone from the computer</li>
<li>On the phone, go to the Contacts menu, click the Options button and select &#8220;Copy &gt; From Memory Card&#8221;</li>
<li>It will then begin copying all your contacts in their full glory to your phone! I had about 1500 contacts to copy across, and I started it just before I started writing this post, and it still isn&#8217;t done&#8230; (it takes a while)</li>
</ol>
<p>You&#8217;re done! I don&#8217;t think the categories that were saved on the Palm are copied across, but at least you now have all your contacts, and all of their full vCard information with them. So this should have copied across email addresses, multiple phone numbers, addresses, etc.</p>
<p>As above &#8211; if you can&#8217;t execute PHP scripts on your own, then drop me a comment, and I&#8217;ll sort you out with a split up file and its outputs. There is a spam trapper running on my comments box below, so make sure you have JavaScript turned on when viewing this page!</p>
<p>Do you have an easier way to do this? If so, please let me know and I&#8217;ll link to your method from this post!!</p>
<a href="http://www.facebook.com/share.php?u=http%3A%2F%2Fwww.kaiesh.com%2F116%2Fhow-to-migrate-contacts-from-a-palm-treo-680-to-a-nokia-e71-without-outlook&amp;t=How%20to%20migrate%20contacts%20from%20a%20Palm%20Treo%20680%20to%20a%20Nokia%20e71%20without%20Outlook" id="facebook_share_link_116">Share on Facebook</a>
	<script type="text/javascript">
	<!--
	var button = document.getElementById('facebook_share_link_116') || document.getElementById('facebook_share_icon_116') || document.getElementById('facebook_share_both_116') || document.getElementById('facebook_share_button_116');
	if (button) {
		button.onclick = function(e) {
			var url = this.href.replace(/share\.php/, 'sharer.php');
			window.open(url,'sharer','toolbar=0,status=0,width=626,height=436');
			return false;
		}
	
		if (button.id === 'facebook_share_button_116') {
			button.onmouseover = function(){
				this.style.color='#fff';
				this.style.borderColor = '#295582';
				this.style.backgroundColor = '#3b5998';
			}
			button.onmouseout = function(){
				this.style.color = '#3b5998';
				this.style.borderColor = '#d8dfea';
				this.style.backgroundColor = '#fff';
			}
		}
	}
	-->
	</script>
	]]></content:encoded>
			<wfw:commentRss>http://www.kaiesh.com/116/how-to-migrate-contacts-from-a-palm-treo-680-to-a-nokia-e71-without-outlook/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Iterating through class constants in PHP</title>
		<link>http://www.kaiesh.com/113/iterating-through-class-constants-in-php</link>
		<comments>http://www.kaiesh.com/113/iterating-through-class-constants-in-php#comments</comments>
		<pubDate>Fri, 18 Jun 2010 11:22:08 +0000</pubDate>
		<dc:creator>Kaiesh</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[class]]></category>
		<category><![CDATA[constants]]></category>
		<category><![CDATA[oop]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://www.kaiesh.com/?p=113</guid>
		<description><![CDATA[I was breaking my head trying to figure out the best way to reference a particular set of constants in one of my objects so that I didnt&#8217;t unncessarily need to create a new database table. Fortunately, I found this thread about looping through class constants using reflectors. As a summary, it can be done [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.kaiesh.com%2F113%2Fiterating-through-class-constants-in-php"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.kaiesh.com%2F113%2Fiterating-through-class-constants-in-php&amp;style=normal" height="61" width="50" /><br />
			</a>
		</div>
<p><img class="alignleft" title="Web Code Icon" src="http://www.kamkash.com/images/icon-dynamicJavascriptWidgets.png" alt="" width="88" height="88" />I was breaking my head trying to figure out the best way to reference a particular set of constants in one of my objects so that I didnt&#8217;t unncessarily need to create a new database table. Fortunately, I found this thread about <a href="http://www.tek-tips.com/viewthread.cfm?qid=1593572&amp;page=5" target="_blank">looping through class constants using reflectors</a>.</p>
<p>As a summary, it can be done in a very small amount of code:<br />
<code>class test{<br />
    const CONSTANT = 'foo';<br />
}<br />
$t = new test;<br />
$r = new ReflectionObject($t);<br />
print_r($r-&gt;getConstants());</code></p>
<p>With the appropriate naming convention &#8211; everything else is easy!</p>
<p>Thanks to <a href="http://www.tek-tips.com/userinfo.cfm?member=jpadie" target="_blank">jpadie</a>.</p>
<a href="http://www.facebook.com/share.php?u=http%3A%2F%2Fwww.kaiesh.com%2F113%2Fiterating-through-class-constants-in-php&amp;t=Iterating%20through%20class%20constants%20in%20PHP" id="facebook_share_link_113">Share on Facebook</a>
	<script type="text/javascript">
	<!--
	var button = document.getElementById('facebook_share_link_113') || document.getElementById('facebook_share_icon_113') || document.getElementById('facebook_share_both_113') || document.getElementById('facebook_share_button_113');
	if (button) {
		button.onclick = function(e) {
			var url = this.href.replace(/share\.php/, 'sharer.php');
			window.open(url,'sharer','toolbar=0,status=0,width=626,height=436');
			return false;
		}
	
		if (button.id === 'facebook_share_button_113') {
			button.onmouseover = function(){
				this.style.color='#fff';
				this.style.borderColor = '#295582';
				this.style.backgroundColor = '#3b5998';
			}
			button.onmouseout = function(){
				this.style.color = '#3b5998';
				this.style.borderColor = '#d8dfea';
				this.style.backgroundColor = '#fff';
			}
		}
	}
	-->
	</script>
	]]></content:encoded>
			<wfw:commentRss>http://www.kaiesh.com/113/iterating-through-class-constants-in-php/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Tutorial on Creating Dynamic JavaScript Widgets for Third Party Sites</title>
		<link>http://www.kaiesh.com/103/tutorial-on-creating-dynamic-javascript-widgets-for-third-party-sites</link>
		<comments>http://www.kaiesh.com/103/tutorial-on-creating-dynamic-javascript-widgets-for-third-party-sites#comments</comments>
		<pubDate>Tue, 15 Jun 2010 18:10:42 +0000</pubDate>
		<dc:creator>Kaiesh</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[VenueMirror]]></category>
		<category><![CDATA[dynamic data]]></category>
		<category><![CDATA[forms]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[third party sites]]></category>
		<category><![CDATA[widget]]></category>

		<guid isPermaLink="false">http://www.kaiesh.com/?p=103</guid>
		<description><![CDATA[One of the things I get asked a lot about are the JavaScript widgets that I make, that can be installed on third party websites. The VenueMirror VenueSearch widget at the top of this page is an example of this. The search bar is actually loaded through a JavaScript call that pulls the information from [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.kaiesh.com%2F103%2Ftutorial-on-creating-dynamic-javascript-widgets-for-third-party-sites"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.kaiesh.com%2F103%2Ftutorial-on-creating-dynamic-javascript-widgets-for-third-party-sites&amp;style=normal" height="61" width="50" /><br />
			</a>
		</div>
<p><img src="http://www.kaiesh.com/images/code-outsourcing.png" align="left">One of the things I get asked a lot about are the JavaScript widgets that I make, that can be installed on third party websites. The VenueMirror VenueSearch widget at the top of this page is an example of this. The search bar is actually loaded through a JavaScript call that pulls the information from another server. This technique for loading content onto third party websites is not unusual, but it seems there are too few tutorials out there about how to do this. Firstly though &#8211; one must question why indeed you would do this.</p>
<p><span id="more-103"></span><strong>The Rationale</strong></p>
<p>Placing a form onto a third party website that posts back to a different domain is simple and can be done using plain HTML. However, if the form is populated with a large amount of data, or if the data in the form is dynamic in nature then it makes sense to drive this dynamically. While that sounds logical, to make this easier to understand &#8211; reflect on the VenueSearch form above; the VenueSearch form has country and city data, and the choices in the dropdown list are dynamically driven by what cities venues are available in. As new venues are added everyday to VenueMirror, the size of the lists increases &#8211; so this in turn means that the options in the dropdown have to be updated. It is not feasible to go around updating partner websites everytime the lists change &#8211; so this must be done automatically.</p>
<p>There are many, many examples of such cases &#8211; including simple things like booking forms. How many times have you seen forms which include dates that are in the past? Hotel websites are notorious for this, as the third party booking sites are using static forms for the post back of information. These can be cleaned up by using dynamically driven forms.</p>
<p>Hopefully, I have now made the case and rationale clear for why and where dynamic widgets are useful.</p>
<p><strong>The Logic behind the Method</strong></p>
<p>Basic assumptions:</p>
<ol>
<li>You have a website hosted at http://www.mysite.com</li>
<li>You have a need to place forms, or data, on third party websites that are data driven</li>
<li>The data driving the forms is either housed on, or accessible to http://www.mysite.com</li>
<li>The third party website can be any other website, but it allows you to place JavaScript code onto the pages (note that WordPress blogs hosted on WordPress.com do not support this)</li>
</ol>
<p>The method then works like this:</p>
<ol>
<li>A dynamic file is created on http://www.mysite.com, if it takes parameters then they must be supplied using the GET method
<ul>
<li>The dynamic file can be powered by PHP/ASP/etc etc, it doesn&#8217;t matter &#8211; but the output must be in plaintext format</li>
<li>The output is actually syntactically formatted to be in JavaScript</li>
</ul>
</li>
<li>A naming structure for the third party websites is chosen, and will be the name of the DIV deployed on third party websites</li>
<li>A snippet of code that references the dynamic file, and the DIV is created, and can be deployed onto multiple third party websites</li>
<li>When the third party website is loaded, the JavaScript is also loaded, and executes the remote script by making a GET request to it</li>
<li>The remote script instructs the page to populate the predefined named DIV with new content</li>
</ol>
<p><strong>Sample Implementation</strong></p>
<p><strong>Step 1 &#8211; The dynamic content</strong></p>
<p>Assume that in this implementation, your goal was to announce how many elements existed in your current working PHP directory, your remote code to do this simple task would look like:<br />
<code>&lt;?<br />
$d = dir(getcwd());<br />
$count = 0;<br />
while (false !== ($entry = $d-&gt;read())) {<br />
$count++;<br />
}<br />
$d-&gt;close();<br />
echo $count;<br />
?&gt;</code></p>
<p>While not the most useful of scripts by itself, it serves the purpose of being suitably dynamic. The next step is to work on a naming convention that can be used when deploying DIVs on remote servers.</p>
<p><strong>Step 2 &#8211; The naming convention</strong></p>
<p>The naming convention comes in two flavours &#8211; static or dynamic. A static naming convention is useful if you do not want to do any user/account specific logging, and just want to get your content out there and only expect one DIV to be updated on the page. A dynamic naming convention can be used to uniquely track JavaScript calls, and even have multiple dynamic widgets from the same server on the same page. Static is easy &#8211; so let&#8217;s go with dynamic to make things more exciting.</p>
<p>A simple dynamic naming convention would be to say we&#8217;ll use the name of the site (e.g. kaiesh_com) and append the username of the calling user to it. So if the user account Joe_Blogs were to deploy the JavaScript widget, it would look like: kaiesh_com_Joe_Blogs</p>
<p>The naming convention is totally up to you, there is nothing specific about this part, except for the fact that you must have a convention that you can predict and manage. Dynamic conventions are extremely useful as they allow for extensive logging/tracking.</p>
<p><strong>Step 3 &#8211; JavaScript syntactic formatting</strong></p>
<p>Now that the core dynamic functionality, and the naming convention have been defined, the code output must be updated to be JavaScript. And the path to the script must be defined, so assume this is held at http://www.mysite.com/myfile.php. So the code would now read:</p>
<p><code>&lt;?<br />
$userinput = $_GET['uname'];<br />
$d = dir(getcwd());<br />
$count = 0;<br />
while (false !== ($entry = $d-&gt;read())) {<br />
$count++;<br />
}<br />
$d-&gt;close();<br />
/* === YOU SHOULD ONLY USE ONE OF THE FOLLOWING === */<br />
/* if you are *not* using jQuery you would use this JavaScript line */<br />
?&gt;document.getElementById('kaiesh_com_&lt;? echo $userinput'; ?&gt;).innerHTML("&lt;? echo $count; ?&gt;");&lt;?<br />
/* if you are using jQuery then you would use this line */<br />
?&gt;$("#kaiesh_com_&lt;? echo $userinput'; ?&gt;").html("&lt;? echo $count; ?&gt;");&lt;?<br />
?&gt;</code></p>
<p>The above code provides you with two options &#8211; one if you were using <a href="http://www.jquery.com" target="_blank">jQuery</a>, and the other if you were not. So only use one of those &#8211; it also assumes that the username will be provided in the GET request through the parameter &#8216;uname&#8217;.</p>
<p><strong>Step 4 &#8211; The client side code </strong></p>
<p>So, you have now completed the server side programming, now we have to work on the client side snippet. Remember the naming structure that was defined in Step 2, and how we retrieved the dynamic component in Step 3, that now becomes important in generating the client side code. The code that would be deployed on other servers is now:<br />
<code>&lt;div id="kaiesh_com_joe_Blogs"&gt;&lt;/div&gt;<br />
&lt;script type="text/javascript" src="http://www.mysite.com/myfile.php?uname=Joe_Blogs"&gt;&lt;/script&gt;</code></p>
<p><strong>Step 5 &#8211; Deployment</strong></p>
<p>Now the snippet we have made in Step 4, can be deployed into any page, in so long as the file in Step 3 has been created, and is uploaded to http://www.mysite.com/myfile.php</p>
<p><strong>Demonstration</strong></p>
<p>I don&#8217;t have time to write a mock up demonstration right now! So please explore the snippet used to make the search bar at the top of the page. I will write a simple demo for this tutorial soon!</p>
<p>Have you implemented dynamic widgets on sites before? Do you have another method? I would be keen to see you have used this. If you have any questions, suggestions, or find anything confusing, please feel free to let me know!</p>
<a href="http://www.facebook.com/share.php?u=http%3A%2F%2Fwww.kaiesh.com%2F103%2Ftutorial-on-creating-dynamic-javascript-widgets-for-third-party-sites&amp;t=Tutorial%20on%20Creating%20Dynamic%20JavaScript%20Widgets%20for%20Third%20Party%20Sites" id="facebook_share_link_103">Share on Facebook</a>
	<script type="text/javascript">
	<!--
	var button = document.getElementById('facebook_share_link_103') || document.getElementById('facebook_share_icon_103') || document.getElementById('facebook_share_both_103') || document.getElementById('facebook_share_button_103');
	if (button) {
		button.onclick = function(e) {
			var url = this.href.replace(/share\.php/, 'sharer.php');
			window.open(url,'sharer','toolbar=0,status=0,width=626,height=436');
			return false;
		}
	
		if (button.id === 'facebook_share_button_103') {
			button.onmouseover = function(){
				this.style.color='#fff';
				this.style.borderColor = '#295582';
				this.style.backgroundColor = '#3b5998';
			}
			button.onmouseout = function(){
				this.style.color = '#3b5998';
				this.style.borderColor = '#d8dfea';
				this.style.backgroundColor = '#fff';
			}
		}
	}
	-->
	</script>
	]]></content:encoded>
			<wfw:commentRss>http://www.kaiesh.com/103/tutorial-on-creating-dynamic-javascript-widgets-for-third-party-sites/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Creating Line Graphs in JPEG Format through PHP</title>
		<link>http://www.kaiesh.com/83/creating-line-graphs-in-jpeg-format-through-php</link>
		<comments>http://www.kaiesh.com/83/creating-line-graphs-in-jpeg-format-through-php#comments</comments>
		<pubDate>Tue, 25 May 2010 03:17:36 +0000</pubDate>
		<dc:creator>Kaiesh</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[VenueMirror]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[user generated content]]></category>
		<category><![CDATA[website]]></category>

		<guid isPermaLink="false">http://www.venuemirror.com/blog/?p=83</guid>
		<description><![CDATA[A while ago I wrote about making use of information collected by websites &#8211; I find graphs a great way to do this. And while there are lots of great graphing objects, or tools available today, it can be a hectic scene to try and find a free one that you want for basic use. [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.kaiesh.com%2F83%2Fcreating-line-graphs-in-jpeg-format-through-php"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.kaiesh.com%2F83%2Fcreating-line-graphs-in-jpeg-format-through-php&amp;style=normal" height="61" width="50" /><br />
			</a>
		</div>
<p>A while ago I wrote about <a href="http://www.kaiesh.com/74/useful-currency-information-by-accident">making use of information collected by websites</a> &#8211; I find graphs a great way to do this. And while there are lots of great graphing objects, or tools available today, it can be a hectic scene to try and find a free one that you want for basic use. So quick modifications to existing code can sometimes be exactly what you need! Below is the code that was used to create the graphs seen in that previous post.<br />
<span id="more-83"></span></p>
<p>At the top of my graphing file, I&#8217;ve added two functions that I need to make use of while processing input from the user:</p>
<pre>
<code><span style="color: #4f9a4d; font-weight: bold;">//convert the submitted string to be only an integer</span>
function parseInt($string) {
 if(preg_match('/(\d+)/', $string, $array)) {
  return $array[1];
 } else {
  return 0;
 }
}
<span style="color: #4f9a4d; font-weight: bold;">/* given variable intVal, make sure it sits between a minimum number, and a maximum number! */</span>
function bound($intVal, $min, $max){
 $thisVal = parseInt($intVal);
 if ($thisVal &amp;lt; $min){
  $thisVal = $min;
 }
 if ($thisVal &amp;gt; $max){
  $thisVal = $max;
 }
 return $thisVal;
}</code>
</pre>
<p>Then I actually grab the input from the user &#8211; as this will usually be in within an IMG tag, all submitted parameters are going to be part of a GET request:</p>
<pre>
<code><span style="color: #4f9a4d; font-weight: bold;">//How many points on the graph are desired</span>
$idealRows = bound($_GET['points'], 5, 20);
<span style="color: #4f9a4d; font-weight: bold;">//The currency to peg against</span>
$baseValue = bound($_GET['base'], 1, 5);
<span style="color: #4f9a4d; font-weight: bold;">//The currency that varies against the peg</span>
$floatValue = bound($_GET['float'], 1, 5);
<span style="color: #4f9a4d; font-weight: bold;">//How many days in the past to start the graph from</span>
$skipDays = bound($_GET['skip'], 0, 45);</code>
</pre>
<p>Now that we know what the user wants the graphic to do, we can pull the necessary information out of the database. I have modeled this for connectivity to MySQL, and have abstracted out table components so that you can easily adapt this to any table that you want:</p>
<pre>
<code><span style="color: #4f9a4d; font-weight: bold;">/* Get the daily currency information over the user specified period */</span>
$currencyQuery = "SELECT field1, field2 FROM tableName WHERE currencyRefCode='".$baseValue."' AND currency2RefCode='".$floatValue."' ORDER BY sequenceElement DESC LIMIT ".$skipDays.", ".$idealRows.";";</code>
</pre>
<p>After you have structured your query to your database, then you need to run it and extract the data row by row:</p>
<pre>
<code><span style="color: #4f9a4d; font-weight: bold;">//Run the SQL query</span>
$cqRes = mysql_query($currencyQuery);
<span style="color: #4f9a4d; font-weight: bold;">/* Find out how many rows were returned by SQL */</span>
$num_entries = mysql_num_rows($cqRes);
<span style="color: #4f9a4d; font-weight: bold;">/* As long as there was more than one row we can do some work! */</span>
if ($num_entries &gt; 0){
<span style="color: #4f9a4d; font-weight: bold;">/* As our currency table is ordered the wrong way round (i.e. it goes back in time) we need to start from the end and work backwards! */</span>
 $loadPos = $num_entries - 1;
 <span style="color: #4f9a4d; font-weight: bold;">//While rows exist in the table, extract data</span>
 while ($cqRow = mysql_fetch_array($cqRes, MYSQL_NUM)){
  <span style="color: #4f9a4d; font-weight: bold;">//Store the floating value in an array</span>
  $nt["currVal"][$loadPos] =$cqRow[0];
  <span style="color: #4f9a4d; font-weight: bold;">/* Store the date of this value in an array, but crop the MYSQL datestamp down to only the parts that we want using substr */</span>
  $nt["month"][$loadPos] = substr($cqRow[1], 6, 5);
  <span style="color: #4f9a4d; font-weight: bold;">/* Move the array pointer back a value */</span>
  $loadPos--;
 }
}else{
 <span style="color: #4f9a4d; font-weight: bold;">// Woops! Nothing could be found using this query!</span>
 die ("Invalid currency query");
}</code>
</pre>
<p>Now that the data has been made available, preparations for the actual image canvas can be made:</p>
<pre>
<code>$x_gap=40; <span style="color: #4f9a4d; font-weight: bold;">// The gap between each point in y axis</span>
$x_max=$x_gap*($num_entries+1); <span style="color: #4f9a4d; font-weight: bold;">/* Maximum width of the graph or horizontal axis */</span>
$top_gap = 20; <span style="color: #4f9a4d; font-weight: bold;">/* The minimum distance to keep from the top of the image */</span>
$y_elev = 30; <span style="color: #4f9a4d; font-weight: bold;">/* The distance to elevate the graph from the bottom of the image */ </span>
$y_max = 150; <span style="color: #4f9a4d; font-weight: bold;">/* The maximum height of the graph canvas */ </span>
<span style="color: #4f9a4d; font-weight: bold;">/* Determine the lowest point and highest point that will be graphed */</span>
$minVal = min($nt["currVal"]);
$maxVal = max($nt["currVal"]);
<span style="color: #4f9a4d; font-weight: bold;">/* Now a scaling factor will be determined - this allows the graph to pronounce differences between values, otherwise the graph would look quite boring! */</span>
if ($maxVal - $minVal ==0){
 <span style="color: #4f9a4d; font-weight: bold;">/* There is no difference! So this graph will be a straight line */</span>
 $scaleFact = 1;
}else{
 <span style="color: #4f9a4d; font-weight: bold;">/* There is some difference, so this graph will have ups and downs */ </span>
 $scaleFact = $maxVal-$minVal;
}
<span style="color: #4f9a4d; font-weight: bold;">/* Determine the full scaling factor to be used by determining the largest pixel difference between points */</span>
$scaler=($y_max-$top_gap)/($scaleFact);</code>
</pre>
<p>So this has now allowed us to determine the size of the canvas, and the distance between points vertically and horizontally &#8211; so prepare the image canvas in PHP:</p>
<pre>
<code><span style="color: #4f9a4d; font-weight: bold;">//create the canvas</span>
$im = @ImageCreate ($x_max, $y_max+$y_elev)
<span style="color: #4f9a4d; font-weight: bold;">//if that failed, then kill the script</span>
or die ("Cannot Initialize new GD image stream");
<span style="color: #4f9a4d; font-weight: bold;">//set up all the colours (image resource, R, G, B)</span>
$background_color = ImageColorAllocate ($im, 255, 255, 255);
$text_color = ImageColorAllocate ($im, 233, 14, 91);
$graph_color = ImageColorAllocate ($im,25,25,25);
$grid_color = ImageColorAllocate ($im,125,125,125); </code>
</pre>
<p>As the canvas is ready, the points have been loaded into an array, and the scaling factors are known, now we can actually plot each point onto the graph! By the way, I am using <a href="http://www.venuemirror.com">VenueMirror</a>&#8216;s currency objects here &#8211; and the added benefit that I get from that is that in this script is that they return things like currency codes. Above, where there is an SQL query &#8211; I would have actually used methods from the objects themselves to get the graphing points. If you copy/paste this code, it will break here &#8211; so please change yours to reflect the currency codes, or other data descriptors here!</p>
<pre>
<code>$x1=0;
$y1=0;
$first_one=true;
<span style="color: #4f9a4d; font-weight: bold;">/* Put the title of the image into the image! */</span>
ImageString($im,2,5,5,"How many ".$floatCurr-&gt;getCurrCode()." buy 1 ".$baseCurr-&gt;getCurrCode()." - http://www.venuemirror.com/blog/74/useful-currency-information-by-accident",$graph_color);
<span style="color: #4f9a4d; font-weight: bold;">/* Start walking through the array of points */</span>
for($pos=0; $pos &lt; $num_entries; $pos++){
 $x2=$x1+$x_gap; <span style="color: #4f9a4d; font-weight: bold;">// Shifting in X axis</span>
 $y2=$y_max-(($nt["currVal"][$pos]-$minVal)*$scaler); <span style="color: #4f9a4d; font-weight: bold;">// Coordinate of Y axis</span>
 <span style="color: #4f9a4d; font-weight: bold;">//Write the floating currency value to the image next to the point</span>
 ImageString($im,2,$x2,$y2,round($nt["currVal"][$pos],2),$graph_color);
 <span style="color: #4f9a4d; font-weight: bold;">// Drawing the grid vertically//</span>
 imageline ($im,$x2, $y_max,$x2,$y2,$grid_color);
 ImageString($im, 2, $x2-($x_gap/2), $y_max+($y_elev/2), $nt["month"][$pos], $graph_color);
 <span style="color: #4f9a4d; font-weight: bold;">//Line above is to print month names on the graph</span>
 if(!$first_one){ <span style="color: #4f9a4d; font-weight: bold;">// this is to prevent from starting $x1= and $y1=0</span>
  imageline ($im,$x1, $y1,$x2,$y2,$text_color); <span style="color: #4f9a4d; font-weight: bold;">// Drawing the line between two points//</span>
 }
 $x1=$x2; <span style="color: #4f9a4d; font-weight: bold;">// Storing the value for next draw</span>
 $y1=$y2;
 $first_one=false; <span style="color: #4f9a4d; font-weight: bold;">// Now flag is set to allow the drawing</span>
}
<span style="color: #4f9a4d; font-weight: bold;">//Output the image</span>
ImageJPEG ($im);</code>
</pre>
<p>Credit also goes to this tutorial on <a href="http://www.plus2net.com/php_tutorial/gd-linegp2.php">Plus2Net</a>, as that provides good insight on how to actually draw graphs. I took much of what they wrote (and their code), and rendered it into a complete actual example here.</p>
<p>Do you have anything that you&#8217;re looking to create report style graphs about? There are other features in PHP that let you make 3D bar charts, and pie charts, and we use them a lot for internal reporting. Do you need information on those too? If you have any examples of graphs that you&#8217;re making from internal data then please post links to them below!</p>
<p>Also, if you find any bugs, security holes, or other horrible things in this code then please let me know! Do you also want a full file to download?</p>
<p>Cheers!<br />
K</p>
<p>P.S. I know that I said that I would post that the code the following day, but it&#8217;s a been a bit crazy recently &#8211; so I&#8217;m sorry about the delay!</p>
<a href="http://www.facebook.com/share.php?u=http%3A%2F%2Fwww.kaiesh.com%2F83%2Fcreating-line-graphs-in-jpeg-format-through-php&amp;t=Creating%20Line%20Graphs%20in%20JPEG%20Format%20through%20PHP" id="facebook_share_link_83">Share on Facebook</a>
	<script type="text/javascript">
	<!--
	var button = document.getElementById('facebook_share_link_83') || document.getElementById('facebook_share_icon_83') || document.getElementById('facebook_share_both_83') || document.getElementById('facebook_share_button_83');
	if (button) {
		button.onclick = function(e) {
			var url = this.href.replace(/share\.php/, 'sharer.php');
			window.open(url,'sharer','toolbar=0,status=0,width=626,height=436');
			return false;
		}
	
		if (button.id === 'facebook_share_button_83') {
			button.onmouseover = function(){
				this.style.color='#fff';
				this.style.borderColor = '#295582';
				this.style.backgroundColor = '#3b5998';
			}
			button.onmouseout = function(){
				this.style.color = '#3b5998';
				this.style.borderColor = '#d8dfea';
				this.style.backgroundColor = '#fff';
			}
		}
	}
	-->
	</script>
	]]></content:encoded>
			<wfw:commentRss>http://www.kaiesh.com/83/creating-line-graphs-in-jpeg-format-through-php/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
