<?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>Claudio&#039;s Hideout &#187; Programmazione</title>
	<atom:link href="http://claudio.cicali.name/post/category/programmazione/feed/" rel="self" type="application/rss+xml" />
	<link>http://claudio.cicali.name</link>
	<description>Claudio Cicali web hub</description>
	<lastBuildDate>Sun, 25 Sep 2011 11:29:05 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Modialog, a jQuery plugin for modal dialogs</title>
		<link>http://claudio.cicali.name/post/2011/06/modialog-a-jquery-plugin-for-modal-dialogs/</link>
		<comments>http://claudio.cicali.name/post/2011/06/modialog-a-jquery-plugin-for-modal-dialogs/#comments</comments>
		<pubDate>Fri, 17 Jun 2011 17:15:40 +0000</pubDate>
		<dc:creator>claudio</dc:creator>
				<category><![CDATA[Annunci]]></category>
		<category><![CDATA[Blog]]></category>
		<category><![CDATA[Programmazione]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[javascript]]></category>

		<guid isPermaLink="false">http://claudio.cicali.name/?p=1023</guid>
		<description><![CDATA[I&#8217;ve just released a very small plugin for jQuery. It&#8217;s called Modialog and it aims to be the smallest &#8220;modal dialog boxes&#8221; plugin (there are already a lot of them out there). It weights only 2KB and works with every recent browser. You can take a look at its bare bone demo page.]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve just released a very small plugin for jQuery. It&#8217;s called <a href="https://github.com/claudioc/modialog">Modialog</a> and it aims to be the smallest &#8220;modal dialog boxes&#8221; plugin (there are already a lot of them <a href="https://itswadesh.wordpress.com/2011/04/13/15-jquery-popup-modal-dialog-plugins-and-tutorials/">out there</a>). It weights only 2KB and works with every recent browser. You can take a look at its bare bone <a href="http://claudioc.github.com/modialog/demo.html">demo page</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://claudio.cicali.name/post/2011/06/modialog-a-jquery-plugin-for-modal-dialogs/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to export your friendfeed stream (posts and comments)</title>
		<link>http://claudio.cicali.name/post/2011/01/how-to-export-your-friendfeed-stream-posts-and-comments/</link>
		<comments>http://claudio.cicali.name/post/2011/01/how-to-export-your-friendfeed-stream-posts-and-comments/#comments</comments>
		<pubDate>Fri, 07 Jan 2011 10:29:51 +0000</pubDate>
		<dc:creator>claudio</dc:creator>
				<category><![CDATA[Annunci]]></category>
		<category><![CDATA[Articoli]]></category>
		<category><![CDATA[Blog]]></category>
		<category><![CDATA[Programmazione]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[english]]></category>
		<category><![CDATA[export]]></category>
		<category><![CDATA[friendfeed]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://claudio.cicali.name/?p=976</guid>
		<description><![CDATA[I just wrote a script to easily download your FULL friendfeed stream. I mean: every post with comments, likes and even images and/or files. Enough for the good news: the bad news is that this a PHP command line script and you have to know how to run it. On a recent  OSX or Linux [...]]]></description>
			<content:encoded><![CDATA[<p><a rel="attachment wp-att-980" href="http://claudio.cicali.name/post/2011/01/how-to-export-your-friendfeed-stream-posts-and-comments/ff-2/"><img class="alignleft size-full wp-image-980" title="ff" src="http://claudio.cicali.name/wp-content/uploads/2011/01/ff1.png" alt="" width="227" height="50" /></a></p>
<p>I just wrote a script to easily download your FULL <a href="http://friendfeed.com">friendfeed</a> stream. I mean: every post with comments, likes and even images and/or files. Enough for the good news: the bad news is that this a PHP command line script and you have to know how to run it. On a recent  OSX or Linux environment you should be ready to go. For Windows-ers it could be a little more difficult. Sorry.</p>
<p>Anyway, here is the features list:</p>
<ul>
<li>can fetch a private stream, giving your <a href="http://friendfeed.com/remotekey">remote key</a></li>
<li>locally downloads images and files (detects already downloaded things)</li>
<li>upon subsequent runs, it tries to get only the newly added posts</li>
<li>the output file is <a href="http://www.json.org/">JSON</a></li>
<li>it scales well!</li>
<li>it&#8217;s free software (MIT license)</li>
</ul>
<p>
Download the scripts <a href="https://github.com/claudioc/ffexp">from Github</a> (the link points to the project page, where you can read the README too. In this case you&#8217;re interested to the <a href="https://github.com/claudioc/ffexp/blob/master/ffexp.php">ffexp.php</a> script).
</p>
<p>You then may run it like:</p>
<pre>php ffexp.php somefilename.json</pre>
<p>As you may infer from the output file extension, the output is plain good JSON. This format is <strong>very</strong> handy for whatever thing you may need to do with the export file. But this is up to you (or your programmer friend).
</p>
<p>As an example of <em>JSON postprocessor</em> I also wrote <strong>a converter</strong> that given your export file will render a fully functional HTML file, looking just like a Friendfeed page. It also automatically embeds the necessary JavaScript, CSS and even icon images. <a href="https://github.com/claudioc/ffexp/blob/master/ffexp2html.php">Download the ffexp2html from Github</a>, open it, read the fine documentation and run it like:</p>
<pre>php ffexp2html.php somefilename.json &gt; somefilename.html</pre>
<p>Now you can open the somefile.html file with your browser (no internet connection needed). You may find a generated <a href="http://web20.it/stuff/caludio.html">output here</a>.</p>
<p>Limits? Yes there are:</p>
<ul>
<li>No download of your DMs (don&#8217;t know exactly why, maybe a limit of the API. But I don&#8217;t care)</li>
<li>You can download even entire rooms (just use the room name as the username), but it seems that there is a limit of how back you can go. Very high, but it exists.</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://claudio.cicali.name/post/2011/01/how-to-export-your-friendfeed-stream-posts-and-comments/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Convert Delicious bookmarks to CSV</title>
		<link>http://claudio.cicali.name/post/2010/12/convert-delicious-bookmarks-to-csv/</link>
		<comments>http://claudio.cicali.name/post/2010/12/convert-delicious-bookmarks-to-csv/#comments</comments>
		<pubDate>Fri, 17 Dec 2010 15:54:46 +0000</pubDate>
		<dc:creator>claudio</dc:creator>
				<category><![CDATA[Annunci]]></category>
		<category><![CDATA[Blog]]></category>
		<category><![CDATA[Programmazione]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[convert]]></category>
		<category><![CDATA[delicious]]></category>
		<category><![CDATA[english]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://claudio.cicali.name/?p=964</guid>
		<description><![CDATA[Following the news that the Delicious social bookmarking service will soon be dismissed by Yahoo!, people started wondering which other service could they use in its place and how to better export their delicious bookmarks. This post is not yet another list of sites, but I&#8217;d try to help to better manage the exodus and even gain [...]]]></description>
			<content:encoded><![CDATA[<p>Following the news that the <a href="http://delicious.com">Delicious</a> social bookmarking service will soon be dismissed by Yahoo!, people started wondering which other service could they use in its place and how to better export their delicious bookmarks. This post is not yet another list of sites, but I&#8217;d try to help to better manage the exodus and even gain something from this deliciousastrous.</p>
<p>I wrote a little script in PHP that converts your bookmarks file <a href="https://secure.delicious.com/settings/bookmarks/export">exported from Delicious</a> in some other formats. The script, if you&#8217;re in the mood, is even easily extensibile if you provide it another &#8220;driver&#8221; to convert in another format (you write it and then plug it into the script. Pretty straightforward).</p>
<p>The script is ready to be used if you need to <strong>convert the file in CSV</strong>.</p>
<p>Run it like this:</p>
<pre>php deliconv.php delicious_export.html &gt; delicious_export.csv</pre>
<p>Another idea on how to use the script would be to check every URL for its existance. It&#8217;s a pretty easy task if you know how to use the curl extension. I&#8217;ll leave it as an exercise for the reader :)</p>
<p>So, if know how to run PHP from the command line, <a href="http://lab.web20.it/uploads/deliconv.php.txt">grab the script here</a> (remove the .txt extension).</p>
<p>There is also a Delicious XML exporter, <a href="http://deliciousxml.com/">out there</a>.</p>
<p>Update: my friend <a href="http://www.nicoladagostino.net/">Nicola D&#8217;Agostino</a> has collected some other <a href="http://www.nicoladagostino.net/2010-fuga-da-delicious-come-copiare-i-dati.html">useful informations and tricks</a> on the matter.</p>
]]></content:encoded>
			<wfw:commentRss>http://claudio.cicali.name/post/2010/12/convert-delicious-bookmarks-to-csv/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using «Federated Login for Google Account Users» in your application</title>
		<link>http://claudio.cicali.name/post/2010/11/using-%c2%abfederated-login-for-google-account-users%c2%bb-in-your-application/</link>
		<comments>http://claudio.cicali.name/post/2010/11/using-%c2%abfederated-login-for-google-account-users%c2%bb-in-your-application/#comments</comments>
		<pubDate>Mon, 29 Nov 2010 09:31:14 +0000</pubDate>
		<dc:creator>claudio</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[Programmazione]]></category>
		<category><![CDATA[google]]></category>
		<category><![CDATA[integration]]></category>
		<category><![CDATA[login]]></category>
		<category><![CDATA[openid]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://claudio.cicali.name/?p=949</guid>
		<description><![CDATA[I recently had to add an authentication system to an application of mine. Another login, another password checking, another&#8230; Boooring. Given the nature of the application I decided that this time I could cut the mess down and go only with the «Use your Google account» &#8220;one click&#8221; login. Why not? Lot of people have an [...]]]></description>
			<content:encoded><![CDATA[<p>I recently had to add an authentication system to an application of mine.</p>
<p>Another login, another password checking, another&#8230; Boooring. Given the nature of the application I decided that this time I could cut the mess down and go only with the «Use your Google account» &#8220;one click&#8221; login. Why not? Lot of people have an google account already and <strong>it&#8217;s OpenID</strong>!</p>
<p>The usual Google documentation page <a href="http://code.google.com/apis/accounts/docs/OpenID.html">is this one</a>. The good news is that if you follow this guide you probably will not need to read that whole page :) Later on you should integrate this very document with the Google one.</p>
<p>The first thing to know is that you are going to write an <a href="http://openid.net/">OpenID</a> client/consumer. OpenID 2 protocol is indeed the system behind the whole client/server scenario from your application (the client) and the Google accounting system (the server). I have to assume that you know what that means (at an high level, at least). The examples here are in <strong>PHP</strong> and below I will provide some sample code for you to play with.</p>
<p>OK; so here are the relevant points:</p>
<ul>
<li>This one is theoretical, but it&#8217;s how Google deployed the OpenID protocol on top of his already existing authentication system. Normally, in a &#8220;pure&#8221; OpenID environment, during the login process the user will give you his/her openid identifier (an URL); using that identifier your program will discover (via the Yadis protocol) which is the corresponding server party to talk to for the authentication process. In the Google scenario you don&#8217;t know which is the user&#8217;s OpenID identifier (the user, of course, is not even aware that there&#8217;s something like &#8220;openid&#8221; involved in the way s/he logs in). You have NOT to ask her for her &#8220;google account&#8221;; you have to make him press a button or follow a link to &#8220;Login with your Google account&#8221;. But you DO know who you have to ask for protocol informations and not have to infer it from the user&#8217;s OpenID (technically, a discovery process is needed anyway). Upon a succesfull login you WILL have the user&#8217;s OpenID identifier; it&#8217;s something like a generated string, not choosen by the user and crafted by Google itself.</li>
<li>You need a recent OpenID library that supports OpenID 2.0 XRI and Yadis discovery. This <strong>excludes</strong> (as for now) the Zend Framework OpenID component (it does support OpenID 2.0, but not the discovery part in the version Google uses). Too bad. You then need to go straight to the <a href="http://www.janrain.com/openid-enabled">JanRain library</a></li>
<li>Don&#8217;t bother thinking about Simple Registration (SREG): Google does support the more advanced (and useful) Attribute Exchange (AX) extension only</li>
<li>Speaking of profile data, there is nothing much you can get: email, name and surname. I noticed that unless you specify each one as <em>mandatory</em> (within the AX request), the user is not even asked &#8211; by Google &#8211; to give them to you. There&#8217;s probably somethng I misunderstood, but this is it.</li>
</ul>
<p>On your side, the login process will consist of two distint phases: one that <strong>initiates</strong> the login process the and one that <strong>finalizes</strong> it.</p>
<p>Normally you point your &#8220;Login with Google&#8230;&#8221; link to the script that implements the initiation phase (let&#8217;s say &#8220;login.php&#8221;). The finalize script (let&#8217;s say &#8220;finalize.php&#8221;) will be called by the Google server as per protocol. There is a lot more to know about the OpenID process, of course, but the library should hide the gory details for you.</p>
<p>The login script will immediately and trasparently forward the user to the real Google account login page. The finalize script will have the logic that checks if the authentication has been succesfull or not and act consequently.</p>
<p>I&#8217;m about to show you some code, but keep in mind that <strong>this is NOT </strong>valid PHP code; I want you to understand what&#8217;s going on rather than being able to just copy/paste. To further limit clutter I did not even add basic error checking. Please check the JanRain library examples for full fledged (and working) code.</p>
<p>So, for the login process:</p>
<pre class="brush: php; title: ; wrap-lines: false; notranslate">
# Requires the needed JanRain scripts
require_once &quot;Auth/OpenID/Consumer.php&quot;;
require_once &quot;Auth/OpenID/FileStore.php&quot;;
require_once &quot;Auth/OpenID/AX.php&quot;;

# Setup the library (leaved blank on purpose).
# Will also create the $store variable used below
...

$consumer = new Auth_OpenID_Consumer($store);

$auth_request = $consumer-&gt;begin(&quot;https://www.google.com/accounts/o8/id&quot;);

# Create attribute request object (this is where you prepare the Attribute Exchange request)
$attribute = array();
$attribute[] = Auth_OpenID_AX_AttrInfo::make('http://axschema.org/contact/email', 2, true, 'email');
$attribute[] = Auth_OpenID_AX_AttrInfo::make('http://axschema.org/namePerson/first', 1, false, 'firstname');
$attribute[] = Auth_OpenID_AX_AttrInfo::make('http://axschema.org/namePerson/last', 1, false, 'lastname');

# Create AX fetch request
$ax = new Auth_OpenID_AX_FetchRequest();

# Add attributes to AX fetch request
foreach($attribute as $attr){
  $ax-&gt;add($attr);
}

$auth_request-&gt;addExtension($ax);

$return_to = sprintf(&quot;http://%s:%s%s/finalize.php&quot;, $_SERVER['SERVER_NAME'], $_SERVER['SERVER_PORT'], dirname($_SERVER['PHP_SELF']));
$trust_root = sprintf(&quot;http://%s:%s%s/&quot;, $_SERVER['SERVER_NAME'], $_SERVER['SERVER_PORT'], dirname($_SERVER['PHP_SELF']));

$form_html = $auth_request-&gt;htmlMarkup($trust_root, $return_to, false, array('id' =&gt; 'openid_message'));

# This will actually redirect to Google
print $form_html;
</pre>
<p>This is what I have in my finalize.php script:</p>
<pre class="brush: php; title: ; wrap-lines: false; notranslate">
# Requires the needed JanRain scripts
require_once &quot;Auth/OpenID/Consumer.php&quot;;
require_once &quot;Auth/OpenID/FileStore.php&quot;;
require_once &quot;Auth/OpenID/AX.php&quot;;

# Setup the library (leaved blank on purpose).
# Will also create the $store variable used below
...

$consumer = new Auth_OpenID_Consumer($store);

$return_to = sprintf(&quot;http://%s:%s%s/finalize.php&quot;, $_SERVER['SERVER_NAME'], $_SERVER['SERVER_PORT'], dirname($_SERVER['PHP_SELF']));
$response = $consumer-&gt;complete($return_to);

$msg = '';

switch($response-&gt;status) {

  case Auth_OpenID_CANCEL:
    # This means the authentication was cancelled by the user
    $msg = 'Verification cancelled.';
    break;

  case Auth_OpenID_FAILURE:
    $msg = &quot;OpenID authentication failed: &quot; . $response-&gt;message;
    break;

  case Auth_OpenID_SUCCESS:
    # &quot;$openid&quot; is the user openid given by Google
    $openid = $response-&gt;getDisplayIdentifier();
    $ax_resp = Auth_OpenID_AX_FetchResponse::fromSuccessResponse($response);
    # Here you could save the user data in session for further references...
    ...

    # Redirect the user to her dashboard
    header('Location: /account');
    exit();

}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://claudio.cicali.name/post/2010/11/using-%c2%abfederated-login-for-google-account-users%c2%bb-in-your-application/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Video: integrare Twitter con Drupal 6</title>
		<link>http://claudio.cicali.name/post/2010/10/video-integrare-twitter-con-drupal-6/</link>
		<comments>http://claudio.cicali.name/post/2010/10/video-integrare-twitter-con-drupal-6/#comments</comments>
		<pubDate>Sun, 24 Oct 2010 10:10:19 +0000</pubDate>
		<dc:creator>claudio</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[Multimedia]]></category>
		<category><![CDATA[Programmazione]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[drupal]]></category>
		<category><![CDATA[screencast]]></category>
		<category><![CDATA[twitter]]></category>
		<category><![CDATA[video]]></category>
		<category><![CDATA[vimeo]]></category>

		<guid isPermaLink="false">http://claudio.cicali.name/?p=841</guid>
		<description><![CDATA[In questo video presento l&#8217;installazione e la configurazione del modulo OAuth e Twitter all&#8217;interno di una fresca installazione di Drupal 6. Enjoy! Integrare Twitter con Drupal 6 from Claudio Cicali on Vimeo.]]></description>
			<content:encoded><![CDATA[<p>In questo video presento l&#8217;installazione e la configurazione del modulo OAuth e Twitter all&#8217;interno di una fresca installazione di Drupal 6. Enjoy!</p>
<div style="align: center">
<iframe src="http://player.vimeo.com/video/16136654" width="550" height="344" frameborder="0"></iframe>
<p><a href="http://vimeo.com/16136654">Integrare Twitter con Drupal 6</a> from <a href="http://vimeo.com/user749899">Claudio Cicali</a> on <a href="http://vimeo.com">Vimeo</a>.</p>
</div>
]]></content:encoded>
			<wfw:commentRss>http://claudio.cicali.name/post/2010/10/video-integrare-twitter-con-drupal-6/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>In search for a project releases announcement standard</title>
		<link>http://claudio.cicali.name/post/2010/09/project-releases-announcement-standard/</link>
		<comments>http://claudio.cicali.name/post/2010/09/project-releases-announcement-standard/#comments</comments>
		<pubDate>Tue, 07 Sep 2010 17:24:02 +0000</pubDate>
		<dc:creator>claudio</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[Programmazione]]></category>
		<category><![CDATA[Software]]></category>

		<guid isPermaLink="false">http://claudio.cicali.name/?p=834</guid>
		<description><![CDATA[Quite recently I launched a site to host a project of mine. appdate.it is meant to be sort of a &#8220;hub&#8221; for people to be costantly notified of recent releases of mainstream open source software projects (Apache httpd, MySQL, jQuery, OpenOffice, you name it&#8230;). Projects are manually added (by me), where adding a new project [...]]]></description>
			<content:encoded><![CDATA[<p>Quite recently I launched a site to host a project of mine. <a href="http://www.appdate.it"><strong>appdate.it</strong></a> is meant to be sort of a &#8220;hub&#8221; for people to be costantly notified of recent releases of mainstream open source software projects (Apache httpd, MySQL, jQuery, OpenOffice, you name it&#8230;). Projects are manually added (by me), where adding a new project means writing a quite simple Python bot that scrapes the project&#8217;s site in search for the usual info: the <span style="text-decoration: underline;">version number(s)</span>, the <span style="text-decoration: underline;">release date</span>, the <span style="text-decoration: underline;">Changelog</span>, the <span style="text-decoration: underline;">download instructions</span> (or directly the link).</p>
<p>As you may imagine this scraping process is tedious to set up and prone to errors in the medium/long period. I have to read through the HTML of the page and try to find the patterns that must be <strong>interpreted</strong> to obtain the needed information (as for the moment, the bots rely on a regular expression match system). But what if the project owner(s) redesign the site? Yeah, the bot miserably fails and calls for help (me, as usual). For example: recently Apache added an &#8220;(httpd)&#8221; string to the release page of its httpd server, and for the 2.2 version only :) The 2.0 branch still has no &#8220;httpd&#8221; string in it&#8230;</p>
<p><strong>Now I&#8217;m wondering if a system could be implemented for the project site webmaster to give a more reliable system to give project like mine a way to gather this (all in all) very little piece of information they need.</strong></p>
<p>What could be the best way to describe and publish the information about VERSION_ID, RELEASE_DATE, CHANGELOG, DOWNLOAD_URI for a project? What do you suggest? This is a short list of ideas, so far:</p>
<ul>
<li>META element(s) on the home page HTML</li>
<li>HTTP header(s) to be requested via HTTP HEAD method</li>
<li>a common, stated web service via a REST URI like http://someproject.info/info</li>
<li>an RSS dialect</li>
<li>a &#8220;standard&#8221; already exists that I&#8217;m not aware of :)</li>
</ul>
<p>Your comment would be very appreciated :)</p>
<p><strong>Updates:</strong></p>
<p>In the comments void points out the <a href="http://trac.usefulinc.com/doap">DOAP project</a>. Really interesting.</p>
]]></content:encoded>
			<wfw:commentRss>http://claudio.cicali.name/post/2010/09/project-releases-announcement-standard/feed/</wfw:commentRss>
		<slash:comments>12</slash:comments>
		</item>
		<item>
		<title>Date in italiano in PHP</title>
		<link>http://claudio.cicali.name/post/2010/02/date-in-italiano-in-php/</link>
		<comments>http://claudio.cicali.name/post/2010/02/date-in-italiano-in-php/#comments</comments>
		<pubDate>Thu, 25 Feb 2010 11:16:46 +0000</pubDate>
		<dc:creator>claudio</dc:creator>
				<category><![CDATA[Articoli]]></category>
		<category><![CDATA[Programmazione]]></category>
		<category><![CDATA[date]]></category>
		<category><![CDATA[datetime]]></category>
		<category><![CDATA[i18n]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[quikie]]></category>
		<category><![CDATA[time]]></category>

		<guid isPermaLink="false">http://claudio.cicali.name/?p=724</guid>
		<description><![CDATA[Usi date() o strftime() ma queste continuano a visualizzare il nome dei mesi e dei giorni in inglese mentre tu le vuoi vedere in italiano? Hai letto che devi usare setlocale(LC_ALL, &#8220;it_IT.utf8&#8243;); ma anche facendolo non cambia niente? Ecco cosa devi fare: devi usare solo la strftime() e non la date(), visto che quest&#8217;ultima non [...]]]></description>
			<content:encoded><![CDATA[<p>Usi <a href="http://php.net/manual/en/function.date.php">date()</a> o <a href="http://php.net/manual/en/function.strftime.php">strftime()</a> ma queste continuano a visualizzare il nome dei mesi e dei giorni in inglese mentre tu le vuoi vedere in italiano? Hai letto che devi usare setlocale(LC_ALL, &#8220;it_IT.utf8&#8243;); ma anche facendolo non cambia niente?</p>
<p>Ecco cosa devi fare:</p>
<ul>
<li><strong>devi</strong> usare solo la strftime() e non la date(), visto che quest&#8217;ultima non è sensibile al locale del sistema</li>
<li>devi verificare che il tuo sistema abbia il supporto per il locale italiano (altrimenti il nome dei mesi da dove se lo prende? Il PHP non ha mica tutti i mesi in tutte le lingue &#8220;dentro sé stesso&#8221;). Verificalo con il comando <strong>locale -a</strong>. Ti verrà visualizzata la lista di tutti i locali supportati sul tuo sistema</li>
<li>se il locale che ti serve non è presente nella lista, lo devi <em>installare</em>. Il comando è <strong>locale-gen</strong> e il parametro è il locale che ti interessa (es: <strong>locale-gen it</strong>, installerà tutti i locale italiani conosciuti, compreso quello standard e quello svizzero)</li>
<li>prendi la stringa ESATTA che identifica il locale che ti interessa e la usi come argomento della funzione PHP <strong><a href="http://php.net/manual/en/function.setlocale.php">setlocale()</a><span style="font-weight: normal;"> prima di usare la strftime</span></strong>. Esempio: <strong>setlocale(LC_TIME, &#8220;it_IT.utf8&#8243;)</strong></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://claudio.cicali.name/post/2010/02/date-in-italiano-in-php/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>SVN customized bash prompt (and Git!)</title>
		<link>http://claudio.cicali.name/post/2010/02/svn-customized-bash-prompt/</link>
		<comments>http://claudio.cicali.name/post/2010/02/svn-customized-bash-prompt/#comments</comments>
		<pubDate>Tue, 09 Feb 2010 11:37:55 +0000</pubDate>
		<dc:creator>claudio</dc:creator>
				<category><![CDATA[Annunci]]></category>
		<category><![CDATA[Articoli]]></category>
		<category><![CDATA[Programmazione]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[english]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[svn]]></category>

		<guid isPermaLink="false">http://claudio.cicali.name/?p=650</guid>
		<description><![CDATA[I recently had to split an SVN repository of mine into a TRUNK and a TAGged branch. Nothing fancy: a tag to identify the REV1.x and the TRUNK to keep developing. From time to time I have to svn switch, jumping from the tagged branch to the trunk (testing, merging, usual staff&#8230;). And you know [...]]]></description>
			<content:encoded><![CDATA[<p>I recently had to split an SVN repository of mine into a TRUNK and a TAGged branch. Nothing fancy: a tag to identify the REV1.x and the TRUNK to keep developing.</p>
<p>From time to time I have to <strong>svn switch</strong>, jumping from the tagged branch to the trunk (testing, merging, usual staff&#8230;). And you know what? I&#8217;m keeping committing on the tagged branch! And that <strong>is bad</strong> (more on this with an appropriate future post. I promise).</p>
<p>How beautiful could be having a bash prompt that will costantly display the branch I&#8217;m in and the svn repository revision of the current directory?</p>
<p>So, here we are:</p>
<p>append this code to your ~/.bashrc, logout/login and enter a svn managed directory (beware: I&#8217;ve tested it only on my Ubuntu box&#8230; the key here is to use the PROMPT_COMMAND env variabile, passing it the function that does the &#8220;sniffing&#8221;. The PROMPT_COMMAND command will be executed every time, just before displaying the shell prompt).</p>
<pre class="brush: bash; gutter: false; title: ; notranslate">
PROMPT_COMMAND=prompt_command

prompt_command() {

  if [[ -d &quot;.svn&quot; ]] ; then
    local info rev url ver
    info=$(LC_MESSAGES=C svn info 2&gt;/dev/null)
    rev=$(echo &quot;${info}&quot; | awk '/^Revision: [0-9]+/{print $2}')
    url=$(echo &quot;${info}&quot; | awk '/^URL: .*/{print $2}')

    echo ${url} | grep -q &quot;/trunk\b&quot;
    if [[ $? -eq 0 ]] ; then
      ver=trunk
    else
      echo ${url} | grep -q &quot;/tags\b&quot;
      if [[ $? -eq 0 ]] ; then
        ver=tag-$(echo ${url} | grep -o &quot;/tags.*&quot; | awk -F/ '{print $3}')
      fi
    fi

    echo -e &quot;\e[00;33m[svn:r${rev}@${ver}]\e[00m&quot;
  fi

}
</pre>
<p>The svn information will be displayed in yellow (is the 33 in the final echo line). Change it at your liking.</p>
<p>UPDATE: <a href="http://www.develer.com">Giovanni Bajo</a> gives the hints for the "-q" switch and the LC_MESSAGES trick to avoid locale inconsistences.</p>
<p>Giovanni has gone a step forward, giving us the code for a git enhanced prompt too.</p>
<p>Here it is:</p>
<pre class="brush: bash; gutter: false; title: ; notranslate">
  local gitout
  gitout=$(git branch -v --abbrev --no-color 2&gt;/dev/null)
  if [[ $? -eq 0 ]]; then
    local full branch sha1
    full=$(echo &quot;${gitout}&quot; | grep '^*')
    branch=$(echo &quot;${full}&quot; | awk '/^* \w+ \w+/{print $2}')
    sha1=$(echo &quot;${full}&quot; | awk '/^* \w+ \w+/{print $3}')
    echo -e &quot;\e[00;33m[git:${sha1}@${branch}]\e[00m&quot;
  fi
</pre>
<p>Thanks to Uqbar on Freenode IRC for the awk hints!</p>
<p>example:</p>
<pre>claudioc@enebish:~/Sites$
claudioc@enebish:~/Sites$ cd scrive2/
[svn:r452@trunk]
claudioc@enebish:~/Sites/scrive2$ svn switch $myrepos/tags/R2.4
[svn:r431@tag-R2.4]
claudioc@enebish:~/Sites/scrive2$</pre>
]]></content:encoded>
			<wfw:commentRss>http://claudio.cicali.name/post/2010/02/svn-customized-bash-prompt/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>Compilare Thunderbird</title>
		<link>http://claudio.cicali.name/post/2010/02/compilare-thunderbird/</link>
		<comments>http://claudio.cicali.name/post/2010/02/compilare-thunderbird/#comments</comments>
		<pubDate>Mon, 08 Feb 2010 08:52:15 +0000</pubDate>
		<dc:creator>claudio</dc:creator>
				<category><![CDATA[Articoli]]></category>
		<category><![CDATA[Programmazione]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[thunderbird]]></category>

		<guid isPermaLink="false">http://claudio.cicali.name/?p=645</guid>
		<description><![CDATA[Thunderbird: per diversi motivi, tra cui il pieno supporto ai 64bit e l&#8217;integrazione con Calendar (Sunbird) che mi permette di tenere sincronizzato anche il calendario di Google, preferisco sempre compilare la mia versione. Non ci vuole molto, una volta che sai quello che ti serve e dove prenderlo. Ti scarichi la versione che ti interessa [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.mozillamessaging.com">Thunderbird</a>: per diversi motivi, tra cui il pieno supporto ai 64bit e l&#8217;integrazione con Calendar (Sunbird) che mi permette di tenere sincronizzato anche il calendario di Google, preferisco sempre compilare la mia versione. Non ci vuole molto, una volta che sai quello che ti serve e dove prenderlo.</p>
<p>Ti scarichi la versione che ti interessa dal repository delle <a href="http://releases.mozilla.org/pub/mozilla.org/thunderbird">versioni di Thunderbird</a> (che non è facile da trovare, inspiegabilmente).</p>
<p>Te lo scompatti da qualche parte (io uso ~/opt).</p>
<p>Ti accerti di avere installati i seguenti pacchetti (Ubuntu)</p>
<div id="_mcePaste">
<ul>
<li>build-essential</li>
<li>libgtk2.0-dev</li>
<li>libdbus-glib-1-dev</li>
<li>libxt-dev</li>
<li>libidl-dev</li>
</ul>
</div>
<p>Te lo configuri con il seguente comando:</p>
<pre>./configure --enable-application=mail --with-system-bz2 --with-system-zlib --with-system-jpeg --enable-calendar --disable-ldap --enab
le-official-branding --disable-accessibility --disable-ogg --disable-wave --disable-inspector-apis --disable-installer --disable-upda
ter --disable-tests --disable-parental-controls  --disable-logging --disable-necko-wifi</pre>
<p>Ovviamente dai un&#8217;occhiata ai parametri perché potrebbero non essere tutti di tuo gradimento (hint: <strong>./configure &#8211;help | less</strong>).</p>
<p>Esegui <strong>make</strong> e attendi una <span style="text-decoration: underline;">quindicina di minuti</span>.</p>
<p>Il binario di Thunderbird te lo trovi poi in ~/opt/thunderbird-3.0/comm-1.9.1/mozilla/dist/bin/thunderbird</p>
]]></content:encoded>
			<wfw:commentRss>http://claudio.cicali.name/post/2010/02/compilare-thunderbird/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Use Facebook Connect in your application</title>
		<link>http://claudio.cicali.name/post/2010/01/use-facebook-connect-in-your-application/</link>
		<comments>http://claudio.cicali.name/post/2010/01/use-facebook-connect-in-your-application/#comments</comments>
		<pubDate>Mon, 25 Jan 2010 08:00:12 +0000</pubDate>
		<dc:creator>claudio</dc:creator>
				<category><![CDATA[Articoli]]></category>
		<category><![CDATA[Programmazione]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[connect]]></category>
		<category><![CDATA[facebook]]></category>
		<category><![CDATA[how to]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://claudio.cicali.name/?p=615</guid>
		<description><![CDATA[Recently I&#8217;ve got to enable one site of mine with this &#8220;Facebook Connect&#8221; thingy, my primary goal being the increase of the conversion rate, in the way that people could use their Facebook account to log into my web site without a need for a boring registration process. Just click two buttons, and you&#8217;re in. [...]]]></description>
			<content:encoded><![CDATA[<p>Recently I&#8217;ve got to enable one site of mine with this &#8220;<a href="http://developers.facebook.com/connect.php">Facebook Connect</a>&#8221; thingy, my primary goal being the increase of the conversion rate, in the way that people could use their Facebook account to log into my web site without a need for a boring registration process. Just click two buttons, and you&#8217;re in. If a person had a site account already, I&#8217;ll give him the opportunity to merge her Facebook account with the old one. Eventually, upon a succesfull &#8220;connect&#8221; round, a new account would be created within my application. It&#8217;s a cute <em>www</em>: a web win-win.</p>
<p>That is all what I needed, from Facebook: I do not need any fancy &#8220;get your friends here&#8221; or &#8220;post in your wall&#8221; rubbish. Simple and plain &#8220;single sign on&#8221;, among Facebook and my application.</p>
<p>After a quick search, the tutorials I found <a href="http://www.goldsteintech.com/facebook_connect/tutorial.php">here</a> and there were very <em>disappointing</em> (just a point of view, no offense), with a lot of useless PHP code. So I give you just one more tutorial that focuses more on the process than in the copy &amp; paste kind of help.</p>
<p>I will use PHP for some examples, and FB for &#8220;Facebook&#8221; so bear with me and give it a spin.</p>
<p>What you need:</p>
<ul>
<li>a FB account, if you don&#8217;t own one already. Unlikely; I&#8217;ll skip this step :)</li>
<li>a new FB application need to be created</li>
<li>the FB PHP library, to easily talk to their RESTful API</li>
<li>Some code refactoring of your own</li>
</ul>
<h3><strong>Creating a new FB application.</strong></h3>
<p>Two paths, here:</p>
<ul>
<li>the <a href="http://www.facebook.com/developers/createapp.php">long and detailed multistep form</a></li>
<li><a href="http://www.facebook.com/developers/createapp.php"></a>the <a href="http://developers.facebook.com/setup.php">super easy wizard</a></li>
</ul>
<p>Note that, whichever way you&#8217;ll choose, you will end up creating the exact same thing: an FB application (all your applications are stored <a href="http://www.facebook.com/developers/">here</a>).</p>
<p>We&#8217;ll use <strong>the wizard</strong>:</p>
<ul>
<li>the <strong>website name</strong> is just the name of the application (the handle by which you&#8217;ll refer to it in the application list).</li>
<li>the <strong>website url</strong> is self explanatory. Note that you could use ANY kind of URL, even something like &#8220;http://myapplication.localdomain&#8221;. In fact, FB will not need to contact the site, so you can use an development URL as well. For the test purposes I created two applications: one for the &#8220;real thing&#8221; and one for the mydomain.local devel environment.</li>
</ul>
<p>The next step will ask you to download a file. You can put the file WHEREVER you want. The root directory of your site is the first choice, and it&#8217;s where the wizard will try to find it. There&#8217;s no need for the wizard to find the file, though: it&#8217;s only a test. You can download the file and skip the test pressing &#8220;<em>Upload later</em>&#8220;. Two words about that particular file: the file is part of the system that permits our application to be proxied to FB (and vice-versa). I will not enter in details here, but think about this file as your &#8220;gateway&#8221; to and from the FB requests (<a href="http://wiki.developers.facebook.com/index.php/Cross_Domain_Communication_Channel">more info</a>). The other thing is: there is NOTHING in that file that identifies you application. Every FB application of the world could use the same xd_receiver.htm file. The file name itself is not important&#8230; it&#8217;s just the default. More on this later.</p>
<p>The third step is the landing page for your newly created FB application. Just a comfy place to pick things up. You need to write down the <strong>API KEY</strong> and the <strong>SECRET</strong> strings. You&#8217;ll use them from within your application.</p>
<p>What you also need to take from this page is the JavaScript snippet at point 1) and the <a href="http://wiki.developers.facebook.com/index.php/Category:FBML_tags">FBML</a> markup for the &#8220;Connect with Facebook&#8221; button at point 2).</p>
<p>Enough for the FB setup.</p>
<h3><strong>The FB PHP Library and the FB API</strong></h3>
<p>This is a set of helper PHP classes that will give you a simple PHP API interface to the <a href="http://wiki.developers.facebook.com/index.php/API">RESTful FB API</a>. You could even NOT use the library, and talk directly to the REST endpoints with some code of your own. Your choice.<br />
The FB API are <a href="http://wiki.developers.facebook.com/index.php/API">documented here</a>, while you can download the latest version of the PHP 5 Library via SVN</p>
<pre class="brush: jscript; light: true; title: ; wrap-lines: false; notranslate">
svn co http://svn.facebook.com/svnroot/platform/clients/php/trunk/ fb
</pre>
<p> (more info on <a href="http://wiki.developers.facebook.com/index.php/User:Client_Libraries">FB Client libraries</a>)</p>
<p>We are finally ready to get our hands dirty.</p>
<h3><strong>Hands on the code</strong></h3>
<p>We first need to focus on how things works, at an higher level. What will happen when a not logged-in user will click the &#8220;Connect with Facebook&#8221; button? Using some sort of <em>magic</em> Facebook will test if the user is currently logged in Facebook. If it&#8217;s not, it will spawn a <em>popup window</em> asking two things: the user has to agree to give your application access to her data, and after that Facebook will ask her for credential (username/password, as usual). Upon a succesful login, FB will redirect the user to your application toward an url of your choice (let&#8217;s call it the &#8220;<em>FB Connect endpoint</em>&#8220;).<br />
If the user is already logged in Facebook and has already given permission to our application to read some of her data, the login process will be completely transparent. The user clicks on our FB blue-ish button, and he will be instantly logged in our application too. Oh, joy.</p>
<p>As for the HTML part, you will place the FBML markup for the login button you got beforehand wherever you want. The FBML have to be programmatically converted in HTML by JavaScript, and for that to work you need to include the JavaScript snippet you already have. Put it at the end of your &lt;body&gt;, for example, and then run the FB.init() function. This function will be passed two parameters: the API KEY and the name and location of the &#8220;gateway&#8221; file. As said before, if the second parameter is not passed, the default is &#8220;xd_receiver.htm&#8221; on the document root.</p>
<pre class="brush: jscript; highlight: [2]; title: ; wrap-lines: false; notranslate">
  &lt;!-- The login button, somewhere in your page --&gt;
  &lt;fb:login-button onlogin=&quot;window.location='/fbconnect.php';&quot; v=&quot;2&quot; size=&quot;medium&quot;&gt;Login with Facebook&lt;/fb:login-button&gt;
  ...
  &lt;!-- At the page end of the page, presumibly --&gt;
  &lt;script src=&quot;http://static.ak.connect.facebook.com/js/api_lib/v0.4/FeatureLoader.js.php/en_US&quot;&gt;&lt;/script&gt;
  &lt;script&gt;
    FB.init(&quot;b4bbr43b4bb3b3b3&quot;);
  &lt;/script&gt;
&lt;/body&gt;
&lt;/html&gt;
</pre>
<p>The interesting part, here, is in the highlighted row. The <strong>onlogin</strong> attribute contains what we pretentiously called the &#8220;FB Connect endpoint&#8221;. The onlogin attribute value is a JavaScript snippet that will be automatically run after a succesfull FB login. What we say here is: after a login, please redirect the user to our &#8220;fbconnect.php&#8221; page.<br />
The fbconnect.php page is where <em>OUR magic</em> will happen. There, we will use the FB Client API to ask FB some questions: &#8220;Is this guy a Facebook, logged in user?&#8221;, &#8220;Can you please give me the picture of him?&#8221;&#8230; and so on.<br />
The code, here, is given only as an example; think about it more as a <em>pseudocode,</em> really. The actual code I use is somewhat more complex, and I needed to dumb it down a little for clarity.</p>
<pre class="brush: php; title: ; wrap-lines: false; notranslate">
require(&quot;fb/facebook.php&quot;);
$fb = new Facebook(&quot;b4bbr43b4bb3b3b3&quot;, &quot;supersecret1234&quot;);
/* If it's present, ask FB for the ID of the current user */
$fbId = $fb-&gt;get_loggedin_user();
if (empty($fbId)) {
  /* No FB user, redirect to home page */
  header(&quot;Location: /&quot;);
}
/* Now we know the FB user id.
   It's our responsability to ask our Database if we already know him */
</pre>
<p>You need to have a way to find one user of yours given its FB user id. For instance I used a &#8220;fb_id&#8221; column in my Users table.</p>
<p>What happens now is up to you. There will presumably be two major cases:</p>
<ol>
<li>the user already exists: I programmatically login him into my application, and redirect to the home page as a logged in user.</li>
<li>the user does not exist: I give her the choice to merge her old account or to create a new one</li>
</ol>
<p>For the merge part, I need him to login with his credentials and then update the Users table with his FB id.</p>
<p>For the registration part, I luckily do not need anything else that FB can&#8217;t give me; so it&#8217;s a matter of pushing a button. The code is something like that:</p>
<pre class="brush: php; title: ; wrap-lines: false; notranslate">
$fbInfo = $fb-&gt;api_client-&gt;users_getInfo($fbId, array('name', 'pic_square', 'proxied_email'));
$model = new User();
$name = $fbInfo['name'];
$tries=1;
# find a unique username
do {
  $user = $model-&gt;fetchRow($model-&gt;select()-&gt;where('username=?', $name));
  if (!$user)
    break;
  else
    $name = $name . ($tries++);
} while(TRUE);
$user = $model-&gt;createRow();
$user-&gt;username = $name;
$user-&gt;avatar = $fbInfo['pic_square'];
$user-&gt;name = $fbInfo['name'];
$user-&gt;fb_proxy_email = $fbInfo['proxied_email'];
$user-&gt;fb_id = $fbId;
...
$user-&gt;save();
...
</pre>
<p>Finally, let me complain a bit: I find writing code that interacts with Facebook a very frustrating experience. The information you need is scattered all over the web (and the Facebook site itself, even), and examples quality is very poor. The technology behing FB is very sophisticated, though, and no matter what they try to do, you need to grasp some concepts that are sometimes quite difficult to master or a nightmare to debug.</p>
<p>Good luck.</p>
<h3>Further readings</h3>
<ul>
<li><a href="http://developers.facebook.com/connect.php">The official Facebook Connect page</a> (and the developers <a href="http://wiki.developers.facebook.com/index.php/Facebook_Connect">Wiki one</a>)</li>
<li><a href="http://wiki.developers.facebook.com/index.php/How_Connect_Authentication_Works">How Connect Authentication Works</a></li>
<li><a href="http://mashable.com/2009/01/12/facebook-connect-implementations/">10 Great Implementations of Facebook Connect</a></li>
<li>What is behind <a href="http://wiki.developers.facebook.com/index.php/Cross_Domain_Communication">Cross Domain Communication</a> and <a href="http://msdn.microsoft.com/en-us/library/bb735305.aspx">even more</a></li>
<li><a href="http://wiki.developers.facebook.com/index.php/API">Facebook API</a> documentation</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://claudio.cicali.name/post/2010/01/use-facebook-connect-in-your-application/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
	</channel>
</rss>

