francescomecca.eu/_site/page4/index.html
2016-11-19 18:38:14 +01:00

448 lines
24 KiB
HTML
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!DOCTYPE html>
<html lang="en-us">
<head>
<link href="http://gmpg.org/xfn/11" rel="profile">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<!-- Enable responsiveness on mobile devices-->
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1">
<title>
Caught in the Net &middot; La rete ti cattura ma libera il pensiero
</title>
<!-- CSS -->
<link rel="stylesheet" href="/public/css/poole.css">
<link rel="stylesheet" href="/public/css/syntax.css">
<link rel="stylesheet" href="/public/css/hyde.css">
<!-- Icons -->
<link rel="apple-touch-icon-precomposed" sizes="144x144" href="/public/apple-touch-icon-144-precomposed.png">
<link rel="shortcut icon" href="/public/favicon.ico">
<!-- RSS -->
<link rel="alternate" type="application/rss+xml" title="RSS" href="/atom.xml">
</head>
<body class="theme-base-09">
<div class="sidebar">
<div class="container sidebar-sticky">
<div class="sidebar-about">
<h1>
<a href="/">
Caught in the Net
</a>
</h1>
<p class="lead"></p>
</div>
<nav class="sidebar-nav">
<a class="sidebar-nav-item" href="/">Home</a>
<a class="sidebar-nav-item" href="/about/">About</a>
<a class="sidebar-nav-item" href="/archive/">Archive</a>
<a class="sidebar-nav-item" href="/contattami/">Contact me</a>
<a class="sidebar-nav-item" href="/feed.xml">RSS</a>
<a class="sidebar-nav-item" href="http://francescomecca.eu:3000/explore/repos">Personal Git</a>
<span class="sidebar-nav-item" href="" >Powered by Jekyll and Hyde</span>
</nav>
<p>&copy; 2016. CC BY-SA 4.0 International </p>
</div>
</div>
<h3 class="masthead-title">
<a href="/" title="Home">Caught in the Net</a>
</h3>
<div class="content container">
<div class="posts">
<div class="post">
<h1 class="post-title">
<a href="/index.php/archives/207">
The Buridan&#8217;s donkey paradox
</a>
</h1>
<span class="post-date">20 Sep 2015</span>
<p style="text-align: left;">
The Buridan&#8217;s donkey is an illustration of a paradox regarding the philosophy of moral determinism and free will.
</p>
<p style="text-align: left;">
The paradox shows an hypothetical situation in which a donkey searching for food is caught in the middle of two equally appealing stacks of hay located at the same distance from the donkey. Because the donkey has no real reason to choose one over the other he dies of starvation.
</p>
<p><a href="https://en.wikipedia.org/wiki/Buridan&#x27;s_ass"><img class="aligncenter size-full wp-image-209" src="http://francescomecca.eu/wp-content/uploads/2015/09/Deliberations_of_Congress.jpg" alt="Deliberations_of_Congress" width="431" height="425" srcset="http://francescomecca.eu/wp-content/uploads/2015/09/Deliberations_of_Congress-300x296.jpg 300w, http://francescomecca.eu/wp-content/uploads/2015/09/Deliberations_of_Congress.jpg 431w" sizes="(max-width: 431px) 100vw, 431px" /></a>I have decided to write a cli program that chooses for me when I can&#8217;t make up my mind.</p>
<p>The program is written in C++ and when invoked along with two or more arguments it puts them in a vector and then changes the order randomly.</p>
<figure class="highlight"><pre><code class="language-c" data-lang="c"><span class="cp">#include &lt;iostream&gt;
#include &lt;vector&gt;
#include &lt;algorithm&gt;
#include &lt;random&gt;
#include &lt;string&gt;
#include &lt;sys/poll.h&gt;
</span><span class="n">using</span> <span class="n">namespace</span> <span class="n">std</span><span class="p">;</span>
<span class="k">struct</span> <span class="n">pollfd</span> <span class="n">stdin_poll</span> <span class="o">=</span> <span class="p">{</span>
<span class="p">.</span><span class="n">fd</span> <span class="o">=</span> <span class="n">fileno</span> <span class="p">(</span><span class="n">stdin</span><span class="p">),</span> <span class="p">.</span><span class="n">events</span> <span class="o">=</span> <span class="n">POLLIN</span>
<span class="p">};</span>
<span class="kt">void</span> <span class="nf">read_from_piped_input</span> <span class="p">(</span><span class="n">vector</span><span class="o">&lt;</span><span class="n">string</span><span class="o">&gt;&amp;</span> <span class="n">lst</span><span class="p">)</span>
<span class="p">{</span>
<span class="n">string</span> <span class="n">x</span><span class="p">;</span>
<span class="k">while</span> <span class="p">(</span><span class="n">getline</span> <span class="p">(</span><span class="n">cin</span><span class="p">,</span> <span class="n">x</span><span class="p">))</span> <span class="p">{</span>
<span class="n">lst</span><span class="p">.</span><span class="n">push_back</span> <span class="p">(</span><span class="n">x</span><span class="p">);</span>
<span class="p">}</span>
<span class="p">}</span>
<span class="kt">void</span> <span class="nf">read_from_arguments</span> <span class="p">(</span><span class="k">const</span> <span class="kt">int</span><span class="o">&amp;</span> <span class="n">argc</span><span class="p">,</span> <span class="kt">char</span><span class="o">*</span> <span class="n">argv</span><span class="p">[],</span> <span class="n">vector</span><span class="o">&lt;</span><span class="n">string</span><span class="o">&gt;&amp;</span> <span class="n">lst</span><span class="p">)</span>
<span class="p">{</span>
<span class="k">if</span> <span class="p">(</span><span class="n">argc</span> <span class="o">==</span> <span class="mi">1</span><span class="p">)</span> <span class="p">{</span>
<span class="n">cout</span> <span class="o">&lt;&lt;</span> <span class="s">"Usage: asino [string] [string] ..."</span> <span class="o">&lt;&lt;</span> <span class="n">endl</span><span class="p">;</span>
<span class="n">exit</span><span class="p">;</span>
<span class="p">}</span>
<span class="k">for</span> <span class="p">(</span><span class="n">vector</span><span class="o">&lt;</span><span class="n">string</span><span class="o">&gt;::</span><span class="n">size_type</span> <span class="n">i</span> <span class="o">=</span> <span class="mi">1</span><span class="p">;</span> <span class="n">i</span> <span class="o">&lt;</span> <span class="n">argc</span><span class="p">;</span> <span class="o">++</span><span class="n">i</span><span class="p">)</span> <span class="p">{</span>
<span class="n">lst</span><span class="p">.</span><span class="n">push_back</span> <span class="p">(</span><span class="n">argv</span><span class="p">[</span><span class="n">i</span><span class="p">]);</span>
<span class="p">}</span>
<span class="p">}</span>
<span class="kt">int</span> <span class="nf">main</span> <span class="p">(</span><span class="kt">int</span> <span class="n">argc</span><span class="p">,</span> <span class="kt">char</span><span class="o">*</span> <span class="n">argv</span><span class="p">[])</span>
<span class="p">{</span>
<span class="n">vector</span><span class="o">&lt;</span><span class="n">string</span><span class="o">&gt;</span> <span class="n">lst</span><span class="p">;</span>
<span class="kt">int</span> <span class="n">poll_ret</span> <span class="o">=</span> <span class="n">poll</span> <span class="p">(</span><span class="o">&amp;</span><span class="n">stdin_poll</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">0</span><span class="p">);</span>
<span class="k">if</span> <span class="p">(</span><span class="n">poll_ret</span> <span class="o">&gt;</span> <span class="mi">0</span><span class="p">)</span> <span class="p">{</span>
<span class="n">read_from_piped_input</span> <span class="p">(</span><span class="n">lst</span><span class="p">);</span>
<span class="p">}</span>
<span class="k">else</span> <span class="p">{</span>
<span class="n">read_from_arguments</span> <span class="p">(</span><span class="n">argc</span><span class="p">,</span> <span class="n">argv</span><span class="p">,</span> <span class="n">lst</span><span class="p">);</span>
<span class="p">}</span>
<span class="n">random_device</span> <span class="n">rd</span><span class="p">;</span>
<span class="n">mt19937</span> <span class="n">m</span><span class="p">(</span><span class="n">rd</span><span class="p">());</span>
<span class="n">shuffle</span> <span class="p">(</span><span class="n">lst</span><span class="p">.</span><span class="n">begin</span> <span class="p">(),</span> <span class="n">lst</span><span class="p">.</span><span class="n">end</span> <span class="p">(),</span> <span class="n">m</span><span class="p">);</span>
<span class="kt">int</span> <span class="n">i</span> <span class="o">=</span> <span class="mi">1</span><span class="p">;</span>
<span class="k">for</span> <span class="p">(</span><span class="n">vector</span><span class="o">&lt;</span><span class="n">string</span><span class="o">&gt;::</span><span class="n">iterator</span> <span class="n">it</span> <span class="o">=</span> <span class="n">lst</span><span class="p">.</span><span class="n">begin</span> <span class="p">();</span> <span class="n">it</span> <span class="o">!=</span> <span class="n">lst</span><span class="p">.</span><span class="n">end</span> <span class="p">();</span> <span class="o">++</span><span class="n">it</span><span class="p">)</span> <span class="p">{</span>
<span class="n">cout</span> <span class="o">&lt;&lt;</span> <span class="n">i</span><span class="o">++</span> <span class="o">&lt;&lt;</span> <span class="s">". "</span> <span class="o">&lt;&lt;</span> <span class="o">*</span><span class="n">it</span> <span class="o">&lt;&lt;</span> <span class="n">endl</span><span class="p">;</span>
<span class="p">}</span>
<span class="p">}</span></code></pre></figure>
<p>I have used the <a href="http://en.cppreference.com/w/cpp/numeric/random/mersenne_twister_engine" target="_blank">Mersenne Twister PRNG</a> just to give it a try.</p>
<p style="text-align: left;">
One of the challenges was to read from stdin instead of arguments when the program is piped after another program in the shell:
</p>
<figure class="highlight"><pre><code class="language-sh" data-lang="sh">ls /media/my_movies/ | buridan</code></pre></figure>
<p>So I have used poll() that checks for a specified amount of time if the selected device (/dev/stdin in my case) can perform I/O operations; in my code:</p>
<figure class="highlight"><pre><code class="language-bash" data-lang="bash">poll <span class="o">(</span>&amp;stdin_poll, 1, 0<span class="o">)</span></code></pre></figure>
<p>I selected the POLLIN as event so poll() only checks if there is data to read, 1 as the number of items in the fds array, 0 milliseconds of timeout because when the program is invoked /dev/stdin may already contain input.</p>
<p>The program should be compiled this way:</p>
<figure class="highlight"><pre><code class="language-bash" data-lang="bash">g++ -std<span class="o">=</span>c++11 ./program.cpp -o output</code></pre></figure>
<p>You are free to reuse this little piece of code as you wish.</p>
<p>EDIT: 02-04-2016
The original idea for the Buridan&#39;s donkey came from my mentor <a href="https://twitter.com/bassosimone">Simone Basso</a> who wrote the original one in haskell.</p>
<p style="text-align: right;">
Francesco Mecca
</p>
</div>
<div class="post">
<h1 class="post-title">
<a href="/index.php/archives/198">
About Perl packages in Gentoo
</a>
</h1>
<span class="post-date">11 Sep 2015</span>
<p>In this post I wish to explain a bit about Perl related ebuilds in Gentoo and how to update from perl-core to virtual/perl without conflicts.</p>
<p>First of all the core distribution of Perl is included in <a href="https://packages.gentoo.org/package/dev-lang/perl">dev-lang/Perl</a> along with <a href="http://perldoc.perl.org/index-modules-A.html">modules</a>.</p>
<p>The <a href="https://sources.gentoo.org/cgi-bin/viewvc.cgi/gentoo-x86/perl-core/">perl-core category</a> in portage contains ebuilds for perl modules, some of which are included in the core perl distibution. The perl-core ebuilds overrides the perl-core modules such that you can update them without recompiling dev-lang/Perl.</p>
<p>Each perl-core module has a corrensponding virtual/perl-* package. The virtual category is used by portage when emerging to take into account that a module can be either provided by dev-lang/perl package or found in perl-core category.</p>
<p>So, what to do in case of blocks when upgrading your Gentoo machine?</p>
<p>Perl-cleaner is a package provided to get rid of these blocks and to migrate from perl-core to virtual/perl-*.</p>
<pre class="wp-code-highlight prettyprint linenums:1">emerge perl-cleaner
emerge dev-lang/perl
perl-cleaner --all</pre>
<p>if you still have problems when upgrading @world you add a backtrack option</p>
<pre class="wp-code-highlight prettyprint linenums:1">emerge -uDN --backtrack=30 @world</pre>
<p>or you can unmerge all perl-core packages and then finally upgrade world</p>
<pre class="wp-code-highlight prettyprint linenums:1">emerge --unmerge perl-core/*</pre>
<p>This will remove all perl-core packages that virtual/perl-* packages will bring back if needed.</p>
<p style="text-align: right;">
Francesco Mecca
</p>
</div>
<div class="post">
<h1 class="post-title">
<a href="/index.php/archives/177">
56 secondi di celebrita`
</a>
</h1>
<span class="post-date">31 Aug 2015</span>
<p><a href="http://www.mantellini.it/2015/08/26/state-al-riparo/" target="_blank" rel="http://www.mantellini.it/2015/08/26/state-al-riparo/"><img class="aligncenter wp-image-178 size-full" src="http://francescomecca.eu/wp-content/uploads/2015/08/Schermata-2015-08-26-alle-22.29.31.jpg" alt="" width="644" height="533" srcset="http://francescomecca.eu/wp-content/uploads/2015/08/Schermata-2015-08-26-alle-22.29.31-300x248.jpg 300w, http://francescomecca.eu/wp-content/uploads/2015/08/Schermata-2015-08-26-alle-22.29.31.jpg 644w" sizes="(max-width: 644px) 100vw, 644px" /></a></p>
<p>Dura 56 secondi il video di Vester Lee Flanagan che testimonia l&#8217;omicidio in prima persona di due giornalisti in Virginia durante un live broadcast televisivo. Durante l&#8217;inseguimento nel quale si e` tolto la vita Flanagan ha caricato su Twitter e Facebook il video dell&#8217;uccisione in prima persona.</p>
<p>Twitter e Facebook hanno tempestivamente censurato il video e rimosso l&#8217;account dell&#8217;omicida ed alcune emittenti televisive (come SkyTg24) hanno scelto allo stesso modo di non pubblicare il video in diretta.</p>
<h3 id="to-publish-or-not-to-publish">To publish or not to publish?</h3>
<p>E` quindi una decisione giusta quella di non pubblicare il video?</p>
<p><a href="https://stevebuttry.wordpress.com/2015/08/26/media-should-avoid-indulging-attention-seeking-killers/" target="_blank">Steve Buttry sul suo blog</a> si esprime in questo modo:</p>
<blockquote>
<p>1) Someone who attacks during a live telecast is seeking attention. Obviously you need to report the attack, but I would not broadcast the attack or make it available online.</p>
<p>[&#8230;]</p>
<p>4) I see no ethical justification for publishing videos shot by the killer. That is the ultimate in attention-seeking behavior.</p>
<p>5) You can report the mental health issues, gun access issues and other issues that a story presents without publicizing or profiling the killer.</p>
<p>6) My focus would be on the people who were killed or injured. They warrant media attention, not the person who was seeking it.</p>
</blockquote>
<p>1)Una persona che attacca durante una trasmissione in diretta e` alla ricerca di attenzione. Naturalmente si deve rendere noto l&#8217;atto, ma io non lo trasmetterei ne lo pubblicherei online.</p>
<p>[&#8230;]</p>
<p>4) Non vedo giustificazioni etiche per pubblicare il video: e` l&#8217;esempio piu` eclatante di ricerca di attenzioni.</p>
<p>5) Puoi discutere sui problemi mentali, la questione relativa al facile accesso alle armi e tutti gli altri problemi di questa storia senza mostrare o pubblicizzare il killer.</p>
<p>6) Io mi concentrerei sulle persone ferite o uccise. Loro meritano l&#8217;attenzione dei media, non la persona che la cercava.</p>
<h3 id="famoso-in-un-istante">Famoso in un istante</h3>
<p>E` ovvio che Flanagan stesse cercando i suoi 15 minuti di fama con <a href="http://www.theguardian.com/us-news/2015/aug/27/virginia-shooting-in-an-instant-vester-flanagan-broadcast-death-to-the-world" target="_blank">questo atto</a>, ma a mio parere non ci sarebbe riuscito se non sfruttando nuovi strumenti quali lo smartphone e i social network. Molto difficilmente sarebbe riuscito 20 anni fa utilizzando i media tradizionali a filmarsi in prima persona in una situazione del genere e a rendere cosi` tante persone testimoni del suo gesto.</p>
<p>Per questo non mi trovo d&#8217;accordo con Steve Buttry che afferma che il video non andrebbe reso disponibile online. i nuovi media hanno un ruolo diverso nella condivisione dei contenuti e soprattutto nel mantenimento della memoria storica. Un video del genere non aggiunge alcun valore investigativo o giornalistico al caso ma puo` ritenersi utile per analisi differenti, in primis psicologiche, ed ha sicuramente un valore storico (da quanto conosco e` il primo video in prima persona di un omicidio con queste dinamiche).</p>
<h3 id="lo-specchio-nero">Lo specchio nero</h3>
<p>Chi come me e` un grande fan della serie TV <a href="https://en.wikipedia.org/wiki/Black_Mirror_%28TV_series%29" target="_blank">Black Mirror</a> avra` sicuramente ricordato il primo episodio della serie: National Anthem.</p>
<p>Questo episodio e` un&#8217;analisi sottile e dettagliata della natura umana, che di fronte ad eventi che suscitano un cosi` grande clamore sospendono ogni giudizio morale e dimenticano il motivo per cui si trovano a guardare cio` che hanno di fronte.</p>
<p>Allo stesso modo trovo miserevole poter assistere a giornalisti ed emittenti televisive che per attirare spettatori nelle proprie reti mostrano il video integrale.</p>
<p>Come in National Anthem chi ha perpetrato il crimine non ci ha costretto ad essere complici del suo gesto.</p>
<p style="text-align: right;">
Francesco Mecca
</p>
</div>
<div class="post">
<h1 class="post-title">
<a href="/index.php/archives/171">
Addio Blogspot
</a>
</h1>
<span class="post-date">25 Aug 2015</span>
<p><a href="http://dashburst.com/nsa-needs-google-eye-in-sky/"><img class="aligncenter wp-image-172 size-medium" src="http://francescomecca.eu/wp-content/uploads/2015/08/googlebigbrother-296x300.jpg" alt="" width="296" height="300" srcset="http://francescomecca.eu/wp-content/uploads/2015/08/googlebigbrother-296x300.jpg 296w, http://francescomecca.eu/wp-content/uploads/2015/08/googlebigbrother.jpg 669w" sizes="(max-width: 296px) 100vw, 296px" /></a>Ho deciso di abbandonare Blogspot per le stesse ragioni per cui ho smesso di utilizzare i servizi Google due anni fa: privacy e controllo.</p>
<p>Ora il blog e` disponibile a questo indirizzo ed e` fisicamente sul mio Raspberry PI che utilizza Raspbian + WordPress.</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
</div>
<div class="post">
<h1 class="post-title">
<a href="/index.php/archives/99">
A pochi metri da Stallman
</a>
</h1>
<span class="post-date">21 Jul 2015</span>
<p><span style="font-family: inherit;">Il 25 giugno sono stato alla presentazione del master di primo livello in “<a href="http://nexacenter.org/2015/06/master-software-libero">Management del Software Libero</a>”, che si e` tenuto nella sala della palazzo della Regione Piemonte. </span></p>
<p><span style="font-family: inherit;"><br /> Non mento dicendo che a questo incontro ci sono andato principalmente per ascoltare il professor <a href="https://www.youtube.com/watch?v=gdsd2L_pqs4">Angelo Meo</a> (che ha aiutato a curare parte del programma del master) e <a href="http://stallman.org/">Richard Stallman</a>. </span></p>
<table class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;" cellspacing="0" cellpadding="0" align="center">
<tr>
<td style="text-align: center;">
<a style="margin-left: auto; margin-right: auto;" href="http://francescomecca.eu/wp-content/uploads/2015/08/5d468-photo181239520039119435.jpg"><img src="http://francescomecca.eu/wp-content/uploads/2015/08/5d468-photo181239520039119435.jpg?w=300" alt="" width="400" height="300" border="0" /></a>
</td>
</tr>
<tr>
<td class="tr-caption" style="text-align: center;">
foto originale distribuita in <a href="https://creativecommons.org/licenses/by-nc-nd/4.0/">CC-by-nd-nc</a>
</td>
</tr>
</table>
<p><span style="font-family: inherit;"> Il master, ha spiegato Meo, si occupa di fornire le competenze necessarie per permettere un&#8217;analisi precisa costi / benefici nel momento della transizione verso il free software all&#8217;interno di un&#8217;azienda, transizione che deve essere priva di attriti e semplice per i dipendenti.</span></p>
<p><span style="font-family: inherit;">Per questo si compie un percorso di studi che tratta gli aspetti giuridici ed economici, oltre che tecnologici.<br /> </span></p>
<p><span style="font-family: inherit;">Infine Meo ha ricordato di come Internet sia tanto madre quanto figlia del software libero e ci ha brevemente ricordato di come Torino <a href="http://torino.repubblica.it/cronaca/2014/08/03/news/il_comune_rinnova_i_pc_e_d_laddio_a_microsoft_risparmiamo_6_milioni-93067980/">ha risparmiato 6 milioni di euro</a>.<br /> </span></p>
<p><span style="font-family: inherit;">Il keynote di Stallman invece e` stato una piacevole introduzione al software libero per i neofiti, in particolare: </span></p>
<ul>
<li><span style="font-family: inherit;"> </span><span style="font-family: inherit;">Microsoft, Apple e i <a href="https://www.fsf.org/campaigns/drm.html">DRM</a>; </span></li>
<li><span style="font-family: inherit;"> </span><span style="font-family: inherit;">4 liberta` fondamentali del software libero; </span></li>
<li><span style="font-family: inherit;"> </span><span style="font-family: inherit;"><a href="https://www.gnu.org/philosophy/open-source-misses-the-point.html">open source != FOSS</a>;</span></li>
<li><span style="font-family: inherit;"> </span><span style="font-family: inherit;">limiti del software proprietario per l&#8217;utente finale.</span></li>
</ul>
<table class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;" cellspacing="0" cellpadding="0" align="center">
<tr>
<td style="text-align: center;">
<a style="margin-left: auto; margin-right: auto;" href="http://francescomecca.eu/wp-content/uploads/2015/08/633e7-192-168-0-152.jpe"><img src="http://francescomecca.eu/wp-content/uploads/2015/08/633e7-192-168-0-152.jpe?w=300" alt="" width="400" height="300" border="0" /></a>
</td>
</tr>
<tr>
<td class="tr-caption" style="text-align: center;">
Saint IGNUcius della chiesa di Emacs, foto originale
</td>
</tr>
</table>
<p><span style="font-family: inherit;">Sono state indimenticabili le espressioni dei 2 relatori quando Stallman ha indossato la veste di <a href="https://stallman.org/cgi-bin/showpage.cgi?path=/saint.html&term=saint&type=norm&case=0">Saint IGNUcius</a> e quando ha aperto l&#8217;asta per un peluche di gnu, mascotte della FSF. </span></p>
<div style="text-align: right;">
<span style="font-family: inherit;">Francesco Mecca </span>
</div>
</div>
</div>
<div class="pagination">
<a class="pagination-item older" href="/page5">Older</a>
<a class="pagination-item newer" href="/page3">Newer</a>
</div>
</div>
<!--<link rel="alternate" type="application/rss+xml" title="Francesco Mecca RSS" href="/feed.xml">-->
</body>
</html>