<?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>Sébastien Barbieri's blog &#187; truc de g33k</title>
	<atom:link href="http://blog.sbw.be/category/truc-de-g33k/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.sbw.be</link>
	<description>My life, my work, my projects</description>
	<lastBuildDate>Mon, 28 Jun 2010 05:28:18 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>That&#8217;s it I&#8217;m in</title>
		<link>http://blog.sbw.be/2010/04/28/thats-it-im-in/</link>
		<comments>http://blog.sbw.be/2010/04/28/thats-it-im-in/#comments</comments>
		<pubDate>Wed, 28 Apr 2010 15:34:22 +0000</pubDate>
		<dc:creator>Sébastien Barbieri</dc:creator>
				<category><![CDATA[freelance]]></category>
		<category><![CDATA[truc de g33k]]></category>
		<category><![CDATA[csm]]></category>
		<category><![CDATA[scrum]]></category>

		<guid isPermaLink="false">http://blog.sbw.be/?p=405</guid>
		<description><![CDATA[I&#8217;m officially Certified Scrum Master: http://www.scrumalliance.org/profiles/88649-sebastien-barbieri
]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m officially Certified Scrum Master: <a href="http://bit.ly/9wG5pM">http://www.scrumalliance.org/profiles/88649-sebastien-barbieri</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.sbw.be/2010/04/28/thats-it-im-in/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>#web #continuous #integration: #Autodeploy on #commit</title>
		<link>http://blog.sbw.be/2009/12/11/web-continuous-integration-auto-deploy-on-commit/</link>
		<comments>http://blog.sbw.be/2009/12/11/web-continuous-integration-auto-deploy-on-commit/#comments</comments>
		<pubDate>Fri, 11 Dec 2009 20:13:13 +0000</pubDate>
		<dc:creator>Sébastien Barbieri</dc:creator>
				<category><![CDATA[freelance]]></category>
		<category><![CDATA[truc de g33k]]></category>
		<category><![CDATA[commit]]></category>
		<category><![CDATA[continuous]]></category>
		<category><![CDATA[deploy]]></category>
		<category><![CDATA[integration]]></category>
		<category><![CDATA[rsync]]></category>
		<category><![CDATA[svn]]></category>
		<category><![CDATA[web]]></category>

		<guid isPermaLink="false">http://blog.sbw.be/?p=341</guid>
		<description><![CDATA[Option 1
In 4 steps

svn commit to the repository
the pre-commit hook will check the code with svnlook and will validate the commit message (based on regexp such has bug# &#8230;, text minimal size&#8230;)
the post-commit hook will try to connect to the ITT (Integration Team Testing) if you have the good acronym, I&#8217;ll update
once connected a script [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Option 1</strong></p>
<div id="attachment_342" class="wp-caption aligncenter" style="width: 1011px"><a href="http://blog.sbw.be/wp-content/uploads/2009/12/PostCommitAutoDeploy.png"><img src="http://blog.sbw.be/wp-content/uploads/2009/12/PostCommitAutoDeploy.png" alt="post commit auto deploy" title="PostCommitAutoDeploy" width="1001" height="449" class="size-full wp-image-342" /></a><p class="wp-caption-text">post commit auto deploy</p></div>
<p>In 4 steps</p>
<ol>
<li><strong>svn commit</strong> to the repository</li>
<li>the <strong>pre-commit hook</strong> will check the code with <a href="http://svnbook.red-bean.com/en/1.5/svn.reposadmin.maint.html#svn.reposadmin.maint.tk.svnlook">svnlook</a> and will validate the commit message (based on regexp such has bug# &#8230;, text minimal size&#8230;)</li>
<li>the <strong>post-commit hook</strong> will try to connect to the ITT (Integration Team Testing) <em>if you have the good acronym, I&#8217;ll update</em></li>
<li>once connected a script should be launched (and forgot &#038;;) This script should:
<ul>
<li><strong>Do a svn checkout locally so the code could be tested (in /var/www &#8230;)</strong>. <em>This method has several drawback:  instability of the site while exporting, destruction of ITT generated file (if any)&#8230;</em></li>
<li>Do a<strong> svn checkout in a temporary directory</strong> (/export/&lt;projectname&gt;) and then use <strong>rsync</strong> to do a fast compare and copy changes only without deleting the existing, excluding the .svn folders</li>
<li>Do a<strong> svn export in a temporary directory</strong> (/tmp/&lt;projectname&gt;) and then use the same <strong>rsync</strong> than above but this time you don&#8217;t have to exclude the .svn</li>
</ul>
<p>The fastest is the second one (svn checkout -> /export/&lt;projectname&gt; + rsync &#8211; .svn folders)
 </li>
</ol>
<p><strong>Option 2</strong></p>
<p>There is another <strong>alternative</strong> if you have space and sufficient right on your <strong>svn repository</strong>: the svn export/svn checkout is done locally and you use rsync to <strong>deploy</strong> the site on the ITT server.</p>
<p><strong>Option 3</strong></p>
<p>There is a third <strong>alternative</strong> if you have one more server (a synchro server) that will be used to store the svn export (at least the last one and maybe 2-3 version before) and that will take care of the rsync between one of its local checkout/export and the ITT server.</p>
<p><strong>Conclusion</strong></p>
<p>The last option has the big advantage of being a intermediate repository that can deploy any revision to any server &#8230; but that&#8217;s another paper.</p>
<p>I used the 3 options, and the first one (the simplest/cheapest) is very easy to maintain and to set up, so it&#8217;s a must have for team < 15 &#8230; bigger team may think about the other options but will have to put additional resources to design the whole deployment system.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.sbw.be/2009/12/11/web-continuous-integration-auto-deploy-on-commit/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Pear / php update &#8211; pear.php.net is using a unsupported protocal</title>
		<link>http://blog.sbw.be/2009/12/08/pear-php-update-pear-php-net-is-using-a-unsupported-protocal/</link>
		<comments>http://blog.sbw.be/2009/12/08/pear-php-update-pear-php-net-is-using-a-unsupported-protocal/#comments</comments>
		<pubDate>Tue, 08 Dec 2009 00:16:15 +0000</pubDate>
		<dc:creator>Sébastien Barbieri</dc:creator>
				<category><![CDATA[truc de g33k]]></category>
		<category><![CDATA[ce]]></category>
		<category><![CDATA[pear]]></category>
		<category><![CDATA[server]]></category>
		<category><![CDATA[zend]]></category>
		<category><![CDATA[zend studio]]></category>

		<guid isPermaLink="false">http://blog.sbw.be/?p=337</guid>
		<description><![CDATA[and you get some wonderful error message such as: Notice: Undefined variable: dorest in PEAR/Command/Install.php on line 1220
Sometimes it happens&#8230;
Solution: locate the .channels/ directory
For ubuntu with Zend-CE 5.2 it&#8217;s in /usr/local/zend/share/pear/.channels/
And delete everything in there

sudo rm /usr/local/zend/share/pear/.channels/*
then do a fresh pear update-channels to reconstruct the serialized cache file in .channels/
sudo pear update-channels
if you also want [...]]]></description>
			<content:encoded><![CDATA[<p>and you get some wonderful error message such as: Notice: Undefined variable: dorest in PEAR/Command/Install.php on line 1220</p>
<p>Sometimes it happens&#8230;</p>
<p>Solution: locate the .channels/ directory<br />
For ubuntu with Zend-CE 5.2 it&#8217;s in /usr/local/zend/share/pear/.channels/</p>
<p>And delete everything in there<br />
<code><br />
sudo rm /usr/local/zend/share/pear/.channels/*</code></p>
<p>then do a fresh pear update-channels to reconstruct the serialized cache file in .channels/</p>
<p><code>sudo pear update-channels</code></p>
<p>if you also want to also install phpunit</p>
<p><code><br />
cd /usr/local/zend/bin/<br />
sudo ./pear channel-discover pear.phpunit.de<br />
sudo ./pear install phpunit/PHPUnit<br />
</code></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.sbw.be/2009/12/08/pear-php-update-pear-php-net-is-using-a-unsupported-protocal/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ERROR 1307 (HY000) at line &#8230;: Failed to CREATE PROCEDURE</title>
		<link>http://blog.sbw.be/2009/11/05/error-1307-hy000-at-line-failed-to-create-procedure/</link>
		<comments>http://blog.sbw.be/2009/11/05/error-1307-hy000-at-line-failed-to-create-procedure/#comments</comments>
		<pubDate>Thu, 05 Nov 2009 10:48:49 +0000</pubDate>
		<dc:creator>Sébastien Barbieri</dc:creator>
				<category><![CDATA[truc de g33k]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[upgrade]]></category>

		<guid isPermaLink="false">http://blog.sbw.be/?p=328</guid>
		<description><![CDATA[Just a reminder for myself&#8230;
After any mysql upgrade run from the terminal:
sudo mysql_upgrade (mac/*nix)
or
mysql_upgrade.exe (windows)
]]></description>
			<content:encoded><![CDATA[<p>Just a reminder for myself&#8230;</p>
<p>After any mysql upgrade run from the terminal:<br />
sudo mysql_upgrade (mac/*nix)<br />
or<br />
mysql_upgrade.exe (windows)</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.sbw.be/2009/11/05/error-1307-hy000-at-line-failed-to-create-procedure/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Firefox Ubiquity php search handy command</title>
		<link>http://blog.sbw.be/2009/08/26/firefox-ubiquity-php-search-handy-command/</link>
		<comments>http://blog.sbw.be/2009/08/26/firefox-ubiquity-php-search-handy-command/#comments</comments>
		<pubDate>Wed, 26 Aug 2009 14:22:35 +0000</pubDate>
		<dc:creator>Sébastien Barbieri</dc:creator>
				<category><![CDATA[Projects]]></category>
		<category><![CDATA[freelance]]></category>
		<category><![CDATA[truc de g33k]]></category>
		<category><![CDATA[firefox]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[ubiquity]]></category>

		<guid isPermaLink="false">http://blog.sbw.be/?p=301</guid>
		<description><![CDATA[Just created a Firfow Ubiquity php search command based on 2 other work: http://download.sbw.be/projects/ubiquity/php-search.html
]]></description>
			<content:encoded><![CDATA[<p>Just created a Firfow Ubiquity php search command based on 2 other work: <a href="http://download.sbw.be/projects/ubiquity/php-search.html">http://download.sbw.be/projects/ubiquity/php-search.html</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.sbw.be/2009/08/26/firefox-ubiquity-php-search-handy-command/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Daily scrum backlog, today, tomorrow &#8230;</title>
		<link>http://blog.sbw.be/2009/08/04/daily-scrum-backlog-today-tomorrow/</link>
		<comments>http://blog.sbw.be/2009/08/04/daily-scrum-backlog-today-tomorrow/#comments</comments>
		<pubDate>Tue, 04 Aug 2009 15:17:07 +0000</pubDate>
		<dc:creator>Sébastien Barbieri</dc:creator>
				<category><![CDATA[je bosse là]]></category>
		<category><![CDATA[truc de g33k]]></category>

		<guid isPermaLink="false">http://blog.sbw.be/?p=296</guid>
		<description><![CDATA[Mes developpeurs sont plein d&#8217;humour &#8230; dans le daily scrum backlog du jour j&#8217;ai reçu ceci:
TODAY

added update load and delete methods
secured checks
updated database for thumbnails

TOMORROW

Thumbnails handling

TOYOTA

ah bah dis donc, elle bonne celle-là !


]]></description>
			<content:encoded><![CDATA[<p>Mes developpeurs sont plein d&#8217;humour &#8230; dans le daily scrum backlog du jour j&#8217;ai reçu ceci:</p>
<p><strong>TODAY</strong></p>
<ul>
<li>added update load and delete methods</li>
<li>secured checks</li>
<li>updated database for thumbnails</li>
</ul>
<p><strong>TOMORROW</strong></p>
<ul>
<li>Thumbnails handling</li>
</ul>
<p><strong>TOYOTA</strong></p>
<ul>
<li>ah bah dis donc, elle bonne celle-là !</li>
</ul>
<p><img src="http://blog.sbw.be/wp-content/uploads/2009/08/today_tomorrow_toyota.png" alt="today_tomorrow_toyota" title="today_tomorrow_toyota" width="251" height="59" class="aligncenter size-full wp-image-297" /></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.sbw.be/2009/08/04/daily-scrum-backlog-today-tomorrow/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Really impress by Google Wave error handling + reporting</title>
		<link>http://blog.sbw.be/2009/07/20/really-impress-by-google-wave-error-handling-reporting/</link>
		<comments>http://blog.sbw.be/2009/07/20/really-impress-by-google-wave-error-handling-reporting/#comments</comments>
		<pubDate>Mon, 20 Jul 2009 08:36:18 +0000</pubDate>
		<dc:creator>Sébastien Barbieri</dc:creator>
				<category><![CDATA[freelance]]></category>
		<category><![CDATA[truc de g33k]]></category>

		<guid isPermaLink="false">http://blog.sbw.be/?p=286</guid>
		<description><![CDATA[While muting a wave and moving it to the trash folder :-)
I can&#8217;t wait to wave :P
]]></description>
			<content:encoded><![CDATA[<div id="attachment_287" class="wp-caption alignnone" style="width: 1034px"><img src="http://blog.sbw.be/wp-content/uploads/2009/07/google_wave_error_handling-1024x216.png" alt="Dr. Wave ready to listen" title="google_wave_error_handling" width="800" height="169" class="size-large wp-image-287" /><p class="wp-caption-text">Dr. Wave ready to listen</p></div>
<p>While muting a wave and moving it to the trash folder :-)</p>
<p>I can&#8217;t wait to wave :P</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.sbw.be/2009/07/20/really-impress-by-google-wave-error-handling-reporting/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ubuntu on: ATI Mobility Radeon HD 3650 &#8211; hp EliteBook 8530p</title>
		<link>http://blog.sbw.be/2009/06/18/ubuntu-ati-hd-3650-elitebook/</link>
		<comments>http://blog.sbw.be/2009/06/18/ubuntu-ati-hd-3650-elitebook/#comments</comments>
		<pubDate>Thu, 18 Jun 2009 06:45:47 +0000</pubDate>
		<dc:creator>Sébastien Barbieri</dc:creator>
				<category><![CDATA[truc de g33k]]></category>
		<category><![CDATA[8530p]]></category>
		<category><![CDATA[ati]]></category>
		<category><![CDATA[elitebook]]></category>
		<category><![CDATA[hd 3650]]></category>
		<category><![CDATA[ubuntu]]></category>

		<guid isPermaLink="false">http://blog.sbw.be/?p=273</guid>
		<description><![CDATA[To install ubuntu on this PC you need to

 desactivate the FAN in the BIOS menu

Deactivate in the BIOS: Fan Always on while on AC Power


desactivate acpi for the ATI card

System > Administration > Hardware Drivers > ATI/AMD propietary FGLRX graphic driver: Install but don&#8217;t reboot now !!!
In a terminal: sudo aticonfig &#8211;initial
In a terminal: [...]]]></description>
			<content:encoded><![CDATA[<p>To install ubuntu on this PC you need to</p>
<ol>
<li> desactivate the FAN in the BIOS menu
<ul>
<li>Deactivate in the BIOS: Fan Always on while on AC Power</li>
</ul>
</li>
<li>desactivate acpi for the ATI card
<ul>
<li>System > Administration > Hardware Drivers > ATI/AMD propietary FGLRX graphic driver: <strong>Install</strong> but don&#8217;t reboot now !!!</li>
<li>In a terminal: <strong>sudo aticonfig &#8211;initial</strong></li>
<li>In a terminal: <strong>sudo aticonfig &#8211;acpi-services=off</strong></li>
<li>Now you may reboot, in the terminal: <strong>sudo reboot</strong></li>
</ul>
</li>
<p>sources:</p>
<ul>
<li>
<a href="http://gurudelleccelsopicco.wordpress.com/2009/02/24/ubuntu-810-on-hp-elitebook-8530p/trackback/">http://gurudelleccelsopicco.wordpress.com/2009/02/24/ubuntu-810-on-hp-elitebook-8530p/trackback/</a>
</li>
<li>
<a href="http://www.phoronix.com/forums/showthread.php?t=15215">http://www.phoronix.com/forums/showthread.php?t=15215</a>
</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://blog.sbw.be/2009/06/18/ubuntu-ati-hd-3650-elitebook/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The last day of epoch (32) &#8211; toute une époque :-)</title>
		<link>http://blog.sbw.be/2009/06/13/the-last-day-of-epoch-32-toute-une-epoque/</link>
		<comments>http://blog.sbw.be/2009/06/13/the-last-day-of-epoch-32-toute-une-epoque/#comments</comments>
		<pubDate>Sat, 13 Jun 2009 11:30:08 +0000</pubDate>
		<dc:creator>Sébastien Barbieri</dc:creator>
				<category><![CDATA[8th chakra]]></category>
		<category><![CDATA[Questions existentielles]]></category>
		<category><![CDATA[freelance]]></category>
		<category><![CDATA[truc de g33k]]></category>
		<category><![CDATA[epoch]]></category>
		<category><![CDATA[timestamp]]></category>
		<category><![CDATA[unix]]></category>

		<guid isPermaLink="false">http://blog.sbw.be/?p=261</guid>
		<description><![CDATA[Is Tue, 19 Jan 2038 04:14:07 +0100.
The next second, we will be back on Fri, 13 Dec 1901 20:55:13 +0009.
And unfortunately, I will not be retired at that time&#8230; I&#8217;m pretty sure that it will be like in the 80s with every developer thinking that his code will last only few months (years)&#8230; when it [...]]]></description>
			<content:encoded><![CDATA[<p>Is <strong>Tue, 19 Jan 2038 04:14:07 +0100</strong>.<br />
The next second, we will be back on <strong>Fri, 13 Dec 1901 20:55:13 +0009</strong>.</p>
<p>And unfortunately, I will not be retired at that time&#8230; I&#8217;m pretty sure that it will be like in the 80s with every developer thinking that his code will last only few months (years)&#8230; when it will actually last much longer.</p>
<p>Most of the liunuix (linux and unix) systems use timestamp stored as an unisgned integer 32 bit starting Thu, 01 Jan 1970 01:00:00 +0100.</p>
<p>The idea was to be able to measure time for a &#8220;long&#8221; period of time, from now (in the 70s) and in the past.<br />
So they decided to use half of the 2^32 for the past (prior to 1/1/1970) and the other half for the future.</p>
<p>So be it&#8230;</p>
<p>Now we are about 40 years later, and we still use the same representation. We already had a party for the <a href="http://code.sbw.be/php/timestamp.php?timestamp=1234567890">unix timestamp 1234567890</a> (which is quite stupid because it&#8217;s in base 10).</p>
<p>And now javascript, Java, PHP and C &#8230; use the unix timestamp&#8230; which means ajax, web 2.0, comet &#8230; which means: most of the online banking system, internet sites and all the smalls scripts that in few line check your credential and your billing to allow you to connect to the Internet&#8230; All the logging system, all the monitoring systems&#8230; well everything that you don&#8217;t see, just under the internet sea you surf on.</p>
<p>So what will be the next party thema?</p>
<ul>
<li>the end of the internet as we knew it</li>
<li>the end of the unix system</li>
<li>the 0&#215;80000000 seconds since epoch?</li>
</ul>
<p>Anyway, because of the ongoing ecological breakdown, the human kind will probably collapse before&#8230; so after the <a href="http://en.wikipedia.org/wiki/Y2K38">Y2K38</a> bug, the world will just be their kingdom. The kingdom of bugs.</p>
<p>Unless we spend time (which is running) in each of our application to think about that right now (and if we spend just about the same amount of time solving the earth ecology problem it will not be useless).</p>
<p><script language="javascript" type="text/javascript">
today  = new Date();
todayEpoch  = today.getTime();
targetEpoch = 2147483647000;</p>
<p>daysLeft = Math.floor(((targetEpoch - todayEpoch) / (60*60*24)) / 1000);
document.write("You still have: "+daysLeft+" days ");
</script></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.sbw.be/2009/06/13/the-last-day-of-epoch-32-toute-une-epoque/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Distance between cities</title>
		<link>http://blog.sbw.be/2009/06/12/distance-between-cities/</link>
		<comments>http://blog.sbw.be/2009/06/12/distance-between-cities/#comments</comments>
		<pubDate>Fri, 12 Jun 2009 07:06:45 +0000</pubDate>
		<dc:creator>Sébastien Barbieri</dc:creator>
				<category><![CDATA[Projects]]></category>
		<category><![CDATA[truc de g33k]]></category>
		<category><![CDATA[belgium]]></category>
		<category><![CDATA[cities]]></category>
		<category><![CDATA[latitude]]></category>
		<category><![CDATA[longitude]]></category>
		<category><![CDATA[zip]]></category>

		<guid isPermaLink="false">http://blog.sbw.be/?p=256</guid>
		<description><![CDATA[First of all I need to cite my sources: 


		Calculate distance, bearing and more between two Latitude/Longitude points
	

		Geocoding Belgium Postal Codes
	

The goal of my project was to find out which cities are nearby (within a user specified distance).
Of course users don&#8217;t know their city coordinate, so you will have to find out by yourself. To [...]]]></description>
			<content:encoded><![CDATA[<p>First of all I need to cite my sources: </p>
<ul>
<li>
		<a href="http://www.movable-type.co.uk/scripts/latlong.html">Calculate distance, bearing and more between two Latitude/Longitude points</a>
	</li>
<li>
		<a href="http://www.jedi.be/blog/2009/04/29/geocoding-belgium-postal-codes/">Geocoding Belgium Postal Codes</a>
	</li>
</ul>
<p>The goal of my project was to find out which cities are nearby (within a user specified distance).<br />
Of course users don&#8217;t know their city coordinate, so you will have to find out by yourself. To do so, I used the JEDI trick (<a href="http://www.jedi.be/blog/2009/04/29/geocoding-belgium-postal-codes/">Geocoding Belgium Postal Codes</a>) which is:</p>
<ul>
<ol>Downloading the csv of cities and zip code (available on the <a href="http://www.post.be/site/fr/residential/customerservice/search/postal_codes.html">national mail </a>site for Belgium, I don&#8217;t know for other countries)</ol>
<ol>Writing a small piece of code to parse the csv and retrieve the right latitude and longitude via google geo service</ol>
</ul>
<p>I could have downloaded <a href="http://www.jedi.be/blog/wp-content/uploads/2009/04/geocodes.csv">the file from the JEDI site</a> but I really needed to do it by myself.</p>
<p>So the next thing to do is: finding the cities within an arbitrary distance.</p>
<p>This was based on the documentation I found on the movable-type math site.</p>
<p>All I did is translating the Javascript function to PHP functions:</p>
<pre class="brush: php;">
    private function sphericalDistance($lat1,$lon1,$lat2,$lon2){
        $R = 6371.0; // km
        $d = acos(
                sin(deg2rad($lat1))*sin(deg2rad($lat2))
                + cos(deg2rad($lat1))*cos(deg2rad($lat2))
                * cos(deg2rad($lon2-$lon1))
             )
             * $R;
        return $d;
    }

    private function haversineDistance($lat1,$lon1,$lat2,$lon2){
        $R = 6371.0; // km
        $dLat = deg2rad($lat2-$lat1);
        $dLon = deg2rad($lon2-$lon1);
        $a = sin($dLat/2) * sin($dLat/2)
            + cos(deg2rad($lat1)) * cos(deg2rad($lat2))
            * sin($dLon/2) * sin($dLon/2);
        $c = 2.0 * atan2(sqrt($a), sqrt(1-$a));
        $d = $R * $c;
        return $d;
    }

    private function vincentyDistance($lat1,$lon1,$lat2,$lon2){
        $a = 6378137.0; $b = 6356752.3142;  $f = 1/298.257223563;  // WGS-84 ellipsiod
        $L = deg2rad($lon2-$lon1);
        $U1 = atan((1-$f) * tan(deg2rad($lat1)));
        $U2 = atan((1-$f) * tan(deg2rad($lat2)));
        $sinU1 = sin($U1);
        $cosU1 = cos($U1);
        $sinU2 = sin($U2);
        $cosU2 = cos($U2);
        $lambda = $L;
        $lambdaP = $L;
        $iterLimit = 100;
        do{
            $sinLambda = sin($lambda);
            $cosLambda = cos($lambda);
            $sinSigma = sqrt(($cosU2*$sinLambda) * ($cosU2*$sinLambda) +
                        ($cosU1*$sinU2-$sinU1*$cosU2*$cosLambda) * ($cosU1*$sinU2-$sinU1*$cosU2*$cosLambda));
            if($sinSigma==0) return 0;
            $cosSigma = $sinU1 * $sinU2 + $cosU1*$cosU2*$cosLambda;
            $sigma = atan2($sinSigma, $cosSigma);
            $sinAlpha = $cosU1 * $cosU2 * $sinLambda / $sinSigma;
            $cosSqAlpha = 1 - $sinAlpha*$sinAlpha;
            if($cosSqAlpha!=0){
                $cos2SigmaM = $cosSigma - 2*$sinU1*$sinU2/$cosSqAlpha;
            }else{
                $cos2SigmaM =0;
            }
            $C = $f/16*$cosSqAlpha*(4+$f*(4-3*$cosSqAlpha));
            $lambdaP = $lambda;
            $lambda = $L + (1-$C) * $f * $sinAlpha *
                    ($sigma + $C*$sinSigma*($cos2SigmaM+$C*$cosSigma*(-1+2*$cos2SigmaM*$cos2SigmaM)));
        }while(abs($lambda-$lambdaP) &gt; 1e-12 &amp;&amp; --$iterLimit&gt;0);
        if($iterLimit == 0) return false; // formula failed to converge
        $uSq = $cosSqAlpha * ($a*$a - $b*$b) / ($b*$b);
        $A = 1 + $uSq/16384.0*(4096+$uSq*(-768+$uSq*(320-175*$uSq)));
        $B = $uSq/1024.0 * (256+$uSq*(-128+$uSq*(74-47*$uSq)));
        $deltaSigma = $B*$sinSigma*($cos2SigmaM+$B/4*($cosSigma*(-1+2*$cos2SigmaM*$cos2SigmaM)
                    - $B/6*$cos2SigmaM*(-3+4*$sinSigma*$sinSigma)*(-3+4*$cos2SigmaM*$cos2SigmaM)));
        $s = $b*$A*($sigma-$deltaSigma);
        return $s/1000.0;
    }
</pre>
<p>And that&#8217;s it&#8230;</p>
<p>So if you want the<a href="http://code.sbw.be/php/belgianCitiesCoord.data"> php serialized cities of Belgium with Zip, cityname, uppercase cityname, longitude,latitude</a>.</p>
<p>I didn&#8217;t do a lot at all, just put every source together.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.sbw.be/2009/06/12/distance-between-cities/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
