<?xml version="1.0" encoding="UTF-8" standalone="no"?><rss xmlns:atom="http://www.w3.org/2005/Atom" xmlns:blogger="http://schemas.google.com/blogger/2008" xmlns:gd="http://schemas.google.com/g/2005" xmlns:georss="http://www.georss.org/georss" xmlns:openSearch="http://a9.com/-/spec/opensearchrss/1.0/" xmlns:thr="http://purl.org/syndication/thread/1.0" version="2.0"><channel><atom:id>tag:blogger.com,1999:blog-6293392127511442927</atom:id><lastBuildDate>Thu, 05 Sep 2024 15:27:06 +0000</lastBuildDate><category>ubuntu</category><category>javascript</category><category>processing</category><category>wii</category><category>firefox</category><category>twitter</category><title>Nicopi!</title><description></description><link>http://nicopi.blogspot.com/</link><managingEditor>noreply@blogger.com (Nicopi)</managingEditor><generator>Blogger</generator><openSearch:totalResults>9</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><item><guid isPermaLink="false">tag:blogger.com,1999:blog-6293392127511442927.post-5903293870720672957</guid><pubDate>Mon, 19 Sep 2011 15:22:00 +0000</pubDate><atom:updated>2011-09-19T17:22:04.227+02:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">ubuntu</category><title>Te lo dice la mucca</title><description>&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgrcCeaqn1NYLti4TK17h7xQfhyphenhyphenWJbhDWIrpb1ZhIbpoKRzxVoZPYIOG3ZYz_YucX7C9HlLqtayuf1MbvLQ0wv5JhJIGIH-r6WuZQl2nuwsgS51jHSoqdDuGIW86Ic-98hSodWEIK7qzA/s1600/mucca.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="177" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgrcCeaqn1NYLti4TK17h7xQfhyphenhyphenWJbhDWIrpb1ZhIbpoKRzxVoZPYIOG3ZYz_YucX7C9HlLqtayuf1MbvLQ0wv5JhJIGIH-r6WuZQl2nuwsgS51jHSoqdDuGIW86Ic-98hSodWEIK7qzA/s320/mucca.png" width="320" /&gt;&lt;/a&gt;&lt;/div&gt;
Cowsay è un programma, sviluppato da Tony Monroe, che genera l'immagine ASCII di una mucca con un messaggio scritto all'interno di un baloon.&lt;br /&gt;
A cosa serve? A strapparvi un sorriso ogni volta che la mucca sparerà una delle sue battute o qualche citazione!&lt;br /&gt;
&lt;br /&gt;
&lt;a name='more'&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="font-size: large;"&gt;Installazione&lt;/span&gt;&lt;br /&gt;
I pacchetti da installare sono &lt;i&gt;cowsay&lt;/i&gt; e &lt;i&gt;fortune&lt;/i&gt;, ma oltre a questi si possono installare anche:&lt;br /&gt;
&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;&lt;b&gt;fortunes-it:&lt;/b&gt; battute in italiano;&lt;/li&gt;
&lt;li&gt;&lt;b&gt;fortunes-it-off:&lt;/b&gt; battute in italiano, un po' più volgari;&lt;/li&gt;
&lt;li&gt;&lt;b&gt;fortunes-bofh-excuses:&lt;/b&gt; le scuse dei Bastard Operators From Hell, ossia sysadmin un po' sadici :D&lt;/li&gt;
&lt;/ul&gt;
&lt;br /&gt;
il tutto con:&lt;br /&gt;
&lt;blockquote&gt;
&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;sudo apt-get install cowsay fortunes fortunes-it fortunes-it-off fortunes-bofh-excuses&amp;nbsp;&lt;/span&gt;&lt;/blockquote&gt;
&lt;br /&gt;
&lt;span class="Apple-style-span" style="font-size: large;"&gt;Configurazione&lt;/span&gt;&lt;br /&gt;
Possiamo modificare il file di configurazione della console bash in modo da essere accolti dalla mucca ogni volta che apriamo il terminale. Per fare ciò è sufficiente aprire .bashrc con gedit (o con un altro editor di testo):&lt;br /&gt;
&lt;blockquote&gt;
&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;gedit .bashrc&amp;nbsp;&lt;/span&gt;&lt;/blockquote&gt;
e in fondo al file copiare questa stringa:&lt;br /&gt;
&lt;blockquote&gt;
&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;/usr/games/cowsay $(/usr/games/fortune)&amp;nbsp;&lt;/span&gt;&lt;/blockquote&gt;
&lt;br /&gt;
&amp;nbsp;Il gioco è fatto!&lt;br /&gt;
&lt;br /&gt;
Fonti| &lt;a href="http://it.wikipedia.org/wiki/Cowsay"&gt;1&lt;/a&gt;,&lt;a href="http://guide.debianizzati.org/index.php/Cowsay,_la_mucca_che_ci_parla_dal_terminale"&gt;2&lt;/a&gt;</description><link>http://nicopi.blogspot.com/2011/09/te-lo-dice-la-mucca.html</link><author>noreply@blogger.com (Nicopi)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" height="72" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgrcCeaqn1NYLti4TK17h7xQfhyphenhyphenWJbhDWIrpb1ZhIbpoKRzxVoZPYIOG3ZYz_YucX7C9HlLqtayuf1MbvLQ0wv5JhJIGIH-r6WuZQl2nuwsgS51jHSoqdDuGIW86Ic-98hSodWEIK7qzA/s72-c/mucca.png" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-6293392127511442927.post-2948431768463181677</guid><pubDate>Wed, 23 Mar 2011 22:21:00 +0000</pubDate><atom:updated>2011-03-24T00:56:49.093+02:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">javascript</category><category domain="http://www.blogger.com/atom/ns#">twitter</category><title>Javascript| Visualizzare ultimi tweet nel proprio blog</title><description>&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a id="single" href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhjM9bbhcx8qtIaXyCP8qORbpyopl15yHEZGIn1v6OuE-y8t1gPcX90SD9Y3ee09IPRK0uvtK48Tdu3URsfwN3PhdbewthVpBx42CPhW_1hVMKpuPe8Yq8VaMg_QHXCssCZCjG5vbF8zA/s1600/logoperpost.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="137" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhjM9bbhcx8qtIaXyCP8qORbpyopl15yHEZGIn1v6OuE-y8t1gPcX90SD9Y3ee09IPRK0uvtK48Tdu3URsfwN3PhdbewthVpBx42CPhW_1hVMKpuPe8Yq8VaMg_QHXCssCZCjG5vbF8zA/s400/logoperpost.png" width="400" /&gt;&lt;/a&gt;&lt;/div&gt;Come sappiamo, twitter mette a disposizione un &lt;a href="http://twitter.com/about/resources/widgets/widget_profile" target="_blank"&gt;widget&lt;/a&gt; che consente di &lt;b&gt;mostrare i nostri ultimi tweet&lt;/b&gt; agli utenti che visitano il nostro blog.&lt;br /&gt;
Nonostante questo sia un&amp;nbsp; buon modo di fare ciò, potremmo voler &lt;b&gt;implementare la visualizzazione dei tweet&lt;/b&gt; senza dover utilizzare la soluzione proposta dal famoso &lt;b&gt;social network&lt;/b&gt; (ad esempio per avere maggiori possibilità di &lt;b&gt;personalizzazione&lt;/b&gt;).&lt;br /&gt;
Vediamo allora come fare!&lt;br /&gt;
&lt;br /&gt;
&lt;span class="Apple-style-span" style="font-size: large;"&gt;&lt;b&gt;#1 Widget RSS&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
Consiste nell'inserire un &lt;b&gt;widget RSS&lt;/b&gt; (possibile sia su Wordpress che su Blogger) con il feed del nostro account twitter.&lt;br /&gt;
L'indirizzo del feed RSS è del tipo:&lt;br /&gt;
&lt;blockquote&gt;http://twitter.com/statuses/user_timeline/username.rss&lt;/blockquote&gt;dove username è il nome utente che abbiamo su twitter.&lt;br /&gt;
&lt;br /&gt;
&lt;a name='more'&gt;&lt;/a&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="font-size: large;"&gt;&lt;b&gt;#2 Funzione javascript messa a disposizione da twitter&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;pre class="java" name="code"&gt;&amp;lt;div id="twitter_div"&amp;gt;&amp;lt;ul id="twitter_update_list"&amp;gt;&amp;lt;/ul&amp;gt;
&amp;lt;/div&amp;gt;
&amp;lt;script src="http://twitter.com/javascripts/blogger.js" type="text/javascript"&amp;gt;&amp;lt;/script&amp;gt;
&amp;lt;script src="http://twitter.com/statuses/user_timeline/username.json?callback=twitterCallback2&amp;amp;count=1" type="text/javascript"&amp;gt;&amp;lt;/script&amp;gt;
&lt;/pre&gt;Provate ad aggiungere questo pezzo di codice ad una qualsiasi pagina HTML e vedrete "comparire" il vostro ultimo tweet.&lt;br /&gt;
Potete modificare &lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;count=1&lt;/span&gt; in modo da visualizzare più di 1 tweet e naturalmente dovete sostituire "&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;username&lt;/span&gt;" con il &lt;b&gt;vostro nome utente&lt;/b&gt;.&lt;br /&gt;
I tweet compaiono in un &lt;b&gt;elenco puntato&lt;/b&gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;span class="Apple-style-span" style="font-size: large;"&gt;&lt;b&gt;#3 Funzione javascript (senza elenco puntato e con riferimenti temporali in italiano)&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
Prima di tutto è necessario inserire il codice riportato qui sotto, tra tag &amp;lt;script&amp;gt; all'interno dell'header della pagina web oppure all'interno di un &lt;b&gt;file .js&lt;/b&gt; da importare:&lt;br /&gt;
&lt;pre class="java" name="code"&gt;function twitterCallback2(twitters) {
  var statusHTML = [];
  for (var i=0; i&amp;lt;twitters.length; i++){
    var username = twitters[i].user.screen_name;
    var status = twitters[i].text.replace(/((https?|s?ftp|ssh)\:\/\/[^"\s\&amp;lt;\&amp;gt;]*[^.,;'"&amp;gt;\:\s\&amp;lt;\&amp;gt;\)\]\!])/g, function(url) {
      return '&amp;lt;a href="'+url+'"&amp;gt;'+url+'&amp;lt;/a&amp;gt;';
    }).replace(/\B@([_a-z0-9]+)/ig, function(reply) {
      return  reply.charAt(0)+'&amp;lt;a href="http://twitter.com/'+reply.substring(1)+'"&amp;gt;'+reply.substring(1)+'&amp;lt;/a&amp;gt;';
    });
    statusHTML.push('&amp;lt;span&amp;gt;'+status+'&amp;lt;/span&amp;gt; &amp;lt;a style="font-size:85%" href="http://twitter.com/'+username+'/statuses/'+twitters[i].id_str+'"&amp;gt;'+relative_time(twitters[i].created_at)+'&amp;lt;/a&amp;gt;&amp;lt;/br&amp;gt;');
  }
  document.getElementById('twitter_update_list').innerHTML = statusHTML.join('');
}

