<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss 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/" version="2.0">

<channel>
	<title>Paolo Casarini</title>
	
	<link>http://www.casarini.org/blog</link>
	<description>happy programming</description>
	<lastBuildDate>Sat, 13 Apr 2013 06:45:01 +0000</lastBuildDate>
	<language>it</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5.1</generator>
		<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/casarini" /><feedburner:info xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" uri="casarini" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><item>
		<title>Facebook Home “unlocked” [NO ROOT]</title>
		<link>http://www.casarini.org/blog/2013/facebook-home-no-root/</link>
		<comments>http://www.casarini.org/blog/2013/facebook-home-no-root/#comments</comments>
		<pubDate>Sat, 13 Apr 2013 06:23:17 +0000</pubDate>
		<dc:creator>paolo</dc:creator>
				<category><![CDATA[misc]]></category>
		<category><![CDATA[android]]></category>
		<category><![CDATA[facebook]]></category>
		<category><![CDATA[mobile]]></category>

		<guid isPermaLink="false">http://www.casarini.org/blog/?p=604</guid>
		<description><![CDATA[Così titola un articolo su XDA che mette a disposizione una versione modificata di Facebook Home che può essere installata su tutti i telefoni Android a prescindere dal modello e senza dover ricorrere alla modifica di file di sistema con i permessi di root. Non sono un facebook fan e uso il mio account facebook [...]]]></description>
				<content:encoded><![CDATA[<p><img src="http://www.casarini.org/blog/wp-content/uploads/2013/04/facebook-icon.png" alt="Facebook Lab" width="128" height="128" class="alignleft size-full wp-image-608" />Così titola un articolo su <a href="http://forum.xda-developers.com/showthread.php?t=2232307" target="_new">XDA</a> che mette a disposizione una versione modificata di <a href="https://www.facebook.com/home" target="_new">Facebook Home</a> che può essere installata su tutti i telefoni Android a prescindere dal modello e senza dover ricorrere alla modifica di file di sistema con i permessi di <em>root</em>.</p>
<p>Non sono un <em>facebook fan</em> e uso il mio account facebook di rado, ma mi interessa molto l&#8217;evoluzione del web e del mondo mobile e così ho provato la procedura sul mio Galaxy Nexus. Tutto funziona perfettamente e se siete curiosi di vedere che cosa si sono inventati potete fare come segue:</p>
<ul>
<li><strong>disinstalla le applicazioni originali di <em>Facebook</em> e <em>Facebook Home</em>, nel caso siano pre-installate nel telefono dovrai probabilmente diventare root per rimuoverle;</strong></li>
<li>scompatta il file .rar scaricabile <a href="https://mega.co.nz/#!1Ysw1KgJ!DUqEfA2bAwagcM6bNdAeu3ToqwQ_f-m06M_GrS4_yeE" target="_new">qui</a>;</li>
<li>installa entrambi gli APK;</li>
<li>abilita <em>Facebook Home</em> nelle impostazioni di <em>Facebook</em>.</li>
</ul>
<p>Di seguito alcuni avvertimenti e considerazioni&#8230;<span id="more-604"></span></p>
<p><strong>ATTENZIONE:</strong> la procedura richiede che sia installata una applicazione modificata rispetto a quella ufficiale alla quale, per farla funzionare, dovrete fornire le vostre credenziali per accedere a <em>Facebook</em>. Io mi sono fidato, visto il contesto all&#8217;interno è stato fatto il post, ma dovete sapere che state facendo due cose potenzialmente pericolose per la vostra <em>privacy</em>:</p>
<ul>
<li>state installando una applicazione da una fonte non certificata;</li>
<li>state fornendo le vostre credenziali e quindi le chiavi per tutti i dati contenuti nel vostro account facebook ad una applicazione potenzialmente maliziosa.</li>
</ul>
<p>Fatte queste precisazioni, penso che terrò installato questo home replacement per qualche giorno prima di rimuoverlo <img src='http://www.casarini.org/blog/wp-includes/images/smilies/icon_razz.gif' alt=':-P' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.casarini.org/blog/2013/facebook-home-no-root/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ACRA self-hosted script with node.js and MongoDb</title>
		<link>http://www.casarini.org/blog/2013/acra-nodejs-mongodb/</link>
		<comments>http://www.casarini.org/blog/2013/acra-nodejs-mongodb/#comments</comments>
		<pubDate>Sat, 09 Feb 2013 21:57:41 +0000</pubDate>
		<dc:creator>paolo</dc:creator>
				<category><![CDATA[english]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[android]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[mobile]]></category>
		<category><![CDATA[mongodb]]></category>
		<category><![CDATA[node.js]]></category>

		<guid isPermaLink="false">http://www.casarini.org/blog/?p=576</guid>
		<description><![CDATA[I developed an Android application that uses the Acra library to track exceptions. This library offers lots of backend solutions but the easiest way to collect reports, it suggests, is to use a Google Spreadsheet. This kind of solution is becoming deprecated so I decided to implement an alternative solution that uses the HttpPostSender already [...]]]></description>
				<content:encoded><![CDATA[<p><img src="http://www.casarini.org/blog/wp-content/uploads/2013/02/ACRANewLogo.png" alt="ACRANewLogo" width="100" class="alignleft size-full wp-image-100" />I developed an <a href="https://play.google.com/store/apps/details?id=org.casarini.android.aicmobile" title="AiC Mobile" target="_blank">Android application</a> that uses the <a href="http://acra.ch" title="ACRA - Know you BUGS." target="_blank">Acra library</a> to track exceptions. This library offers lots of backend solutions but the easiest way to collect reports, it suggests, is to use a Google Spreadsheet. This kind of solution is <a href="https://plus.google.com/118444843928759726538/posts/GTTgsrEQdN6" target="_blank">becoming deprecated</a> so I decided to implement an alternative solution that uses the <code>HttpPostSender</code> already provided by the library.</p>
<p>Exception reports are flat pieces of information, each of which could be considered as a standalone document, so I choose <a href="http://www.mongodb.org/" title="MongoDB" target="_blank">MongoDb</a> to store data as JSON objects and to experiment a fast RESTfull interface. I used <a href="http://nodejs.org/" title="node.js" target="_blank">node.js</a> to build the HTTP layer to support the POST requests coming from mobile devices.</p>
<p><span id="more-576"></span></p>
<p>I assume that MongoDB and node.js are already installed and configured so I start with the package dependencies descriptor of my new node.js application which declares two dependencies:</p>
<ul>
<li><a href="http://expressjs.com/" title="node.js web application framework" target="_blank">Express</a> to manage the REST interface and easy routing;</li>
<li>MongoDB to manage the communication with the storage.
</ul>
<p><code><strong>package.json</strong></code></p>
<div class="igBar"><span id="ljavascript-5"><a href="#" onclick="javascript:showPlainTxt('javascript-5'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">JAVASCRIPT:</span>
<div id="javascript-5">
<div class="javascript">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #3366CC;">"name"</span>: <span style="color: #3366CC;">"acra-logger"</span>,</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #3366CC;">"description"</span>: <span style="color: #3366CC;">"ACRA Logger Application"</span>,</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #3366CC;">"version"</span>: <span style="color: #3366CC;">"0.0.1"</span>,</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #3366CC;">"private"</span>: <span style="color: #003366; font-weight: bold;">true</span>,</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #3366CC;">"dependencies"</span>: <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #3366CC;">"express"</span>: <span style="color: #3366CC;">"3.x"</span>,</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #3366CC;">"mongodb"</span>:<span style="color: #3366CC;">"1.2.x"</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Now you can launch <code>npm install</code> to download all the needed packages and start coding. At the end of the download process you should have a working directory structure like the following:</p>
<pre>
\node_modules\
    \express\
        ...
    \mongodb\
        ...
\package.json
</pre>
<p>The application I built is quite simple and supports four REST apis, which uses different http verbs to manage different tasks. All apis requires an <code>appid</code>, which you can freely decide for your app, and which is needed to collect reports that come from different applications in their specific collections: each <code>appid</code> will have its collection within the database.</p>
<p><br/><strong>API reference:</strong></p>
<ul>
<li><strong>POST</strong> <code>/logs/:appid</code> to receive mobile exception reports from ACRA;</li>
<li><strong>GET</strong> <code>/logs/:appid</code> to retrieve all stored reports;</li>
<li><strong>GET</strong> <code>/logs/:appid/:id</code> to retrieve the report with the given <em>object id</em>;</li>
<li><strong>DELETE</strong> <code>/logs/:appid/:id</code> to delete the report with the given <em>object id</em>;</li>
</ul>
<p><br/><strong>API implementation:</strong><br />
<code><strong>server.js</strong></code></p>
<div class="igBar"><span id="ljavascript-6"><a href="#" onclick="javascript:showPlainTxt('javascript-6'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">JAVASCRIPT:</span>
<div id="javascript-6">
<div class="javascript">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #003366; font-weight: bold;">var</span> express = require<span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">'express'</span><span style="color: #66cc66;">&#41;</span>,</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; logger = require<span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">'./routes/logger'</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #003366; font-weight: bold;">var</span> app = express<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">app.<span style="color: #006600;">configure</span><span style="color: #66cc66;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span> <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; app.<span style="color: #003366; font-weight: bold;">use</span><span style="color: #66cc66;">&#40;</span>express.<span style="color: #006600;">logger</span><span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">'dev'</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;&nbsp; &nbsp; &nbsp;<span style="color: #009900; font-style: italic;">/* 'default', 'short', 'tiny', 'dev' */</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; app.<span style="color: #003366; font-weight: bold;">use</span><span style="color: #66cc66;">&#40;</span>express.<span style="color: #006600;">bodyParser</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">app.<span style="color: #006600;">post</span><span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">'/logs/:appid'</span>, logger.<span style="color: #006600;">addLog</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">app.<span style="color: #006600;">get</span><span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">'/logs/:appid/:id'</span>, logger.<span style="color: #006600;">findById</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">app.<span style="color: #006600;">get</span><span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">'/logs/:appid'</span>, logger.<span style="color: #006600;">findAll</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">app.<span style="color: #000066; font-weight: bold;">delete</span><span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">'/logs/:appid/:id'</span>, logger.<span style="color: #006600;">deleteLog</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">app.<span style="color: #006600;">listen</span><span style="color: #66cc66;">&#40;</span><span style="color: #CC0000;color:#800000;">3000</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">console.<span style="color: #006600;">log</span><span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">'Listening on port 3000...'</span><span style="color: #66cc66;">&#41;</span>; </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p><code><strong>routes/logger.js</strong></code></p>
<div class="igBar"><span id="ljavascript-7"><a href="#" onclick="javascript:showPlainTxt('javascript-7'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">JAVASCRIPT:</span>
<div id="javascript-7">
<div class="javascript">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #003366; font-weight: bold;">var</span> mongo = require<span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">'mongodb'</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #003366; font-weight: bold;">var</span> Server = mongo.<span style="color: #006600;">Server</span>,</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; Db = mongo.<span style="color: #006600;">Db</span>,</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; BSON = mongo.<span style="color: #006600;">BSONPure</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #003366; font-weight: bold;">var</span> server = <span style="color: #003366; font-weight: bold;">new</span> Server<span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">'localhost'</span>, <span style="color: #CC0000;color:#800000;">27017</span>, <span style="color: #66cc66;">&#123;</span>auto_reconnect: <span style="color: #003366; font-weight: bold;">true</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">db = <span style="color: #003366; font-weight: bold;">new</span> Db<span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">'acraloggerdb'</span>, server<span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">db.<span style="color: #000066;">open</span><span style="color: #66cc66;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #66cc66;">&#40;</span>err, db<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">if</span><span style="color: #66cc66;">&#40;</span>!err<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; console.<span style="color: #006600;">log</span><span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">"Connected to 'acraloggerdb' database"</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">exports.<span style="color: #006600;">findById</span> = <span style="color: #003366; font-weight: bold;">function</span><span style="color: #66cc66;">&#40;</span>req, res<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #003366; font-weight: bold;">var</span> appid = req.<span style="color: #006600;">params</span>.<span style="color: #006600;">appid</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #003366; font-weight: bold;">var</span> id = req.<span style="color: #006600;">params</span>.<span style="color: #006600;">id</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; console.<span style="color: #006600;">log</span><span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">'['</span> + appid + <span style="color: #3366CC;">'] Retrieving log: '</span> + id<span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; db.<span style="color: #006600;">collection</span><span style="color: #66cc66;">&#40;</span>appid, <span style="color: #003366; font-weight: bold;">function</span><span style="color: #66cc66;">&#40;</span>err, collection<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; collection.<span style="color: #006600;">findOne</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span><span style="color: #3366CC;">'_id'</span>:<span style="color: #003366; font-weight: bold;">new</span> BSON.<span style="color: #006600;">ObjectID</span><span style="color: #66cc66;">&#40;</span>id<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#125;</span>, <span style="color: #003366; font-weight: bold;">function</span><span style="color: #66cc66;">&#40;</span>err, <span style="color: #000066; font-weight: bold;">item</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; res.<span style="color: #006600;">send</span><span style="color: #66cc66;">&#40;</span><span style="color: #000066; font-weight: bold;">item</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">exports.<span style="color: #006600;">findAll</span> = <span style="color: #003366; font-weight: bold;">function</span><span style="color: #66cc66;">&#40;</span>req, res<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #003366; font-weight: bold;">var</span> appid = req.<span style="color: #006600;">params</span>.<span style="color: #006600;">appid</span>;&nbsp; &nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; db.<span style="color: #006600;">collection</span><span style="color: #66cc66;">&#40;</span>appid, <span style="color: #003366; font-weight: bold;">function</span><span style="color: #66cc66;">&#40;</span>err, collection<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; collection.<span style="color: #006600;">find</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">toArray</span><span style="color: #66cc66;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #66cc66;">&#40;</span>err, items<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; res.<span style="color: #006600;">send</span><span style="color: #66cc66;">&#40;</span>items<span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">exports.<span style="color: #006600;">addLog</span> = <span style="color: #003366; font-weight: bold;">function</span><span style="color: #66cc66;">&#40;</span>req, res<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #003366; font-weight: bold;">var</span> appid = req.<span style="color: #006600;">params</span>.<span style="color: #006600;">appid</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #003366; font-weight: bold;">var</span> log = req.<span style="color: #006600;">body</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; console.<span style="color: #006600;">log</span><span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">'['</span> + appid + <span style="color: #3366CC;">'] Adding log: '</span> + JSON.<span style="color: #006600;">stringify</span><span style="color: #66cc66;">&#40;</span>log<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; db.<span style="color: #006600;">collection</span><span style="color: #66cc66;">&#40;</span>appid, <span style="color: #003366; font-weight: bold;">function</span><span style="color: #66cc66;">&#40;</span>err, collection<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; collection.<span style="color: #006600;">insert</span><span style="color: #66cc66;">&#40;</span>log, <span style="color: #66cc66;">&#123;</span>safe:<span style="color: #003366; font-weight: bold;">true</span><span style="color: #66cc66;">&#125;</span>, <span style="color: #003366; font-weight: bold;">function</span><span style="color: #66cc66;">&#40;</span>err, result<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #66cc66;">&#40;</span>err<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; res.<span style="color: #006600;">send</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span><span style="color: #3366CC;">'error'</span>:<span style="color: #3366CC;">'An error has occurred'</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span> <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; console.<span style="color: #006600;">log</span><span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">'Success: '</span> + JSON.<span style="color: #006600;">stringify</span><span style="color: #66cc66;">&#40;</span>result<span style="color: #66cc66;">&#91;</span><span style="color: #CC0000;color:#800000;">0</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; res.<span style="color: #006600;">send</span><span style="color: #66cc66;">&#40;</span>result<span style="color: #66cc66;">&#91;</span><span style="color: #CC0000;color:#800000;">0</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">exports.<span style="color: #006600;">deleteLog</span> = <span style="color: #003366; font-weight: bold;">function</span><span style="color: #66cc66;">&#40;</span>req, res<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #003366; font-weight: bold;">var</span> appid = req.<span style="color: #006600;">params</span>.<span style="color: #006600;">appid</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #003366; font-weight: bold;">var</span> id = req.<span style="color: #006600;">params</span>.<span style="color: #006600;">id</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; console.<span style="color: #006600;">log</span><span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">'['</span> + appid + <span style="color: #3366CC;">'] Deleting log: '</span> + id<span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; db.<span style="color: #006600;">collection</span><span style="color: #66cc66;">&#40;</span>appid, <span style="color: #003366; font-weight: bold;">function</span><span style="color: #66cc66;">&#40;</span>err, collection<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; collection.<span style="color: #006600;">remove</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span><span style="color: #3366CC;">'_id'</span>:<span style="color: #003366; font-weight: bold;">new</span> BSON.<span style="color: #006600;">ObjectID</span><span style="color: #66cc66;">&#40;</span>id<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#125;</span>, <span style="color: #66cc66;">&#123;</span>safe:<span style="color: #003366; font-weight: bold;">true</span><span style="color: #66cc66;">&#125;</span>, <span style="color: #003366; font-weight: bold;">function</span><span style="color: #66cc66;">&#40;</span>err, result<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #66cc66;">&#40;</span>err<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; res.<span style="color: #006600;">send</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span><span style="color: #3366CC;">'error'</span>:<span style="color: #3366CC;">'An error has occurred - '</span> + err<span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span> <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; console.<span style="color: #006600;">log</span><span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">''</span> + result + <span style="color: #3366CC;">' document(s) deleted'</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; res.<span style="color: #006600;">send</span><span style="color: #66cc66;">&#40;</span>req.<span style="color: #006600;">body</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p><br/><strong>Running self-hosted backend and ACRA integration</strong><br />
To run the implemented node.js rest interface to start receiving reports from our apps, you now have to launch the command <code>node server.js</code> and you should receive a message like the following:</p>
<pre>
Listening on port 3000...
Connected to 'acraloggerdb' database
</pre>
<p>From the Android side the integration is trivial. You just have to install ACRA, choose an <em>appid</em> for your application and then modify fromUri to send data to your server.</p>
<div class="igBar"><span id="ljava-8"><a href="#" onclick="javascript:showPlainTxt('java-8'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">JAVA:</span>
<div id="java-8">
<div class="java">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">@ReportsCrashes<span style="color: #66cc66;">&#40;</span>formUri = <span style="color: #ff0000;">"http://yourserver/logs/myappid"</span>, formKey=<span style="color: #ff0000;">""</span><span style="color: #66cc66;">&#41;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Enjoy!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.casarini.org/blog/2013/acra-nodejs-mongodb/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Neve, neve, neve!</title>
		<link>http://www.casarini.org/blog/2012/neve-neve-neve/</link>
		<comments>http://www.casarini.org/blog/2012/neve-neve-neve/#comments</comments>
		<pubDate>Sat, 11 Feb 2012 10:45:01 +0000</pubDate>
		<dc:creator>paolo</dc:creator>
				<category><![CDATA[family]]></category>
		<category><![CDATA[bob]]></category>
		<category><![CDATA[kids]]></category>
		<category><![CDATA[snow]]></category>

		<guid isPermaLink="false">http://www.casarini.org/blog/?p=563</guid>
		<description><![CDATA[Tanta neve a Bologna quest'anno e tutto sembra più bello o, più realisticamente, è semplicemente tutto diverso e il cambiamento imposto ti obbliga a rivedere il tuo giudizio sulle cose. A parte la filosofia spiccia il fine settimana scorso è stata l'occasione per andare un po' sul bob e fare un po' di foto sotto [...]]]></description>
				<content:encoded><![CDATA[<p>Tanta neve a Bologna quest'anno e tutto sembra più bello o, più realisticamente, è semplicemente tutto diverso e il cambiamento imposto ti obbliga a rivedere il tuo giudizio sulle cose.<br />
A parte la filosofia spiccia il fine settimana scorso è stata l'occasione per andare un po' sul bob e fare un po' di foto sotto la neve e, per collezionarle, ho provato il servizio <a href="http://anomoto.com">animoto</a> con grande soddisfazione!</p>
<p>Ecco il risultato:<br />
<object id="vp11X13V" width="432" height="240" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"><param name="movie" value="http://static.animoto.com/swf/w.swf?w=swf/vp1&#038;e=1328955956&#038;f=1X13V8gGKPOOkDPYVUKzWQ&#038;d=182&#038;m=a&#038;r=240p+480p&#038;volume=100&#038;start_res=480p&#038;i=m&#038;options="></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed id="vp11X13V" src="http://static.animoto.com/swf/w.swf?w=swf/vp1&#038;e=1328955956&#038;f=1X13V8gGKPOOkDPYVUKzWQ&#038;d=182&#038;m=a&#038;r=240p+480p&#038;volume=100&#038;start_res=480p&#038;i=m&#038;options=" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="432" height="240"></embed></object></p>
]]></content:encoded>
			<wfw:commentRss>http://www.casarini.org/blog/2012/neve-neve-neve/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Perché javascript migliora l’accessibilità di EPUB 3</title>
		<link>http://www.casarini.org/blog/2011/perche-javascript-migliora-laccessibilita-di-epub-3/</link>
		<comments>http://www.casarini.org/blog/2011/perche-javascript-migliora-laccessibilita-di-epub-3/#comments</comments>
		<pubDate>Sun, 06 Mar 2011 20:33:56 +0000</pubDate>
		<dc:creator>paolo</dc:creator>
				<category><![CDATA[digital publishing]]></category>
		<category><![CDATA[eBook]]></category>
		<category><![CDATA[EPUB 3]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[MathJax]]></category>

		<guid isPermaLink="false">http://www.casarini.org/blog/?p=525</guid>
		<description><![CDATA[Di recente è uscito un post di Strahinja Marković che mette sotto accusa l'introduzione di javascript nel formato EPUB 3. In un primo momento mi sono trovato d'accordo con le posizioni sostenute in tale post, ma poi mi sono accorto che, per chi ha a cuore i libri scolastici o i manuali universitari del futuro, [...]]]></description>
				<content:encoded><![CDATA[<p>Di recente è uscito un <a href="http://sigildev.blogspot.com/2011/02/analysis-of-epub3-and-uh-bit-more.html">post</a> di Strahinja Marković che mette sotto accusa l'introduzione di javascript nel formato <code>EPUB 3</code>. In un primo momento mi sono trovato d'accordo con le posizioni sostenute in tale post, ma poi mi sono accorto che, per chi ha a cuore i libri scolastici o i manuali universitari del futuro, può trovare in javascript un grande alleato, sia per far evolvere il libro da punto di vista didattico (come ho spiegato in un precedente <a href="/blog/2011/grafici-interattivi-nei-libri-del-futuro-grazie-ad-epub-3-e-jsxgraph/">articolo</a>), sia per migliorare la sua accessibilità.</p>
<p>L'esempio che porterò è quello delle formule: non c'è nulla di meno accessibile di una formula in un libro digitale realizzata con una immagine bitmap. Anche in testi non matematici quando si usa una formula, tale elemento è spesso chiave per la comprensione di un concetto e l'impossibilità di poterla leggere può rendere un testo inutile a fini didattici.</p>
<p><span id="more-525"></span><br />
Per risolvere il problema dell'accessibilità delle formule, nel recente <a href="http://idpf.org/epub/30"><em>draft</em> del formato <code>EPUB 3</code></a> è stato introdotta la possibilità di rappresentare queste ultime nel formato MathML:</p>
<blockquote><p>
<strong>2.1.4.1 Embedded MathML</strong><br />
<em>› 2.1.4.1.1 Introduction</em></p>
<p>XHTML Content Documents support embedded MathML <a href="http://www.w3.org/TR/MathML/">[MATHML]</a> but limit its usage to a restricted subset of the full MathML markup language.</p>
<p>This subset is designed to ease the implementation burden on Reading Systems and to promote accessibility, while retaining compatibility with HTML5 User Agents <a href="http://www.w3.org/TR/html5/">[HTML5]</a>.
</p></blockquote>
<p>Se però in questo modo abbiamo finalmente la possibilità di rappresentare le formule in un linguaggio formale tale da rendere l'interno testo leggibile da chiunque, con ogni probabilità rendiamo le cose più difficili alla stragrande maggioranza degli studenti poiché non vi è nessun eReader attualmente in commercio in grado di disegnare nativamente MathML. Sappiamo infatti che non basta che una possibilità tecnica venga messa a disposizione per fare in modo che questa venga utilizzata e correttamente gestita. Per fare un esempio nel campo ben più competitivo dei browser Internet, basta pensare al fatto che attualmente solo Mozilla Firefox è in grado di disegnare correttamente MathML.</p>
<p>Disegnare formule non è un mestiere semplice e la non disponibilità di eReader in grado di mostrare correttamente MathML all'interno di libri in formato <code>EPUB 3</code> potrebbe portare gli editori a continuare a realizzare le formule facendo l'embedding di immagini bitmap.</p>
<p>Per colmare il gap tra la possibilità tecnica offerta dal nuovo standard e l'effettiva capacità degli eReader di supportare tale nuovo formato, ci può venire in aiuto <a href="http://www.mathjax.org/">MathJax</a>, libreria <em>javascript</em> che funziona piuttosto bene e capace di renderizzare formule espresse in Tex e MathML all'interno di codice HTML5. In questo senso, la possibilità di inserire del codice <em>javascript</em> all'interno dei libri in formato <code>EPUB 3</code> permetterà di sfruttare immediatamente la possibilità di descrivere le formule in un linguaggio formale e di creare, quindi, fin da subito, materiale didattico totalmente accessibile.</p>
<p>Per fare qualche esempio di come potrebbe risultare un testo di nuova generazione con delle formule, di seguito scriverò due formule in MathML che verranno disegnate dalla libreria MathJax. La libreria, opportunamente configurata, intercetta automaticamente le formule all'interno del codice HTML e si occupa del loro rendering senza modificare l'accessibilità del documento.</p>
<p>Formula per la soluzione di una equazione di secondo grado:</p>
<math display='block'><mrow><mi>x</mi><mo>=</mo><mfrac><mrow><mo>&#x2212;</mo><mi>b</mi><mo>&#x00B1;</mo><msqrt><mrow><msup><mi>b</mi><mn>2</mn></msup><mo>&#x2212;</mo><mn>4</mn><mi>a</mi><mi>c</mi></mrow></msqrt></mrow><mrow><mn>2</mn><mi>a</mi></mrow></mfrac></mrow></math>
<p>Legge di gravitazione universale:</p>
<math display='block'><mi>F</mi><mo>=</mo><mi>G</mi><mfrac><mrow><msub><mi>m</mi><mn>1</mn></msub><msub><mi>m</mi><mn>2</mn></msub></mrow><msup><mi>r</mi><mn>2</mn</msup></mfrac></math>
<p><br/><br />
<br/></p>
]]></content:encoded>
			<wfw:commentRss>http://www.casarini.org/blog/2011/perche-javascript-migliora-laccessibilita-di-epub-3/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Grafici interattivi nei libri del futuro grazie ad EPUB 3 e JSXGraph</title>
		<link>http://www.casarini.org/blog/2011/grafici-interattivi-nei-libri-del-futuro-grazie-ad-epub-3-e-jsxgraph/</link>
		<comments>http://www.casarini.org/blog/2011/grafici-interattivi-nei-libri-del-futuro-grazie-ad-epub-3-e-jsxgraph/#comments</comments>
		<pubDate>Sat, 05 Mar 2011 22:11:52 +0000</pubDate>
		<dc:creator>paolo</dc:creator>
				<category><![CDATA[digital publishing]]></category>
		<category><![CDATA[eBook]]></category>
		<category><![CDATA[EPUB 3]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[JSXGraph]]></category>

		<guid isPermaLink="false">http://www.casarini.org/blog/?p=488</guid>
		<description><![CDATA[Nel dibattito tra governo ed editori, si parla spesso di digitalizzazione dei libri scolastici e spesso questo dibattito si ferma all'analisi dei costi, ovvero di quanto i libri debbano costare meno perché non stampati su carta, senza entrare nel merito di come un libro scolastico dovrebbe essere uno strumento migliore per la didattica sfruttando i [...]]]></description>
				<content:encoded><![CDATA[<p>Nel dibattito tra governo ed editori, si parla spesso di digitalizzazione dei libri scolastici e spesso questo dibattito si ferma all'analisi dei costi, ovvero di quanto i libri debbano costare meno perché non stampati su carta, senza entrare nel merito di come un libro scolastico dovrebbe essere uno strumento migliore per la didattica sfruttando i potenziali offerti dai nuovi media.</p>
<p>Fino ad ora era difficile pensare a un libro scolastico in formato digitale che non fosse il pdf preparato per la stampa poiché i formati alternativi, come il formato ePub o il formato Mobipocket, non erano assolutamente all'altezza di un compito difficile come quello di rappresentare la complessità espositiva di un libro scolastico.</p>
<p>Di recente, però, è stato presentato il primo <a href="http://idpf.org/epub/30"><em>draft</em> del formato <code>EPUB 3</code></a>, evoluzione del formato che attualmente viene utilizzato per la vendita di e-book dai principali editori e piattaforme per il delivery di libri in formato digitale.</p>
<p>Tale evoluzione introduce numerosi elementi innovativi in questo campo che permettono di pensare al libro scolastico o al manuale universitario in modo nuovo, creando i presupposti per far evolvere lo strumento libro anche dal punto di vista didattico.<br />
In questa direzione un esempio è quello di integrare apparati dinamici come possono essere i grafici di una funzione matematica alla quale si possono cambiare i parametri che ne determinano l'andamento.</p>
<p><span id="more-488"></span><br />
Dal punto di vista tecnico ciò che ci permette di poter ipotizzare tali interazioni è la possibilità di inserire all'interno di libri in formato <code>EPUB 3</code> del codice <em>javascript</em>, come viene descritto nelle <a href="http://idpf.org/epub/30/spec/epub30-contentdocs.html#sec-scripted-content">specifiche</a> attuali del formato:</p>
<blockquote><p>
<strong>2.4.1 Introduction</strong></p>
<p>EPUB Content Documents may contain scripting using the facilities defined for this in the respective underlying specifications ([HTML5] and [SVG]). When an EPUB Content Document contains scripting, it is referred to in this specification and its sibling specifications as a Scripted Content Document.
</p></blockquote>
<p>Per fare un esempio concreto pensiamo alla possibilità di poter controllare le variabili in gioco in una delle più comuni curve che si studiano in geometria analitica e in analisi matematica come la parabola. L'espressione per rappresentare matematicamente la parabola è piuttosto semplice ma per capire come possa essere disegnata la curva nel piano in base al segno e ai valori delle variabili in gioco, i libri stampati, solitamente propongono diversi grafici statici (almeno 3 o 4).</p>
<p>Utilizzando un grafico interattivo realizzato, ad esempio, con la libreria javascript <a href="http://jsxgraph.uni-bayreuth.de/wp/">JSXGraph</a>, è possibile esprimere la formula della parabola generica:</p>
<dd><img src="https://chart.googleapis.com/chart?cht=tx&#038;chl=y%20%3D%20ax%5E2%20%2B%20bx%20%2Bc" alt="y = ax^2 + bx +c"/></p>
<p>parametrizzandone il disegno del grafico rispetto ai parametri <strong><em>a</em></strong>, <strong><em>b</em></strong> , <strong><em>c</em></strong></p>
<pre><div id='box' class='jxgbox' style='width:500px; height:500px;'></div><script type='text/javascript'>

var brd = JXG.JSXGraph.initBoard('box',{boundingbox:[-5,5,5,-5], keepaspectratio:true, axis:true});
brd.suspendUpdate();
var a = brd.create('slider',[[0.5,-3],[3.5,-3],[-5,1,5]], {name:'a'});
var b = brd.create('slider',[[0.5,-3.5],[3.5,-3.5],[-5,0,5]], {name:'b'});
var c = brd.create('slider',[[0.5,-4],[3.5,-4],[-5,0.5,5]], {name:'c'});
var p = brd.create('curve',
             [function(t){ return t},
              function(t){ return a.Value()*t*t + b.Value()*t + c.Value();},
              -20, 20
             ],
             {strokeWidth:1, strokeColor:'black'});
brd.unsuspendUpdate()
</script></pre>
<p>I vantaggi di utilizzo, dal punto di vista didattico, di un apparato di questo genere penso siano immediati sia per l'uso che si può fare dell'e-book in classe, sia per lo studio individuale. Concetti astratti come lo spostamento del fuoco della parabola e l'inversione del verso della concavità sono sperimentabili direttamente su grafico offrendo una lettura visiva immediata con notevoli benefici sulla semplicità di apprendimento.</p>
<p>Questo è solo un primo esempio delle potenzialità che il nuovo formato <code>EPUB 3</code> ha introdotto. Se fino a poco tempo fa non era possibile immaginare una evoluzione dell'e-book tale da poter rispondere alle esigenze didattiche attuali, ora è tecnicamente possibile e starà agli editori saper sfruttare tali potenzialità e alle istituzioni creare il contesto per cui l'evoluzione del libro elettronico come strumento didattico migliore del libro stampato abbia luogo.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.casarini.org/blog/2011/grafici-interattivi-nei-libri-del-futuro-grazie-ad-epub-3-e-jsxgraph/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Android local HTML viewer</title>
		<link>http://www.casarini.org/blog/2011/android-local-html-viewer/</link>
		<comments>http://www.casarini.org/blog/2011/android-local-html-viewer/#comments</comments>
		<pubDate>Sat, 29 Jan 2011 17:15:29 +0000</pubDate>
		<dc:creator>paolo</dc:creator>
				<category><![CDATA[programming]]></category>
		<category><![CDATA[android]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[WebView]]></category>

		<guid isPermaLink="false">http://www.casarini.org/blog/?p=478</guid>
		<description><![CDATA[I recently made a very simple Activity to display an HTML file stored within an Android app. This task could be useful to add an help page to your app without dealing with layouts. First you need the HTML file you want to display and you have to put it in the res/raw directory of [...]]]></description>
				<content:encoded><![CDATA[<p>I recently made a very simple <em>Activity</em> to display an HTML file stored within an Android app. This task could be useful to add an help page to your app without dealing with layouts.</p>
<p>First you need the HTML file you want to display and you have to put it in the <code>res/raw</code> directory of your project. We'll access to this directory with the <code>getResources().openRawResource(int id)</code> method.</p>
<p>Now we need a widget that is able to display an HTML string like the <code>android.webkit.WebView</code> and a layout with this widget inside that will be used by our  <em>Activity</em>:</p>
<div class="igBar"><span id="lxml-12"><a href="#" onclick="javascript:showPlainTxt('xml-12'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">XML:</span>
<div id="xml-12">
<div class="xml">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;</span>?xml <span style="color: #000066;">version</span>=<span style="color: #ff0000;">"1.0"</span> <span style="color: #000066;">encoding</span>=<span style="color: #ff0000;">"utf-8"</span>?<span style="font-weight: bold; color: black;">&gt;</span></span>&nbsp; </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;LinearLayout</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; xmlns:<span style="color: #000066;">android</span>=<span style="color: #ff0000;">"http://schemas.android.com/apk/res/android"</span>&nbsp; </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; android:<span style="color: #000066;">orientation</span>=<span style="color: #ff0000;">"vertical"</span>&nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; android:layout_<span style="color: #000066;">width</span>=<span style="color: #ff0000;">"fill_parent"</span>&nbsp; </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; android:layout_<span style="color: #000066;">height</span>=<span style="color: #ff0000;">"fill_parent"</span><span style="font-weight: bold; color: black;">&gt;</span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp;&nbsp; &nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;WebView</span> android:<span style="color: #000066;">id</span>=<span style="color: #ff0000;">"@+id/web_engine"</span>&nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; android:layout_<span style="color: #000066;">width</span>=<span style="color: #ff0000;">"fill_parent"</span>&nbsp; </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; android:layout_<span style="color: #000066;">height</span>=<span style="color: #ff0000;">"fill_parent"</span><span style="font-weight: bold; color: black;">/&gt;</span></span>&nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/LinearLayout<span style="font-weight: bold; color: black;">&gt;</span></span></span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p><br/><br />
<span id="more-478"></span><br />
Finally, we can implement an <em>Activity</em> that loads our HTML file from resources when it starts putting in the <code>onCreate</code> method something like the following:</p>
<div class="igBar"><span id="ljava-13"><a href="#" onclick="javascript:showPlainTxt('java-13'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">JAVA:</span>
<div id="java-13">
<div class="java">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">WebView engine = <span style="color: #66cc66;">&#40;</span>WebView<span style="color: #66cc66;">&#41;</span> findViewById<span style="color: #66cc66;">&#40;</span>R.<span style="color: #006600;">id</span>.<span style="color: #006600;">web_engine</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><a href="http://www.google.com/search?q=allinurl%3AInputStream+java.sun.com&amp;bntl=1"><span style="color: #aaaadd; font-weight: bold;">InputStream</span></a> in = getResources<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">openRawResource</span><span style="color: #66cc66;">&#40;</span>rawFileRes<span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>in != <span style="color: #000000; font-weight: bold;">null</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">try</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #993333;">int</span> size = in.<span style="color: #006600;">available</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #993333;">byte</span><span style="color: #66cc66;">&#91;</span><span style="color: #66cc66;">&#93;</span> buffer = <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #993333;">byte</span><span style="color: #66cc66;">&#91;</span>size<span style="color: #66cc66;">&#93;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; in.<span style="color: #006600;">read</span><span style="color: #66cc66;">&#40;</span>buffer<span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; in.<span style="color: #006600;">close</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; htmldata = <span style="color: #000000; font-weight: bold;">new</span> <a href="http://www.google.com/search?q=allinurl%3AString+java.sun.com&amp;bntl=1"><span style="color: #aaaadd; font-weight: bold;">String</span></a><span style="color: #66cc66;">&#40;</span>buffer<span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span> <span style="color: #000000; font-weight: bold;">catch</span><span style="color: #66cc66;">&#40;</span><a href="http://www.google.com/search?q=allinurl%3AIOException+java.sun.com&amp;bntl=1"><span style="color: #aaaadd; font-weight: bold;">IOException</span></a> ioe<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; Log.<span style="color: #006600;">e</span><span style="color: #66cc66;">&#40;</span>TAG, <span style="color: #ff0000;">"Error while loading the raw HTML resource : "</span> + ioe.<span style="color: #006600;">getMessage</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">engine.<span style="color: #006600;">loadData</span><span style="color: #66cc66;">&#40;</span>htmldata, mimetype, encoding<span style="color: #66cc66;">&#41;</span>; </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p><br/><br />
To be more general I implemented this <em>Activity</em> to accept two parameters:<br />
 * a title to put as Activity title;<br />
 * a resId that identify the specific HTML resource to load.<br />
You can find the complete source of this <em>Activity</em> here: <a href="/blog/wp-content/uploads/2011/01/HtmlViewer.java">HtmlViewer.java</a></p>
<p>Now that our work is finished, assuming that the HTML file that we want to display is <code>res/raw/quickref.html</code>, we can invoke our HTML Viewer via <em>Intent</em> with somthing like this:</p>
<div class="igBar"><span id="ljava-14"><a href="#" onclick="javascript:showPlainTxt('java-14'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">JAVA:</span>
<div id="java-14">
<div class="java">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">Intent i = <span style="color: #000000; font-weight: bold;">new</span> Intent<span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">this</span>, HtmlViewer.<span style="color: #000000; font-weight: bold;">class</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">i.<span style="color: #006600;">putExtra</span><span style="color: #66cc66;">&#40;</span>HtmlViewer.<span style="color: #006600;">TITLERES_PARAM</span>, <span style="color: #ff0000;">"Quick Reference"</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">i.<span style="color: #006600;">putExtra</span><span style="color: #66cc66;">&#40;</span>HtmlViewer.<span style="color: #006600;">RAWFILERES_PARAM</span>, R.<span style="color: #006600;">raw</span>.<span style="color: #006600;">quickref</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">startActivity<span style="color: #66cc66;">&#40;</span>i<span style="color: #66cc66;">&#41;</span>; </div>
</li>
</ol>
</div>
</div>
</div>
<p>
<br/></p>
]]></content:encoded>
			<wfw:commentRss>http://www.casarini.org/blog/2011/android-local-html-viewer/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Adding delay to C port knocking client</title>
		<link>http://www.casarini.org/blog/2011/adding-delay-to-c-port-knocking-client/</link>
		<comments>http://www.casarini.org/blog/2011/adding-delay-to-c-port-knocking-client/#comments</comments>
		<pubDate>Sat, 29 Jan 2011 15:46:28 +0000</pubDate>
		<dc:creator>paolo</dc:creator>
				<category><![CDATA[4]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[C]]></category>
		<category><![CDATA[port-knocking]]></category>

		<guid isPermaLink="false">http://www.casarini.org/blog/?p=469</guid>
		<description><![CDATA[I often use the C port knocking client developed by Judd Vinet and I also took inspiration from its code to write a PHP implementation of that. I recently noticed that, sometimes and more often when I use it on 3G Internet connections, the port knocking authentication fails because (I suppose) the connects tried are [...]]]></description>
				<content:encoded><![CDATA[<p>I often use the C port knocking client developed by <a href="http://www.zeroflux.org/projects/knock">Judd Vinet</a> and I also took inspiration from its code to write a <a href="/blog/free-software/phpknockclient/">PHP implementation</a> of that.</p>
<p>I recently noticed that, sometimes and more often when I use it on 3G Internet connections, the port knocking authentication fails because (I suppose) the <code>connects</code> tried are too fast and arrive at server in the wrong order. So I thought that inserting a delay between connections could help and, based on my experience, it works great!</p>
<p>So I patched the <a href="http://www.zeroflux.org/proj/knock/files/knock-0.5.tar.gz">0.5 version</a> of Judd's code to add a new parameter (-d) to specify a delay in millis between connections.</p>
<p><span id="more-469"></span></p>
<p>Download binaries:</p>
<ul>
<li><a href="/blog/wp-content/uploads/2011/01/knock.macosx">MacOSX (x86) patched Client</a></li>
<li><a href="/blog/wp-content/uploads/2011/01/knock.linux64">Linux 64bit (x86) patched Client</a></li>
</ul>
<p>And this is the patch to apply to the original code:<br />
<code><br />
*** knock-0.5/src/knock.c	2005-06-27 07:11:34.000000000 +0200<br />
--- knock-0.5.1/src/knock.c	2011-01-19 22:07:30.000000000 +0100<br />
***************<br />
*** 32,38 ****<br />
  #include <getopt.h><br />
  #include <fcntl.h></p>
<p>! static char version[] = "0.5";</p>
<p>  #define PROTO_TCP 1<br />
  #define PROTO_UDP 2<br />
--- 32,38 ----<br />
  #include <getopt.h><br />
  #include <fcntl.h></p>
<p>! static char version[] = "0.5.1";</p>
<p>  #define PROTO_TCP 1<br />
  #define PROTO_UDP 2<br />
***************<br />
*** 44,49 ****<br />
--- 44,50 ----</p>
<p>  int o_verbose = 0;<br />
  int o_udp     = 0;<br />
+ int o_delay   = 0;</p>
<p>  int main(int argc, char** argv)<br />
  {<br />
***************<br />
*** 55,66 ****<br />
  	{<br />
  		{"verbose",   no_argument,       0, 'v'},<br />
  		{"udp",       no_argument,       0, 'u'},<br />
  		{"help",      no_argument,       0, 'h'},<br />
  		{"version",   no_argument,       0, 'V'},<br />
  		{0, 0, 0, 0}<br />
  	};</p>
<p>! 	while((opt = getopt_long(argc, argv, "vuhV", opts, &#038;optidx))) {<br />
  		if(opt < 0) {<br />
  			break;<br />
  		}<br />
--- 56,68 ----<br />
  	{<br />
  		{"verbose",   no_argument,       0, 'v'},<br />
  		{"udp",       no_argument,       0, 'u'},<br />
+ 		{"delay",     no_argument,       0, 'd'},<br />
  		{"help",      no_argument,       0, 'h'},<br />
  		{"version",   no_argument,       0, 'V'},<br />
  		{0, 0, 0, 0}<br />
  	};</p>
<p>! 	while((opt = getopt_long(argc, argv, "vud:hV", opts, &#038;optidx))) {<br />
  		if(opt < 0) {<br />
  			break;<br />
  		}<br />
***************<br />
*** 68,73 ****<br />
--- 70,76 ----<br />
  			case 0:   break;<br />
  			case 'v': o_verbose = 1; break;<br />
  			case 'u': o_udp = 1; break;<br />
+ 			case 'd': o_delay = atoi(optarg); break;<br />
  			case 'V': ver();<br />
  			case 'h': /* fallthrough */<br />
  			default: usage();<br />
***************<br />
*** 128,133 ****<br />
--- 131,138 ----<br />
  			connect(sd, (struct sockaddr*)&#038;addr, sizeof(struct sockaddr));<br />
  		}<br />
  		close(sd);<br />
+ 		vprint("applying a delay of %u milliseconds\n", o_delay);<br />
+ 		usleep(o_delay * 1000);<br />
  	}</p>
<p>  	return(0);<br />
***************<br />
*** 148,153 ****<br />
--- 153,159 ----<br />
  	printf("usage: knock [options] <host>
<port[:proto]> [port[:proto]] ...\n");<br />
  	printf("options:\n");<br />
  	printf("  -u, --udp            make all ports hits use UDP (default is TCP)\n");<br />
+ 	printf("  -d, --delay          add a delay of the specified milliseconds between syns\n");<br />
  	printf("  -v, --verbose        be verbose\n");<br />
  	printf("  -V, --version        display version\n");<br />
  	printf("  -h, --help           this help\n");<br />
</code></p>
]]></content:encoded>
			<wfw:commentRss>http://www.casarini.org/blog/2011/adding-delay-to-c-port-knocking-client/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>package refactoring with sed</title>
		<link>http://www.casarini.org/blog/2010/package-refactoring-with-sed/</link>
		<comments>http://www.casarini.org/blog/2010/package-refactoring-with-sed/#comments</comments>
		<pubDate>Sat, 25 Dec 2010 09:29:51 +0000</pubDate>
		<dc:creator>paolo</dc:creator>
				<category><![CDATA[programming]]></category>
		<category><![CDATA[agile]]></category>
		<category><![CDATA[android]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[refactoring]]></category>

		<guid isPermaLink="false">http://www.casarini.org/blog/?p=461</guid>
		<description><![CDATA[I know I'm a strange boy, with strange problems (at least wrt software development), but recently I had to solve the problem to build a Java project many many times programmatically changing only few parameters on it. One of the change to do was to rename the main package of the project, the package under [...]]]></description>
				<content:encoded><![CDATA[<p>I know I'm a strange boy, with strange problems (at least wrt software development), but recently I had to solve the problem to build a Java project many many times programmatically changing only few parameters on it. One of the change to do was to rename the main package of the project, the package under which all the classes are declared.<br />
To solve this problem I build a very simple bash script that use sed to rename all the occurrences of the old package name with the new one:<br />
<code><br />
#!/bin/bash</p>
<p>PROJECTPATH=$1</p>
<p>mv $PROJECTPATH/src/it/casarini/oldpackage $PROJECT/src/it/casarini/newpackage<br />
export MYLIST=`find $PROJECTPATH/src -type f -name *.java`<br />
for a in $MYLIST; do<br />
&nbsp;&nbsp;&nbsp;&nbsp;echo $a<br />
&nbsp;&nbsp;&nbsp;&nbsp;mv $a $a.orig<br />
&nbsp;&nbsp;&nbsp;&nbsp;sed s/it.casarini.oldpackage/it.casarini.newpackage/g $a.orig > $a<br />
&nbsp;&nbsp;&nbsp;&nbsp;rm $a.orig<br />
done;<br />
</code></p>
]]></content:encoded>
			<wfw:commentRss>http://www.casarini.org/blog/2010/package-refactoring-with-sed/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Riconoscimento vocale in AiC Mobile</title>
		<link>http://www.casarini.org/blog/2010/riconoscimento-vocale-in-aic-mobile/</link>
		<comments>http://www.casarini.org/blog/2010/riconoscimento-vocale-in-aic-mobile/#comments</comments>
		<pubDate>Sun, 24 Oct 2010 18:27:17 +0000</pubDate>
		<dc:creator>paolo</dc:creator>
				<category><![CDATA[family]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[AiC mobile]]></category>
		<category><![CDATA[android]]></category>
		<category><![CDATA[google]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[mobile]]></category>

		<guid isPermaLink="false">http://www.casarini.org/blog/?p=447</guid>
		<description><![CDATA[Ho aggiunto una nuova funzionalità di ricerca all'interno dell'applicazione AiC Mobile per Android (rilasciata con la versione 1.2.0). La funzionlità aggiunta è la possibilità di ricercare nel prontuario dei prodotti senza glutine fornito da AIC semplicemente pronunciando le parole che si vogliono usare come chiavi di ricerca. La funzionalità introdotta sfrutta le API per il [...]]]></description>
				<content:encoded><![CDATA[<p><img alt="" src="/images/ico_150.png" title="AiC mobile" align="left" width="150" height="150" />Ho aggiunto una nuova funzionalità di ricerca all'interno dell'applicazione <a href="http://code.google.com/p/aicmobile/">AiC Mobile</a> per Android (rilasciata con la versione 1.2.0). La funzionlità aggiunta è la possibilità di ricercare nel prontuario dei prodotti senza glutine fornito da <a href="http://www.celiachia.it/">AIC</a> semplicemente pronunciando le parole che si vogliono usare come chiavi di ricerca.<br />
La funzionalità introdotta sfrutta le API per il riconoscimento vocale introdotte sulla piattaforma Android dalla versione 1.5 e usa come motore per l'analisi fonetica quello introdotto con Google Search. In particolare, per usufruire della nuova funzionalità si deve avere almeno una app in grado di soddisfare una richiesta di <a href="http://developer.android.com/resources/articles/speech-input.html">Speech Input</a> (<code>RecognizerIntent.ACTION_RECOGNIZE_SPEECH</code>).<br />
Il miglioramento in usabilità della applicazione è notevole e per darne un'idea, ho realizzato un breve video che ne mostra l'utilizzo:</p>
<p><object width="512" height="320"><param name="movie" value="http://www.youtube.com/v/lBi39805-a0&#038;hl=it_IT&#038;fs=1&#038;"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/lBi39805-a0&#038;hl=it_IT&#038;fs=1&#038;" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="512" height="320"></embed></object></p>
<p>AiC Mobile è disponibile da agosto sul Market Google e viene costantemente migliorata e aggiornata. Per vedere AiC Mobile per Android sul Market o per scaricarla sul proprio telefonino è possibile usufruire del servizio AppBrain qui sotto evidenziato:</p>
<div id='app419' class='appbrain-app'><a href='http://www.appbrain.com/app/aic-mobile/org.casarini.android.aicmobile' style='font-size: 11px; color: #555; font-family: Arial, sans-serif;'>AiC Mobile for Android on AppBrain</a></div>
<p> <script type='text/javascript' language='javascript' src='http://www.appbrain.com/api/api.nocache.js'></script></p>
]]></content:encoded>
			<wfw:commentRss>http://www.casarini.org/blog/2010/riconoscimento-vocale-in-aic-mobile/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Android home and refresh menu icons</title>
		<link>http://www.casarini.org/blog/2010/android-home-and-refresh-menu-icons/</link>
		<comments>http://www.casarini.org/blog/2010/android-home-and-refresh-menu-icons/#comments</comments>
		<pubDate>Fri, 15 Oct 2010 19:55:10 +0000</pubDate>
		<dc:creator>paolo</dc:creator>
				<category><![CDATA[programming]]></category>
		<category><![CDATA[android]]></category>
		<category><![CDATA[icons]]></category>

		<guid isPermaLink="false">http://www.casarini.org/blog/?p=443</guid>
		<description><![CDATA[I love hacking on my Android device, the SDK is well designed and there's always a new technology to study, but to give a complete user experience to our applications we need icons! In particular, I found very useful (even if discouraged by the Android guidelines) to use, for the option menu, the icons included [...]]]></description>
				<content:encoded><![CDATA[<p><img alt="" src="/images/ic_menu_home.png" title="ic_menu_home" class="alignleft" width="48" height="48" /><img alt="" src="/images/ic_menu_refresh.png" title="ic_menu_refresh" class="alignleft" width="48" height="48" />I love hacking on my Android device, the SDK is well designed and there's always a new technology to study, but to give a complete user experience to our applications we need icons! In particular, I found very useful (even if discouraged by the Android guidelines) to use, for the option menu, the icons included in the SDK.<br />
The better web resource I found where you can see which icons are include in the SDK is <a href="http://androiddrawableexplorer.appspot.com/">androiddrawableexplorer</a> but, as his author says, some of them are not public. I don't know why they are not public but for two of them (<code>ic_menu_refresh</code> and <code>ic_menu_home</code>)  I found the source so I've been able to include them in a recent work.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.casarini.org/blog/2010/android-home-and-refresh-menu-icons/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
