<?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>Tohir Solomons</title>
	<atom:link href="http://www.tohir.co.za/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.tohir.co.za</link>
	<description></description>
	<lastBuildDate>Fri, 09 Jul 2010 13:40:51 +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>Installing SASS 3.0 on Ubuntu 10.4</title>
		<link>http://www.tohir.co.za/2010/07/09/installing-sass-3-0-on-ubuntu-10-4/</link>
		<comments>http://www.tohir.co.za/2010/07/09/installing-sass-3-0-on-ubuntu-10-4/#comments</comments>
		<pubDate>Fri, 09 Jul 2010 13:40:51 +0000</pubDate>
		<dc:creator>Tohir</dc:creator>
				<category><![CDATA[HTML, CSS]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Software and Technology]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[sass]]></category>
		<category><![CDATA[ubuntu]]></category>

		<guid isPermaLink="false">http://www.tohir.co.za/?p=409</guid>
		<description><![CDATA[Currently, the HAML/Sass version on Ubuntu is 2.2.17. Version 3, also known as Classy Cassidy, includes new features. So how can you install it on Ubuntu. Firstly, you need Ruby: sudo apt-get install ruby Thereafter (without sudo): gem install haml-edge This will install Haml and Sass into your directory, but at least you will have [...]]]></description>
			<content:encoded><![CDATA[<p>Currently, the <a href="http://sass-lang.com/">HAML/Sass</a> version on Ubuntu is 2.2.17. Version 3, also known as Classy Cassidy, includes new features. So how can you install it on Ubuntu.</p>
<p>Firstly, you need Ruby:</p>
<pre>sudo apt-get install ruby</pre>
<p>Thereafter (without sudo):</p>
<pre>gem install haml-edge</pre>
<p>This will install Haml and Sass into your directory, but at least you will have access to the latest version. Message that appears:</p>
<pre>WARNING:  Installing to ~/.gem since /var/lib/gems/1.8 and
 /var/lib/gems/1.8/bin aren't both writable.
WARNING:  You don't have /home/tohir/.gem/ruby/1.8/bin in your PATH,
 gem executables will not run.
Successfully installed haml-edge-3.1.49
1 gem installed</pre>
<p>You can test that it is the latest version by:</p>
<pre>~/.gem/ruby/1.8/bin/sass -version
</pre>
<p>Which should return:</p>
<pre>Haml/Sass 3.1.49 (Bleeding Edge)</pre>
<p>Lastly, there is a nice command to watch files and auto generate an updated version:</p>
<pre>~/.gem/ruby/1.8/bin/sass -t compact --watch [inputfile]:[outputfile]</pre>
<p>like:</p>
<pre>~/.gem/ruby/1.8/bin/sass -t compact --watch browseView.scss:browseView.css</pre>
<p><map name='google_ad_map_409_d66c8ad2bfa7c2ab'>
<area shape='rect' href='http://imageads.googleadservices.com/pagead/imgclick/409?pos=0' coords='1,2,367,28' />
<area shape='rect' href='http://services.google.com/feedback/abg' coords='384,10,453,23'/></map>
<img usemap='#google_ad_map_409_d66c8ad2bfa7c2ab' border='0' src='http://imageads.googleadservices.com/pagead/ads?format=468x30_aff_img&amp;client=&amp;channel=&amp;output=png&amp;cuid=409&amp;url= http%3A%2F%2Fwww.tohir.co.za%2F2010%2F07%2F09%2Finstalling-sass-3-0-on-ubuntu-10-4%2F' /></p>]]></content:encoded>
			<wfw:commentRss>http://www.tohir.co.za/2010/07/09/installing-sass-3-0-on-ubuntu-10-4/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Blocking Search Results in Google</title>
		<link>http://www.tohir.co.za/2010/05/20/blocking-search-results-in-google/</link>
		<comments>http://www.tohir.co.za/2010/05/20/blocking-search-results-in-google/#comments</comments>
		<pubDate>Thu, 20 May 2010 13:50:51 +0000</pubDate>
		<dc:creator>Tohir</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.tohir.co.za/2010/05/20/blocking-search-results-in-google/</guid>
		<description><![CDATA[I find it quite annoying that when ever I do a search related to ExtJS, two sites (codeweblog.com and defafe.com) are on the first page of results. These two sites simply aggregate ExtJS forum posts, and then present them in a SEO friendly page. Given this, I took to finding a way that can block [...]]]></description>
			<content:encoded><![CDATA[<p>I find it quite annoying that when ever I do a search related to ExtJS, two sites (codeweblog.com and defafe.com) are on the first page of results. These two sites simply aggregate ExtJS forum posts, and then present them in a SEO friendly page.</p>
<p>Given this, I took to finding a way that can block search results. Officially, there&#8217;s no way you can do that from within Google settings (which would have preserved that as you moved from machine to machine), but there are extensions for Firefox. Still looking for a Chrome one!</p>
<p>For Firefox, there are a few extensions. One is <a href="http://www.customizegoogle.com">CustomizeGoogle</a>, but it doesnt work in the latest version of Firefox.</p>
<p>The one that does work is <a href="https://addons.mozilla.org/en-US/firefox/addon/12305/">SurfClarity</a>. It allows you to list of a sites that should be filtered out. It doesn&#8217;t do it from the server-side which would save a 1kb of traffic, but nonetheless is good enough.</p>
<p><map name='google_ad_map_407_d66c8ad2bfa7c2ab'>
<area shape='rect' href='http://imageads.googleadservices.com/pagead/imgclick/407?pos=0' coords='1,2,367,28' />
<area shape='rect' href='http://services.google.com/feedback/abg' coords='384,10,453,23'/></map>
<img usemap='#google_ad_map_407_d66c8ad2bfa7c2ab' border='0' src='http://imageads.googleadservices.com/pagead/ads?format=468x30_aff_img&amp;client=&amp;channel=&amp;output=png&amp;cuid=407&amp;url= http%3A%2F%2Fwww.tohir.co.za%2F2010%2F05%2F20%2Fblocking-search-results-in-google%2F' /></p>]]></content:encoded>
			<wfw:commentRss>http://www.tohir.co.za/2010/05/20/blocking-search-results-in-google/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to Loop through the Properties of an Object in JavaScript</title>
		<link>http://www.tohir.co.za/2010/05/10/how-to-loop-through-the-properties-of-an-object-in-javascript/</link>
		<comments>http://www.tohir.co.za/2010/05/10/how-to-loop-through-the-properties-of-an-object-in-javascript/#comments</comments>
		<pubDate>Mon, 10 May 2010 12:41:39 +0000</pubDate>
		<dc:creator>Tohir</dc:creator>
				<category><![CDATA[Internet]]></category>
		<category><![CDATA[JavaScript]]></category>

		<guid isPermaLink="false">http://www.tohir.co.za/?p=404</guid>
		<description><![CDATA[for (var key in object) {    alert('value of '+key+is+object[key]); }]]></description>
			<content:encoded><![CDATA[<pre>for (var key in object) {
    alert('value of '+key+is+object[key]);
}</pre>
<p><map name='google_ad_map_404_d66c8ad2bfa7c2ab'>
<area shape='rect' href='http://imageads.googleadservices.com/pagead/imgclick/404?pos=0' coords='1,2,367,28' />
<area shape='rect' href='http://services.google.com/feedback/abg' coords='384,10,453,23'/></map>
<img usemap='#google_ad_map_404_d66c8ad2bfa7c2ab' border='0' src='http://imageads.googleadservices.com/pagead/ads?format=468x30_aff_img&amp;client=&amp;channel=&amp;output=png&amp;cuid=404&amp;url= http%3A%2F%2Fwww.tohir.co.za%2F2010%2F05%2F10%2Fhow-to-loop-through-the-properties-of-an-object-in-javascript%2F' /></p>]]></content:encoded>
			<wfw:commentRss>http://www.tohir.co.za/2010/05/10/how-to-loop-through-the-properties-of-an-object-in-javascript/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Wireshark and [truncated]</title>
		<link>http://www.tohir.co.za/2010/05/10/wireshark-and-trucated/</link>
		<comments>http://www.tohir.co.za/2010/05/10/wireshark-and-trucated/#comments</comments>
		<pubDate>Mon, 10 May 2010 09:49:00 +0000</pubDate>
		<dc:creator>Tohir</dc:creator>
				<category><![CDATA[Internet]]></category>
		<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://www.tohir.co.za/?p=399</guid>
		<description><![CDATA[I&#8217;ve posted a tutorial on how to get wireshark up and running on Ubuntu. The one problem , though, is that sometimes (actually often) you get [truncated]. How can you untruncate or turn it off or increase its size. This isn&#8217;t the answer, but a way of how to get access to the full response: [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve posted a tutorial on <a href="http://www.tohir.co.za/2010/02/01/getting-started-with-wireshark-the-fiddler-for-ubuntu/">how to get wireshark up and running on Ubuntu</a>. The one problem , though, is that sometimes (actually often) you get [truncated]. How can you untruncate or turn it off or increase its size.</p>
<p>This isn&#8217;t the answer, but a way of how to get access to the full response:</p>
<p>Right Click on the Packet in Line-based text data, then choose Copy &gt; Bytes (Printable Text Only).</p>
<p>This will place the full response, and you can paste it in a text editor.</p>
<p><map name='google_ad_map_399_d66c8ad2bfa7c2ab'>
<area shape='rect' href='http://imageads.googleadservices.com/pagead/imgclick/399?pos=0' coords='1,2,367,28' />
<area shape='rect' href='http://services.google.com/feedback/abg' coords='384,10,453,23'/></map>
<img usemap='#google_ad_map_399_d66c8ad2bfa7c2ab' border='0' src='http://imageads.googleadservices.com/pagead/ads?format=468x30_aff_img&amp;client=&amp;channel=&amp;output=png&amp;cuid=399&amp;url= http%3A%2F%2Fwww.tohir.co.za%2F2010%2F05%2F10%2Fwireshark-and-trucated%2F' /></p>]]></content:encoded>
			<wfw:commentRss>http://www.tohir.co.za/2010/05/10/wireshark-and-trucated/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Starting to like the toolbar in Ubuntu 10.4 file manager</title>
		<link>http://www.tohir.co.za/2010/05/04/starting-to-like-the-toolbar-in-ubuntu-10-4-file-manager/</link>
		<comments>http://www.tohir.co.za/2010/05/04/starting-to-like-the-toolbar-in-ubuntu-10-4-file-manager/#comments</comments>
		<pubDate>Tue, 04 May 2010 08:52:08 +0000</pubDate>
		<dc:creator>Tohir</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.tohir.co.za/?p=395</guid>
		<description><![CDATA[The one thing that horrified me in the latest version of Ubuntu was the &#8216;new&#8217; toolbar for Nautilus or the file manager. However, after reading Deconstructing Nautilus and rebuilding it better, I have to admit, I enjoy it. Why? Even though I tend to browser elsewhere by typing in the path, the UP button is [...]]]></description>
			<content:encoded><![CDATA[<p>The one thing that horrified me in the latest version of Ubuntu was the &#8216;new&#8217; toolbar for Nautilus or the file manager.</p>
<p><img class="aligncenter size-full wp-image-396" title="ubuntu10.4toolbar" src="http://www.tohir.co.za/wp-content/uploads/2010/05/ubuntu10.4toolbar.png" alt="" width="802" height="106" /></p>
<p>However, after reading <a href="http://www.design-by-izo.com/2010/02/27/deconstructing-nautilus-and-rebuilding-it-better/">Deconstructing Nautilus and rebuilding it better</a>, I have to admit, I enjoy it. Why?</p>
<p>Even though I tend to browser elsewhere by typing in the path, the UP button is probably the most used button by myself. Switching to the location bar provides no alternative, but keeping the button bar allows one a form of up button.</p>
<p>Secondly, CTRL+L is probably something I can live with.</p>
<p>Given the whole debate around this, the lesson I believe is that don&#8217;t ignore your existing users. If you are going to change something, inform your users!</p>
<p>Given the opensource community spirit, it wont be long before someone does a quick script to bring back the old toolbar. If you are looking to do that today, have a look at: <a href="https://help.ubuntu.com/community/RestoreNautilusLocationBar">https://help.ubuntu.com/community/RestoreNautilusLocationBar</a></p>
<p><map name='google_ad_map_395_d66c8ad2bfa7c2ab'>
<area shape='rect' href='http://imageads.googleadservices.com/pagead/imgclick/395?pos=0' coords='1,2,367,28' />
<area shape='rect' href='http://services.google.com/feedback/abg' coords='384,10,453,23'/></map>
<img usemap='#google_ad_map_395_d66c8ad2bfa7c2ab' border='0' src='http://imageads.googleadservices.com/pagead/ads?format=468x30_aff_img&amp;client=&amp;channel=&amp;output=png&amp;cuid=395&amp;url= http%3A%2F%2Fwww.tohir.co.za%2F2010%2F05%2F04%2Fstarting-to-like-the-toolbar-in-ubuntu-10-4-file-manager%2F' /></p>]]></content:encoded>
			<wfw:commentRss>http://www.tohir.co.za/2010/05/04/starting-to-like-the-toolbar-in-ubuntu-10-4-file-manager/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Being in touch with the Nabi Muhammad (PBUH)</title>
		<link>http://www.tohir.co.za/2010/05/03/being-in-touch-with-the-nabi-muhammad/</link>
		<comments>http://www.tohir.co.za/2010/05/03/being-in-touch-with-the-nabi-muhammad/#comments</comments>
		<pubDate>Mon, 03 May 2010 01:55:31 +0000</pubDate>
		<dc:creator>Tohir</dc:creator>
				<category><![CDATA[Reflections/Thoughts]]></category>

		<guid isPermaLink="false">http://www.tohir.co.za/?p=390</guid>
		<description><![CDATA[For the past couple of weeks, I&#8217;ve taken to reading Muhammad: His Life Based on the Earliest Sources by Martin Lings. One of the many touching incidents occurred in Madina. The Prophet (PBUH) had to serve in multiple roles as the leader of the Muslims, governor of Madina, prophet, etc. At this time, he divided [...]]]></description>
			<content:encoded><![CDATA[<p>For the past couple of weeks, I&#8217;ve taken to reading Muhammad: His Life Based on the Earliest Sources by Martin Lings. One of the many touching incidents occurred in Madina.</p>
<p>The Prophet (PBUH) had to serve in multiple roles as the leader of the Muslims, governor of Madina, prophet, etc. At this time, he divided his day into three. 1/3 for family time, 1/3 for community affairs and a 1/3 to spent in worship and prayer.</p>
<p>Some of the companions felt as if they were losing touch with the Prophet, given his multiple roles, fixed time in them, and the large amount of people who were all vying for his attention.</p>
<p>In this regard, Allah revealed the verse:</p>
<p style="text-align: center;"><img class="alignnone size-full wp-image-391" title="salutationsverse" src="http://www.tohir.co.za/wp-content/uploads/2010/05/salutationsverse.gif" alt="" width="500" height="45" /></p>
<p style="text-align: center;">Surely Allah and His Angels bless the Prophet. Oh you,  who      believe, call for blessings on him, and salute with (respectable)  salutations. (Chapter 33: Verse 56)</p>
<p>This would be their (and our way) of staying connected with him!</p>
<p>The Prophet (PBUH) would also add: <span><span>“Whoever invokes blessings on me once,  Allah will invoke blessings upon him ten times”</span></span></p>
<p><map name='google_ad_map_390_d66c8ad2bfa7c2ab'>
<area shape='rect' href='http://imageads.googleadservices.com/pagead/imgclick/390?pos=0' coords='1,2,367,28' />
<area shape='rect' href='http://services.google.com/feedback/abg' coords='384,10,453,23'/></map>
<img usemap='#google_ad_map_390_d66c8ad2bfa7c2ab' border='0' src='http://imageads.googleadservices.com/pagead/ads?format=468x30_aff_img&amp;client=&amp;channel=&amp;output=png&amp;cuid=390&amp;url= http%3A%2F%2Fwww.tohir.co.za%2F2010%2F05%2F03%2Fbeing-in-touch-with-the-nabi-muhammad%2F' /></p>]]></content:encoded>
			<wfw:commentRss>http://www.tohir.co.za/2010/05/03/being-in-touch-with-the-nabi-muhammad/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Vodacom and Rotten DNS, Connected but not quite connected</title>
		<link>http://www.tohir.co.za/2010/05/03/vodacom-and-rotten-dns-connections/</link>
		<comments>http://www.tohir.co.za/2010/05/03/vodacom-and-rotten-dns-connections/#comments</comments>
		<pubDate>Mon, 03 May 2010 01:28:27 +0000</pubDate>
		<dc:creator>Tohir</dc:creator>
				<category><![CDATA[Internet]]></category>

		<guid isPermaLink="false">http://www.tohir.co.za/?p=385</guid>
		<description><![CDATA[One of the most annoying issues using Vodacom to connect to the internet is that sometimes the DNS server used is so badly rotten, internet use is practically useless. DNS is the system that converts a domain example www.google.com to an IP Address, something &#8216;computers&#8217; can interpret and understand. When this process fails, it may [...]]]></description>
			<content:encoded><![CDATA[<p>One of the most annoying issues using Vodacom to connect to the internet is that sometimes the DNS server used is so badly rotten, internet use is practically useless.</p>
<p>DNS is the system that converts a domain example www.google.com to an IP Address, something &#8216;computers&#8217; can interpret and understand. When this process fails, it may appear the internet is down. All that is happening, however, is that the process of converting domain names to IP Addresses is slow (or dead).</p>
<p>One way to fix this is to use alternative DNS servers/addresses. By switching DNS addresses, you are basically saying, use this server to convert domains to IP addresses.</p>
<p>First things to check:</p>
<ol>
<li>You have an internet connection. This will not help if you do have one</li>
<li>Check that entering an IP address works, example: http://41.1.224.101</li>
</ol>
<blockquote>
<ul>
<li>http://41.1.224.101 (vodacom.co.za)</li>
<li>http://41.203.21.136 (mybroadband.co.za)</li>
<li>http:// 196.8.95.20 (standardbank.co.za)</li>
<li>http://74.125.43.106 (google.co.za)</li>
</ul>
</blockquote>
<p>If this works, but entering www.vodacom.co.za doesn&#8217;t, then changing DNS entries will help. Edit your connection settings, and try one of the following:</p>
<p>196.43.46.190 &#8211; SAIX<br />
196.207.40.165 &#8211; Vodacom<br />
168.10.2.2 &#8211; Internet Solutions (IS)<br />
208.67.222.222 &#8211; OpenDNS<br />
208.67.220.220 &#8211; OpenDNS alt</p>
<p>It is possible to mix them up, rather than using two by the same company.</p>
<p><map name='google_ad_map_385_d66c8ad2bfa7c2ab'>
<area shape='rect' href='http://imageads.googleadservices.com/pagead/imgclick/385?pos=0' coords='1,2,367,28' />
<area shape='rect' href='http://services.google.com/feedback/abg' coords='384,10,453,23'/></map>
<img usemap='#google_ad_map_385_d66c8ad2bfa7c2ab' border='0' src='http://imageads.googleadservices.com/pagead/ads?format=468x30_aff_img&amp;client=&amp;channel=&amp;output=png&amp;cuid=385&amp;url= http%3A%2F%2Fwww.tohir.co.za%2F2010%2F05%2F03%2Fvodacom-and-rotten-dns-connections%2F' /></p>]]></content:encoded>
			<wfw:commentRss>http://www.tohir.co.za/2010/05/03/vodacom-and-rotten-dns-connections/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Electricity Tariff Increase Calculator</title>
		<link>http://www.tohir.co.za/2010/02/24/electricity-tariff-increase-calculator/</link>
		<comments>http://www.tohir.co.za/2010/02/24/electricity-tariff-increase-calculator/#comments</comments>
		<pubDate>Wed, 24 Feb 2010 11:45:48 +0000</pubDate>
		<dc:creator>Tohir</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.tohir.co.za/?p=377</guid>
		<description><![CDATA[The National Energy Regulator of South Africa on Wednesday granted state-owned utility Eskom a 24,8% tariff increase for the 2010/11 financial year, falling short of the power firm&#8217;s request for a 35% hike. For the following two financial years, Eskom was granted increases of 25,8% and 25,9% respectively. How much does that amount to for [...]]]></description>
			<content:encoded><![CDATA[<p>The National Energy Regulator of South Africa on Wednesday granted state-owned utility Eskom a 24,8% tariff increase for the 2010/11 financial year, falling short of the power firm&#8217;s request for a 35% hike. For the following two financial years, Eskom was granted increases of 25,8% and 25,9% respectively.</p>
<p>How much does that amount to for you? Try the calculator below:</p>
<iframe class="" src="http://www.tohir.co.za/electricity_rate_calculator.html" style="width: 400px; height: 280px; " frameborder="0" scrolling="" onload="scro11me(this)"></iframe><script type="text/javascript">function scro11me(f){f.contentWindow.scrollTo(0,0); }</script>
<p>Read the story on <a href="http://www.mg.co.za/article/2010-02-24-nersa-grants-eskom-248-price-rise">Mail and Guardian</a></p>
<p><map name='google_ad_map_377_d66c8ad2bfa7c2ab'>
<area shape='rect' href='http://imageads.googleadservices.com/pagead/imgclick/377?pos=0' coords='1,2,367,28' />
<area shape='rect' href='http://services.google.com/feedback/abg' coords='384,10,453,23'/></map>
<img usemap='#google_ad_map_377_d66c8ad2bfa7c2ab' border='0' src='http://imageads.googleadservices.com/pagead/ads?format=468x30_aff_img&amp;client=&amp;channel=&amp;output=png&amp;cuid=377&amp;url= http%3A%2F%2Fwww.tohir.co.za%2F2010%2F02%2F24%2Felectricity-tariff-increase-calculator%2F' /></p>]]></content:encoded>
			<wfw:commentRss>http://www.tohir.co.za/2010/02/24/electricity-tariff-increase-calculator/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Road Closures for opening of Parliament</title>
		<link>http://www.tohir.co.za/2010/02/08/road-closures-for-opening-of-parliament/</link>
		<comments>http://www.tohir.co.za/2010/02/08/road-closures-for-opening-of-parliament/#comments</comments>
		<pubDate>Mon, 08 Feb 2010 12:51:27 +0000</pubDate>
		<dc:creator>Tohir</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.tohir.co.za/?p=371</guid>
		<description><![CDATA[Here&#8217;s a Google Map of the road closures for the opening of South African Parliament function scro11me(f){f.contentWindow.scrollTo(0,0); } View Opening of Parliament 2010 in a larger map Would it not have been easier for them to stick to DeWaal Drive, Roeland Street?]]></description>
			<content:encoded><![CDATA[<p>Here&#8217;s a Google Map of the road closures for the opening of South African Parliament</p>
<iframe class="" src="http://maps.google.com/maps/ms?ie=UTF8&amp;hl=en&amp;msa=0&amp;all=-33.921088,18.425757&amp;spn=0.00438,0.011362&amp;t=h&amp;msid=117948265150003085682.00047f15df8a642301b50&amp;output=embed" style="width: 100%; height: 480px; " frameborder="0" scrolling="" onload="scro11me(this)"></iframe><script type="text/javascript">function scro11me(f){f.contentWindow.scrollTo(0,0); }</script><br />
<small>View <a style="color:#0000FF;text-align:left" href="http://maps.google.com/maps/ms?ie=UTF8&amp;hl=en&amp;t=h&amp;msa=0&amp;msid=117948265150003085682.00047f15df8a642301b50&amp;ll=-33.923029,18.424158&amp;spn=0.017093,0.027466&amp;z=15&amp;source=embed">Opening of Parliament 2010</a> in a larger map</small></p>
<p>Would it not have been easier for them to stick to DeWaal Drive, Roeland Street?</p>
<p><map name='google_ad_map_371_d66c8ad2bfa7c2ab'>
<area shape='rect' href='http://imageads.googleadservices.com/pagead/imgclick/371?pos=0' coords='1,2,367,28' />
<area shape='rect' href='http://services.google.com/feedback/abg' coords='384,10,453,23'/></map>
<img usemap='#google_ad_map_371_d66c8ad2bfa7c2ab' border='0' src='http://imageads.googleadservices.com/pagead/ads?format=468x30_aff_img&amp;client=&amp;channel=&amp;output=png&amp;cuid=371&amp;url= http%3A%2F%2Fwww.tohir.co.za%2F2010%2F02%2F08%2Froad-closures-for-opening-of-parliament%2F' /></p>]]></content:encoded>
			<wfw:commentRss>http://www.tohir.co.za/2010/02/08/road-closures-for-opening-of-parliament/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MySQL &#8211; getting two items per source in a single query</title>
		<link>http://www.tohir.co.za/2010/02/04/mysql-getting-two-items-per-source-in-a-single-query/</link>
		<comments>http://www.tohir.co.za/2010/02/04/mysql-getting-two-items-per-source-in-a-single-query/#comments</comments>
		<pubDate>Thu, 04 Feb 2010 21:46:27 +0000</pubDate>
		<dc:creator>Tohir</dc:creator>
				<category><![CDATA[Software and Technology]]></category>

		<guid isPermaLink="false">http://www.tohir.co.za/?p=366</guid>
		<description><![CDATA[Assume you have the following table called stories with the following data. And you have run the following query: SELECT * FROM stories ORDER BY storydate DESC id source title storydate 10 cnn Story 10 2010-01-21 9 bbcnews Story 9 2010-01-20 8 bbcnews Story 8 2010-01-19 7 skynews Story 7 2010-01-18 6 cnn Story 6 [...]]]></description>
			<content:encoded><![CDATA[<p>Assume you have the following table called stories with the following data. And you have run the following query:</p>
<pre>SELECT * FROM stories ORDER BY storydate DESC</pre>
<table border="1" width="100%">
<tbody>
<tr>
<td>id</td>
<td>source</td>
<td>title</td>
<td>storydate</td>
</tr>
<tr>
<td>10</td>
<td>cnn</td>
<td>Story 10</td>
<td>2010-01-21</td>
</tr>
<tr>
<td>9</td>
<td>bbcnews</td>
<td>Story 9</td>
<td>2010-01-20</td>
</tr>
<tr>
<td>8</td>
<td>bbcnews</td>
<td>Story 8</td>
<td>2010-01-19</td>
</tr>
<tr>
<td>7</td>
<td>skynews</td>
<td>Story 7</td>
<td>2010-01-18</td>
</tr>
<tr>
<td>6</td>
<td>cnn</td>
<td>Story 6</td>
<td>2010-01-17</td>
</tr>
<tr>
<td>5</td>
<td>bbcnews</td>
<td>Story 5</td>
<td>2010-01-16</td>
</tr>
<tr>
<td>4</td>
<td>cnn</td>
<td>Story 4</td>
<td>2010-01-15</td>
</tr>
<tr>
<td>3</td>
<td>skynews</td>
<td>Story 3</td>
<td>2010-01-14</td>
</tr>
<tr>
<td>2</td>
<td>skynews</td>
<td>Story 2</td>
<td>2010-01-13</td>
</tr>
<tr>
<td>1</td>
<td>cnn</td>
<td>Story 1</td>
<td>2010-01-12</td>
</tr>
</tbody>
</table>
<p>Now for the challenge. What happens if you are required to get the top two stories from each source? One option is to first get the order of the sources, and then loop through each one of them:</p>
<pre>SELECT DISTINCT source FROM stories ORDER BY storydate DESC</pre>
<p>&lt;loop &#8220;source&#8221; as &#8220;sourceid&#8221;&gt;</p>
<pre>      SELECT * FROM stories WHERE source = "{sourceid}" ORDER BY storydate DESC LIMIT 2</pre>
<p>&lt;/loop&gt;</p>
<p>Another option is to do the in MySQL itself! Unsure if there is a better way of doing this, but here&#8217;s mine using UNION and Sub Selects:</p>
<pre>(SELECT * FROM stories WHERE source =
<strong>(SELECT DISTINCT source FROM stories ORDER BY storydate DESC LIMIT 0,1)</strong> ORDER BY storydate DESC LIMIT 2)
UNION
(SELECT * FROM stories WHERE source =
<strong>(SELECT DISTINCT source FROM stories ORDER BY storydate DESC LIMIT 1,1)</strong> ORDER BY storydate DESC LIMIT 2)
UNION
(SELECT * FROM stories WHERE source =
<strong>(SELECT DISTINCT source FROM stories ORDER BY storydate DESC LIMIT 2,1)</strong> ORDER BY storydate DESC LIMIT 2)</pre>
<h3>Explanation:</h3>
<p>The bold section are subselects and form the WHERE clause of the query. Here  we want the first, second and third as per source, but only one at a time. Once we have two results per item, we use UNION to join them together.</p>
<p>One thing to note though. Even though it returns the latest two stories per source, the final table is not sorted by storydate! This can be done using PHP sorting techniques. Is there a way of doing this one time in MySQL?</p>
<p><map name='google_ad_map_366_d66c8ad2bfa7c2ab'>
<area shape='rect' href='http://imageads.googleadservices.com/pagead/imgclick/366?pos=0' coords='1,2,367,28' />
<area shape='rect' href='http://services.google.com/feedback/abg' coords='384,10,453,23'/></map>
<img usemap='#google_ad_map_366_d66c8ad2bfa7c2ab' border='0' src='http://imageads.googleadservices.com/pagead/ads?format=468x30_aff_img&amp;client=&amp;channel=&amp;output=png&amp;cuid=366&amp;url= http%3A%2F%2Fwww.tohir.co.za%2F2010%2F02%2F04%2Fmysql-getting-two-items-per-source-in-a-single-query%2F' /></p>]]></content:encoded>
			<wfw:commentRss>http://www.tohir.co.za/2010/02/04/mysql-getting-two-items-per-source-in-a-single-query/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