function relative_time(time_value) {
  var values = time_value.split(" ");
  time_value = values[1] + " " + values[2] + ", " + values[5] + " " + values[3];
  var parsed_date = Date.parse(time_value);
  var relative_to = (arguments.length &amp;gt; 1) ? arguments[1] : new Date();
  var delta = parseInt((relative_to.getTime() - parsed_date) / 1000);
  delta = delta + (relative_to.getTimezoneOffset() * 60);

  if (delta &amp;lt; 60) {
    return 'meno di un minuto fa';
  } else if(delta &amp;lt; 120) {
    return 'circa un minuto fa';
  } else if(delta &amp;lt; (60*60)) {
    return (parseInt(delta / 60)).toString() + ' minuti fa';
  } else if(delta &amp;lt; (120*60)) {
    return 'circa un ora fa';
  } else if(delta &amp;lt; (24*60*60)) {
    return 'circa ' + (parseInt(delta / 3600)).toString() + ' ore fa';
  } else if(delta &amp;lt; (48*60*60)) {
    return '1 giorno fa';
  } else {
    return (parseInt(delta / 86400)).toString() + ' giorni fa';
  }
}
&lt;/pre&gt;poi basterà aggiungere nella parte della pagina &lt;b&gt;dove si vuole compaiano i tweet&lt;/b&gt; il seguente codice:&lt;br /&gt;
&lt;pre class="java" name="code"&gt;&amp;lt;div id="twitter_div"&amp;gt;&amp;lt;span id="twitter_update_list"&amp;gt;&amp;lt;/span&amp;gt;g&amp;lt;/div&amp;gt;
&amp;lt;script src="http://twitter.com/statuses/user_timeline/nicopi.json?callback=twitterCallback2&amp;amp;count=5" type="text/javascript"&amp;gt;&amp;lt;/script&amp;gt;
&lt;/pre&gt;Questa soluzione è ispirata alla funzione javascript del punto #2, con la differenza che è in &lt;b&gt;italiano&lt;/b&gt; (prima: "10 minutes ago", ora: "10 minuti fa") e che &lt;b&gt;non utilizza più un elenco puntato&lt;/b&gt; ma una semplice lista di tweet.&lt;br /&gt;
&lt;br /&gt;
&lt;span class="Apple-style-span" style="font-size: large;"&gt;&lt;b&gt;#4 Funzione javascript che elimina i tweet tra utenti&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
Questa è la versione che uso qui sul blog.&lt;br /&gt;
&lt;b&gt;Problema:&lt;/b&gt; Molte volte rispondo a diversi utenti su twitter e tutti questi tweet &lt;b&gt;iniziano con @username&lt;/b&gt;. Voglio che vengano visualizzati &lt;b&gt;tutti i tweet&lt;/b&gt; &lt;b&gt;tranne&lt;/b&gt; quelli che &lt;b&gt;iniziano&lt;/b&gt; con il &lt;b&gt;carattere @&lt;/b&gt;.&lt;br /&gt;
&lt;pre class="java" name="code"&gt;function twitterCallback2(twitters) {
  var statusHTML = [];
  var i=0;
  while (i&amp;lt;twitters.length){
    var username = twitters[i].user.screen_name;
    var status = twitters[i].text.replace(/((https?|s?ftp|ssh)\:\/\/[^"\s\&amp;lt;\&amp;gt;]*[^.,;'"&amp;gt;\:\s\&amp;lt;\&amp;gt;\)\]\!])/g, function(url) {
      return '&amp;lt;a href="'+url+'"&amp;gt;'+url+'&amp;lt;/a&amp;gt;';
    }).replace(/\B@([_a-z0-9]+)/ig, function(reply) {
      return  reply.charAt(0)+'&amp;lt;a href="http://twitter.com/'+reply.substring(1)+'"&amp;gt;'+reply.substring(1)+'&amp;lt;/a&amp;gt;';
    });
    if (status[0]!='@'){
    statusHTML.push('&amp;lt;span&amp;gt;'+status+'&amp;lt;/span&amp;gt; &amp;lt;a style="font-size:85%" href="http://twitter.com/'+username+'/statuses/'+twitters[i].id_str+'"&amp;gt;'+relative_time(twitters[i].created_at)+'&amp;lt;/a&amp;gt;&amp;lt;/br&amp;gt;');
    i=twitters.lengt;
    }
    i++;
  }
  document.getElementById('twitter_update_list').innerHTML = statusHTML.join('');
}

