<?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>Bob Belderbos</title>
	<atom:link href="http://bobbelderbos.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://bobbelderbos.com</link>
	<description>I like to solve problems and experiment with new technologies</description>
	<lastBuildDate>Sun, 19 Feb 2012 23:51:33 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
<xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" name="robots" content="noindex" />
		<item>
		<title>New Facebook App / travel site: Globe Explorer</title>
		<link>http://bobbelderbos.com/2012/02/new-facebook-app-travel-site-globe-explorer/</link>
		<comments>http://bobbelderbos.com/2012/02/new-facebook-app-travel-site-globe-explorer/#comments</comments>
		<pubDate>Sun, 19 Feb 2012 21:45:12 +0000</pubDate>
		<dc:creator>Bob</dc:creator>
				<category><![CDATA[Web development]]></category>
		<category><![CDATA[Work in progress]]></category>

		<guid isPermaLink="false">http://bobbelderbos.com/?p=1717</guid>
		<description><![CDATA[<style type="text/css">
div.img
{
  height:auto;  
  width: 25%;
  float: left;
  text-align: center;
}	

div.img img
{
  display: inline;
  margin: 2px;
  height:auto;
  width: auto;
  border: 1px solid #ffffff;
}
div.img a:hover img {border: 1px solid #0000ff;}
div.desc
{
  text-align: center;
  font-weight: normal;
  width: auto;
  margin: 2px;
  padding-bottom:1cm;
}
</style>
In today&#8217;s post I present a new Facebook App: Globe Explorer. I will show some printscreens and techniques I used in the current design. As usual, I started simple to expand with new features in the future. The idea of the app is to bring together basic info of almost all countries in the world [...]]]></description>
			<content:encoded><![CDATA[<style type="text/css">
div.img
{
  height:auto;  
  width: 25%;
  float: left;
  text-align: center;
}	

div.img img
{
  display: inline;
  margin: 2px;
  height:auto;
  width: auto;
  border: 1px solid #ffffff;
}
div.img a:hover img {border: 1px solid #0000ff;}
div.desc
{
  text-align: center;
  font-weight: normal;
  width: auto;
  margin: 2px;
  padding-bottom:1cm;
}
</style>
<p> In today&#8217;s post I present a new Facebook App: <a href="http://www.bobbelderbos.com/globe/" target="_blank">Globe Explorer</a>. I will show some printscreens and techniques I used in the current design. As usual, I <a href="http://bobbelderbos.com/2011/04/make-developer-life-easier/" target="_blank">started simple</a> to expand with new features in the future.</p>
<p><span id="more-1717"></span></p>
<p><img class="size-full" src="http://bobbelderbos.com/wp-content/uploads/2012/02/logo.jpg" alt="featured image" style="float:right; margin: 20px;" width="150"></p>
<p> The idea of the app is to bring together basic info of almost all countries in the world and show attractive photos. See <a href="http://bobbelderbos.com/2012/02/how-to-start-building-your-own-countrytravel-api/" target="_blank">my last post</a> how I got the basic data.</p>
<p>On top of that I built a login with Facebook to allow people to add recommendations and &#8220;special things&#8221; of the country, to add more personal value to the data. Again, a lot more can be done like user profiles, allow users to upload photos, location checkins, user following/mentions/likes, etc., but this is a start.</p>
<p>In the rest of the post, I&#8217;ll show you some techniques I used developing this site.</p>
<p><fb:like href="" send="true" width="580" show_faces="false" action="like" font=""></fb:like></p>
<h3> The design</h3>
<p>This is the homepage::</p>
<p><img class="size-full" src="http://bobbelderbos.com/wp-content/uploads/2012/02/homepage_logged_out.png" alt="homepage logged out" style="float:none; margin: 20px;" width="580"></p>
<p>With more navigation options when logged in with Facebook:</p>
<p><img class="size-full" src="http://bobbelderbos.com/wp-content/uploads/2012/02/homepage_logged_in.png" alt="homepage logged in" style="float:none; margin: 20px;" width="580"></p>
<p> When browsing to a country, the image gallery changes to display photos of that country:</p>
<p><img class="size-full" src="http://bobbelderbos.com/wp-content/uploads/2012/02/ecuador_gallery.png" alt="ecuador image gallery" style="float:none; margin: 20px;" width="432"></p>
<p>Images show a bigger version when hovering over them with your mouse. This is done with the jQuery plugin <a href="http://cssglobe.com/post/1695/easiest-tooltip-and-image-preview-using-jquery" target="_blank">Image Preview</a>:</p>
<p><img class="size-full" src="http://bobbelderbos.com/wp-content/uploads/2012/02/images_overlay1.png" alt="images overalay" style="float:none; margin: 20px;" width="428"><br />
<img class="size-full" src="http://bobbelderbos.com/wp-content/uploads/2012/02/images_overlay2.png" alt="images overlay" style="float:none; margin: 20px;" width="280"><br />
 <img class="size-full" src="http://bobbelderbos.com/wp-content/uploads/2012/02/image_overlay3.png" alt="image overlay" style="float:none; margin: 20px;" width="489"></p>
<p>Basic specs from DB, again see my <a href="http://bobbelderbos.com/2012/02/how-to-start-building-your-own-countrytravel-api/" target="_blank">preparation work</a> how I got the data:</p>
<p><img class="size-full" src="http://bobbelderbos.com/wp-content/uploads/2012/02/specs.png" alt="specs" style="float:none; margin: 20px;" width="401"></p>
<p>A typical country page, for example <a href="http://www.bobbelderbos.com/globe/tr" target="_blank">Turkey</a>:</p>
<p><img class="size-full" src="http://bobbelderbos.com/wp-content/uploads/2012/02/turkey_page.png" alt="turkey country page" style="float:none; margin: 20px;" width="580"></p>
<p> &#8230; or what about <a href="http://www.bobbelderbos.com/globe/br" target="_blank">Brazil</a>?</p>
<p><img class="size-full" src="http://bobbelderbos.com/wp-content/uploads/2012/02/brazil.png" alt="brazil country page" style="float:none; margin: 20px;" width="580"></p>
<h3> Technologies behind it</h3>
<h4> HTML5 boilerplate</h4>
<p>This is indeed, <a href="http://html5boilerplate.com/" target="_blank">as their page says</a>, &#8220;a rock-solid default for HTML5 awesome&#8221;: performance, HTML5 ready, cross-browser support, CSS skeleton, etc. I did put in a <a href="http://meyerweb.com/eric/tools/css/reset/" target="_blank">reset css</a> to wipe out more unwanted default browser styles.</p>
<h4> h1 and h2 fonts</h4>
<p>The header fonts are &#8220;Philosopher&#8221; which you can get from <a href="http://www.google.com/webfonts#ChoosePlace:select" target="_blank">Google Web Fonts</a> and is easy to add:</p>
<pre class="brush: php; title: ; notranslate">
   &lt;link href='http://fonts.googleapis.com/css?family=Philosopher:400,700' rel='stylesheet' type='text/css'&gt;
</pre>
<h4> Clean URLs</h4>
<p>Each country is accessible under baseurl/two-digits, for example:</p>
<p><a href="http://www.bobbelderbos.com/globe/ni" target="_blank">Nicaragua</a>:</p>
<p><img class="size-full" src="http://bobbelderbos.com/wp-content/uploads/2012/02/cleanurl1.png" alt="clean urls" style="float:none; margin: 20px;" width="259"></p>
<p><a href="http://www.bobbelderbos.com/globe/br" target="_blank">Brazil</a>:</p>
<p><img class="size-full" src="http://bobbelderbos.com/wp-content/uploads/2012/02/cleanurl2.png" alt="clean urls" style="float:none; margin: 20px;" width="303"></p>
<p>This is much better than index.php?country=ad. Put this in .htaccess (if you use Apache webserver) to support clean URLs (see also <a href="http://bobbelderbos.com/2011/01/clean-urls-must-use/" target="_blank">this post</a>)</p>
<pre class="brush: php; title: ; notranslate">
   RewriteEngine On
   RewriteRule  ^[a-z0-9]+\.(php|js|css|html)$ - [NC,L]
   RewriteRule ^([a-zA-Z_0-9\-\.]+)$ index.php?country=$1
</pre>
<h4> Autocomplete</h4>
<p>One of the things I like most and <a href="http://bobbelderbos.com/2011/01/my-5-favorite-jquery-snippets/" target="_blank">one of my favorite jQuery plugins</a> (<a href="http://bobbelderbos.com/2011/12/sharemovies-new-feature-search-interface-instant-trailers/" target="_blank">another recent example of its power</a>). You start typing in the search box and the corresponding country(ies) with flag(s) show up, press enter when your country is selected and it redirects to the page of the country. Not that hard to code; the jQuery:</p>
<pre class="brush: php; title: ; notranslate">
   $(&quot;#searchCountry&quot;).autocomplete( &quot;searchCountry.php&quot;);
   ..
   // http://forum.jquery.com/topic/jquery-autocomplete-submit-form-on-result
   $(&quot;#searchCountry&quot;).result(function (event, data, formatted) {
   	$(&quot;#searchCountry&quot;).val('');

   	$(&quot;#feedback&quot;).html('&lt;img class=&quot;loadingImg&quot; src=&quot;img/ajax-loader.gif&quot; id=&quot;loading&quot; /&gt;');

   	var country = formatted.replace(/(&lt;.+?&gt;)|\&amp;nbsp;/gi, '');

   	if(country != 'No country found!') {
   		$.post(&quot;getCleanUrl.php&quot;,
   			{ search: country},	function(data){
   				location.href= data;
   			}
   		);
   	} else {
   		$(&quot;#loading&quot;).hide();
   	}
   });
</pre>
<p> &#8230; and the php of &#8220;searchCountry.php&#8221;:</p>
<pre class="brush: php; title: ; notranslate">
   &lt;?php
   include(&quot;conn.php&quot;);
   include(&quot;functions.php&quot;);

   $_GET = sanitize($_GET);

   $q = strtolower($_GET[&quot;q&quot;]);
   if (!$q) return;

   $q = &quot;SELECT iso2,country FROM countries where LOWER(country) like '%$q%' AND longitude NOT LIKE ''&quot;;
   $r = $link-&gt;query($q);

   if(mysqli_num_rows($r)) {
   	while($row = $r -&gt;fetch_object()){
   		$iso2 = strtolower($row-&gt;iso2);
   		echo '&lt;img src=&quot;img/flags/'.$iso2.'.gif&quot;&gt;&amp;nbsp;';
   		echo '&lt;span class=&quot;countryCode&quot; id=&quot;' . $iso2 . '&quot;&gt;'.ucfirst(strtolower($row-&gt;country)) . '&lt;/span&gt;';
   		echo &quot;\n&quot;;
   	}

   } else {
   	echo 'No country found!';
   }
   $link-&gt;close();
   ?&gt;
</pre>
<p> &#8230; and the php of &#8220;getCleanUrl.php&#8221;:</p>
<pre class="brush: php; title: ; notranslate">
   &lt;?php
   include(&quot;conn.php&quot;);
   include(&quot;functions.php&quot;);
   $_POST = sanitize($_POST);
   $search = strtoupper(trim($_POST['search']));

   $q = &quot;SELECT iso2 FROM countries WHERE country LIKE '$search' limit 1&quot;;
   $r = $link-&gt;query($q); 

   while($row = $r -&gt;fetch_object()){
  	 echo strtolower($row-&gt;iso2);
   }
   ?&gt;
</pre>
<p>To see this in action:</p>
<p><img class="size-full" src="http://bobbelderbos.com/wp-content/uploads/2012/02/autocomplete.png" alt="jquery autocomplete" style="float:none; margin: 20px;" width="444"></p>
<h4> Facebook authorization</h4>
<p>Get v.3.1.1 <a href="https://github.com/facebook/php-sdk" target="_blank">from github</a> , usually I copy the with_js_sdk.php which includes both PHP and JS SDKs and get all html out and make it an fb.php include file. Put in you app ID + secret, and you can start to use authorized stuff when $user gets defined (login). I used the login-button from FB with the extra permission to post to wall &#8220;publish_stream&#8221; (only if user checks the box when commenting, see later on):</p>
<pre class="brush: php; title: ; notranslate">
   &lt;div style=&quot;display:inline; &quot; class=&quot;fb-login-button&quot; data-show-faces=&quot;false&quot; data-width=&quot;400&quot; data-max-rows=&quot;1&quot; scope=&quot;publish_stream&quot;&gt;&lt;/div&gt;
</pre>
<p><fb:like href="" send="true" width="580" show_faces="false" action="like" font=""></fb:like></p>
<h4> Get social content</h4>
<p>On each country page a user can add recommendations:</p>
<p><img class="size-full" src="http://bobbelderbos.com/wp-content/uploads/2012/02/recommend_country.png" alt="recommend country" style="float:none; margin: 20px;" width="435"></p>
<p>&#8230; or like &#8220;special things&#8221; (dropdown with Expressions, Food, Cities, Traditions, Movies, Music, etc.):</p>
<p><img class="size-full" src="http://bobbelderbos.com/wp-content/uploads/2012/02/special_things1.png" alt="special things" style="float:none; margin: 20px;" width="441"></p>
<p> When you change the category (object) in &#8220;special things&#8221;, the title changes, compare the previous printscreen with the next two:</p>
<p><img class="size-full" src="http://bobbelderbos.com/wp-content/uploads/2012/02/special_things2.png" alt="special things country" style="float:none; margin: 20px;" width="441"><br />
<img class="size-full" src="http://bobbelderbos.com/wp-content/uploads/2012/02/special_things3.png" alt="special things country" style="float:none; margin: 20px;" width="435"></p>
<p> When comments add up, I use a vertical scroll bar (<a href="http://www.kelvinluck.com/assets/jquery/jScrollPane/jScrollPane.html" target="_blank">jScrollPane</a>), which gives an elegant style while I can leave the &#8220;display comment&#8221; sections a 100px height:</p>
<p><img class="size-full" src="http://bobbelderbos.com/wp-content/uploads/2012/02/jscrollpane.png" alt="example of jScrollPane" style="float:none; margin: 20px;" width="433"></p>
<h4> Post to Facebook</h4>
<p> You can post your comment to Facebook by activating the checkbox under the input field. Opt-in is better I think, because opt-out in FB Apps is usually seen as spammy. Here you see this in action:</p>
<p><img class="size-full" src="http://bobbelderbos.com/wp-content/uploads/2012/02/post_food.png" alt="activate post to FB" style="float:none; margin: 20px;" width="426"></p>
<p>And how this looks on your FB wall:</p>
<p><img class="size-full" src="http://bobbelderbos.com/wp-content/uploads/2012/02/post_to_fb.png" alt="result on FB wall" style="float:none; margin: 20px;" width="448"></p>
<h4> Facebook JS SDK functions:</h4>
<p> You can invite friends and let users share content to their walls with just this code (having included the FB JS SDK above):</p>
<pre class="brush: php; title: ; notranslate">
   function Invite () {
     FB.ui({ method: 'apprequests',
       message: 'Check out this App if you like travelling and exploring countries ...'
     });
   }

   function WriteToWall(urlName, urlLink, urlDescr, urlLogo){
   	 FB.ui({
  		method: 'feed',
      	name: urlName,
  		link: urlLink,
  		description: urlDescr,
         picture: urlLogo
  	});
   }

   .. which you call from your HTML
   
   ..
   &lt;?php if ($user): ?&gt;
  	Hi, &lt;?php echo fbImg($user) . ' '. $user_profile['first_name']; ?&gt;,
  		&lt;a href=&quot;&lt;?php echo $logoutUrl; ?&gt;&quot;&gt;Logout&lt;/a&gt;
  		&amp;nbsp;|&amp;nbsp;&lt;a href=&quot;#&quot; onclick=&quot;WriteToWall('&lt;?php  echo $title.'\',\''.$countryUrl.'\',\''.$metaDescription.'\',\''.$ogImage; ?&gt;')&quot;
  			title=&quot;Send to your wall&quot;&gt;Share this&lt;?php if($_GET) echo ' country'?&gt;&lt;/a&gt;
  		&amp;nbsp;|&amp;nbsp;&lt;a href=&quot;#&quot; onclick=&quot;Invite()&quot; title=&quot;Tell your friends about this app&quot;&gt;Invite friends&lt;/a&gt;

   &lt;?php else:
   ..
</pre>
<p>Invite your friends to use the app:</p>
<p><img class="size-full" src="http://bobbelderbos.com/wp-content/uploads/2012/02/invite_friends.png" alt="invite friends" style="float:none; margin: 20px;" width="580"></p>
<p>Share a certain (country) page to your wall. A random image of the country will be shown (and under the hood set as meta..og:image, the tag Facebook &#8216;listens&#8217; to in order to display the image in the post, more info <a href="http://bobbelderbos.com/2011/03/facebook-like-button-right-image/" target="_blank">here</a>):</p>
<p><img class="size-full" src="http://bobbelderbos.com/wp-content/uploads/2012/02/share_wall2.png" alt="share to wall" style="float:none; margin: 20px;" width="580"></p>
<h4> User registration</h4>
<p> In the fb.php include I check if the user was here before and if not, I register him/her:</p>
<pre class="brush: php; title: ; notranslate">
   ..
   if ($user) {
    try {
      // Proceed knowing you have a logged in user who's authenticated.
      $user_profile = $facebook-&gt;api('/me');  // &lt;= this is from the FB PHP SDK

  	// register user
  	if(!userExists($user) &amp;&amp; $user_profile) {
  		userRegister($user_profile);
  	}
</pre>
<h4> Footer</h4>
<p> In the footer a carousel of flags per continent. You can check <a href="http://bobbelderbos.com/2012/01/twitter-widget-show-latest-tweets-carousel-slide/" target="_blank">this post</a> how to make such a carousel effect with jQuery (and some CSS).</p>
<p><img class="size-full" src="http://bobbelderbos.com/wp-content/uploads/2012/02/flag_slider.png" alt="flag carousel" style="float:none; margin: 20px;" width="448"></p>
<p><fb:like href="" send="true" width="580" show_faces="false" action="like" font=""></fb:like></p>
<h4> To conclude</h4>
<p> This is it for now. Let me know if you have questions and/or if you have any feedback/ suggestions what could be cool to add to <a href="http://www.bobbelderbos.com/globe/" target="_blank">this app</a> &#8230;</p>

	]]></content:encoded>
			<wfw:commentRss>http://bobbelderbos.com/2012/02/new-facebook-app-travel-site-globe-explorer/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to start building your own country/ travel API</title>
		<link>http://bobbelderbos.com/2012/02/how-to-start-building-your-own-countrytravel-api/</link>
		<comments>http://bobbelderbos.com/2012/02/how-to-start-building-your-own-countrytravel-api/#comments</comments>
		<pubDate>Fri, 17 Feb 2012 16:15:10 +0000</pubDate>
		<dc:creator>Bob</dc:creator>
				<category><![CDATA[APIs]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://bobbelderbos.com/?p=1707</guid>
		<description><![CDATA[<style type="text/css">
div.img
{
  height:auto;  
  width: 25%;
  float: left;
  text-align: center;
}	

div.img img
{
  display: inline;
  margin: 2px;
  height:auto;
  width: auto;
  border: 1px solid #ffffff;
}
div.img a:hover img {border: 1px solid #0000ff;}
div.desc
{
  text-align: center;
  font-weight: normal;
  width: auto;
  margin: 2px;
  padding-bottom:1cm;
}
</style>
I am about to finish a travel Facebook App. The design looks promising, especially because of the info and pictures I could crawl together. Few more days and I will release a first draft. For now the answer to: &#8220;how to create your own country API?&#8221; That seemed a challenge at first, but combining 1 [...]]]></description>
			<content:encoded><![CDATA[<style type="text/css">
div.img
{
  height:auto;  
  width: 25%;
  float: left;
  text-align: center;
}	

div.img img
{
  display: inline;
  margin: 2px;
  height:auto;
  width: auto;
  border: 1px solid #ffffff;
}
div.img a:hover img {border: 1px solid #0000ff;}
div.desc
{
  text-align: center;
  font-weight: normal;
  width: auto;
  margin: 2px;
  padding-bottom:1cm;
}
</style>
<p> I am about to finish a travel Facebook App. The design looks promising, especially because of the info and pictures I could crawl together. Few more days and I will release a first draft. For now the answer to: &#8220;how to create your own country API?&#8221; </p>
<p><span id="more-1707"></span></p>
<p><img class="size-full" src="http://bobbelderbos.com/wp-content/uploads/2012/02/country_api.jpg" alt="country api featured image" style="float:right; margin: 20px;" width="150"></p>
<p>That seemed a challenge at first, but combining 1 flat txt file and 2 APIs, I got a pretty decent database that served my purpose.</p>
<p>It serves the travel fans under us to browse countries, viewing nice photos of those countries, and comment on each country page as well (logged in with Facebook). If it works, and people start to add content themselves, it will become a personal experience. It starts basic, new features can always be added.</p>
<p>But before this could work in any way, the app has to provide some content itself. Especially with a travel / country app, photos are unmissable!</p>
<p>In this posts some examples how to get the data required for a country database to build a nice travel app &#8230;</p>
<p><fb:like href="" send="true" width="580" show_faces="false" action="like" font=""></fb:like></p>
<h3> First things first, the raw data</h3>
<p> I used <a href="http://www.geonames.org/export/" target="_blank">geonames.org</a> to get some basic info for all <a href="http://reference.sitepoint.com/html/lang-codes" target="_blank">ISO 2 country codes</a>, see a list <a href="http://download.geonames.org/export/dump/countryInfo.txt" target="_blank">here</a>. I found small, nice country flag gif images <a href="http://stefangabos.ro/other-projects/list-of-world-countries-with-national-flags/" target="_blank">here</a> (filenames match the two-char ISO2 names -> AE, DE, NL, etc.).</p>
<h3> 2nd of all: the worldbank API to get exact longitudes and latitudes per country. </h3>
<p> Lists of these parameters per country exist. We need them for the <a href="http://www.tixik.com/en/info/api" target="_blank">Tixik API</a> (next step). However the lists I found (<a href="http://www.maxmind.com/app/country_latlon" target="_blank">example</a>), did not work quite well with Tixik. What worked best were the results from <a href="http://data.worldbank.org/developers" target="_blank">the worldbank API</a> , for example: <a href="http://api.worldbank.org/countries/ES" target="_blank">for Spain</a> &#8211; you can make the call to get all latitudes/ longitudes for all countries with <a href="http://api.worldbank.org/countries?per_page=300" target="_blank">this call</a>. Then update the DB with these values and you have a pretty nice set to work with:</p>
<p><img class="size-full" src="http://bobbelderbos.com/wp-content/uploads/2012/02/sql_Db.png" alt="sql country table" style="float:none; margin: 20px;" width="580"></p>
<p><fb:like href="" send="true" width="580" show_faces="false" action="like" font=""></fb:like> </p>
<h3> 3rd: tixik country photo links</h3>
<p> Now the fun starts: photos! A travel app is about showing photos. You will see the endresult, but here is the workhorse to get to the data: <a href="http://www.tixik.com/" target="_blank">Tixik</a>. I discovered it by accident, but it has a very simple yet efficient <a href="http://www.tixik.com/en/info/api/" target="_blank">api</a>. Quote from Tixik: &#8220;We have hundreds of thousands of presentations with pictures and texts in multiple languages. Would you like to have some of them on your website?&#8221;</p>
<p> And the answer is &#8220;of course we want that!&#8221;. Well, it is plain simple and now you see the &#8220;why&#8221; of the latitude and longitude of the last step: <a href="http://www.tixik.com/en/api/nearby?lat=36.106121163930377&#038;lng=28.07762145996093&#038;limit=10&#038;key=demo" target="_blank">http://www.tixik.com/en/api/nearby?lat=36.106121163930377&#038;lng=28.07762145996093&#038;limit=10&#038;key=demo</a>. You can raise the limit to get more photos, the key you put in when you sign up with just your name and email. To get some nice picture (links) from Andorra <a href="http://www.tixik.com/en/api/nearby?lat=42.5075&#038;lng=1.5218&#038;limit=50&#038;key=demo" target="_blank">click here</a>.</p>
<p>When processing this info for each country, you have a database with about 10.000 pic links:</p>
<p><img class="size-full" src="http://bobbelderbos.com/wp-content/uploads/2012/02/sql_images.png" alt="images table with imported images from tixik" style="float:none; margin: 20px;" width="580"></p>
<h3> Some code to get this working &#8230;</h3>
<p> I will keep it short given the size of this post. So not all details, just the core things you need to get started. :</p>
<ul>
<li> Create 2 DB tables: one to hold the country info and another to hold links to the images (from Tixik). Relation is the two letter iso2 country code.</li>
<pre class="brush: php; title: ; notranslate">
   CREATE TABLE IF NOT EXISTS `countries` (
     `id` int(11) NOT NULL AUTO_INCREMENT,
     `iso2` varchar(2) NOT NULL,
     `country` varchar(50) NOT NULL,
     `capital` varchar(50) NOT NULL,
     `area` varchar(20) NOT NULL,
     `population` varchar(20) NOT NULL,
     `continent` varchar(2) NOT NULL,
     `currCode` varchar(3) NOT NULL,
     `currName` varchar(20) NOT NULL,
     `phone` varchar(10) NOT NULL,
     `langs` varchar(2) NOT NULL,
     `neighbours` varchar(30) NOT NULL,
     `longitude` varchar(20) DEFAULT NULL,
     `latitude` varchar(20) NOT NULL,
     PRIMARY KEY (`id`)
   ) ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;

   -- --------------------------------------------------------

   --
   -- Table structure for table `images`
   --

   CREATE TABLE IF NOT EXISTS `images` (
     `id` int(11) NOT NULL AUTO_INCREMENT,
     `country` varchar(2) NOT NULL,
     `name` varchar(200) NOT NULL,
     `tn` varchar(200) NOT NULL,
     `tn_big` varchar(200) NOT NULL,
     `created` int(11) NOT NULL,
     PRIMARY KEY (`id`)
   ) ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
</pre>
<li> Import the data from geonames: I got to <a href="http://bobbelderbos.com/src/countries_final.txt" target="_blank">this file</a>. You can run a simple Perl script to bounce the SQL insert statements (see my comment on SQL insert in the next step &#8230;): </li>
<pre class="brush: php; title: ; notranslate">
   while(&lt;&gt;){
  	chomp;
  	@arr = split(/\t/, $_);
&gt;
  	$insert =&quot;INSERT INTO countries (id, iso2, country, capital, area, population, continent, currCode, currName, phone, langs, neighbours) VALUES (NULL, '$arr[0]', '$arr[1]', '$arr[2]', '$arr[3]', '$arr[4]', '$arr[5]', '$arr[6]', '$arr[7]', '$arr[8]', '$arr[9]', '$arr[10]');&quot;;

  	print &quot;$insert\n&quot;;

   }
</pre>
<p> Run it as $ perl test.pl country_file &#8211; it will take that file as input, loop through it, split each line into an array based on the tab character, etc.</p>
<li> Update longitude and latitude from worldbank API: </li>
<pre class="brush: php; title: ; notranslate">
   function getLocationParamsWorldBank(){
   	// saved xml from http://api.worldbank.org/countries?per_page=300
   	$wbUrl = 'api.worldbank.countries.all.xml';
   	$ns='wb';

   	$xml = @simplexml_load_file($wbUrl);
   	$params = array();
   	$counter=0;

   	foreach($xml-&gt;children($ns,true) as $i) {
   		$query = &quot;UPDATE countries SET longitude='&quot;.$i-&gt;longitude.&quot;', latitude='&quot;.$i-&gt;latitude.&quot;' &quot;;
   		$query .= &quot;WHERE iso2='&quot;.$i-&gt;iso2Code.&quot;';&quot;;
   		echo $query .&quot;&lt;br&gt;&quot;;
   	}
   }
</pre>
<p> No SQL security here, because I am going to do the import myself. I can also do the import with PHP MySql commands but for this exercise I wanted to see the commands first and then copy paste. If you want to let PHP do all the work, run something like this on the $query (after having created the database $link object):</p>
<pre class="brush: php; title: ; notranslate">
   $r = $link-&gt;query($query);
   $returnID = $link-&gt;insert_id;

   if(is_numeric($returnID)) {
   ..
</pre>
<li> Last prepare the Tixik URLs to get the images per country and write the links to the images table: </li>
<pre class="brush: php; title: ; notranslate">
   function getThumbs($country) {
   	$params = getLocationParamsDb($country);  // skipped for brevity
   	$xml = queryTixik($params);
   	$images = processTixikImages($xml);
       writeImagesToDb($country, $images); // skipped for brevity
   }

   function queryTixik($params, $limit = 50) {
   	$latitude = $params['latitude']; // form &quot;getLocationParamsDb&quot;
   	$longitude = $params['longitude'];
   	$tixKey = &quot;--obtain from tixik.com -- &quot;;

   	$txUrl = &quot;http://www.tixik.com/en/api/nearby?lat=$latitude&amp;lng=$longitude&amp;limit=$limit&amp;key=$tixKey&quot;;
   	$xml = simplexml_load_file($txUrl, 'SimpleXMLElement', LIBXML_NOCDATA);
   	return $xml;
   }

   function processTixikImages($xml){
   	$images = array(); $i = 0;
   	foreach ($xml-&gt;items-&gt;item as $item) {
   	  if (@fclose(@fopen($item-&gt;tn, &quot;r&quot;)) ) {
   		$images[$i]['name'] = str_replace(&quot;'&quot;,&quot;\'&quot;,$item-&gt;name); // not screw up sql statement
   		$images[$i]['tn'] = $item-&gt;tn; // thumbnail
   		$images[$i]['tn_big'] = $item-&gt;tn_big; // bigger version of image
   		$i++;
   	  }
   	}
   }
</pre>
<p>I became a fan of shortening my functions. It is a good programming practice. Next time I turn the 4 functions into 8, it really makes things cleaner.</p>
<p>Nice trick: LIBXML_NOCDATA allows you to read the CDATA outputs (comments) which are not processed per default by simplexml_load_file. XML Tixik returns, has this occasionally so err on the safe side.</p>
<p>Another thing that I wanted to make sure was that each thumbnail link was actually accessible. <a href="http://www.zann-marketing.com/developer/20051128/check-if-external-image-exists.html" target="_blank">Here is how</a>: basically you can test for the positive return of:</p>
<pre class="brush: php; title: ; notranslate">
   if (@fclose(@fopen($item-&gt;tn, &quot;r&quot;)) ) { .. }
</pre>
<p>Again, I skipped some details to not make this post too long. Play with it, I learned quite a bit putting myself up for this exercise. The result was worth the effort though.</p>
</ul>
<p><fb:like href="" send="true" width="580" show_faces="false" action="like" font=""></fb:like></p>
<h3> Sneak preview</h3>
<p> OK, you might be wondering now: &#8220;the data is there, now what?!&#8221; &#8230; I will give you a quick preview of the FB app I am building &#8230;</p>
<p><img class="size-full" src="http://bobbelderbos.com/wp-content/uploads/2012/02/sneak_preview.jpg" alt="preview travel app" style="float:none; margin: 20px;" width="580"></p>

	]]></content:encoded>
			<wfw:commentRss>http://bobbelderbos.com/2012/02/how-to-start-building-your-own-countrytravel-api/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Git in a nutshell: some basics to get you started</title>
		<link>http://bobbelderbos.com/2012/02/git-in-a-nutshell/</link>
		<comments>http://bobbelderbos.com/2012/02/git-in-a-nutshell/#comments</comments>
		<pubDate>Thu, 09 Feb 2012 18:59:19 +0000</pubDate>
		<dc:creator>Bob</dc:creator>
				<category><![CDATA[Software]]></category>
		<category><![CDATA[Web development]]></category>

		<guid isPermaLink="false">http://bobbelderbos.com/?p=1696</guid>
		<description><![CDATA[<style type="text/css">
div.img
{
  height:auto;  
  width: 25%;
  float: left;
  text-align: center;
}	

div.img img
{
  display: inline;
  margin: 2px;
  height:auto;
  width: auto;
  border: 1px solid #ffffff;
}
div.img a:hover img {border: 1px solid #0000ff;}
div.desc
{
  text-align: center;
  font-weight: normal;
  width: auto;
  margin: 2px;
  padding-bottom:1cm;
}
</style>
Git is really not that hard to learn, yet it is a powerful tool to manage version control of your work. I learned the basics recently studying the Ruby on Rails tutorial. From there Pro Git is an interesting follow-up. This post shows some basic Git to get started. According to the Pro Git book, [...]]]></description>
			<content:encoded><![CDATA[<style type="text/css">
div.img
{
  height:auto;  
  width: 25%;
  float: left;
  text-align: center;
}	

div.img img
{
  display: inline;
  margin: 2px;
  height:auto;
  width: auto;
  border: 1px solid #ffffff;
}
div.img a:hover img {border: 1px solid #0000ff;}
div.desc
{
  text-align: center;
  font-weight: normal;
  width: auto;
  margin: 2px;
  padding-bottom:1cm;
}
</style>
<p> Git is really not that hard to learn, yet it is a powerful tool to manage version control of your work. I learned the basics recently studying the <a href="http://ruby.railstutorial.org/" target="_blank">Ruby on Rails tutorial</a>. From there <a href="http://progit.org" target="_blank">Pro Git</a> is an interesting follow-up. This post shows some basic Git to get started.</p>
<p><span id="more-1696"></span></p>
<p><img class="size-full" src="http://bobbelderbos.com/wp-content/uploads/2012/02/git.png" alt="featured image" style="float:right; margin: 20px;" width="150"></p>
<p> According to the Pro Git book, Git was designed to meet the following goals:</p>
<ul>
<li> It should be fast;</li>
<li> It should have a simple design;</li>
<li> It should have strong support for non-linear development (thousands of parallel branches);</li>
<li> It should be fully distributed;</li>
<li> Git should be able to handle large projects like the Linux kernel efficiently (speed and data size).</li>
</ul>
<p>These are indeed advantages to use Git over other version control systems. It is very fast, mainly because it works against local repositories (vs. remote syncing for every operation).</p>
<p><fb:like href="" send="true" width="580" show_faces="false" action="like" font=""></fb:like></p>
<h3> Initial config</h3>
<p>After <a href="http://git-scm.com/download" target="_blank">installing Git</a> there are some initial configs you should make:</p>
<ul>
<li>Set your name: $ git config &#8211;global user.name &#8220;Fname Lname&#8221; </li>
<li>Set your email: $ git config &#8211;global user.email yourmail@example.com</li>
<li>To make optional aliases: $ git config &#8211;global alias.co checkout</li>
<li>Choose your favorite text editor, mate in my case: $ git config &#8211;global core.editor &#8220;mate -w&#8221;</li>
<li>Pick a diff tool: $ git config &#8211;global merge.tool vimdiff</li>
</ul>
<h3> The basics &#8211; and maybe all you need to know for now (?)</h3>
<p> It requires only a few basic concepts to successfully work with Git (the following commands should be executed in the working directory) :</p>
<ul>
<li>Put your project under git control: $ git init ; this creates a .git directory in your project folder.</li>
<li>Add files to be tracked (staged files): $ git add <files> </li>
<p>If you use $ git add . , the . (dot) adds all files at once.</p>
<p>If you modify a file after you run git add, you have to run git add again to stage the latest version of the file. You can exclude files by filling in the .gitignore file in the working directory (for example to exlude logfiles in a Ruby on Rails project fill it with: .bundle, db/*.sqlite3, log/*.log, tmp/**/*)</p>
<li>Commit changes. Git takes a snapshot now: $ git commit -m &#8220;initial commit&#8221;</li>
<li>Clone a (remote) git project: $ git clone git://github.com/schacon/grit.git mygrit (where mygrit is the local directory you want to copy the project to) &#8211; $ git pull/ push / fetch / clone has much more to it, check out the Pro Git book for more info.</li>
<li>Get info about files, commits, and changes: $ git status / $ git diff / $ git log (<a href="http://gitk.sourceforge.net/" target="_blank">gitk</a> for graphical log viewing). The commands have a lot of switches, Pro Git shows a useful example for filtering in large projects: $ git log &#8211;pretty=&#8221;%h &#8211; %s&#8221; &#8211;author=gitster &#8211;since=&#8221;2008-10-01&#8243; \ &#8211;before=&#8221;2008-11-01&#8243; &#8211;no-merges &#8212; t/  -> pretty powerful!</li>
</ul>
<h3> The real power: Git Branches</h3>
<p> Branches allow to diverge from the main line of development. This allows developers to work on bug fixes and new features without interfering with the main (live) branch (master). Later you can merge branches with each other or with the master branch. The basics are quite simple:</p>
<ul>
<li>Open up a new branch: $ git checkout -b testing ; $ git branch shows you all branches in the project, the single star before one of the branches is the active branch, in this case &#8220;testing&#8221; became the active branch with the &#8220;checkout&#8221; switch.</li>
<li>Commit changes like normal: $ git commit -a -m &#8220;commit message of thing(s) done in branch&#8221;. Again, if you have added any new files to the project since the last commit, you still have to run &#8220;git add&#8221; first.</li>
<li>When done with your branch, switch back to the master with: $ git checkout master</li>
<li>If happy with the results, merge the branch into the main one (master): $ git merge testing</li>
<li>If the branch is not needed anymore, delete it: $ git branch -d testing</li>
</ul>
<p> This is the easiest example of branching, there are more advanced options possible like 3-way merging (merging various branches at once) and rebasing, again see Pro Git for more info.</p>
<p> And this concludes the basics of Git, which matches the first 4 chapters of Pro Git and the end of Chapter 1 of the Ruby on Rails tutorial. I think these notes will cover me 95% in the following web projects I develop (alone). With multiple developers I might need to write a follow-up post with more advanced concepts !</p>
<p><fb:like href="" send="true" width="580" show_faces="false" action="like" font=""></fb:like> </p>
<h3> Set up your GitHub account</h3>
<p> One thing is missing from this basic Git tutorial, setting up <a href="https://github.com/" target="_blank">GitHub</a>! You typically want to push your code to GitHub to have a backup and to allow for collaborations with other developers. Check the &#8220;SSH keys&#8221; part when creating your account. After creating a new repository in the GitHub GUI, pushing your code is easy:</p>
<ul>
<li>The following command configures the push location of your local working directory: $ git remote add origin git@github.com:username/first_app.git</li>
<li>$ git push origin master ; pushes the code to the remote location. Again you need to have the SSH key working to do this. </li>
<li>From here on code changes sync to the remote server each time you run $ git push</li>
</ul>
<h3> Heroku cloud deployment</h3>
<p>The Ruby on Rails tutorial introduced me to <a href="http://www.heroku.com/" target="_blank">Heroku</a> as well. I copy the steps here to push your code to Heroku:</p>
<ul>
<li>Install the corresponding Ruby Gem: $ [sudo] gem install heroku</li>
<li>Sign up for Heroku and configure your SSH keys, then run $ heroku keys:add</li>
<li>To create a subdomain on the Heroku servers, use: $ heroku create &#8211;stack cedar </li>
<p>Heroku return something like &#8220;Created http://severe-fire-61.heroku.com/ | git@heroku.com:severe-fire-61.git  &#8230; Git remote heroku added&#8221; and that is it!</p>
</ul>
<p> You can also use Heroku also when developing Facebook Apps! See this <a href="http://devcenter.heroku.com/articles/facebook" target="_blank">nice tutorial</a>.</p>
<p> For more info, check out the <a href="http://git-scm.com/documentation" target="_blank">Git site&#8217;s documentation</a> as well</p>
<p><fb:like href="" send="true" width="580" show_faces="false" action="like" font=""></fb:like></p>

	]]></content:encoded>
			<wfw:commentRss>http://bobbelderbos.com/2012/02/git-in-a-nutshell/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>Web design shift: read &#8220;Responsive Web Design&#8221;</title>
		<link>http://bobbelderbos.com/2012/01/web-design-shift-read-responsive-web-desig/</link>
		<comments>http://bobbelderbos.com/2012/01/web-design-shift-read-responsive-web-desig/#comments</comments>
		<pubDate>Tue, 24 Jan 2012 22:18:54 +0000</pubDate>
		<dc:creator>Bob</dc:creator>
				<category><![CDATA[Books]]></category>
		<category><![CDATA[Web Design]]></category>

		<guid isPermaLink="false">http://bobbelderbos.com/?p=1692</guid>
		<description><![CDATA[<style type="text/css">
div.img
{
  height:auto;  
  width: 25%;
  float: left;
  text-align: center;
}	

div.img img
{
  display: inline;
  margin: 2px;
  height:auto;
  width: auto;
  border: 1px solid #ffffff;
}
div.img a:hover img {border: 1px solid #0000ff;}
div.desc
{
  text-align: center;
  font-weight: normal;
  width: auto;
  margin: 2px;
  padding-bottom:1cm;
}
</style>
With an increasing amount of web devices (mobile, tablets, higher resolution screens), web designers are faced with a challenge: how to respond well to all? Ethan Marcotte&#8217;s book &#8220;Responsive Web Design&#8221; provides a potential shift in how we design for the web! When I started to design for the web some years ago, I loved [...]]]></description>
			<content:encoded><![CDATA[<style type="text/css">
div.img
{
  height:auto;  
  width: 25%;
  float: left;
  text-align: center;
}	

div.img img
{
  display: inline;
  margin: 2px;
  height:auto;
  width: auto;
  border: 1px solid #ffffff;
}
div.img a:hover img {border: 1px solid #0000ff;}
div.desc
{
  text-align: center;
  font-weight: normal;
  width: auto;
  margin: 2px;
  padding-bottom:1cm;
}
</style>
<p> With an increasing amount of web devices (mobile, tablets, higher resolution screens), web designers are faced with a challenge: how to respond well to all? Ethan Marcotte&#8217;s book &#8220;Responsive Web Design&#8221; provides a potential shift in how we design for the web!</p>
<p><span id="more-1692"></span></p>
<p><img class="size-full" src="http://bobbelderbos.com/wp-content/uploads/2012/01/responsive_web_design.png" alt="featured image" style="float:right; margin: 20px;" width="150"></p>
<p> When I started to design for the web some years ago, I loved fixed width designs. But most fixed width pages aren&#8217;t easily readable on a mobile device. New devices are invented every year and the number of pages accessed through mobile browsers keeps increasing rapidly! So I think this book is a must read for each web designer. The book is well written, with clear examples, and you can probably digest the 141 pages in one or two days.</p>
<h3> Ingredients for a responsive design</h3>
<p> Print and web are inherently different media, yet up until recently a lot of sites were build as if they were for the print medium. I like the approach Marcotte introduces: one responsive web design instead of different designs for different devices. According to Marcotte the following 3 elements make up for responsive web designs:</p>
<ul>
<li> A flexible, grid-based layout,</li>
<li> Flexible images and media, </li>
<li> Media queries (CSS3)</li>
</ul>
<p> Chapters 2,3 and 4 deal with these. The last chapter provides additional info on the responsive design cycle and progressive enhancement.</p>
<p><fb:like href="" send="true" width="580" show_faces="false" action="like" font=""></fb:like></p>
<h4> 1. The flexible grid (and fonts)</h4>
<p>Before touching the grid design, we should set up the font-size to 100% as a base and use &#8220;ems&#8221; to size text up or down. What the grid is concerned Marcotte explains how to go from pixels to percentages based on the width values. You can start with pixels and calculate the percentages with the formula &#8220;target / context = result&#8221;, so if a .blog div is 900px (target) and lives in a body of 960px (context), the .blog div should be 900/ 960  = 0.9375 = 93.75%. Then for the divs that live in .blog, .blog is the context so a left column would be 530/900, etc. The same applies for flexible margins (gutters between blocks).</p>
<h4> 2. Flexible images</h4>
<p> A neat trick is to give the img a max-width of 100% to never cross the width of the div it lives in. There are some issues (distorted images) with IE < 7, so you can use AlphaImageLoader to correct this. The author further explains interesting techniques with "overflow: hidden".</p>
<h4> 3. Media queries</h4>
<p> As of CSS2 you could define media types: all, screen, print, handheld, etc. As this was very generic (&#8220;handheld&#8221; for iphone and older phones), W3C came up with something better in the CSS3 spec: media queries.</p>
<p> Apart from the media type, media queries also detect the physical characteristics of the devices or browsers that render our content. A typical media query is &#8220;@media screen and (min-width: 1024px) { .. css rules .. }&#8221;: this not only requires the screen medium type, but also a viewport of at least 1024px wide, for the CSS rules to be applied.</p>
<p>This is awesome, because now we can target very specific conditions. You can use the min-width and max-width conditions on a variety of features, for example: width, height, aspect-ratio, resolution, grid and more (see page 76-78). And they can be chained together! For example: &#8220;@media screen and (min-device-width: 480px) and (orientation: landscape) { &#8230; }&#8221;</p>
<p>The most important point is that media queries are useful if you have the groundwork set up well: a liquid layout, flexible fonts and images. The best way is to follow the book step-by-step applying the examples on your own &#8220;responsive web design&#8221;.</p>
<p><fb:like href="" send="true" width="580" show_faces="false" action="like" font=""></fb:like> </p>
<h3> Some examples of responsive design</h3>
<p>Four sites worth studying (just resize your browser window to see the amazing effect &#8211; wow) :</p>
<ul>
<li> <a href="http://ethanmarcotte.com" target="_blank">Ethan Marcotte</a> (book author)</li>
<li> <a href="http://robot-or-not.com/" target="_blank">The book&#8217;s example site</a></li>
<li> <a href="http://simplebits.com" target="_blank">Dan Cederholm</a> </li>
<li> <a href="http://cognition.happycog.com" target="_blank">Happy Cog</a></li>
</ul>
<h3> Mobile first</h3>
<p>A good approach these days is to start designing for the smaller mobile canvas and progressively enhance with media queries targeting higher resolutions with &#8220;min-width&#8221; (&#8220;resolution breakpoints&#8221;). I probably will experiment with this approach designing future sites (Ethan convinced me!).</p>
<p>What about you? Let me know what experiences you have designing &#8220;responsive web designs&#8221; &#8230;</p>

	]]></content:encoded>
			<wfw:commentRss>http://bobbelderbos.com/2012/01/web-design-shift-read-responsive-web-desig/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Why the Kindle is my number one reading device</title>
		<link>http://bobbelderbos.com/2012/01/why-the-kindle-is-my-number-one-reading-device/</link>
		<comments>http://bobbelderbos.com/2012/01/why-the-kindle-is-my-number-one-reading-device/#comments</comments>
		<pubDate>Thu, 19 Jan 2012 03:03:59 +0000</pubDate>
		<dc:creator>Bob</dc:creator>
				<category><![CDATA[Productivity]]></category>
		<category><![CDATA[Technology]]></category>

		<guid isPermaLink="false">http://bobbelderbos.com/?p=1683</guid>
		<description><![CDATA[<style type="text/css">
div.img
{
  height:auto;  
  width: 25%;
  float: left;
  text-align: center;
}	

div.img img
{
  display: inline;
  margin: 2px;
  height:auto;
  width: auto;
  border: 1px solid #ffffff;
}
div.img a:hover img {border: 1px solid #0000ff;}
div.desc
{
  text-align: center;
  font-weight: normal;
  width: auto;
  margin: 2px;
  padding-bottom:1cm;
}
</style>
The kindle is serious reading pleasure for me. I actually get a lot of reading done without getting my eyes tired. I still have the GEN3 (photo). Now you can get a Kindle Touch for $99 and a Kindle Fire for $199, however the older Kindle is just brilliant. Why does the Kindle Rock ? [...]]]></description>
			<content:encoded><![CDATA[<style type="text/css">
div.img
{
  height:auto;  
  width: 25%;
  float: left;
  text-align: center;
}	

div.img img
{
  display: inline;
  margin: 2px;
  height:auto;
  width: auto;
  border: 1px solid #ffffff;
}
div.img a:hover img {border: 1px solid #0000ff;}
div.desc
{
  text-align: center;
  font-weight: normal;
  width: auto;
  margin: 2px;
  padding-bottom:1cm;
}
</style>
<p> The kindle is serious reading pleasure for me. I actually get a lot of reading done without getting my eyes tired. I still have the GEN3 (photo). Now you can get a Kindle Touch for $99 and a Kindle Fire for $199, however the older Kindle is just brilliant.</p>
<p><span id="more-1683"></span></p>
<h3> Why does the Kindle Rock ? </h3>
<h4> 1. The screen quality</h4>
<p>It reads like a paper book, it does not reflect in the sun. You can read great quantities without getting eye-tired. This is especially important due to the large amount of books I have on my list ;) &#8211; It is true though that the Kindle format is way better than the average pdf. Most pdf books however read well enough.</p>
<h4> 2. Device management</h4>
<p>Navigation is pretty simple. The touch version probably is better, but the older one with the sidebuttons works quite well. The Amazon store integration is awesome. You buy a book online and it syncs automatically to your Kindle. I am not sure how 3G is offered now, but when I bought my GEN3 Kindle about a year ago, 3G was just a little bit more expensive, so ideal for travelling independency. But without 3G you can still sync your books via Wifi, or just connect your Kindle to your laptop for old-fashioned USB transfers.</p>
<h4> 3. No distractions (!)</h4>
<p>This is an important argument for me to stick with the Kindle for reading. I am a big fan of Apple products, but when it comes to reading, all (social) apps and notifications are not doing any good: I never get much reading done. This is not the case with a Kindle: you basically use it for what it is good at: accessing ebooks. As many things: the simpler the better and the more efficient.</p>
<h4> 4. Design</h4>
<p><img class="size-full" src="http://bobbelderbos.com/wp-content/uploads/2012/01/Screen-shot-2012-01-18-at-9.12.23-PM.png" alt="featured image" style="float:right; margin: 20px;" width="150"></p>
<p>The design is great. I think the screen size is ideal for reading. You can also change character size, screen orientation (vertical vs. horizontal), spacing, etc. Again I have a GEN3 that had this all figured out quite well already. I imagine the newer versions only got better. The GEN3 already had MP3 support which you can easily toggle with alt-spacebar, so I can even 100% concentrate in public places. It even had text-to-voice already, so at least the Kindle formatted books can be read out loud if I want to listen for a change. Another important thing to note is the large battery duration. I don&#8217;t have the specs at hand, but it is not often I have to recharge.</p>
<p><fb:like href="" send="true" width="580" show_faces="false" action="like" font=""></fb:like></p>
<p> These are some highlights of my satisfaction with my GEN3 Kindle. Conclusion: low distraction rate, reading-friendly paper-like screen format, and easy book syncing (pdf / epub / usb / purchased). For me it&#8217;s the best reading device out there.</p>

	]]></content:encoded>
			<wfw:commentRss>http://bobbelderbos.com/2012/01/why-the-kindle-is-my-number-one-reading-device/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Twitter widget to show your latest tweets in carousel slider</title>
		<link>http://bobbelderbos.com/2012/01/twitter-widget-show-latest-tweets-carousel-slide/</link>
		<comments>http://bobbelderbos.com/2012/01/twitter-widget-show-latest-tweets-carousel-slide/#comments</comments>
		<pubDate>Sun, 08 Jan 2012 18:27:42 +0000</pubDate>
		<dc:creator>Bob</dc:creator>
				<category><![CDATA[Jquery]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://bobbelderbos.com/?p=1663</guid>
		<description><![CDATA[<style type="text/css">
div.img
{
  height:auto;  
  width: 25%;
  float: left;
  text-align: center;
}	

div.img img
{
  display: inline;
  margin: 2px;
  height:auto;
  width: auto;
  border: 1px solid #ffffff;
}
div.img a:hover img {border: 1px solid #0000ff;}
div.desc
{
  text-align: center;
  font-weight: normal;
  width: auto;
  margin: 2px;
  padding-bottom:1cm;
}
</style>
Today I show you a script to display the latest tweets on your website or blog. You can use two ways: make a call to Twitter&#8217;s user_timeline or use YQL/ search.twitter. I will wrap the results in the Tiny Carousel jQuery plugin. Read on &#8230; Start &#038; issues I started simple with a an import [...]]]></description>
			<content:encoded><![CDATA[<style type="text/css">
div.img
{
  height:auto;  
  width: 25%;
  float: left;
  text-align: center;
}	

div.img img
{
  display: inline;
  margin: 2px;
  height:auto;
  width: auto;
  border: 1px solid #ffffff;
}
div.img a:hover img {border: 1px solid #0000ff;}
div.desc
{
  text-align: center;
  font-weight: normal;
  width: auto;
  margin: 2px;
  padding-bottom:1cm;
}
</style>
<p>Today I show you a script to display the latest tweets on your website or blog. You can use two ways: make a call to Twitter&#8217;s user_timeline or use YQL/ search.twitter. I will wrap the results in the Tiny Carousel jQuery plugin. Read on &#8230;</p>
<p><span id="more-1663"></span></p>
<h3> Start &#038; issues</h3>
<p>I started simple with a an import of Twitter user_timeline with file_get_contents (from URL: <a href="http://twitter.com/statuses/user_timeline/bbelderbos.json?count=5" target="_blank">http://twitter.com/statuses/user_timeline/bbelderbos.json?count=5</a>), based on <a href="http://blog.ninanet.com/2010/04/19/twitter-feed-with-php" target="_blank">this post</a>. However, although this worked perfectly on localhost, on my remote server it did not. Besides, I soon got a <a href="http://stackoverflow.com/questions/4390913/twitter-rate-limit-exceeded-clients-may-not-make-more-than-350-requests-per-hou" target="_blank">Rate limit exceeded</a> response from Twitter (which does not make sense because <a href="https://dev.twitter.com/docs/rate-limiting" target="_blank">at least I should have 150 requests per hour</a>) You can get the code <a href="http://bobbelderbos.com/src/lastTweets/timeline_php" target="_blank">here</a>.</p>
<p><fb:like href="" send="true" width="580" show_faces="false" action="like" font=""></fb:like></p>
<h3> Alternative solution: YQL</h3>
<p><img class="size-full" src="http://bobbelderbos.com/wp-content/uploads/2012/01/twitterwidget.jpg" alt="featured image" style="float:right; margin: 20px;" width="150"></p>
<p>Recently <a href="http://bobbelderbos.com/2011/12/select-from-internet-examples-yql-api/" target="_blank">I blogged about YQL</a>, a powerful way to crawl the internet. Twitter is well represented among its tables. So I applied what I learned to get my tweets via the search.twitter table in YQL. See the code below: yql.php does the heavy lifting. Instead of file_get_contents (which I would use normally), I use curl to get the URL content. That seemed to work better with my remote server. It returns JSON (you can also choose XML or RSS, but JSON is said to be fastest). Use json_decode to parse JSON into an array. You see some commented lines you can uncomment to print debug info in case you have any issue. I use the <a href="http://www.baijs.nl/tinycarousel/" target="_blank">Tiny Carousel jQuery plugin</a> to show the results in a nice slider.</p>
<h3> Full code display</h3>
<p> == yql.php ==</p>
<pre class="brush: php; title: ; notranslate">
   &lt;?php
   $query = &quot;select text,profile_image_url from twitter.search where q='from:@bbelderbos' limit 10&quot;;
   $url = &quot;http://query.yahooapis.com/v1/public/yql?q=&quot;;
   $url .= rawurlencode($query);
   $url .= &quot;&amp;format=json&amp;env=store://datatables.org/alltableswithkeys&quot;;

   // using curl, as file_get_contents sometimes fails on remote server
   // $json = file_get_contents($url, true);
   $json = get_data($url);

   $info = json_decode($json, true) ;
   // debug, if json_decode fails
   // $error = json_last_error(); echo $error; exit;
   // debug, check structure result
   // echo &quot;&lt;pre&gt;&quot;; print_r($info ); echo &quot;&lt;/pre&gt;&quot;; exit; 

   // function to get URL via cURL
   // from: http://davidwalsh.name/download-urls-content-php-curl
   function get_data($url) {
     $ch = curl_init();
     $timeout = 5;
     curl_setopt($ch,CURLOPT_URL,$url);
     curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
     curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,$timeout);
     $data = curl_exec($ch);
     curl_close($ch);
     return $data;
   }
   ?&gt;
</pre>
<p>Roll your own YQL query at the <a href="http://developer.yahoo.com/yql/console/" target="_blank">YQL console</a>:</p>
<p><img class="size-full" src="http://bobbelderbos.com/wp-content/uploads/2012/01/yql_query.png" alt="yql query" style="float:none; margin: 20px;" width="580"></p>
<p> == index.php ==</p>
<pre class="brush: php; title: ; notranslate">
   &lt;?php include 'yql.php'; ?&gt;
   &lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Strict//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd&quot;&gt;
   &lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot; lang=&quot;en&quot; xml:lang=&quot;en&quot;&gt;

   &lt;head&gt;
   	&lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=utf-8&quot; /&gt;
   	&lt;title&gt;Last Tweets @bbelderbos&lt;/title&gt;
   	&lt;link rel=&quot;stylesheet&quot; href=&quot;style.css&quot; type=&quot;text/css&quot; media=&quot;screen&quot;/&gt;

   	&lt;script type=&quot;text/javascript&quot; src=&quot;js/jquery-1.4.2.min.js&quot;&gt;&lt;/script&gt;
   	&lt;script type=&quot;text/javascript&quot; src=&quot;js/jquery.tinycarousel.min.js&quot;&gt;&lt;/script&gt;
   	&lt;script type=&quot;text/javascript&quot;&gt;
   		$(document).ready(function(){
   			$('#slider1').tinycarousel({ pager: true, interval: true, intervaltime: 5000  });
   		});
   	&lt;/script&gt;	

   &lt;/head&gt;
   &lt;body&gt;
   	&lt;div id=&quot;slider1&quot;&gt;
   		&lt;div class=&quot;viewport&quot;&gt;
   			&lt;ul class=&quot;overview&quot;&gt;
   				&lt;?php
   				foreach($info['query']['results']['results'] as $tweet) {
   					$tweetText = $tweet['text'];
   					$avatar = $tweet['profile_image_url'];

   					// URLs (from http://www.phpro.org/examples/URL-to-Link.html)
   					$tweetText = preg_replace(&quot;/([\w]+:\/\/[\w-?&amp;;#~=\.\/\@]+[\w\/])/i&quot;,&quot;&lt;a target=\&quot;_blank\&quot; href=\&quot;$1\&quot; target=\&quot;_blank\&quot;&gt;$1&lt;/a&gt;&quot;,$tweetText);

   					// twitter handles
   					$tweetText = preg_replace('/(@\S+)/i',&quot;&lt;a target=\&quot;_blank\&quot; href=\&quot;http://twitter.com/$1\&quot; target=\&quot;_blank\&quot;&gt;$1&lt;/a&gt;&quot;,$tweetText);

   					// hash tags map to search?q=#hash
   					$tweetText = preg_replace('/(#)(\S+)/i',&quot;&lt;a target=\&quot;_blank\&quot; href=\&quot;http://twitter.com/search?q=%23$2\&quot; target=\&quot;_blank\&quot;&gt;$1$2&lt;/a&gt;&quot;,$tweetText);	

   					echo '&lt;li&gt;&lt;a href=&quot;http://twitter.com/bbelderbos&quot; target=&quot;_blank&quot;&gt;&lt;img src=&quot;'.$avatar.'&quot; alt=&quot;bob avatar&quot;&gt;&lt;/a&gt;&lt;p&gt;'.$tweetText . &quot;&lt;/p&gt;&lt;/li&gt;&quot;;
   				}
   				?&gt;
   			&lt;/ul&gt;
   		&lt;/div&gt;
   	&lt;/div&gt;
   &lt;/body&gt;
   &lt;/html&gt;
</pre>
<p>The preg_matches are to turn handles (@), hash tags (#) and links into URLs. I am not expanding on the CSS in this post, let me know if you have any questions.</p>
<p><fb:like href="" send="true" width="580" show_faces="false" action="like" font=""></fb:like></p>
<p>Check it out:</p>
<ul>
<li>See this in action <a href="http://bobbelderbos.com/src/lastTweets/" target="_blank">here</a>. </li>
<li>You can download the code <a href="http://bobbelderbos.com/src/lastTweets/code.zip" target="_blank">here</a></li>
<li>In an iframe on <a href="http://bobbelderbos.com" target="_blank">my homepage</a>: </li>
<p><img class="size-full" src="http://bobbelderbos.com/wp-content/uploads/2012/01/example_widget.png" alt="widget example" style="float:none; margin: 20px;" width="580">
</ul>

	]]></content:encoded>
			<wfw:commentRss>http://bobbelderbos.com/2012/01/twitter-widget-show-latest-tweets-carousel-slide/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
		<item>
		<title>Ruby script to get Facebook Like stats for your blog</title>
		<link>http://bobbelderbos.com/2012/01/ruby-script-facebook-like-stats-blog/</link>
		<comments>http://bobbelderbos.com/2012/01/ruby-script-facebook-like-stats-blog/#comments</comments>
		<pubDate>Wed, 04 Jan 2012 17:36:08 +0000</pubDate>
		<dc:creator>Bob</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://bobbelderbos.com/?p=1658</guid>
		<description><![CDATA[<style type="text/css">
div.img
{
  height:auto;  
  width: 25%;
  float: left;
  text-align: center;
}	

div.img img
{
  display: inline;
  margin: 2px;
  height:auto;
  width: auto;
  border: 1px solid #ffffff;
}
div.img a:hover img {border: 1px solid #0000ff;}
div.desc
{
  text-align: center;
  font-weight: normal;
  width: auto;
  margin: 2px;
  padding-bottom:1cm;
}
</style>
In spite of my proposed Scala, HTML5, and Mobile learning, I will start this New Year learning Ruby :) &#8211; I am about to read Eloquent Ruby, but before that I wanted to wet my apetite with a practical case &#8230; The challenge Browsing http://facebook.stackoverflow.com/, I saw a nice one to work on: Getting all [...]]]></description>
			<content:encoded><![CDATA[<style type="text/css">
div.img
{
  height:auto;  
  width: 25%;
  float: left;
  text-align: center;
}	

div.img img
{
  display: inline;
  margin: 2px;
  height:auto;
  width: auto;
  border: 1px solid #ffffff;
}
div.img a:hover img {border: 1px solid #0000ff;}
div.desc
{
  text-align: center;
  font-weight: normal;
  width: auto;
  margin: 2px;
  padding-bottom:1cm;
}
</style>
<p> In spite of my proposed Scala, HTML5, and Mobile learning, I will start this New Year learning Ruby :) &#8211; I am about to read <a href="http://www.amazon.es/Eloquent-Ruby-Addison-Wesley-Professional/dp/0321584104" target="_blank">Eloquent Ruby</a>, but before that I wanted to wet my apetite with a practical case &#8230;</p>
<p><span id="more-1658"></span></p>
<h3> The challenge</h3>
<p> Browsing <a href="http://facebook.stackoverflow.com/" target="_blank">http://facebook.stackoverflow.com/</a>, I saw a nice one to work on: <a href="http://stackoverflow.com/questions/4645500/getting-all-likes-on-my-domain-facebook/8720314#8720314" target="_blank">Getting all likes on my domain (facebook)</a>. So how to get stats on likes for each of your blog posts? Read on &#8230;</p>
<p><fb:like href="" send="true" width="580" show_faces="false" action="like" font=""></fb:like></p>
<h3> How to do it</h3>
<p><img class="size-full" src="http://bobbelderbos.com/wp-content/uploads/2012/01/ruby_likes.jpg" alt="featured image" style="float:right; margin: 20px;" width="150"></p>
<p> It is nice to get a feel of a language by first playing with it, <a href="http://bobbelderbos.com/2011/08/simple-text-to-html-parser-perl-wordpress/" target="_blank">I took the same approach learning Perl</a>. Of course I had to use Google a lot for even basic things (Ruby hashes, loops, the very useful Perl Dumper variant &#8220;pp&#8221;, etc.), but I soon became convinced that Ruby is fun to learn and a powerful language to have in your toolkit.</p>
<p> First step is to make a sitemap XML file of your site. It turned out I had to do that anyways for SEO purposes. For WordPress there is <a href="http://wordpress.org/extend/plugins/google-sitemap-generator/" target="_blank">an excellent plugin</a>. You can see my sitemap <a href="http://bobbelderbos.com/sitemap.xml" target="_blank">here</a>.</p>
<p> So we start scripting. First we need to load that file from the web with a call to &#8220;Net::HTTP.get_response&#8221; (requires &#8216;net/https&#8217;)</p>
<p> Next you want to parse the XML to get all the URLs. REXML makes that simple with &#8220;REXML::Document.new(xml_data)&#8221; and then you use &#8220;doc.elements.each(&#8216;urlset/url/loc&#8217;)&#8221; to loop over the URLs</p>
<p> Then the real data crunching: you reach out to <a href="https://graph.facebook.com/?ids=" target="_blank">https://graph.facebook.com/?ids=</a> which (I just discovered) does except a comma-seperated list of URLs. Keep in mind the https so require &#8216;net/https&#8217; and use &#8220;http.use_ssl = true&#8221;. Obviously this is the desired way to do it: clustering all URLs together to make one big query instead of hundreds of small ones. You do need to shave the last comma off, otherwise the query will fail (url[0..-2])</p>
<p> Facebook Graph returns JSON so this needs to be parsed with JSON.parse (requires &#8216;json&#8217;). I put all the results in the &#8220;likes&#8221; hash (keys are URLs, values are the number of likes). You could sort it numerically descending in Ruby, but I was comfortable doing it from the cli with &#8220;ruby getBlogLikeStats.rb | sort -n -k2&#8243;</p>
<p> And that is all there is to it. Building this in Ruby turned out to be a painless and fun process. And that for somebody that still has to learn the language basics, nice!</p>
<h3> Source</h3>
<p> Source is printed below and you can download it <a href="http://bobbelderbos.com/src/getBlogLikeStats.rb" target="_blank">here</a>.</p>
<p><fb:like href="" send="true" width="580" show_faces="false" action="like" font=""></fb:like> </p>
<pre class="brush: php; title: ; notranslate">
   #!/usr/bin/env ruby
   require 'net/https'
   require 'rexml/document'
   require 'json';
   
   urlXml = 'http://bobbelderbos.com/sitemap.xml'
   url = 'https://graph.facebook.com/?ids='
   likes = Hash.new;
   
   xml_data = Net::HTTP.get_response(URI.parse(urlXml)).body
   doc = REXML::Document.new(xml_data)
   
   doc.elements.each('urlset/url/loc')  { |element| url += element.text + &quot;,&quot; }
   
   uri = URI.parse(url[0..-2])
   http = Net::HTTP.new(uri.host, uri.port)
   http.use_ssl = true
   request = Net::HTTP::Get.new(uri.path + &quot;?&quot; + uri.query)
   response = http.request(request)
   data = response.body
   result = JSON.parse(data)
   
   result.each { |url| likes[url[1]['id']] = url[1]['shares'] }
   
   likes.each do|url,numLikes|
     puts &quot;#{url}: #{numLikes}&quot;
   end
</pre>
<p> Have fun!</p>
<h3> Update 08.01.2012: What about Twitter? </h3>
<p>With the <a href="http://help.tweetmeme.com/2009/10/12/core-api/" target="_blank">Tweetmeme API</a> you can easily query the amount of tweets. Only incovenience is that http://api.tweetmeme.com/url_info.json?url accepts only 1 URL at the time it seems, so you need to make a call for each URL (as opposed to the earlier mentioned Facebook Graph API that does handle multiple URLs in one call)</p>
<p>Ruby code to get your <a href="http://bobbelderbos.com/src/getBlogTweetStats.rb" target="_blank">tweet stats</a>:</p>
<p>Executing the script from CLI:</p>
<p><img class="size-full" src="http://bobbelderbos.com/wp-content/uploads/2012/01/cli_tweet_stats.png" alt="cli tweet stats" style="float:none; margin: 20px;" width="580"></p>
<p><fb:like href="" send="true" width="580" show_faces="false" action="like" font=""></fb:like></p>
<pre class="brush: php; title: ; notranslate">
   #!/usr/bin/env ruby
   # copyright (c) 2012 Bob Belderbos
   # created: January 2012
   require 'net/http'
   require 'uri'
   require 'rexml/document'
   require 'json'
   require 'pp'

   urlXml = 'http://bobbelderbos.com/sitemap.xml'
   url = 'http://api.tweetmeme.com/url_info.json?url='

   xml_data = Net::HTTP.get_response(URI.parse(urlXml)).body
   doc = REXML::Document.new(xml_data)

   doc.elements.each('urlset/url/loc')  do |element|
     url += element.text
     resp = Net::HTTP.get_response(URI.parse(url))
     data = resp.body
     result = JSON.parse(data)
     print &quot;#{result['story']['url']} =&gt; #{result['story']['url_count']}\n&quot;
   end
</pre>

	]]></content:encoded>
			<wfw:commentRss>http://bobbelderbos.com/2012/01/ruby-script-facebook-like-stats-blog/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>An overview of a productive 2011, 2012: more to come &#8230;</title>
		<link>http://bobbelderbos.com/2011/12/overview-productive-2011-2012-more-to-come/</link>
		<comments>http://bobbelderbos.com/2011/12/overview-productive-2011-2012-more-to-come/#comments</comments>
		<pubDate>Wed, 28 Dec 2011 17:30:17 +0000</pubDate>
		<dc:creator>Bob</dc:creator>
				<category><![CDATA[Web Technologies]]></category>

		<guid isPermaLink="false">http://bobbelderbos.com/?p=1642</guid>
		<description><![CDATA[<style type="text/css">
div.img
{
  height:auto;  
  width: 25%;
  float: left;
  text-align: center;
}	

div.img img
{
  display: inline;
  margin: 2px;
  height:auto;
  width: auto;
  border: 1px solid #ffffff;
}
div.img a:hover img {border: 1px solid #0000ff;}
div.desc
{
  text-align: center;
  font-weight: normal;
  width: auto;
  margin: 2px;
  padding-bottom:1cm;
}
</style>
As a tradition at the end of the year I&#8217;ll take a moment to reflect back what this blog brought you this year. 2011 was a year of APIs, good books, reading and music apps, Perl exploring and more &#8230; Up and foremost, you can check all posts in the Archives (which is created with [...]]]></description>
			<content:encoded><![CDATA[<style type="text/css">
div.img
{
  height:auto;  
  width: 25%;
  float: left;
  text-align: center;
}	

div.img img
{
  display: inline;
  margin: 2px;
  height:auto;
  width: auto;
  border: 1px solid #ffffff;
}
div.img a:hover img {border: 1px solid #0000ff;}
div.desc
{
  text-align: center;
  font-weight: normal;
  width: auto;
  margin: 2px;
  padding-bottom:1cm;
}
</style>
<p>As a <a href="http://bobbelderbos.com/2010/12/essential-posts-2010/" target="_blank">tradition</a> at the end of the year I&#8217;ll take a moment to reflect back what this blog brought you this year. 2011 was a year of APIs, good books, reading and music apps, Perl exploring and more &#8230;</p>
<p><span id="more-1642"></span></p>
<p>Up and foremost, you can check all posts in the <a href="http://bobbelderbos.com/posts/" target="_blank">Archives</a> (which is created with the very cool <a href="http://www.prelovac.com/vladimir/wordpress-professional-developers" target="_blank">Snazzy Archives</a>). </p>
<p><fb:like href="" send="true" width="580" show_faces="false" action="like" font=""></fb:like></p>
<p><img class="size-full" src="http://bobbelderbos.com/wp-content/uploads/2011/12/2011_overview.png" alt="featured image" style="float:right; margin: 20px;" width="150"></p>
<p>01.2011: one of my favorites is the post about the <a href="http://bobbelderbos.com/2011/01/build-movie-trailer-api-using-gdata/" target="_blank">Youtube gdata API</a> to make a trailer wrapper for <a href="http://sharemovi.es" target="_blank">sharemovi.es</a>. I did some twitter digests as well, but stopped it, because I found it too much clutter. Some cool <a href="http://bobbelderbos.com/2011/01/my-5-favorite-jquery-snippets/" target="_blank">jQuery snippets</a> (and later <a href="http://bobbelderbos.com/2011/09/nice-jquery-plugin-jeditable/" target="_blank">jeditable</a>). More jQuery in 2012, that&#8217;s for sure!</p>
<p>02.2011: post about <a href="http://bobbelderbos.com/2011/02/great-book-about-software-engineering/" target="_blank">one of my favorite books about software development</a></p>
<p>03.2011: what turned out to be a popular post: <a href="http://bobbelderbos.com/2011/03/facebook-like-button-right-image/" target="_blank">Let Facebook &#8220;Like&#8221; button pick the right image!</a>. This post answered a question a lot of developers had: why doesn&#8217;t Facebook show the right image when I &#8220;like&#8221; a post? Now meta tag definition is more apparent in the Open Graph Beta, but back in March this was an issue lots of us struggled with. Another interesting post was <a href="http://bobbelderbos.com/2011/03/new-facebook-comments-plugin/" target="_blank">the pros and cons of the FB comment box plugin</a> that had its second version released. I would embrace it but some weeks ago, <a href="http://bobbelderbos.com/2011/12/comments-back-on-blog-disqus/" target="_blank">I decided to stick with Disqus</a>. Definite hightlight in March was my <a href="http://bobbelderbos.com/2011/03/new-facebook-app-my-reading-list/" target="_blank">weekend-hack-Facebook-app &#8220;My Reading List&#8221;</a> (visit it <a href="http://www.bobbelderbos.com/books/" target="_blank">here</a>). People are still sharing books weekly via this App, nice!</p>
<p>04.2011 &#8211; some FB posts, but highlights are two well received articles about <a href="http://bobbelderbos.com/2011/04/advance-career-read-passionate-programmer/" target="_blank">the passionate programmer</a>, still one of my favorite inspirational career titles, and some notes on <a href="http://bobbelderbos.com/2011/04/make-developer-life-easier/" target="_blank">good software development</a></p>
<p>05.2011 &#8211; no posts</p>
<p>06.2011 &#8211; back to Facebook App creation. After sharemovi.es and &#8220;my reading list&#8221;, I wanted to do something with Music, so I made <a href="http://bobbelderbos.com/2011/06/new-facebook-app-friends-jukebox/" target="_blank">Friends Jukebox</a> (visit <a href="http://www.friendsjukebox.com/" target="_blank">here</a>): a simple app to know what music your friends like, bundling the power of the LastFM API and the Youtube API to provide artist data and music videos. Video demos about all 3 FB Apps can be seen <a href="http://bobbelderbos.com/2011/07/video-demos-my-fb-apps/" target="_blank">here</a> (btw, <a href="http://www.screenr.com/" target="_blank">Screenr</a> is an awesome piece of software to record and propagate your own videos).</p>
<p>07.2011 &#8211; quite some activity: <a href="http://bobbelderbos.com/2011/07/example-simple-facebook-canvasapp-never-forget-a-birthday/" target="_blank">canvas app example for a birthday app</a>; FB has something like this already, but it was all about the tutorial side, and poring it into a new design. Then <a href="http://bobbelderbos.com/2011/07/fql-powerful-way-query-facebook-graph-api/" target="_blank">FB FQL</a>, a post on <a href="http://bobbelderbos.com/2011/07/10-steps-proficient-blogger/" target="_blank">blogging</a>, and on <a href="http://bobbelderbos.com/2011/07/becoming-good-debugger/" target="_blank">debugging</a>.</p>
<p>08.2011 &#8211; <a href="http://bobbelderbos.com/2011/08/my-first-week-of-perl/" target="_blank">I started to learn Perl</a>, that turned out a powerful tool to have in my toolkit! Some practical experimenting: <a href="http://bobbelderbos.com/2011/08/facebook-api-post-with-perl-from-cli/" target="_blank">how to post to FB with Perl</a>, <a href="http://bobbelderbos.com/2011/08/simple-text-to-html-parser-perl-wordpress/" target="_blank">a simple script to convert text to html for WordPress</a> (which still saves me time weekly). G+ was about to release its API but <a href="http://bobbelderbos.com/2011/08/googleplus-import-profile-posts/" target="_blank">you could already do stuff</a>.</p>
<p>09.2011 &#8211; I switched to posterous getting domain <a href="http://exploringtheweb.net/" target="_blank">http://exploringtheweb.net/</a>, but moved back because it is hard to maintain two blogs and bobbelderbos.com has its history and loyal visitors. That aside, I designed a <a href="http://bobbelderbos.com/2011/09/my-reading-list-widget/" target="_blank">My Reading List widget</a> (see in action in the sidebar), there are some more small posts with tricks, check <a href="http://bobbelderbos.com/posts/" target="_blank">the archives</a></p>
<p>10.2011 &#8211; 3 posts, but I&#8217;d like to mention my <a href="http://bobbelderbos.com/2011/10/how-to-scrape-a-webpage-with-perl/" target="_blank">experimenting with Perl to scrape a webpage</a></p>
<p>11.2011 &#8211; an interesting new <a href="http://bobbelderbos.com/2011/11/yii-1-1-application-development-cookbook/" target="_blank">Yii title I reviewed</a>, a reader request: <a href="http://bobbelderbos.com/2011/11/facebook-api-post-to-page-and-as-page/" target="_blank">a page to post and maintain Facebook pages</a> (as the ID of the FB page!), but what really stood out was a huge spike in visits from hackers news on: <a href="http://bobbelderbos.com/2011/11/movie-database-imdb-api-perl/" target="_blank">Your own movie database in 5 minutes with IMDb API and Perl</a>, a simple movie DB app scrapìng <a href="http://imdbapi.com/" target="_blank">imdbapi</a>with Perl (I would use <a href="http://www.themoviedb.org/" target="_blank">themoviedb.org</a> <a href="http://bobbelderbos.com/2011/12/sharemovies-new-feature-search-interface-instant-trailers/" target="_blank">a month later</a>)</p>
<p>12.2011 &#8211; <a href="http://bobbelderbos.com/2011/12/select-from-internet-examples-yql-api/" target="_blank">browse the net with YQL</a>, <a href="http://bobbelderbos.com/2011/12/sharemovies-new-feature-search-interface-instant-trailers/" target="_blank">a rich movie search interface with instant trailers</a> and at last <a href="http://bobbelderbos.com/2011/12/reading-facebook-application-development-with-graph-api-cookbook/" target="_blank">a review of FB Graph API cookbook</a>, a useful resource for FB API developers.</p>
<p><fb:like href="" send="true" width="580" show_faces="false" action="like" font=""></fb:like></p>
<h3>2012 starts, what&#8217;s next? </h3>
<p>I probably will start (or pick up) investigating: Node.js / Javascript, Mobile development (Appcelerator Titanium), REST, Ruby on Rails, Python and Django, Cloud, maybe a compiled language (C++ or Java), security (PHP!), OOP programming, more books on software development. Enough ideas, but &#8230;</p>
<h3> What do you think should be on the web tech blog agenda? </h3>
<p>Don&#8217;t hesitate, any idea that can be classified as &#8220;Web technology and/or programming&#8221; is welcome, leave them below in the comments or on <a href="https://www.facebook.com/pages/bobbelderboscom/160267890674014" target="_blank">my FB page</a>.</p>
<p>2012 means more web, more technology, more programming, and consequently more blogging. Keep on developing and working on your ideas, I am happy to share mines. Happy 2012!</p>

	]]></content:encoded>
			<wfw:commentRss>http://bobbelderbos.com/2011/12/overview-productive-2011-2012-more-to-come/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Reading: FB App Development with Graph API Cookbook</title>
		<link>http://bobbelderbos.com/2011/12/reading-facebook-application-development-with-graph-api-cookbook/</link>
		<comments>http://bobbelderbos.com/2011/12/reading-facebook-application-development-with-graph-api-cookbook/#comments</comments>
		<pubDate>Fri, 23 Dec 2011 17:30:32 +0000</pubDate>
		<dc:creator>Bob</dc:creator>
				<category><![CDATA[APIs]]></category>
		<category><![CDATA[Books]]></category>

		<guid isPermaLink="false">http://bobbelderbos.com/?p=1636</guid>
		<description><![CDATA[<style type="text/css">
div.img
{
  height:auto;  
  width: 25%;
  float: left;
  text-align: center;
}	

div.img img
{
  display: inline;
  margin: 2px;
  height:auto;
  width: auto;
  border: 1px solid #ffffff;
}
div.img a:hover img {border: 1px solid #0000ff;}
div.desc
{
  text-align: center;
  font-weight: normal;
  width: auto;
  margin: 2px;
  padding-bottom:1cm;
}
</style>
I just finished reading Facebook Application Development with Graph API Cookbook. It provides over 90 recipes to create web apps with the Facebook API. The variety of topics and the amount of practical code examples makes it a useful reference for the FB API developer. The book is structured as follows: The first 3 chapters [...]]]></description>
			<content:encoded><![CDATA[<style type="text/css">
div.img
{
  height:auto;  
  width: 25%;
  float: left;
  text-align: center;
}	

div.img img
{
  display: inline;
  margin: 2px;
  height:auto;
  width: auto;
  border: 1px solid #ffffff;
}
div.img a:hover img {border: 1px solid #0000ff;}
div.desc
{
  text-align: center;
  font-weight: normal;
  width: auto;
  margin: 2px;
  padding-bottom:1cm;
}
</style>
<p> I just finished reading <a href="http://www.packtpub.com/facebook-application-development-with-graph-api-cookbook/book" target="_blank">Facebook Application Development with Graph API Cookbook</a>. It provides over 90 recipes to create web apps with the <a href="https://developers.facebook.com/" target="_blank">Facebook API</a>. The variety of topics and the amount of practical code examples makes it a useful reference for the FB API developer.</p>
<p><span id="more-1636"></span></p>
<p><img class="size-full" src="http://bobbelderbos.com/wp-content/uploads/2011/12/fbapi1.jpg" alt="featured image" style="float:right; margin: 20px;" width="150"></p>
<p> The book is structured as follows:</p>
<ul>
<li> The first 3 chapters are a basic introduction how the API works: get the PHP SDK, set up your first (canvas) app, interacting with the social graph and how to query Facebook.</li>
<li> Chapters 4-6 focus on Javascript: chapter 4 introduces the JS SDK, chapter 5 is about Facebook Dialogs, and chapter 6 deals with the various social plugins from Facebook that you integrate on your site (like button, activity feed, etc). </li>
<li> Chapters 7-9 show a bit more advanced topics: integrating web pages (chapter 7), virtual Facebook currency to actually earn money through Facebook (chapter 8) and advertising / metrics data (chapter 9).</li>
<li> Chapter 10 is the most fun: it shows some complete Facebook apps you can build with the API</li>
<li> Chapter 11 is bonus and important moving forward: it shows the <a href="https://developers.facebook.com/docs/beta/" target="_blank">Open Graph Beta</a> that was presented several months ago at Facebook&#8217;s G8.</li>
</ul>
<p><fb:like href="" send="true" width="580" show_faces="false" action="like" font=""></fb:like></p>
<h3> Code samples</h3>
<p>I didn&#8217;t have time to play with all the code samples yet, but they form a great resource for both new developers wanting to get to know the framework, as well as the intermediate/advanced developer that wants to enhance his/her skills.</p>
<p>Writing a FB API book is more than challenging knowing that the platform is updated very often. I found my FB apps broken this week because I didn&#8217;t anticipated the <a href="https://developers.facebook.com/blog/post/614/" target="_blank">oauth2 change</a> that went live (announced on the Facebook developers blog). This might be an issue with the code samples, because I didn&#8217;t see the &#8220;oauth: true&#8221; in the FB.init calls, which was the change I had to put into my apps last weeks to make them work again (more info about the fix <a href="https://developers.facebook.com/blog/post/534/" target="_blank">here</a>). Another example is the depricated $facebook->getSession() on page 15 of the book (now: $facebook->getUser() in PHP SDK 3.1) which I spotted on the <a href="http://www.botskool.com/geeks/facebook-application-development-graph-api-cookbook" target="_blank">author&#8217;s blog post comments</a>.</p>
<p>This seems inevitable, and it means you need to be prepared to have the API documentation at hand and tweak (but hey &#8230; isn&#8217;t this the best way to learn anyway?). As the book is from November this year, there won&#8217;t be many of these issues, but in 1 or 2 years time there might be, so probably it would be a good idea to release an updated version of the book by then.</p>
<p>Kudos to the author for the amount of samples. I also think he did a good job of explaining them, and adding other technologies like PHP GD (image creation) and jQuery to pretty up the examples.</p>
<h3> Writing style and structure</h3>
<p>The book is easy to read/follow. It goes through the concepts in a logical order, building new examples upon previous ones. It is not necessary to read it sequentially though. There are backreferences to prerequisites, so with some experience you can easily jump in anywhere. As with most of Packt&#8217;s cookbooks the structure for each recipe is: &#8220;get ready -> how to do it -> how it works -> references&#8221;, as with <a href="http://bobbelderbos.com/2011/11/yii-1-1-application-development-cookbook/" target="_blank">Yii&#8217;s cookbook</a>, this worked pretty well for me. It allows for both quick scanning of code (after all a cookbook really is a reference work) as well as detailed study of the examples. </p>
<h3> Open graph</h3>
<p>I liked the fact that the author paid some attention to the Open Graph Beta. I still have to develop my first App in it, and from what I&#8217;ve seen (Spotify, reading apps), it seems the way forward! Trivia: I actually contacted the author several weeks ago that I was going to read/review his title, asking him if he had seen the G8 conf and thus if he could do a chapter on the OG Beta. I got a prompt response and I am glad he put it in :)</p>
<h3> Learning by doing</h3>
<p>From a personal view, learning the FB API is about practicing, writing code, play with the PHP / JS SDKs and many methods the FB API has. The many examples suits this purpose well. Again, things change fast at Facebook, and usually announcing it on their blog, so if you are developing FB apps, follow the developers blog and use this book as reference making sure you also check the latest API docs. </p>
<p><fb:like href="" send="true" width="580" show_faces="false" action="like" font=""></fb:like></p>
<h3> Conclusion</h3>
<p>I found the content and the way it is presented very useful. Although the book is brand new, there are already some recent changes in both PHP and JS SDKs that might affect the code. So make sure you check the FB API documentation.</p>
<p>The advantage of this book over the API docs, is the structured format to learn the subject and clear explanations. It covers a wide range of topics in a reasonable size of 340 pages, including interesting advanced topics like virtual currency, advertising and metrics. The book&#8217;s samples show a strong integration with the social graph (the real API&#8217;s strength!), and a chapter on the way forward: the Open Graph Beta.</p>
<p>So I can recommend this title to every developer that works with the Facebook API.</p>

	]]></content:encoded>
			<wfw:commentRss>http://bobbelderbos.com/2011/12/reading-facebook-application-development-with-graph-api-cookbook/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>How to make a rich movie search interface with instant trailers</title>
		<link>http://bobbelderbos.com/2011/12/sharemovies-new-feature-search-interface-instant-trailers/</link>
		<comments>http://bobbelderbos.com/2011/12/sharemovies-new-feature-search-interface-instant-trailers/#comments</comments>
		<pubDate>Mon, 12 Dec 2011 22:59:42 +0000</pubDate>
		<dc:creator>Bob</dc:creator>
				<category><![CDATA[Jquery]]></category>
		<category><![CDATA[Work in progress]]></category>

		<guid isPermaLink="false">http://bobbelderbos.com/?p=1603</guid>
		<description><![CDATA[<style type="text/css">
div.img
{
  height:auto;  
  width: 25%;
  float: left;
  text-align: center;
}	

div.img img
{
  display: inline;
  margin: 2px;
  height:auto;
  width: auto;
  border: 1px solid #ffffff;
}
div.img a:hover img {border: 1px solid #0000ff;}
div.desc
{
  text-align: center;
  font-weight: normal;
  width: auto;
  margin: 2px;
  padding-bottom:1cm;
}
</style>
Today a quick post to show you a new feature I rolled out last week on sharemovi.es: #nw or Now Watching. Go check it out here. In this post some printscreens and a what technologies I used More on the technology behind it When you start to type a movie name it queries themoviedb.org API for [...]]]></description>
			<content:encoded><![CDATA[<style type="text/css">
div.img
{
  height:auto;  
  width: 25%;
  float: left;
  text-align: center;
}	

div.img img
{
  display: inline;
  margin: 2px;
  height:auto;
  width: auto;
  border: 1px solid #ffffff;
}
div.img a:hover img {border: 1px solid #0000ff;}
div.desc
{
  text-align: center;
  font-weight: normal;
  width: auto;
  margin: 2px;
  padding-bottom:1cm;
}
</style>
<p>Today a quick post to show you a new feature I rolled out last week on <a href="http://sharemovi.es" target="_blank">sharemovi.es</a>: #nw or Now Watching. Go check it out <a href="http://sharemovi.es/nw/" target="_blank">here</a>. In this post some printscreens and a what technologies I used</p>
<p><span id="more-1603"></span></p>
<p><img class="size-full" src="http://bobbelderbos.com/wp-content/uploads/2011/12/Screen-shot-2011-12-12-at-10.45.47-PM.png" alt="rich autocomplete" style="float:none; margin: 20px;" width="580"></p>
<p><fb:like href="" send="true" width="580" show_faces="false" action="like" font=""></fb:like></p>
<h3> More on the technology behind it</h3>
<p>When you start to type a movie name it queries <a href="http://api.themoviedb.org/2.1/" target="_blank">themoviedb.org API</a> for movie info. The API seems quite complete and the response it fast. I thought name, poster, year, rating and short summary extract would be most relevant &#8230; and &#8230; the trailer. You see the red youtube button? Well &#8230; when you hover with your mouse over the whole row, the trailer loads in the white box. All thanks to some jQuery &#8211; see the <a href="http://sharemovi.es/nw/base.js" target="_blank">JS code</a>; in order to not make too many calls to themoviedb.org API, I use <a href="bobbelderbos.com/2011/12/select-from-internet-examples-yql-api/" target="_blank">YQL</a> to dynamically look up the trailer. You can also use <a href="http://bobbelderbos.com/2011/01/build-movie-trailer-api-using-gdata/" target="_blank">Gdata/ Youtube</a>.</p>
<p><img class="size-full" src="http://bobbelderbos.com/wp-content/uploads/2011/12/newSharemovi.es_.jpg" alt="featured image" style="float:right; margin: 20px;" width="150"></p>
<p>I use an autocomplete box from the <a href="http://ajax.googleapis.com/ajax/libs/jqueryui/1/jquery-ui.min.js" target="_blank">jQuery UI</a>, it comes with some nice styles incorporated. I <a href="http://www.ajaxload.info/" target="_blank">rolled my own loader gif</a>, but the real workhorses are PHP and jQuery, a powerful duo.</p>
<p>The &#8216;autocomplete&#8217; function polls the API via search.php upon detected key strokes. I had to play a bit with &#8216;renderItem&#8217; to show a rich result (poster, etc). Upon &#8216;select&#8217; of a title, comment.php is called to generate a customized form with message and share buttons. The field is readonly (not editable), but clicking on the pencil, jQuery takes the readonly attribute off (removeAttr) so you can edit it.</p>
<p>I didn&#8217;t include Twitter / Facebook APIs, just a link to the corresponding page with the right URL parameters. With FB dialogs you can give quite some options and it does not require authorization because the user has to submit the info anyway. The links get created in the .submit .. &#8216;click&#8217; function (note the encodeURIComponent). A richer experience is using one of the APIs. As sharemovi.es has the FB API setup already, I will definitely build this in. I will also integrate this richer experience into sharemovi.es as a whole. I&#8217;d like movies to be added to sharemovi.es this way, manual or automagically.</p>
<p>Note the live function in the <a href="http://sharemovi.es/nw/base.js" target="_blank">jQuery code</a>: when you add new content without page refresh (Ajax), your JS needs to be made aware that that content is there, this is what &#8216;live&#8217; is for.</p>
<p>Now the trailer bit: &#8216;mouseenter&#8217; and &#8216;mouseleave&#8217; are the functions responsible for loading/ hiding the trailer for each title. You see another $.post, but now to youtube.php which as said uses YQL to find the corresponding movie trailer. And it returns an iframe that fits nicely in the white mini-canvas.</p>
<p><fb:like href="" send="true" width="580" show_faces="false" action="like" font=""></fb:like></p>
<h3>So step-by-step:</h3>
<p>1. Go to <a href="sharemovi.es/nw/" target="_blank">sharemovi.es/nw/</a> (or at the homepage click on &#8220;Now Watching&#8221; to use the embedded version).</p>
<p>2. Start to type a movie, you should see titles approximating what you type:</p>
<p><img class="size-full" src="http://bobbelderbos.com/wp-content/uploads/2011/12/Screen-shot-2011-12-12-at-10.45.47-PM.png" alt="trailer autocomplete" style="float:none; margin: 20px;" width="580"></p>
<p>3. When you hover over the row, you should see a trailer starting to play:</p>
<p><img class="size-full" src="http://bobbelderbos.com/wp-content/uploads/2011/12/Screen-shot-2011-12-12-at-10.45.54-PM1.png" alt="trailer playing" style="float:none; margin: 20px;" width="580"></p>
<p>4. When you click on one of the movies, a share box slides down with a proposed text.</p>
<p><img class="size-full" src="http://bobbelderbos.com/wp-content/uploads/2011/12/Screen-shot-2011-12-12-at-10.46.45-PM.png" alt="share box" style="float:none; margin: 20px;" width="580"><br />
<a href=""><img class="alignnone" title="Screen shot 2011-12-12 at 10.46.45 PM" src="" alt="" width="600" /></a></p>
<p>5. Example of clicking Facebook button (I put the text &#8220;want to see this one&#8221; in as addition)<br />
<img class="size-full" src="http://bobbelderbos.com/wp-content/uploads/2011/12/Screen-shot-2011-12-12-at-10.47.02-PM.png" alt="fb button" style="float:none; margin: 20px;" width="580"></p>
<p>6. Same for twitter, however I clicked the pencil which made the field editable:<br />
<img class="size-full" src="http://bobbelderbos.com/wp-content/uploads/2011/12/Screen-shot-2011-12-12-at-10.47.25-PM.png" alt="edit button clicked" style="float:none; margin: 20px;" width="580"></p>
<p>7. And the result shown on Twitter before posting. Again with APIs this can all be slicker but I wanted an easy standalone example:<br />
<img class="size-full" src="http://bobbelderbos.com/wp-content/uploads/2011/12/Screen-shot-2011-12-12-at-10.47.34-PM.png" alt="share on twitter" style="float:none; margin: 20px;" width="580"></p>
<p><fb:like href="" send="true" width="580" show_faces="false" action="like" font=""></fb:like></p>
<h4>Update 18.01.2012</h4>
<p>The complete source code is posted <a href="http://bobbelderbos.com/src/now_watching.zip" target="_blank">here</a>. Enjoy &#8230; and please leave me a comment if you use it somewhere &#8230;</p>

	]]></content:encoded>
			<wfw:commentRss>http://bobbelderbos.com/2011/12/sharemovies-new-feature-search-interface-instant-trailers/feed/</wfw:commentRss>
		<slash:comments>13</slash:comments>
		</item>
	</channel>
</rss>

