<?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>Flying memes</title>
	<atom:link href="http://sandropaganotti.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://sandropaganotti.com</link>
	<description>Just another WordPress weblog</description>
	<lastBuildDate>Sun, 08 Jan 2012 16:00:34 +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>Copy with Style bundle now available for TextMate 2</title>
		<link>http://sandropaganotti.com/2012/01/08/copy-with-style-bundle-now-available-for-textmate-2/</link>
		<comments>http://sandropaganotti.com/2012/01/08/copy-with-style-bundle-now-available-for-textmate-2/#comments</comments>
		<pubDate>Sun, 08 Jan 2012 15:59:55 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Annunci]]></category>
		<category><![CDATA[bundle]]></category>
		<category><![CDATA[copy with style]]></category>
		<category><![CDATA[textmate 2]]></category>

		<guid isPermaLink="false">http://sandropaganotti.com/?p=570</guid>
		<description><![CDATA[I&#8217;ve always owned a debt of gratitude to Bartosz Blimke and his amazingly simple &#8216;copy with style&#8217; Textmate bundle which lets you copy and paste chunks of code to external programs (eg: Keynote) while keeping all the syntax highlight working. Today I was disappointed discovering that this bundle is no longer working on Textmate 2, so I [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve always owned a debt of gratitude to <a href="https://github.com/bblimke">Bartosz Blimke</a> and his amazingly simple &#8216;copy with style&#8217; Textmate bundle which lets you copy and paste chunks of code to external programs (eg: Keynote) while keeping all the syntax highlight working.</p>
<p><span id="more-570"></span><br />
Today I was disappointed discovering that this bundle is no longer working on Textmate 2, so <a href="https://github.com/sandropaganotti/copy-with-style-tmbundle/tree/textmate-2">I forked the original repository</a> and made the necessary changes to bring back to work this bundle.</p>
<p>You can install with this simple instructions:</p>
<pre><code>
mkdir -p ~/Library/Application\ Support/Avian/Pristine\ Copy
cd ~/Library/Application\ Support/Avian/Pristine\ Copy/
git clone -b textmate-2 https://github.com/sandropaganotti/copy-with-style-tmbundle.git "Copy with Style.tmbundle"
</code></pre>
<p>To make this work remember to switch Textmate 2 chosen theme at least once in order to make the necessary preference be saved in .plist file (it&#8217;s still in alpha <img src='http://sandropaganotti.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> .</p>
]]></content:encoded>
			<wfw:commentRss>http://sandropaganotti.com/2012/01/08/copy-with-style-bundle-now-available-for-textmate-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Handling thousands of pics from a mobile device</title>
		<link>http://sandropaganotti.com/2011/11/27/handling-thousands-of-pics-from-a-mobile-device/</link>
		<comments>http://sandropaganotti.com/2011/11/27/handling-thousands-of-pics-from-a-mobile-device/#comments</comments>
		<pubDate>Sun, 27 Nov 2011 21:25:21 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Algoritmi]]></category>
		<category><![CDATA[Approfondimenti]]></category>
		<category><![CDATA[canvas]]></category>
		<category><![CDATA[lot of images]]></category>
		<category><![CDATA[mobile safari]]></category>

		<guid isPermaLink="false">http://sandropaganotti.com/?p=561</guid>
		<description><![CDATA[Lately I&#8217;ve been involved into a fascinating project called PepperTweet which consist in extract and visualize streams of pics from twitter starting from some search keywords. While working on a new visualization algorithm I discovered how easy it is to make mobile browsers crash trying to display a relative small amount of images.  I&#8217;ve used an [...]]]></description>
			<content:encoded><![CDATA[<p>Lately I&#8217;ve been involved into a fascinating project called <a href="http://peppertweet.com/" target="_blank">PepperTweet</a> which consist in extract and visualize streams of pics from twitter starting from some search keywords.</p>
<p><span id="more-561"></span>While working on a new visualization algorithm I discovered how easy it is to make mobile browsers crash trying to display a relative small amount of images.  I&#8217;ve used an IPad 1 with IOs 5 for my tests, so with other devices the results may vary but I think the point is the same, there are two main problems while handling a lot of images from a mobile browser:</p>
<h3>Loading rate:</h3>
<p>If I load <a href="http://jsfiddle.net/sandro_paganotti/GMs4d/embedded/result/" target="_blank">this simple javascript code</a> in my IPad mobile safari just crash, this is because (imho) the device is not able to handle such a big image loading rate and goes into some form of buffer overflow.</p>
<p><iframe style="width: 100%; height: 300px;" src="http://jsfiddle.net/sandro_paganotti/GMs4d/embedded/js" frameborder="0" width="320" height="240"></iframe></p>
<h3>Image quantity:</h3>
<p>Using the same image (notice how in the previous example I&#8217;ve appended a random number after each image URL in order to force its download) I was able to hit another limit, the maximum number of images a mobile device can display simultaneously, <a href="http://jsfiddle.net/sandro_paganotti/brj6m/2/embedded/result/" target="_blank">this code</a> which tries to print 500 images made my mobile browser freeze:</p>
<p><iframe style="width: 100%; height: 300px;" src="http://jsfiddle.net/sandro_paganotti/brj6m/2/embedded/js" frameborder="0" width="320" height="240"></iframe></p>
<h3>A workaround:</h3>
<p>I&#8217;ve managed to load and show thousands of images using canvas, in the following example each image is loaded, printed on canvas and the discarded, also the number of concurrent loads is limited to avoid browser crash, <a href="http://jsfiddle.net/sandro_paganotti/rrdFt/4/embedded/result/" target="_blank">this example</a> uses 10000 images but I think higher image quantities can be easily reached:</p>
<p><iframe style="width: 100%; height: 300px;" src="http://jsfiddle.net/sandro_paganotti/rrdFt/4/embedded/js,result" frameborder="0" width="320" height="240"></iframe></p>
<h3>Some refinements:</h3>
<p>It seems that mobile Safari cannot handle canvas bigger than a certain value (<a href="http://jsfiddle.net/sandro_paganotti/rrdFt/5/embedded/result/" target="_blank">try this</a>), to handle this problem one solution could be using the &#8216;<a href="http://www.w3.org/TR/html5/the-canvas-element.html#dom-canvas-todataurl" target="_blank">toDataUrl</a>&#8216; method when the canvas is full of pics in order to extract a screenshot. Then this screnneshot can be added to the page before the canvas so the canvas can be cleaned and reused for the upcoming pics.</p>
]]></content:encoded>
			<wfw:commentRss>http://sandropaganotti.com/2011/11/27/handling-thousands-of-pics-from-a-mobile-device/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Real time twitter data visualization with Processing.js</title>
		<link>http://sandropaganotti.com/2011/10/25/real-time-twitter-data-visualization-with-processing-j/</link>
		<comments>http://sandropaganotti.com/2011/10/25/real-time-twitter-data-visualization-with-processing-j/#comments</comments>
		<pubDate>Mon, 24 Oct 2011 22:30:30 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Annunci]]></category>
		<category><![CDATA[Interfaccie]]></category>
		<category><![CDATA[data visualization]]></category>
		<category><![CDATA[Processing]]></category>
		<category><![CDATA[real time]]></category>
		<category><![CDATA[twitter]]></category>

		<guid isPermaLink="false">http://sandropaganotti.com/?p=553</guid>
		<description><![CDATA[Lately I&#8217;ve been pretty busy enjoying some real time data visualization examples and demo. To have some data to work with I decided to use Twitter API, in particular I rely on jQuery LiveTwitter plugin by elektronaut; next I built a stack chart like visualization in which every new tweet of a chosen topic is [...]]]></description>
			<content:encoded><![CDATA[<p>Lately I&#8217;ve been pretty busy enjoying some real time data visualization examples and demo. To have some data to work with I decided to use Twitter API, in particular I rely on <a href="http://elektronaut.github.com/jquery.livetwitter/" target="_blank">jQuery LiveTwitter plugin</a> by elektronaut; next I built a stack chart like visualization in which every new tweet of a chosen topic is dropped over its language column.</p>
<p><span id="more-553"></span></p>
<p style="text-align: left;">To create the view I used Processing.js, which is very easy and simple to work with. Here&#8217;s a screenshot of the completed application:</p>
<p style="text-align: center;"><img class="aligncenter size-full wp-image-554" title="processing js real time infographic" src="http://sandropaganotti.com/wp-content/uploads/2011/10/ishot-586.png" alt="" width="600" height="358" /></p>
<p style="text-align: left;">The application is also featured in Processing.js <a href="http://processingjs.org/exhibition" target="_blank">exhibition page</a> and a <a href="http://javascript.html.it/guide/leggi/216/canvas-guida-pratica/" target="_blank">guide (in italian)</a> is undergoing with all the technical details about its implementation.</p>
]]></content:encoded>
			<wfw:commentRss>http://sandropaganotti.com/2011/10/25/real-time-twitter-data-visualization-with-processing-j/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using the :required pseudo selector to enhance forms</title>
		<link>http://sandropaganotti.com/2011/08/14/using-the-required-pseudo-selector-to-enhance-forms/</link>
		<comments>http://sandropaganotti.com/2011/08/14/using-the-required-pseudo-selector-to-enhance-forms/#comments</comments>
		<pubDate>Sun, 14 Aug 2011 11:29:35 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Interfaccie]]></category>
		<category><![CDATA[css3]]></category>
		<category><![CDATA[form]]></category>
		<category><![CDATA[required]]></category>

		<guid isPermaLink="false">http://sandropaganotti.com/?p=542</guid>
		<description><![CDATA[Lately I come up with this idea on how to enhance a form by using the :required pseudo element. What you can do is mix this new pseudo element with the &#8216;+&#8217; selector in order to modify elements that are adjacent to your input tag, such as the label. Here&#8217;s an example: input:required + label:after [...]]]></description>
			<content:encoded><![CDATA[<p>Lately I come up with this idea on how to enhance a form by using the <a href="http://www.w3.org/TR/css3-ui/#pseudo-required-value">:required</a> pseudo element. What you can do is mix this new pseudo element with the <a href="http://www.w3schools.com/cssref/sel_element_pluss.asp">&#8216;+&#8217;</a> selector in order to modify elements that are adjacent to your input tag, such as the label.</p>
<p><span id="more-542"></span>Here&#8217;s an example:</p>
<pre><code class="css">
input:required + label:after {
  content: ' *';
  color: black;
}
</code></pre>
<p>By this way you are able to dynamically append the classic &#8216;*&#8217; to the labels that belongs to input tags with the required flag. Obviously you have to put the label after the input tag but then you can revert this structure by using some CSS float instructions.</p>
<p>Here&#8217;s the running example:</p>
<p><iframe style="width: 100%; height: 300px;" src="http://jsfiddle.net/sandro_paganotti/9tyhz/3/embedded/css,html,result" width="320" height="240"></iframe></p>
]]></content:encoded>
			<wfw:commentRss>http://sandropaganotti.com/2011/08/14/using-the-required-pseudo-selector-to-enhance-forms/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>A pure CSS3 coverflow effect for Chrome, Firefox and Safari</title>
		<link>http://sandropaganotti.com/2011/08/05/a-pure-css3-coverflow-effect-for-chrome-firefox-and-safari/</link>
		<comments>http://sandropaganotti.com/2011/08/05/a-pure-css3-coverflow-effect-for-chrome-firefox-and-safari/#comments</comments>
		<pubDate>Thu, 04 Aug 2011 22:23:52 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Interfaccie]]></category>
		<category><![CDATA[coverflow]]></category>
		<category><![CDATA[css3]]></category>
		<category><![CDATA[transform]]></category>
		<category><![CDATA[transition]]></category>

		<guid isPermaLink="false">http://sandropaganotti.com/?p=516</guid>
		<description><![CDATA[I&#8217;ve been recently playing with some of the newest CSS3 features, such as pseudoclasses selectors, transition and transform properties and attr(). In order to have something concrete on which test these features  I created a coverflow effect that works only out of CSS instructions without the use of javascript. I used some of the amazing [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been recently playing with some of the newest CSS3 features, such as <a href="http://www.w3.org/TR/css3-selectors/" target="_blank">pseudoclasses selectors</a>, <a href="http://www.w3.org/TR/css3-transitions/" target="_blank">transition</a> and <a href="http://dev.w3.org/csswg/css3-3d-transforms/" target="_blank">transform</a> properties and <a href="http://www.w3.org/TR/css3-values/#attribute" target="_blank">attr()</a>. In order to have something concrete on which test these features  I created <a href="http://sandropaganotti.com/wp-content/goodies/demos/cards/index.html#aela" target="_blank">a coverflow effect that works only out of CSS instructions without the use of javascript</a>.</p>
<p><span id="more-516"></span><br />
I used some of the amazing CSS 3D transformations to archieve this effect under WebKit based browsers. Here&#8217;s a snippet from the page:</p>
<pre><code class="css"> 
  #container{
     margin: 0 auto;
     width: 100%;
     height: 90%;
     max-width: 1024px;
     -webkit-transform-style: preserve-3d;
     -webkit-perspective: 900;
     -webkit-perspective-origin: 100% 30%;
  }
</code></pre>
<p>The container, which is the div that hold the rest of the elements, has some <a href="http://www.webkit.org/blog/386/3d-transforms/" target="_blank">-webkit-*</a> experimental properties that set the position and the distance of the point of view of the user from the scene, as much as it happens with 3D software.</p>
<p>After this each card needs to be rotated against its Y axes; here comes to rescue another CSS3 property:</p>
<pre><code class="css">
  .card{
     -webkit-transform: rotateY( 120deg);
  }
</code></pre>
<p>Then, all you need is find a way to trigger a change of CSS properties in your .card elements while specifying a transition which handles this change smoothly. So first let&#8217;s add this transition:</p>
<pre><code class="css">
  .card{
     -webkit-transition: all 1s ease-out;
  }
</code></pre>
<p>And then let&#8217;s use the :target pseudoclass which gets applied to an &lt;a&gt; element when its name became part of the URL (either because clicked or typed):</p>
<pre><code class="css">
  .card:target{
    -webkit-transform: rotateY( 0deg);
  }
</code></pre>
<p><img src="http://sandropaganotti.com/wp-content/uploads/2011/08/ishot-516-1024x601.png" alt="" title="ishot-516" width="600" class="aligncenter size-large wp-image-535" /></p>
<p>The trickiest part is then try to make this thing works also under Firefox which doesn&#8217;t have 3D transformations. It turns out that you can emulate them by using wisely the skew(xdeg, ydeg) transform, so you can do the following:</p>
<pre><code class="css">
  .card{
     -moz-transform: skew(0deg,-35deg) scale(0.70);
  }
  .card:target{
     -moz-transform: skew(0deg,0deg) scale(1);
  }
</code></pre>
<p>Good, but now there&#8217;s another challenge: how to solve this ?</p>
<p><img src="http://sandropaganotti.com/wp-content/uploads/2011/08/ishot-513-1024x611.png" alt="" title="ishot-513" width="600" class="aligncenter size-large wp-image-526" /></p>
<p>The elements on the right side of the selected one have two issues: they should be inclined on the opposite angle and the way they overlap each other should also be reversed. </p>
<p>To solve the first part we can rely on the <a href="http://w3schools.com/cssref/sel_gen_sibling.asp" target="_blank">~ selector</a> to tell the browser that each element following the selected one must obey to a different skew angle:</p>
<pre><code class="css">
  .card:target ~ .card{
    -moz-transform: skew(0deg,20deg) scale(0.70);
  }
</code></pre>
<p><img src="http://sandropaganotti.com/wp-content/uploads/2011/08/ishot-514-1024x611.png" alt="" title="ishot-514" width="600" class="aligncenter size-large wp-image-529" /></p>
<p>The only solution I found to archive the second issue is to use the <a href="http://w3schools.com/cssref/sel_element_pluss.asp" target="_blank">+ selector</a> iteratively in order to assign a z-index to an element based on its distance from the selected one: </p>
<pre><code class="css">
  .card:target + .card{
    z-index: 10;
  }

  .card:target + .card + .card{
    z-index: 9;
  }

  .card:target + .card + .card + .card {
    z-index: 8;
  }

  .card:target + .card + .card + .card + .card{
    z-index: 7;
  }

  .card:target + .card + .card + .card + .card + .card{
    z-index: 6;
  }

  .card:target + .card + .card + .card + .card + .card + .card{
    z-index: 5;
  }

  .card:target + .card + .card + .card + .card + .card + .card + .card{
    z-index: 4;
  }

  .card:target + .card + .card + .card + .card + .card + .card + .card + .card{
    z-index: 3;
  }

  .card:target + .card + .card + .card + .card + .card + .card + .card + .card + .card{
    z-index: 2;
  }

  .card:target + .card + .card + .card + .card + .card + .card + .card + .card + .card + .card{
    z-index: 1;
  }
</code></pre>
<p>Here&#8217;s the final result:<br />
<img src="http://sandropaganotti.com/wp-content/uploads/2011/08/ishot-515-1024x611.png" alt="" title="ishot-515" width="600" class="aligncenter size-large wp-image-532" /></p>
<p>You can have a working demo at this address:<br />
<a href="http://sandropaganotti.com/wp-content/goodies/demos/cards/index.html#aela" target="_blank">http://sandropaganotti.com/wp-content/goodies/demos/cards/index.html#aela</a></p>
]]></content:encoded>
			<wfw:commentRss>http://sandropaganotti.com/2011/08/05/a-pure-css3-coverflow-effect-for-chrome-firefox-and-safari/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Playing with media queries</title>
		<link>http://sandropaganotti.com/2011/07/09/playing-with-media-queries/</link>
		<comments>http://sandropaganotti.com/2011/07/09/playing-with-media-queries/#comments</comments>
		<pubDate>Sat, 09 Jul 2011 01:10:23 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Interfaccie]]></category>

		<guid isPermaLink="false">http://sandropaganotti.com/?p=503</guid>
		<description><![CDATA[I recently created a small website called &#8216;La piccola biblioteca della natura&#8217; to showcase some of my girlfriend watercolors. I decided to go for a responsive design and set up some nice media-query statements. If you try to resize the browser window you surely notice how the structure of the fruits change in response to [...]]]></description>
			<content:encoded><![CDATA[<p>I recently created a small website called <a href="http://piccolabiblioteca.nijiart.it/" target="_blank">&#8216;La piccola biblioteca della natura&#8217;</a> to showcase some of my <a href="http://nijiart.it/" target="_blank">girlfriend</a> watercolors. I decided to go for a responsive design and set up some nice media-query statements. If you try to resize the browser window you surely notice how the structure of the fruits change in response to this operation.</p>
<p><span id="more-503"></span></p>
<p>&nbsp;</p>
<p style="text-align: center;"><img class="aligncenter size-large wp-image-507" title="ishot-460" src="http://sandropaganotti.com/wp-content/uploads/2011/07/ishot-4601-1024x717.png" alt="" width="614" height="430" /></p>
<p>To archive this result I played a bit with clear and float properties by adding them to some specific elements, here&#8217;s a sample:</p>
<p>The .cestello HTML structure:</p>
<pre>&lt;div class="cestello"&gt;
    &lt;div&gt;
        &lt;a href="#arancia" onclick="PB.to('#arancia');return false;"&gt;
            &lt;img src="img/arancia-small.png" alt="arancia"&gt;
        &lt;/a&gt;
    &lt;/div&gt;
    &lt;div&gt;
        &lt;a href="#banana" onclick="PB.to('#banana');return false;"&gt;
            &lt;img src="img/banana-small.png" alt="banana"&gt;
        &lt;/a&gt;
    &lt;/div&gt;
    &lt;!-- other divs --&gt;
&lt;/div&gt;</pre>
<p>And the corresponding CSS code:</p>
<pre>.cestello{
  float:left;
  width: 100%;
}

@media screen and (min-width:480px) and (max-width:960px){
  .cestello div{
     width: 33%;
  }
  .cestello div:nth-of-type(3){
    clear: right;
  }
  .cestello div:nth-of-type(4){
    clear: left;
  }
}

@media screen and (max-width:480px){
  .cestello{
    float:none;
    width: 80%;
    margin-left: auto;
    margin-right: auto;
  }

  .cestello div{
     width: 50%;
  }
  .cestello div:nth-of-type(even){
    clear: right;
  }
  .cestello div:nth-of-type(odd){
    clear: left;
  }
}</pre>
<p>Here you find the three statuses in which the &#8216;.cestello&#8217; structure may be found. By using some clever CSS3 selector I&#8217;m able to inject &#8216;clear:right&#8217; and &#8216;clear:left&#8217; and change the aspect of the page.</p>
]]></content:encoded>
			<wfw:commentRss>http://sandropaganotti.com/2011/07/09/playing-with-media-queries/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>HTML5 Augmented Reality: fuzzy results</title>
		<link>http://sandropaganotti.com/2011/05/12/html5-augmented-reality-fuzzy-results/</link>
		<comments>http://sandropaganotti.com/2011/05/12/html5-augmented-reality-fuzzy-results/#comments</comments>
		<pubDate>Thu, 12 May 2011 21:34:26 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Algoritmi]]></category>
		<category><![CDATA[Augmented Reality]]></category>
		<category><![CDATA[DeviceOrientationAPI]]></category>

		<guid isPermaLink="false">http://sandropaganotti.com/?p=491</guid>
		<description><![CDATA[I spent a few hours trying to figure out how to deal with the brand new deviceorientation API in order to obtain a nice Augmented Reality effect. First I searched on how to convert Euler Angles to Cartesian Coordinates and I found a nice article about that, then I downloaded the very nice Sylvester library [...]]]></description>
			<content:encoded><![CDATA[<p>I spent a few hours trying to figure out how to deal with the brand new <a href="http://dev.w3.org/geo/api/spec-source-orientation.html">deviceorientation API</a> in order to obtain a nice Augmented Reality effect. First I searched on how to convert Euler Angles to Cartesian Coordinates and I found a <a href="http://www.euclideanspace.com/maths/geometry/rotations/euler/index.htm">nice article about that</a>, then I downloaded the very nice <a href="http://sylvester.jcoglan.com/">Sylvester</a> library which lets you compute matrix operations in Javascript.</p>
<p><span id="more-491"></span></p>
<p>Then I write this code:</p>
<pre><code class="javascript">
Demo1 = function(){
  var demo1 = {};

  demo1.generatePoints = function(numero,dimensioni_box){
    var points = [];
    for(var i=0;i < numero; i++){
      var x0 = Math.floor((Math.random()-0.5)*(dimensioni_box)),
          y0 = Math.floor((Math.random()-0.5)*(dimensioni_box)),
          z0 = Math.floor((Math.random()-0.5)*(dimensioni_box)),
          x1 = x0 + 5;
          y1 = x1 + 5;
          z1 = z0;

      points.push(
        [$M([[x0],[y0],[z0]]), $M([[x1],[y1],[z1]])]
      );
    }
    return points;
  }

  demo1.init = function(evento){
    // #drawboard is a canvas element
    demo1.canvas = document.querySelector('#drawboard');
    demo1.canvas.width  = 320;
    demo1.canvas.height = 480;
    demo1.context = demo1.canvas.getContext('2d');
    demo1.points =  demo1.generatePoints(200, 100);
  };

  demo1.resetCanvas = function(){
     demo1.context.fillStyle = '#FFFFFF';
     demo1.context.fillRect(0,0, demo1.canvas.width, demo1.canvas.height);
     demo1.context.fillStyle = '#000000';
  }

  demo1.cambioOrientamento = function(evento){
    demo1.resetCanvas();

    var heading  = ((evento.alpha > 180 ? evento.alpha - 360 : evento.alpha) * Math.PI) / 180.0;
    var attitude = (evento.beta  *  Math.PI)     / 180.0;
    var bank     = (evento.gamma * (Math.PI/2.0)) / 90.0;

    var ch = Math.cos(heading),     sh = Math.sin(heading),
        ca = Math.cos(attitude),    sa = Math.sin(attitude),
        cb = Math.cos(bank),        sb = Math.sin(bank);

    var rotation_matrix = $M([
          [ch*ca  , -ch*sa*cb + sh*sb , ch*sa*sb + sh*cb    ],
          [sa      , ca*cb             , -ca*sb             ],
          [-sh*ca , sh*sa*cb + ch*sb  , -sh*sa*sb + ch*cb   ]
    ]);

    for(var i=0; i < demo1.points.length; i++){
      var pr  = rotation_matrix.x(demo1.points[i][0]);
      var x   = 160 + ((640*pr.e(1,1)) / (pr.e(3,1)));
          y   = 240 - ((640*pr.e(2,1)) / (pr.e(3,1)));
      demo1.context.fillRect(x,y,10,10);
    }
  };
  return demo1;
}();

window.addEventListener('load',Demo1.init,false);
window.addEventListener('deviceorientation',Demo1.cambioOrientamento,false);
</code></pre>
<p>If you have a device which supports the deviceorientation API (eg: iPhone4) you can test the running example here: <a href="http://sandropaganotti.com/wp-content/goodies/mobile/demo1.html">http://sandropaganotti.com/wp-content/goodies/mobile/demo1.html</a> as you might notice is still far from perfect but at the moment I've no time to refine it and so I have to leave it 'as is' ( still somehow nice IMHO ).</p>
<p>If someone got a clues on this please e-mail me at: &#115;&#097;&#110;&#100;&#114;&#111;&#046;&#112;&#097;&#103;&#097;&#110;&#111;&#116;&#116;&#105;&#064;&#103;&#109;&#097;&#105;&#108;&#046;&#099;&#111;&#109;</p>
]]></content:encoded>
			<wfw:commentRss>http://sandropaganotti.com/2011/05/12/html5-augmented-reality-fuzzy-results/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>HTML5 Video Mosaic: a proof of concept</title>
		<link>http://sandropaganotti.com/2011/03/20/html5-video-mosaic-a-proof-of-concept/</link>
		<comments>http://sandropaganotti.com/2011/03/20/html5-video-mosaic-a-proof-of-concept/#comments</comments>
		<pubDate>Sun, 20 Mar 2011 10:54:25 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Interfaccie]]></category>
		<category><![CDATA[html5]]></category>
		<category><![CDATA[video mosaic]]></category>

		<guid isPermaLink="false">http://sandropaganotti.com/?p=474</guid>
		<description><![CDATA[Following a suggestion by a VJ friend of mine I worked on creating a real time HTML5 video mosaic that can be used to aggregate videos from your hard disk in a custom-size grid. To accomplish that I set-up a two-page structure: a dashboard, used to choose which files to play and to control the [...]]]></description>
			<content:encoded><![CDATA[<p>Following a suggestion by a <a title="Joe Ferrari on linkedIn" href="http://www.linkedin.com/pub/joe-ferrari/7/91a/961" target="_blank">VJ friend of mine</a> I worked on creating a real time HTML5 video mosaic that can be used to aggregate videos from your hard disk in a custom-size grid.</p>
<p><span id="more-474"></span>To accomplish that I set-up a two-page structure: a dashboard, used to choose which files to play and to control the grid size (other controls may came next), and the mosaic page itself: in this way one page can be projected in full-screen while the other one can be viewed on the second monitor.</p>
<p>In the dashboard lays a drop-area where video files can be dropped, dropping one or more file cause afunction &#8216;caricaIlVideo&#8217; to be called:</p>
<pre><code class="javascript">caricaIlVideo = function(evento){
  var files = evento.dataTransfer.files;
  for(var x=0; x &lt; files.length; x++){
    console.log("wooo");
    worker.port.postMessage("comando-verso-mosaic:carica-video:" +
      window.webkitURL.createObjectURL(files[x]));
  }
}
</code></pre>
<p>The function uses Drag And Drop API and File API to recover the dropped files, then a message is sent to a SharedWebWorker for each of the dropped files containing a string like :</p>
<pre><code class="javascript">"comando-verso-mosaic:carica-video:blob:http://sandropaganotti.com/ecba59ec-d1cc-435c-9bd3-ba50e2bf0eab"
</code></pre>
<p>the blob* part is the most interesting: it contains the URL of the File dropped. The SharedWebWorker then unfold the message removing the &#8216;comando-verso-mosaic&#8217; part and sends the rest to the mosaic page.</p>
<p>When the mosaic page receives a message like this it launch a function called &#8216;caricaVideo&#8217;:</p>
<pre><code class="javascript">caricaVideo = function(blob_url){
  var video  = document.createElement('video');
  var source = document.createElement('source');
  video.muted = true;
  video.volume = 0.0;
  video.loop  = true;
  source.src = blob_url;
  source.type= "video/webm";
  video.appendChild(source);
  document.querySelector("#videos").appendChild(video);
  video.addEventListener('canplaythrough', iniziaLaProiezione, false);
}
</code></pre>
<p>The function basically creates a new video element using the blob URL as a source and then attach to the element a listener for the &#8216;canplaythrough&#8217; event, which occurs when the video buffer reach enough capacity to guarantee a full-play performance.</p>
<p>The mosaic has a looping function, called &#8216;aggregaVideo&#8217; which takes care of the drawing stuff: it iterates over all the video elements created and it draws them over a canvas according with the tessellation configuration:</p>
<pre><code class="javascript">aggregaVideo = function(canvas_context, videoboxes){
    canvas_context.canvas.width = canvas_context.canvas.width;
    for(var i=0; i &lt; tassello['tassellazione-y']; i++){
      for(var k=0; k &lt; tassello['tassellazione-x']; k++){
        if(videoboxes[k + i*tassello['tassellazione-y']] != undefined){
          canvas_context.drawImage(videoboxes[k + i*tassello['tassellazione-y']],
            tassello.width * k, tassello.height * i,
            tassello.width , tassello.height
          );
        }
      }
    }
    setTimeout(function(){aggregaVideo(canvas_context,  document.querySelectorAll('#videos video'))},0);
}</code></pre>
<p>Here&#8217;s a video showing the whole thing running:</p>
<p><iframe title="YouTube video player" width="640" height="390" src="http://www.youtube.com/embed/owww1nssLHc?rel=0" frameborder="0" allowfullscreen></iframe></p>
<p>The code of this project is, as usual, <a href="https://github.com/sandropaganotti/html5-video-mosaic">on my github account</a>. </p>
<p>Finally you can test the video mosaic by yourself launching both the <a href="http://sandropaganotti.com/wp-content/goodies/demos/HTML5/html5-video-mosaic/dashboard.html">dashboard</a> and the <a href="http://sandropaganotti.com/wp-content/goodies/demos/HTML5/html5-video-mosaic/mosaic.html">mosaic</a>; be sure to have some webm video files on your computer, you can find some here:  <a href="http://www.webmfiles.org/demo-files/">http://www.webmfiles.org/demo-files/</a> or you can convert some using <a href="http://www.mirovideoconverter.com/">miro video converter</a>. Please note that everything should work, at the moment, only on Chrome 10.</p>
<p>Thanks!</p>
]]></content:encoded>
			<wfw:commentRss>http://sandropaganotti.com/2011/03/20/html5-video-mosaic-a-proof-of-concept/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Something I&#8217;ve been working on</title>
		<link>http://sandropaganotti.com/2011/02/22/something-ive-been-working-on/</link>
		<comments>http://sandropaganotti.com/2011/02/22/something-ive-been-working-on/#comments</comments>
		<pubDate>Mon, 21 Feb 2011 23:07:50 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Annunci]]></category>

		<guid isPermaLink="false">http://sandropaganotti.com/?p=463</guid>
		<description><![CDATA[What I did the last two months? I was preparing the html.it HTML5 guide which will be released starting from the next week. Right by now a preview chapter is already available and, if you are interested, you might also want to follow the presentation event, taking place the 28th of february in Rome. Talking [...]]]></description>
			<content:encoded><![CDATA[<p>What I did the last two months? I was preparing the <a href="http://www.html.it/" target="_blank">html.it</a> HTML5 guide which will be released starting from the next week. Right by now <a title="A preview chapter" href="http://xhtml.html.it/guide/leggi/202/guida-html5-anteprima/" target="_blank">a preview chapter is already available</a> and, if you are interested, you might also want to follow <a href="http://eventi.html.it/html5/" target="_blank">the presentation event</a>, taking place the 28th of february in Rome.</p>
<p>Talking about events, the last saturday there was <a href="http://ugialt.net/" target="_blank">UGIALT.net</a> and I had the pleasure <a href="http://vimeo.com/20194756" target="_blank">to share a talk</a> with <a href="http://codeclimber.net.nz/" target="_blank">Simone Chiaretta</a>: in just 20 minutes each of us live coded a <a title="Join The Conf!" href="http://jointheconf.heroku.com/conferences">simple application</a> using his preferred language: Ruby on Rails for me and ASP.NET MVC for Simone. It was a really enlightening experience.</p>
]]></content:encoded>
			<wfw:commentRss>http://sandropaganotti.com/2011/02/22/something-ive-been-working-on/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Ruby Spell Doctor: a Ruby binding to Hunspell</title>
		<link>http://sandropaganotti.com/2010/11/25/ruby-spell-doctor-a-ruby-binding-to-hunspell/</link>
		<comments>http://sandropaganotti.com/2010/11/25/ruby-spell-doctor-a-ruby-binding-to-hunspell/#comments</comments>
		<pubDate>Thu, 25 Nov 2010 22:02:11 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Librerie]]></category>
		<category><![CDATA[Hunspell]]></category>
		<category><![CDATA[Ruby Mendicant University]]></category>

		<guid isPermaLink="false">http://sandropaganotti.com/?p=456</guid>
		<description><![CDATA[The idea behind this project was in my head since a while. Then thanks to Gregory Brown and his Ruby Mendicant University, I had the opportunity and the incentive to start developing it. Ruby Spell Doctor bind some of the most useful Hunspell functions making them available to Ruby developers. For who don&#8217;t know, Hunspell is [...]]]></description>
			<content:encoded><![CDATA[<p>The idea behind this project was in my head since a while. Then thanks to <a title="Ruby Mendicant University Homepage" href="http://university.rubymendicant.com/" target="_blank">Gregory Brown and his Ruby Mendicant University</a>, I had the opportunity and the incentive to start developing it. Ruby Spell Doctor bind some of the most useful Hunspell functions making them available to Ruby developers. For who don&#8217;t know, <a title="Hunspell homepage" href="http://hunspell.sourceforge.net/" target="_blank">Hunspell</a> is a widely used open source syntax checker library that is implemented in a lot of softwares, such as OpenOffice, Google Chrome and Mac OSX.</p>
<p><span id="more-456"></span></p>
<p>To archive this result I used <a href="https://github.com/ffi/ffi" target="_blank">FFI</a>: the Ruby snippet used to map the native C function look like this:</p>
<pre><code class="ruby">module Hunspell
  module Wrapper
    extend FFI::Library
    ffi_lib(LIBRARY_PATH)
    attach_function :create,  :Hunspell_create, [:string,  :string], :pointer
    attach_function :spell,   :Hunspell_spell,  [:pointer, :string], :int
    attach_function :suggest, :Hunspell_suggest,[:pointer, :pointer, :string], :int;
  end
end</code></pre>
<p>where LIBRARY_PATH is the path to the compiled hunspell library.</p>
<p>Then the next step was to create a Hunspell class which wraps this module creating a nice ruby-sh interface to the library:</p>
<pre><code class="ruby">module Hunspell
  class Hunspell

    # initialize the class and the anonymus module acting as a wrapper to
    # hunspell
    def initialize(config_obj = nil)
      @dicts = bootstrap(config_obj || CONFIGURATION)
      respawn_handler('default')
    end

    def respawn_handler(dictionary)
      # create the hunspell library object
      @hunspell = FFI::MemoryPointer.new :pointer
      @hunspell = Wrapper.create(
        @dicts[dictionary]['aff'],@dicts[dictionary]['dic']
      )
    end

    # returns true if words is not correct, false otherwise
    def spelled_correctly?(word)
      Wrapper.spell(@hunspell,word) != 0
    end

    # returns an array with suggested words of a given word ([] if no
    # suggestions)
    def suggest(word)
      suggestions = FFI::MemoryPointer.new :pointer, 1
      suggestions_number = Wrapper.suggest(@hunspell,suggestions, word)
      suggestion_pointer = suggestions.read_pointer
      if (suggestion_pointer.null?)
        []
      else
        suggestion_pointer.get_array_of_string(0,suggestions_number).compact
      end
    end

    private

    # get lib directory and default dictionary path
    def bootstrap(config_obj)
      if config_obj.nil?
        raise BootstrapError.new("No configuration info supplied to Hunspell" +
            "constructor and no default configuration file available")
      end
      return config_obj['dictionaries'].merge({
          'default' =&gt; config_obj['dictionaries'][
                          config_obj['dictionaries']['default']]
      })
    end

  end
end
</code></pre>
<p>Well, it&#8217;s almost all here, except for some configuration details that let you choose which language dictionary files to load. The path of these files (a pair of .dic and .aff) can be specified in a .yml file and then sent to the constructor method in a way like this:</p>
<p><strong>YAML (config.yml)</strong></p>
<pre><code class="ruby">dictionaries:
  default: en
  en:
    aff: '/Users/sandropaganotti/RMU/hunspell/hunspell_en_dict/en_US.aff'
    dic: '/Users/sandropaganotti/RMU/hunspell/hunspell_en_dict/en_US.dic'
  it:
    aff: '/Users/sandropaganotti/RMU/hunspell/hunspell_it_dict/it_IT.aff'
    dic: '/Users/sandropaganotti/RMU/hunspell/hunspell_it_dict/it_IT.dic'
</code></pre>
<p><strong>Usage Example</strong></p>
<pre><code class="ruby">module Hunspell
    LIBRARY_PATH = '/path/to/your/hunspell.lib'
end
require 'yaml'
require 'lib/hunspell'
hunspell = Hunspell::Hunspell.new(Yaml.load(File.read('config.yml')))
require 'lib/hunspell'
hunspell.respawn_handler 'it'
hunspell.suggest 'spagtti'
=&gt; ["spaghetti", "spaginati", "spagliati", "spaghetto"]
</code></pre>
<p>And that&#8217;s it! You can find the source code of this library <a title="Ruby Spell Doctor Homepage" href="https://github.com/sandropaganotti/ruby_spell_doctory" target="_blank">on my github account</a>; hope it may be useful!</p>
]]></content:encoded>
			<wfw:commentRss>http://sandropaganotti.com/2010/11/25/ruby-spell-doctor-a-ruby-binding-to-hunspell/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