function relative_time(time_value) {
  var values = time_value.split(" ");
  time_value = values[1] + " " + values[2] + ", " + values[5] + " " + values[3];
  var parsed_date = Date.parse(time_value);
  var relative_to = (arguments.length &amp;gt; 1) ? arguments[1] : new Date();
  var delta = parseInt((relative_to.getTime() - parsed_date) / 1000);
  delta = delta + (relative_to.getTimezoneOffset() * 60);

  if (delta &amp;lt; 60) {
    return 'meno di un minuto fa';
  } else if(delta &amp;lt; 120) {
    return 'circa un minuto fa';
  } else if(delta &amp;lt; (60*60)) {
    return (parseInt(delta / 60)).toString() + ' minuti fa';
  } else if(delta &amp;lt; (120*60)) {
    return 'circa un ora fa';
  } else if(delta &amp;lt; (24*60*60)) {
    return 'circa ' + (parseInt(delta / 3600)).toString() + ' ore fa';
  } else if(delta &amp;lt; (48*60*60)) {
    return '1 giorno fa';
  } else {
    return (parseInt(delta / 86400)).toString() + ' giorni fa';
  }
}
&lt;/pre&gt;&lt;b&gt;Soluzione:&lt;/b&gt; La soluzione che ho scritto è quella che vedete qui sopra. &lt;br /&gt;
Il &lt;b&gt;numero di tweet caricati&lt;/b&gt; è indicato da &lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;count=&lt;/span&gt;, in questo caso 15; tra questi verrà visualizzato &lt;b&gt;quello più recente&lt;/b&gt; che &lt;b&gt;non&lt;/b&gt; inizia con il &lt;b&gt;carattere @&lt;/b&gt;. &lt;br /&gt;
Se tra i 15, &lt;b&gt;nessuno&lt;/b&gt; comincia con un carattere &lt;b&gt;diverso&lt;/b&gt; da @ allora lo script &lt;b&gt;non stampa niente&lt;/b&gt;.&lt;br /&gt;
La funzione &lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;relative_time&lt;/span&gt; serve solo a &lt;b&gt;trasformare&lt;/b&gt; la data e l'ora del tweet in modo tale che se ora sono le 20.00 e abbiamo &lt;b&gt;twittato 10 minuti fa&lt;/b&gt; appaia scritto &lt;b&gt;"10 minuti fa"&lt;/b&gt; e non &lt;b&gt;"19.50"&lt;/b&gt;. (questo è solo un esempio!)&lt;br /&gt;
PS: &lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;i=twitters.lengt;&lt;/span&gt; serve solo ad &lt;b&gt;uscire dal ciclo while&lt;/b&gt;. Avrei potuto metterci un &lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;break&lt;/span&gt;, ma ho preferito così...&lt;br /&gt;
&lt;br /&gt;
Per concludere facciamo gli auguri a twitter che in questi giorni &lt;b&gt;compie 5 anni&lt;/b&gt;. Il team di twitter ha per l'occasione pubblicato un video celebrativo (che potete vedere cliccando &lt;a class="youtube" href="http://www.youtube.com/watch?v=4AN4_N5N52U&amp;amp;feature=player_embedded" target="_blank"&gt;QUI&lt;/a&gt;) nel quale compare anche l'astronauta italiano &lt;a href="http://www.esa.int/esaCP/SEMDDO374OD_Italy_0.html" target="_blank"&gt;Paolo Nespoli&lt;/a&gt;, attualmente al lavoro nella &lt;a href="http://en.wikipedia.org/wiki/International_Space_Station" target="_blank"&gt;ISS&lt;/a&gt; dove permarrà per un periodo di 6 mesi.</description><link>http://nicopi.blogspot.com/2011/03/javascript-visualizzare-ultimi-tweet.html</link><author>noreply@blogger.com (Nicopi)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" height="72" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhjM9bbhcx8qtIaXyCP8qORbpyopl15yHEZGIn1v6OuE-y8t1gPcX90SD9Y3ee09IPRK0uvtK48Tdu3URsfwN3PhdbewthVpBx42CPhW_1hVMKpuPe8Yq8VaMg_QHXCssCZCjG5vbF8zA/s72-c/logoperpost.png" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-6293392127511442927.post-201682899688050823</guid><pubDate>Tue, 22 Mar 2011 20:52:00 +0000</pubDate><atom:updated>2011-03-23T00:59:33.129+02:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">firefox</category><category domain="http://www.blogger.com/atom/ns#">ubuntu</category><title>Firefox 4 da PPA in Italiano</title><description>Poche ore fa ho installato &lt;b&gt;Firefox 4&lt;/b&gt; su &lt;b&gt;Ubuntu 10.10&lt;/b&gt;. Le novità di quest'ultima versione ve le risparmio perchè ne parlano già diversi blog in giro per la &lt;a href="http://www.google.it/search?q=firefox+4&amp;amp;tbm=blg" target="_blank"&gt;blogosfera&lt;/a&gt;.&lt;br /&gt;
I pacchetti che ho installato sono quelli presenti&amp;nbsp;&lt;a href="https://launchpad.net/%7Emozillateam/+archive/firefox-stable"&gt;PPA firefox-stable&lt;/a&gt;&amp;nbsp;del Team Mozilla.&lt;br /&gt;
Nel caso vi tornasse utile ecco la procedura che ho seguito:&lt;br /&gt;
&lt;br /&gt;
1. Dare da terminale questi &lt;a href="http://askubuntu.com/questions/6339/how-do-i-install-firefox-4/6348#6348" target="_blank"&gt;due comandi&lt;/a&gt; per aggiungere i PPA e aggiornare:&lt;br /&gt;
&lt;blockquote&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"&gt;sudo add-apt-repository ppa:mozillateam/firefox-stable&lt;/span&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"&gt;sudo apt-get update &amp;amp;&amp;amp; sudo apt-get upgrade&lt;/span&gt;&lt;/blockquote&gt;&lt;br /&gt;
2. Per installare la &lt;b&gt;lingua italiana&lt;/b&gt; (visto che appena installato sarà in inglese) ho usato &lt;a href="http://releases.mozilla.org/pub/mozilla.org/firefox/releases/4.0/win32/xpi/it.xpi" target="_blank"&gt;questo&lt;/a&gt; file.&lt;br /&gt;
&lt;br /&gt;
Dopo aver cliccato sul link, Firefox chiederà di confermare l'installazione e al successivo riavvio tutto sarà in &lt;b&gt;italiano&lt;/b&gt;!</description><link>http://nicopi.blogspot.com/2011/03/firefox-4-da-ppa-in-italiano.html</link><author>noreply@blogger.com (Nicopi)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-6293392127511442927.post-3851363635286358144</guid><pubDate>Mon, 21 Mar 2011 14:17:00 +0000</pubDate><atom:updated>2011-03-21T16:21:54.791+02:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">javascript</category><title>Fancybox e Iframe</title><description>&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhKTvXK8572M894VEr7K_5pV8heXIRJhRFnmJ0YobaukCyoWsl1PliL61KYDALmI5geTrRw4rXZcMWxxgSL2Urmw2r9vwujBWwLcp3m8fvp5gaJ99Uf0KX49MnBWv8o_mjtGWO2erv-Nw/s1600/fancybox.png" id="single" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="87" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhKTvXK8572M894VEr7K_5pV8heXIRJhRFnmJ0YobaukCyoWsl1PliL61KYDALmI5geTrRw4rXZcMWxxgSL2Urmw2r9vwujBWwLcp3m8fvp5gaJ99Uf0KX49MnBWv8o_mjtGWO2erv-Nw/s320/fancybox.png" width="320" /&gt;&lt;/a&gt;&lt;/div&gt;In questi giorni ho implementato &lt;a href="http://fancybox.net/" target="_blank"&gt;fancybox&lt;/a&gt; nel blog, in modo da far si che cliccando sulle &lt;b&gt;immagini&lt;/b&gt; integrate nei vari post si apra una finestra con &lt;b&gt;l'immagine ingrandita&lt;/b&gt;.&lt;br /&gt;
Oltre a questo, fancybox permette di visualizzare &lt;b&gt;iframe&lt;/b&gt; nel proprio sito: vediamo come farlo nel modo più semplice possibile.&lt;br /&gt;
&lt;br /&gt;
Supponiamo di voler visualizzare la &lt;b&gt;pagina di google&lt;/b&gt; all'interno di un &lt;b&gt;iframe&lt;/b&gt;.&lt;br /&gt;
Iniziamo inserendo&lt;br /&gt;
&lt;pre class="java" name="code"&gt;&amp;lt;a class="extLink" href="http://www.google.it/"&amp;gt;Apri Google&amp;lt;/a&amp;gt;&lt;/pre&gt;nella pagina. Se ora clicchiamo sul link finiremo in Google come accade con un normale link a Google.&lt;br /&gt;
&lt;br /&gt;
A questo punto dobbiamo inserire questo pezzetto di &lt;b&gt;codice&lt;/b&gt; tra tag &amp;lt;script&amp;gt;&lt;br /&gt;
all'interno di &amp;lt;head&amp;gt;&amp;lt;/head&amp;gt;&lt;br /&gt;
&lt;a name='more'&gt;&lt;/a&gt;&lt;pre class="java" name="code"&gt;$(document).ready(function(){
    $(".extLink").fancybox({
         'width' : '75%',
         'height' : '75%',
         'autoScale' : false,
         'transitionIn' : 'none',
         'transitionOut' : 'none',
         'type' : 'iframe',
         'hideOnOverlayClick' : false
     });
});
&lt;/pre&gt;&lt;br /&gt;
In particolare &lt;span class="Apple-style-span" style="color: blue; font-family: 'Courier New', Courier, monospace;"&gt;hideOnOverlayClick&lt;/span&gt; è impostato a &lt;span class="Apple-style-span" style="color: #073763; font-family: 'Courier New', Courier, monospace;"&gt;&lt;b&gt;false&lt;/b&gt;&lt;/span&gt;&amp;nbsp;cosicché l'unico modo per chiudere il frame aperto sia cliccare la &lt;b&gt;X&lt;/b&gt; in alto a destra.&lt;br /&gt;
&lt;br /&gt;
Se ora clicchiamo sul link si aprirà una finestra contenente la pagina di Google, all'interno della nostra pagina web.&lt;br /&gt;
&lt;br /&gt;
Provare per credere: &lt;a class="extLink" href="http://www.google.it/"&gt;Apri Google&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
Le istruzioni per installare fancybox sono &lt;a href="http://fancybox.net/howto" target="_blank"&gt;qui&lt;/a&gt;, mentre le opzioni disponibili sono &lt;a href="http://fancybox.net/api" target="_blank"&gt;qui&lt;/a&gt;.</description><link>http://nicopi.blogspot.com/2011/03/fancybox-e-iframe.html</link><author>noreply@blogger.com (Nicopi)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" height="72" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhKTvXK8572M894VEr7K_5pV8heXIRJhRFnmJ0YobaukCyoWsl1PliL61KYDALmI5geTrRw4rXZcMWxxgSL2Urmw2r9vwujBWwLcp3m8fvp5gaJ99Uf0KX49MnBWv8o_mjtGWO2erv-Nw/s72-c/fancybox.png" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-6293392127511442927.post-8657268298747854411</guid><pubDate>Fri, 18 Mar 2011 13:37:00 +0000</pubDate><atom:updated>2011-03-20T19:11:13.240+02:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">ubuntu</category><title>Software| Annotare PDF con Xournal</title><description>&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a id="single" href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjxduT1FIQLSllVyBnGk7WW7V9iOoTI4KlbgedQTdnzfF4UxV0p2_845p7wjyZhK7ibxkAQ7yZTKUm82eLpy2fBTmnNeqMXQvXeMeKUgngZDFmKMedBr_o0KxQUvIEjOuSr_THIXIy5jw/s1600/imm2.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="242" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjxduT1FIQLSllVyBnGk7WW7V9iOoTI4KlbgedQTdnzfF4UxV0p2_845p7wjyZhK7ibxkAQ7yZTKUm82eLpy2fBTmnNeqMXQvXeMeKUgngZDFmKMedBr_o0KxQUvIEjOuSr_THIXIy5jw/s400/imm2.png" alt="" width="400" /&gt;&lt;/a&gt;&lt;/div&gt;Chiunque passi le giornate su libri e appunti, magari uno sventurato studente di Ingegneria come il sottoscritto, sarà abituato ad avere a che fare con le &lt;b&gt;dispense&lt;/b&gt; messe a disposizione dai vari docenti nei loro siti.&lt;br /&gt;
Nel caso si preferisca studiare direttamente dal proprio pc desktop, notebook o netbook invece che stampare chilometri di carta, può tornare utile un programma che consenta di &lt;b&gt;evidenziare il testo&lt;/b&gt; e di aggiungere appunti a margine.&lt;br /&gt;
Dopo una breve ricerca ho trovato &lt;b&gt;Xournal&lt;/b&gt;, ed è stato amore a prima vista! :D&lt;br /&gt;
&lt;a name='more'&gt;&lt;/a&gt;&lt;br /&gt;
&lt;b&gt;&lt;span class="Apple-style-span" style="font-size: large;"&gt;Vabbè, ma come funziona?&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
Semplice, basta avviare Xournal e da &lt;i&gt;File-&amp;gt;Annotate PDF&lt;/i&gt; importare il file PDF da annotare.&lt;br /&gt;
Una volta importato il PDF sarà possibile sottolineare, evidenziare e aggiungere testo.&lt;br /&gt;
Tutto ciò non andrà a modificare il file PDF originale ma finirà in un file .xoj, anche se è sempre possibile &lt;b&gt;esportare&lt;/b&gt; il tutto in un nuvo file .pdf (&lt;i&gt;File-&amp;gt;Export to PDF&lt;/i&gt;).&lt;br /&gt;
Da &lt;a href="http://en.wikipedia.org/wiki/Xournal"&gt;Wikipedia&lt;/a&gt;:&lt;br /&gt;
&lt;blockquote&gt;Xournal saves in an XML-based format (similar to SVG) which is then compressed with gzip.&lt;/blockquote&gt;&lt;br /&gt;
&lt;b&gt;&lt;span class="Apple-style-span" style="font-size: large;"&gt;Installazione&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
Si può installare direttamente da &lt;b&gt;Ubuntu Software Center&lt;/b&gt; oppure da terminale con&lt;br /&gt;
&lt;blockquote&gt;sudo apt-get install xournal&lt;/blockquote&gt;Per chi fosse interessato, è disponibile una versione anche per Windows.&lt;br /&gt;
&lt;br /&gt;
Homepage| &lt;a href="http://xournal.sourceforge.net/"&gt;Xournal&lt;/a&gt;</description><link>http://nicopi.blogspot.com/2011/03/software-annotare-pdf-con-xournal.html</link><author>noreply@blogger.com (Nicopi)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" height="72" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjxduT1FIQLSllVyBnGk7WW7V9iOoTI4KlbgedQTdnzfF4UxV0p2_845p7wjyZhK7ibxkAQ7yZTKUm82eLpy2fBTmnNeqMXQvXeMeKUgngZDFmKMedBr_o0KxQUvIEjOuSr_THIXIy5jw/s72-c/imm2.png" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-6293392127511442927.post-2671206067415001191</guid><pubDate>Thu, 17 Mar 2011 12:58:00 +0000</pubDate><atom:updated>2011-03-20T19:12:20.661+02:00</atom:updated><title>Buon compleanno, Italia!</title><description>&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a id="single" href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEixDWNgPCRoM84jquPCVnh_ZO1nK6haiCZfvUJaqfcl_LCWHGbvCyxW715OHyfPDtlaIiFBeMIHRUdAcmr6jqVndwSVZ6Q0wu2oYIJYZ3rZAr3hf43KoUIB8eLxsMuCqufN3CYu-qonUA/s1600/frecce.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="299" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEixDWNgPCRoM84jquPCVnh_ZO1nK6haiCZfvUJaqfcl_LCWHGbvCyxW715OHyfPDtlaIiFBeMIHRUdAcmr6jqVndwSVZ6Q0wu2oYIJYZ3rZAr3hf43KoUIB8eLxsMuCqufN3CYu-qonUA/s400/frecce.jpg" width="400" /&gt;&lt;/a&gt;&lt;/div&gt;</description><link>http://nicopi.blogspot.com/2011/03/buon-compleanno-italia.html</link><author>noreply@blogger.com (Nicopi)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" height="72" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEixDWNgPCRoM84jquPCVnh_ZO1nK6haiCZfvUJaqfcl_LCWHGbvCyxW715OHyfPDtlaIiFBeMIHRUdAcmr6jqVndwSVZ6Q0wu2oYIJYZ3rZAr3hf43KoUIB8eLxsMuCqufN3CYu-qonUA/s72-c/frecce.jpg" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-6293392127511442927.post-5610841270988396007</guid><pubDate>Mon, 14 Mar 2011 10:55:00 +0000</pubDate><atom:updated>2011-03-20T19:12:37.791+02:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">ubuntu</category><title>Ubuntu| Cambiare hostname</title><description>&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a id="single" href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjSWReXiLHltkE4b7hv-lgXqZP99AQZCPm_vruXvYVx3vW1cnyCa7IQX0QT7WaBqjnY1XA526-iuyw2Pj3zxU3H9fu3cWlBgoxUIP8Q3SXou6IPwD6Rsp2CD7gPqhbhUiokH69T4rB0qw/s1600/ubuntu.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="84" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjSWReXiLHltkE4b7hv-lgXqZP99AQZCPm_vruXvYVx3vW1cnyCa7IQX0QT7WaBqjnY1XA526-iuyw2Pj3zxU3H9fu3cWlBgoxUIP8Q3SXou6IPwD6Rsp2CD7gPqhbhUiokH69T4rB0qw/s320/ubuntu.jpg" width="320" /&gt;&lt;/a&gt;&lt;/div&gt;Durante la &lt;b&gt;procedura di installazione di Ubuntu&lt;/b&gt;, tra le varie informazioni richieste all'utente, c'è quella di indicare il &lt;b&gt;nome che si vuole assegnare al pc&lt;/b&gt;, in modo che questo sia chiaramente identificabile all'interno della rete locale.&lt;br /&gt;
Nella gran parte dei casi l'utente non si preoccupa della cosa e lascia impostato il nome assegnato di default, che può essere &lt;i&gt;username-desktop&lt;/i&gt; o &lt;i&gt;username-laptop&lt;/i&gt; a seconda dei casi.&lt;br /&gt;
Può capitare che si voglia però &lt;b&gt;modificare tale nome in seguito&lt;/b&gt;, come ho fatto di recente e come riporterò in questo post in modo da potermelo ricordare in futuro :D&lt;br /&gt;
&lt;a name='more'&gt;&lt;/a&gt;&lt;br /&gt;
Per prima cosa modifichiamo il file &lt;i&gt;/etc/hostname&lt;/i&gt; utilizzando i privilegi di amministratore&lt;br /&gt;
&lt;blockquote&gt;sudo nano /etc/hostname&lt;/blockquote&gt;Nella prima riga del file noterete essere riportato il nome attuale dell'host. &lt;b&gt;Cancellatelo e scriveteci il nuovo nome.&lt;/b&gt; Di seguito con  CTRL+X salvate ed uscite dall'editor.&lt;br /&gt;
Ora, diamo il comando&lt;br /&gt;
&lt;blockquote&gt;sudo hostname -F /etc/hostname&lt;/blockquote&gt;e per concludere modifichiamo il file hosts&lt;br /&gt;
&lt;blockquote&gt;sudo nano /etc/hosts&lt;/blockquote&gt;sostituendo al suo interno il vecchio nome host con il nuovo.&lt;br /&gt;
A questo punto possiamo &lt;b&gt;riavviare il PC&lt;/b&gt;.&lt;br /&gt;
&lt;br /&gt;
Come si vuole in questi casi, dopo aver finito mi è venuto il dubbio: "Ma non è che si poteva fare tutto da &lt;a href="http://ubuntu-tweak.com/"&gt;Ubuntu Tweak&lt;/a&gt; ?" e dopo una rapida controllatina la risposta è stata "Doh!"&lt;br /&gt;
Nel famoso programma, sotto la voce&lt;i&gt; Sistema-Dettagi computer&lt;/i&gt; è possibile &lt;b&gt;cambiare l'hostname&lt;/b&gt; con appena un paio di click!</description><link>http://nicopi.blogspot.com/2011/03/ubuntu-cambiare-hostname.html</link><author>noreply@blogger.com (Nicopi)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" height="72" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjSWReXiLHltkE4b7hv-lgXqZP99AQZCPm_vruXvYVx3vW1cnyCa7IQX0QT7WaBqjnY1XA526-iuyw2Pj3zxU3H9fu3cWlBgoxUIP8Q3SXou6IPwD6Rsp2CD7gPqhbhUiokH69T4rB0qw/s72-c/ubuntu.jpg" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-6293392127511442927.post-8834418296456125925</guid><pubDate>Tue, 01 Mar 2011 17:00:00 +0000</pubDate><atom:updated>2011-03-20T19:12:55.539+02:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">processing</category><category domain="http://www.blogger.com/atom/ns#">wii</category><title>Processing| Gioco stile pong con Wiimote</title><description>&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a id="single" href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgdinP5ezU4QGc_eeZLF4cHZCJPTgWHMP8-7YrNVNCdH4K-k4P375vLRDvnA_E_OzEVAkHlP-oOBg_cMI_b_aJXBhZQU7kS36gSYVs5hUgez4Qh6nRAjX9T2bO9gaFpgjA01VBdrH-xsA/s1600/wiigame_005.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="349" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgdinP5ezU4QGc_eeZLF4cHZCJPTgWHMP8-7YrNVNCdH4K-k4P375vLRDvnA_E_OzEVAkHlP-oOBg_cMI_b_aJXBhZQU7kS36gSYVs5hUgez4Qh6nRAjX9T2bO9gaFpgjA01VBdrH-xsA/s400/wiigame_005.png" width="400" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
Lo scopo del gioco è quello di bloccare tutti i cubetti in arrico facendoli rimbalzare indietro muovendo la "racchetta". Per farlo è sufficiente impugnare il Wiimote in orizzontale e ruotarlo per far muovere la "racchetta" verso l'alto o verso il basso.&lt;br /&gt;
Ogni 5 punti, la velocità del gioco aumenta ed è possibile compiere al massimo 3 errori. Al terzo errore il gioco termina.&lt;br /&gt;
il codice non &amp;nbsp;è molto complicato, tuttavia facciamo qualche considerazione su alcuni metodi:&lt;br /&gt;
&lt;ul&gt;&lt;li&gt;&lt;span style="font-family: courier;"&gt;&lt;strong&gt;&lt;span style="color: #339966;"&gt;int&lt;/span&gt; ln(&lt;span style="color: #339966;"&gt;int&lt;/span&gt; n)&lt;/strong&gt;&lt;/span&gt;: serve per poi modificare la posizione del testo con il punteggio, in base al numero di cifre del punteggio;&lt;/li&gt;
&lt;li&gt;&lt;span style="font-family: courier;"&gt;&lt;strong&gt;&lt;span style="color: #339966;"&gt;float&lt;/span&gt; stab(&lt;span style="color: #339966;"&gt;float&lt;/span&gt; Y)&lt;/strong&gt;&lt;/span&gt;: riduce l'effetto "vibrazione" della racchetta;&lt;/li&gt;
&lt;li&gt;&lt;span style="font-family: courier;"&gt;&lt;strong&gt;&lt;span style="color: blue;"&gt;void&lt;/span&gt; newpos()&lt;/strong&gt;&lt;/span&gt;: assegna al mattoncino (o pallina a seconda di come lo volete vedere) una nuova posizione e un nuovo colore (entrambi casuali);&lt;/li&gt;
&lt;li&gt;&lt;span style="font-family: courier;"&gt;&lt;strong&gt;boolean impact()&lt;/strong&gt;&lt;/span&gt;: ritorna &lt;em&gt;true&lt;/em&gt; se vi è un impatto tra la pallina e la racchetta;&lt;/li&gt;
&lt;li&gt;&lt;span style="font-family: courier;"&gt;&lt;strong&gt;&lt;span style="color: blue;"&gt;void&lt;/span&gt; backg()&lt;/strong&gt;&lt;/span&gt;: disegna lo sfondo del gioco, che cambia di colore ad ogni avvio.&lt;/li&gt;
&lt;/ul&gt;&lt;a name='more'&gt;&lt;/a&gt;&lt;pre class="java" name="code"&gt;import lll.wrj4P5.*; 
Wrj4P5 wii; 
color c = color(0,0,0); //ball color 
int width_=600;&amp;nbsp; 
int height_=500; 
float x = width_; //ball position 
float y = width_; //ball position 
float speed = 5; 
&amp;nbsp; 
boolean back=false; 
float yuser=0;&amp;nbsp; 
int imp=0; 
int lives=3; 
PFont f; 
float Y,oldY=0; 
boolean conn=false; 
&amp;nbsp; 
float r=random(255/20); //background 
float g=random(255/20); 
float b=random(255/20); 
&amp;nbsp; 
&amp;nbsp; 
void setup() { 
&amp;nbsp;&amp;nbsp;size(width_,height_); 
&amp;nbsp;&amp;nbsp;f=loadFont("Purisa-48.vlw"); 
&amp;nbsp; 
&amp;nbsp;&amp;nbsp;newpos(); 
&amp;nbsp; 
&amp;nbsp;&amp;nbsp;wii=new Wrj4P5(this); 
&amp;nbsp;&amp;nbsp;wii.connect(); 
&amp;nbsp; 
} 
&amp;nbsp; 
void draw() { 
&amp;nbsp;&amp;nbsp;if(conn==true || (wii.rimokon.isConnected())){ 
&amp;nbsp;&amp;nbsp; &amp;nbsp;conn=true; 
&amp;nbsp;&amp;nbsp; &amp;nbsp;backg(); 
&amp;nbsp; 
&amp;nbsp; 
&amp;nbsp;&amp;nbsp; &amp;nbsp;if(lives&amp;lt;=0){ 
&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp;textFont(f,40); 
&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp;text("Game Over",width/2-100,height/2); 
&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp;return; 
&amp;nbsp;&amp;nbsp; &amp;nbsp;} 
&amp;nbsp; 
&amp;nbsp;&amp;nbsp; &amp;nbsp;move(); 
&amp;nbsp; 
&amp;nbsp;&amp;nbsp; &amp;nbsp;fill(255); 
&amp;nbsp;&amp;nbsp; &amp;nbsp;textFont(f,26); 
&amp;nbsp;&amp;nbsp; &amp;nbsp;text("Lives: "+lives,width-110,height-10); 
&amp;nbsp;&amp;nbsp; &amp;nbsp;textFont(f,40); 
&amp;nbsp;&amp;nbsp; &amp;nbsp;text(imp,width-(25*ln(imp)),30); 
&amp;nbsp;&amp;nbsp; &amp;nbsp;Y=(float)((wii.rimokon.senced.x+1)*(height/3+50)); 
&amp;nbsp; 
&amp;nbsp;&amp;nbsp; &amp;nbsp;Y=stab(Y); 
&amp;nbsp; 
&amp;nbsp;&amp;nbsp; &amp;nbsp;display(); 
&amp;nbsp;&amp;nbsp;}else{ 
&amp;nbsp;&amp;nbsp; &amp;nbsp;fill(0); 
&amp;nbsp;&amp;nbsp; &amp;nbsp;textFont(f,16); 
&amp;nbsp;&amp;nbsp; &amp;nbsp;text("Trying to find a Wiimote",width/2-100,height/2); 
&amp;nbsp;&amp;nbsp;} 
} 
&amp;nbsp; 
int ln(int n){ 
&amp;nbsp;&amp;nbsp;int i=0; 
&amp;nbsp;&amp;nbsp;while (n&amp;gt;0){ 
&amp;nbsp;&amp;nbsp; &amp;nbsp;n=n/10; 
&amp;nbsp;&amp;nbsp; &amp;nbsp;i++; 
&amp;nbsp;&amp;nbsp; &amp;nbsp;println(n); 
&amp;nbsp;&amp;nbsp;} 
&amp;nbsp;&amp;nbsp;return i; 
} 
&amp;nbsp; 
float stab(float Y){ 
&amp;nbsp;&amp;nbsp;if (abs(Y-oldY)&amp;gt;2.5){ 
&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;oldY=Y; 
&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;return Y; 
&amp;nbsp;&amp;nbsp;} 
&amp;nbsp;&amp;nbsp;return oldY; 
} 
&amp;nbsp; 
void move() { 
&amp;nbsp;&amp;nbsp;if(!back){ 
&amp;nbsp;&amp;nbsp; &amp;nbsp;x = x - speed; 
&amp;nbsp;&amp;nbsp; &amp;nbsp;if (x &amp;lt;0) { 
&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp;println("-1"); 
&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp;lives--; 
&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp;newpos(); 
&amp;nbsp;&amp;nbsp; &amp;nbsp;} 
&amp;nbsp;&amp;nbsp;}else{ 
&amp;nbsp;&amp;nbsp; &amp;nbsp;x = x + speed; 
&amp;nbsp;&amp;nbsp; &amp;nbsp;if(x&amp;gt;=width){ 
&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp;back=false; 
&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp;newpos(); 
&amp;nbsp;&amp;nbsp; &amp;nbsp;} 
&amp;nbsp;&amp;nbsp;} 
} 
&amp;nbsp; 
void newpos(){ 
&amp;nbsp;&amp;nbsp; &amp;nbsp;x = width; 
&amp;nbsp;&amp;nbsp; &amp;nbsp;y=random(height-30); 
&amp;nbsp;&amp;nbsp; &amp;nbsp;c=color((int)random(255),(int)random(255),(int)random(255)); 
} 
&amp;nbsp; 
void display() { 
&amp;nbsp;&amp;nbsp;fill(c); 
&amp;nbsp;&amp;nbsp;stroke(c); 
&amp;nbsp;&amp;nbsp;rect(x,y,30,30); 
&amp;nbsp;&amp;nbsp;fill(20); 
&amp;nbsp;&amp;nbsp;noStroke(); 
&amp;nbsp;&amp;nbsp;rect(10, Y,40,80); 
&amp;nbsp;&amp;nbsp;if(impact()){ 
&amp;nbsp;&amp;nbsp; &amp;nbsp;back=true; 
&amp;nbsp;&amp;nbsp; &amp;nbsp;imp++; 
&amp;nbsp;&amp;nbsp; &amp;nbsp;println(imp); 
&amp;nbsp;&amp;nbsp; &amp;nbsp;if(imp%5==0) 
&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp;speed++; 
&amp;nbsp;&amp;nbsp;} 
} 
&amp;nbsp; 
boolean impact(){ 
&amp;nbsp;&amp;nbsp;if((x&amp;lt;=50 &amp;amp;&amp;amp; x&amp;gt;(50-speed)) &amp;amp;&amp;amp; ((y&amp;lt;Y+80) &amp;amp;&amp;amp; (y+40&amp;gt;Y))) 
&amp;nbsp;&amp;nbsp; &amp;nbsp;return true; 
&amp;nbsp;&amp;nbsp;return false; 
} 
&amp;nbsp; 
void backg(){ 
&amp;nbsp;&amp;nbsp;for(int i=0;i&amp;lt;height/20;i++){ 
&amp;nbsp;&amp;nbsp; &amp;nbsp;fill(color((i+1)*r,(i+1)*g,(i+1)*b)); 
&amp;nbsp;&amp;nbsp; &amp;nbsp;noStroke(); 
&amp;nbsp;&amp;nbsp; &amp;nbsp;rect(0,20*i,width,20); 
&amp;nbsp;&amp;nbsp;} 
} 
&amp;nbsp; 
&lt;/pre&gt;Nel video qui sotto potete vedere il gioco in esecuzione.&lt;br /&gt;
&lt;iframe frameborder="0" height="390" src="http://www.youtube.com/embed/6K7EJ7_Xfu0?rel=0" width="480"&gt;&lt;/iframe&gt;&lt;br /&gt;
&lt;br /&gt;
UPDATE 07/03/11: I sorgenti e i file .jar sono disponibili su &lt;a href="http://github.com/nicopi/wiipong"&gt;github&lt;/a&gt;</description><link>http://nicopi.blogspot.com/2011/03/processing-gioco-stile-pong-con-wiimote.html</link><author>noreply@blogger.com (Nicopi)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" height="72" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgdinP5ezU4QGc_eeZLF4cHZCJPTgWHMP8-7YrNVNCdH4K-k4P375vLRDvnA_E_OzEVAkHlP-oOBg_cMI_b_aJXBhZQU7kS36gSYVs5hUgez4Qh6nRAjX9T2bO9gaFpgjA01VBdrH-xsA/s72-c/wiigame_005.png" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-6293392127511442927.post-5083904598997863261</guid><pubDate>Sun, 27 Feb 2011 18:00:00 +0000</pubDate><atom:updated>2011-03-20T19:13:06.417+02:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">processing</category><category domain="http://www.blogger.com/atom/ns#">wii</category><title>Processing| Interfacciamo il Wiimote</title><description>&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a id="single" href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhb_C6df4rrP9beiaq7zxvqqqQRWcuMCp4nw8CyVSC0Mfa6wgbMksFtNj0G0f-rALECSssf9ptjDI_D4-HKOh0DZGbeRt6FUnhRz3fA8BQMY02mxQREKmPW-yWnJwmVcPySgiWP07vmcQ/s1600/cuboRGBwii_003.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="231" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhb_C6df4rrP9beiaq7zxvqqqQRWcuMCp4nw8CyVSC0Mfa6wgbMksFtNj0G0f-rALECSssf9ptjDI_D4-HKOh0DZGbeRt6FUnhRz3fA8BQMY02mxQREKmPW-yWnJwmVcPySgiWP07vmcQ/s400/cuboRGBwii_003.png" width="400" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
Una delle novità più importanti degli ultimi 10 anni nel campo delle console è stato, senza dubbio, il &lt;a href="http://en.wikipedia.org/wiki/Wii_Remote" target="_blank"&gt;Wiimote&lt;/a&gt;: il rivoluzionario controller Wii che consente al giocatore di interaggire con il gioco usando i movimenti del proprio corpo.&lt;br /&gt;
Gli accelerometri presenti nel controller hanno permesso lo sviluppo di giochi molto "pratici", basti pensare a come WiiSport permetta di giocare a baseball o a tennis, impugnando il telecomando come se fosse una mazza o una racchetta e facendo compiere al personaggio del gioco gli stessi movimenti fatti dal giocatore "reale"; cosa impensabile un tempo.&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;&lt;span style="font-size: small;"&gt;Cosa vogliamo fare&lt;/span&gt;&lt;/strong&gt;&lt;br /&gt;
Un semplice programma che permetta di visualizzare i movimenti del Wiimote; ho pensato di utilizzare il Wiimote per ruotare un cubo colorato.&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;&lt;span style="font-size: small;"&gt;Come lo vogliamo fare&lt;/span&gt;&lt;/strong&gt;&lt;br /&gt;
Lo farò con &lt;a href="http://www.processing.org/" target="_blank"&gt;Processing&lt;/a&gt;, che forse conoscerete già e che consentirà di creare il programma senza dover spendere troppe righe di codice. L'ho conosciuto grazie ad &lt;a href="http://www.arduino.cc/" target="_blank"&gt;Arduino&lt;/a&gt;, e non è male!&lt;br /&gt;
Iniziamo!&lt;br /&gt;
&lt;a name='more'&gt;&lt;/a&gt;&lt;br /&gt;
&lt;strong&gt;&lt;span style="font-size: large;"&gt;Le librerie&lt;/span&gt;&lt;/strong&gt;&lt;br /&gt;
Prima di tutto è necessario installare l varie librerie, che sono:&lt;br /&gt;
&lt;strong&gt;&lt;a href="http://code.google.com/p/bluecove/" target="_blank"&gt;Bluecove&lt;/a&gt;&lt;/strong&gt;: permette al nostro programma Java di interfacciarsi con l'hardware bluetooth del sistema.&lt;br /&gt;
Ci servono i file &lt;em&gt;bluecove-2.1.0.jar &lt;/em&gt;, &lt;em&gt;bluecove-gpl-2.1.0.jar&lt;/em&gt;&lt;br /&gt;
&lt;strong&gt;&lt;a href="http://www.world-of-cha0s.hostrocket.com/WiiRemoteJ/" target="_blank"&gt;WiiRemoteJ&lt;/a&gt;&lt;/strong&gt;: Si tratta di una libreria Java che consente di interfacciare il Wiimote con il programma Java.&lt;br /&gt;
Ci serve il file &lt;em&gt;WiiremoteJ.jar&lt;/em&gt;&lt;br /&gt;
&lt;strong&gt;&lt;a href="http://sourceforge.jp/projects/wrj4p5/" target="_blank"&gt;Wrj4p5&lt;/a&gt;&lt;/strong&gt;: Libreria che converte le informazioni ottenute da WiiRemoteJ in qualcosa di più semplice da usare con processing :)&lt;br /&gt;
Ci servono &lt;em&gt;Wrj4p5.jar&lt;/em&gt; e &lt;em&gt;Loc.jar&lt;/em&gt;&lt;br /&gt;
&lt;em&gt;&lt;br /&gt;
&lt;/em&gt;&lt;br /&gt;
Per prima cosa copiamo i file &lt;em&gt;bluecove-2.1.0.jar,&lt;/em&gt;&amp;nbsp;&lt;em&gt;bluecove-gpl-2.1.0.jar &lt;/em&gt;e &lt;em&gt;WiiRemoteJ.jar&lt;/em&gt; nella cartella contenente le librerie di Java. Nel mio caso si trova in &lt;em&gt;/usr/lib/jvm/java-6-sun-1.6.0.24/jre/lib/&amp;nbsp;&lt;/em&gt;&lt;br /&gt;
Poi nelle cartella delle librerie di processing (processing-***/libraries) creiamo la cartella &lt;em&gt;wrj4P5&lt;/em&gt; e la sottocartella&lt;em&gt; library&lt;/em&gt;.&lt;br /&gt;
Qui dentro copiamo i file &lt;em&gt;bluecove-2.1.0.jar&lt;/em&gt;, &lt;em&gt;bluecove-gpl-2.1.0.jar&lt;/em&gt;, &lt;em&gt;Loc.jar&lt;/em&gt;, &lt;em&gt;WiiRemoteJ.jar&lt;/em&gt;, &lt;em&gt;wrj4P5.jar&lt;/em&gt;.&lt;br /&gt;
Finito?&lt;br /&gt;
No. E' necessario installare anche il pacchetto libbluetooth-dev, e quindi diamo un bel:&lt;br /&gt;
&lt;blockquote&gt;sudo apt-get install libbluetooth-dev&lt;/blockquote&gt;&lt;br /&gt;
Finito? Sì :D&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;&lt;span style="font-size: large;"&gt;Il programma&lt;/span&gt;&lt;/strong&gt;&lt;br /&gt;
Ed ecco il programma: si tratta dell'esempio sul cubo RGB presente nel sito di Processing modificato in modo da utilizzare i dati di rotazione del Wiimote invece che il mouse per gestire la rotazione.&lt;br /&gt;
&lt;pre class="java" name="code"&gt;import lll.wrj4P5.*; //importa libreria 
Wrj4P5 wii; //crea un nuovo oggetto
float xmag, ymag = 0; 
float newXmag, newYmag = 0;
float x=1; 
void setup() { 
 size(640, 360, P3D);
 noStroke(); 
 colorMode(RGB, 1); 
 wii=new Wrj4P5(this); 
 wii.connect(); //cerca il wiimote 
} 
 
void draw() { 
 background(0.5); 
 pushMatrix(); 
 translate(width/2, height/2, -30); 
 newXmag = (wii.rimokon.senced.x*150)/float(width) * TWO_PI; 
 newYmag = (wii.rimokon.senced.y*150)/float(height) * TWO_PI; 
 float diff = xmag-newXmag;
 if (abs(diff) &amp;gt;  0.01) { xmag -= diff/4.0; } 
 
 diff = ymag-newYmag;
 if (abs(diff) &amp;gt;  0.01) { ymag -= diff/4.0; } 
 
 rotateX(-ymag); 
 rotateY(-xmag); 
 scale(90); 
 beginShape(QUADS);
 
 fill(0, 1, 1); vertex(-1,  1,  1); 
 fill(1, 1, 1); vertex( 1,  1,  1); 
 fill(1, 0, 1); vertex( 1, -1,  1); 
 fill(0, 0, 1); vertex(-1, -1,  1);
 
 fill(1, 1, 1); vertex( 1,  1,  1);
 fill(1, 1, 0); vertex( 1,  1, -1);
 fill(1, 0, 0); vertex( 1, -1, -1);
 fill(1, 0, 1); vertex( 1, -1,  1); 
 
 fill(1, 1, 0); vertex( 1,  1, -1);
 fill(0, 1, 0); vertex(-1,  1, -1);
 fill(0, 0, 0); vertex(-1, -1, -1);
 fill(1, 0, 0); vertex( 1, -1, -1);
 
 fill(0, 1, 0); vertex(-1,  1, -1);
 fill(0, 1, 1); vertex(-1,  1,  1);
 fill(0, 0, 1); vertex(-1, -1,  1);
 fill(0, 0, 0); vertex(-1, -1, -1);
 
 fill(0, 1, 0); vertex(-1,  1, -1);
 fill(1, 1, 0); vertex( 1,  1, -1);
 fill(1, 1, 1); vertex( 1,  1,  1); 
 fill(0, 1, 1); vertex(-1,  1,  1); 
 
 fill(0, 0, 0); vertex(-1, -1, -1);
 fill(1, 0, 0); vertex( 1, -1, -1);
 fill(1, 0, 1); vertex( 1, -1,  1); 
 fill(0, 0, 1); vertex(-1, -1,  1); 
 
 endShape();
 popMatrix();  &lt;/pre&gt;</description><link>http://nicopi.blogspot.com/2011/02/processing-interfacciamo-il-wiimote.html</link><author>noreply@blogger.com (Nicopi)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" height="72" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhb_C6df4rrP9beiaq7zxvqqqQRWcuMCp4nw8CyVSC0Mfa6wgbMksFtNj0G0f-rALECSssf9ptjDI_D4-HKOh0DZGbeRt6FUnhRz3fA8BQMY02mxQREKmPW-yWnJwmVcPySgiWP07vmcQ/s72-c/cuboRGBwii_003.png" width="72"/><thr:total>0</thr:total></item></channel></rss>