Hi, I'm RiccardoRiccardo Macoratti personal blog2024-02-25T00:00:00Zhttps://ricma.coRiccardo Macorattir.macoratti@gmx.co.ukChrome OS: Nerd Fonts for the terminal2024-02-25T00:00:00Zhttps://ricma.co/posts/tech/tutorials/chrome-os-nerd-fonts/<figure class="center"><img src="https://ricma.co/posts/tech/tutorials/chrome-os-nerd-fonts/chromeos-terminal.webp" alt="screenshot of chrome os terminal using nerd fonts"></figure>
<p>Recently I got hold of a Chrome OS device. While I usually do not sponsor Google products, I quite like this one, because although being low spec, it brings me a viable Linux environment with close to 12 hours of battery.</p>
<p>Since it is such an underpowered device, but I still want to grind some code, the usual VSCode setup is not an option, so I leaned towards a <a href="https://neovim.io/">Neovim</a> setup, <a href="https://www.lunarvim.org/">LunarVim</a> specifically.</p>
<p>To be able to use LunarVim a prerequisite is to use <a href="https://www.nerdfonts.com/">Nerd Fonts</a>, a distribution of some popular programming fonts bundled with all sort of icons. To my surprise there is no straightforward way of setting a custom font, neiter in the Chrome OS UI, nor in the Terminal application itself (although the font selection on the latter is not bad).</p>
<p>But... When there is a will, there is a way, they say.</p>
<h2>A piece of configuration tool left over and a tutorial</h2>
<p>Searching online I discovered the old configuration interface for the Terminal app, from the times it was only an SSH app, was still around and reachable.</p>
<p>Open Chrome and paste the following address in the search bar: <code>chrome-untrusted://terminal/html/nassh_preferences_editor.html</code> (I can't put a link, since being <em>untrusted</em>, as the name suggests, Chrome refuses to open it). A view like the following should open:</p>
<figure class=""><img src="https://ricma.co/posts/tech/tutorials/chrome-os-nerd-fonts/terminal-preferences.webp" alt="screenshot of chrome os terminal old preferences view"><figcaption>Chrome OS old Terminal preferences</figcaption></figure>
<p>From this screen, setting a custom font is a breeze, since there is a field to input custom CSS.</p>
<p>In the "Custom CSS (inline text)" field, put the following lines to fetch <a href="https://www.programmingfonts.org/#cascadia-code">Caskaydia Cove</a>, the Nerd Font version of <a href="https://github.com/microsoft/cascadia-code">Cascadia Cove</a>:</p>
<pre class="language-css"><code class="language-css"><span class="token atrule"><span class="token rule">@font-face</span></span> <span class="token punctuation">{</span><br> <span class="token property">font-family</span><span class="token punctuation">:</span> <span class="token string">"Caskaydia Cove NFM"</span><span class="token punctuation">;</span><br> <span class="token property">src</span><span class="token punctuation">:</span> <span class="token url"><span class="token function">url</span><span class="token punctuation">(</span><span class="token string url">"https://raw.githubusercontent.com/ryanoasis/nerd-fonts/v3.1.1/patched-fonts/CascadiaCode/Regular/CaskaydiaCoveNerdFontMono-Regular.ttf"</span><span class="token punctuation">)</span></span><span class="token punctuation">;</span><br> <span class="token property">font-weight</span><span class="token punctuation">:</span> normal<span class="token punctuation">;</span><br> <span class="token property">font-style</span><span class="token punctuation">:</span> normal<span class="token punctuation">;</span><br><span class="token punctuation">}</span><br><br><span class="token selector">x-row</span> <span class="token punctuation">{</span><br> <span class="token property">text-rendering</span><span class="token punctuation">:</span> optimizeLegibility<span class="token punctuation">;</span><br> <span class="token property">font-variant-ligatures</span><span class="token punctuation">:</span> normal<span class="token punctuation">;</span><br><span class="token punctuation">}</span></code></pre>
<p>Last <code>x-row</code> rules, should optimize the font for legibility and enable font ligatures, but the latter do not seem to work at the moment.</p>
<p>Finally locate the "Text font family" field, and prepend to the already present text the <code>@font-face</code> <code>font-family</code> name that you chose earlier between single quotes. In my example I should use <code>'Caskaydia Cove NFM'</code>, so that the full line becomes <code>'Caskaydia Cove NFM', 'Fira Code', 'Noto Sans Mono'</code>.</p>
<p>Now the terminal app should use the selected font.</p>
<h2>Other fonts</h2>
<p>You could use any font you like, as long as it is hosted somewhere on the Internet, the Terminal app will fetch it and cache it.</p>
<p>In the specific case that you want to use a font hosted on GitHub, like Nerd Fonts, you should be careful to use the link to the Raw GitHub CDN and not the one you get from the GitHub UI, otherwise you will have CORS error. Remember, after all, Chrome OS is a glorified web browser.</p>
<p>The technique that I use to find that link is to use the Network tab on the Chrome Developer Tools (<code>Ctrl+Shift+i</code>) and try to download the font from GitHub. Once you identify the request and click on it, the URL used will be the right one. Take a look at the following screenshot:</p>
<figure class="center"><img src="https://ricma.co/posts/tech/tutorials/chrome-os-nerd-fonts/dev-tools-network.webp" alt="screenshot of chrome dev tools network tab after downloading a font"></figure>
<p>For completeness, you can find all the supported Nerd Fonts, by looking at their GitHub repo, specifically <a href="https://github.com/ryanoasis/nerd-fonts/tree/master/patched-fonts">here</a>.</p>
Migrating to Spring Boot 6.1 | javac -parameters2023-09-22T00:00:00Zhttps://ricma.co/posts/tech/dev/migrating-to-spring-61-javac-parameters/<figure class="center"><img src="https://ricma.co/posts/tech/dev/migrating-to-spring-61-javac-parameters/3-bilion-devices-run-java.webp" alt="screenshot of java installation process saying 3 billion devices run java"></figure>
<p>I'll start with a very loud <strong>sorry</strong>... Would you have lost the chance to post this meme while talking of Java? Me neither.</p>
<p>Now, back to the serious stuff.</p>
<h2>The problem</h2>
<p>Although I have a love-hate relationship with Java, it is what pays my bills every single day. Yes, I am a Java dev.</p>
<p>I was porting a project from Java 17 to Java 20 (or Java 21) and consequently from Spring Boot 3.0.x to Spring Boot 3.2.0 (which at the time of writing is on Milestone stage). Boot 3.2.0 used Spring 6.1 under the hood, whereas 3.0.x used 6.0.</p>
<p>The update worked like a breeze, but when I ran the test suite, there it was an error. Something along the lines of:</p>
<pre class="language-plaintext"><code class="language-plaintext">org.springframework.data.mapping.MappingException: Parameter org.springframework.data.mapping.PreferredConstructor$Parameter@c3f657893 does not have a name!</code></pre>
<p>Something inside Spring Data was not working correctly. Obviously I searched every corner of the web for a solution, but to no avail. I don't know if it was a real undocumented issue or something out of my ignorance, but either way the only way left was the debugger.</p>
<p>After some fiddling, I stumbled upon <a href="https://github.com/spring-projects/spring-framework/blob/main/spring-core/src/main/java/org/springframework/core/StandardReflectionParameterNameDiscoverer.java">StandardReflectionParameterNameDiscoverer.java</a>:</p>
<pre class="language-java"><code class="language-java"><span class="token annotation punctuation">@Nullable</span><br><span class="token keyword">private</span> <span class="token class-name">String</span><span class="token punctuation">[</span><span class="token punctuation">]</span> <span class="token function">getParameterNames</span><span class="token punctuation">(</span><span class="token class-name">Parameter</span><span class="token punctuation">[</span><span class="token punctuation">]</span> parameters<span class="token punctuation">)</span> <span class="token punctuation">{</span><br> <span class="token class-name">String</span><span class="token punctuation">[</span><span class="token punctuation">]</span> parameterNames <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">String</span><span class="token punctuation">[</span>parameters<span class="token punctuation">.</span>length<span class="token punctuation">]</span><span class="token punctuation">;</span><br> <span class="token keyword">for</span> <span class="token punctuation">(</span><span class="token keyword">int</span> i <span class="token operator">=</span> <span class="token number">0</span><span class="token punctuation">;</span> i <span class="token operator"><</span> parameters<span class="token punctuation">.</span>length<span class="token punctuation">;</span> i<span class="token operator">++</span><span class="token punctuation">)</span> <span class="token punctuation">{</span><br> <span class="token class-name">Parameter</span> param <span class="token operator">=</span> parameters<span class="token punctuation">[</span>i<span class="token punctuation">]</span><span class="token punctuation">;</span><br> <span class="token keyword">if</span> <span class="token punctuation">(</span><span class="token operator">!</span>param<span class="token punctuation">.</span><span class="token function">isNamePresent</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span> <span class="token punctuation">{</span><br> <span class="token keyword">return</span> <span class="token keyword">null</span><span class="token punctuation">;</span> <span class="token comment">// the debugger takes this route</span><br> <span class="token punctuation">}</span><br> parameterNames<span class="token punctuation">[</span>i<span class="token punctuation">]</span> <span class="token operator">=</span> param<span class="token punctuation">.</span><span class="token function">getName</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span><br> <span class="token punctuation">}</span><br> <span class="token keyword">return</span> parameterNames<span class="token punctuation">;</span><br><span class="token punctuation">}</span></code></pre>
<p>I learned <code>isNamePresent()</code> goes to some native code to understand if the parameter name is available in the compiled bytecode. Spoiler: it wasn't. Now it was clear it was a reflection issue.</p>
<h2>The solution</h2>
<p>Again, back to the search. What I found was that to have reflection metadata bundled inside the <code>.class</code> files, the code has to be compiled with <code>java -parameters</code>.</p>
<p>I was not using Gradle to run the tests, but IntelliJ. And guess what? Gradle does this automatically granted you have set your <code>sourceCompatibility</code> above 11, while IntelliJ does not. Once I configured the IDE to use <code>javac -parameters</code> everything was back to working order.</p>
<h2>The documentation</h2>
<p>Could it be that such a big change went unannounced? Or again was it due to my ignorance?</p>
<p>The answer can be found promptly on the wiki of the Spring Framework project at <a href="https://github.com/spring-projects/spring-framework/wiki/Upgrading-to-Spring-Framework-6.x">this page</a>:</p>
<blockquote>
<p><code>LocalVariableTableParameterNameDiscoverer</code> has been removed in 6.1. Compile your Java sources with the common Java 8+ <code>-parameters</code> flag for parameter name retention (instead of relying on the <code>-debug</code> compiler flag) in order to be compatible with <code>StandardReflectionParameterNameDiscoverer</code>. With the Kotlin compiler, we recommend the <code>-java-parameters</code> flag.</p>
</blockquote>
<p>It was indeed communicated in some way, although I would have preferred a somewhat louder announcement.</p>
<h2>Final considerations</h2>
<p>Why was this change done only on this minor version update? And why <code>javac</code> does not put parameter names into the bytecode by default?</p>
<p>Well, as this very informative <a href="https://stackoverflow.com/questions/44067477/drawbacks-of-javac-parameters-flag#44075684">Stack Overflow answer</a> states, nothing comes for free.</p>
<p>Summarizing the answer, there are three major concerns:</p>
<ul>
<li>File size</li>
<li>Compatibility</li>
<li>Exposure of sensible information</li>
</ul>
<h3>File size</h3>
<p>As imaginable, filling the <code>.class</code> files with reflection metadata even if not needed increases the size of the class file itself. I don't consider this a real-world problem: Java application tend to be chunky anyway, a couple of megs more are not <em>the</em> issue here.</p>
<h3>Compatibility</h3>
<p>Although changing the parameter names doesn't hurt the binary compatibility of bytecode in the JVM, Java embraces very strictly the segregation pattern and treats them as local variables. You shouldn't really depend on them.</p>
<p>But, sometimes reflection is convenient, think JSON to class mapping or ORMs. I take convenience over dependence every day, especially because Java is already too verbose. Adding other boilerplate to manually map Jackson POJOs is one step more in the direction of "too much".</p>
<h3>Exposure of sensible information</h3>
<p>This can be true. If an attacker gains knowledge of the <code>.class</code> file source (looking at you Log4j), exposing the internal parameter names inherently broadens the attack surface area.</p>
<p>Hopefully my code artifacts will stay well hidden and protected behind some server and not reach any unwanted end user.</p>
<h1>Useful links</h1>
<ul>
<li><a href="https://stackoverflow.com/questions/44067477/drawbacks-of-javac-parameters-flag">Stack Overflow on the drawbacks of <code>-parameters</code></a></li>
<li><a href="https://github.com/spring-projects/spring-framework/wiki/Upgrading-to-Spring-Framework-6.x">Upgrading to Spring Framework 6.x</a></li>
<li><a href="https://github.com/spring-projects/spring-data-jpa/issues/1129">Spring Data JPA GitHub issue showing an example of error</a></li>
</ul>
Hack the Router! Technicolor DGA41322023-09-19T00:00:00Zhttps://ricma.co/posts/tech/tutorials/hack-dga4132/<figure class="center"><img src="https://ricma.co/posts/tech/tutorials/hack-dga4132/dga4132.webp" alt="photo of my dga4132"></figure>
<p>Let's start saying that I <strong>hate</strong> throwing away working stuff, especially if it means producing useless e-waste.</p>
<p>So, I found myself owning two vendor-locked routers, given to me by my previous ISPs, Fastweb and TIM (yes, I am based in Italy). The models were both Technicolor and both very similar: <a href="https://www.fastweb.it/adsl-fibra-ottica/dettagli/modem-fastweb-fastgate/">DGA4131</a>, also known as FASTGate, and <a href="https://www.tim.it/assistenza/assistenza-tecnica/guide-manuali/modem-timhub">DGA4132</a>, also known as TIM HUB.</p>
<p>Since they looked like capable models, I decided to search if they actually were any good and if there was any possibility to free them from the vendor lock.
Not only I discovered they were better than my current model (a <a href="https://www.tp-link.com/uk/home-networking/dsl-modem-router/archer-vr1210v/">TP-Link Archer VR1210v</a>), but also that there existed a project to hack them called <a href="https://hack-technicolor.readthedocs.io">Hacking Technicolor Gateways</a>.</p>
<p>Although the model are quite the same, I chose to use the DGA4132 (TIM HUB) purely due to its shape: it is more like a brick and can be hung on the wall, whereas the DGA4131 (FASTGate) is made to stand on a surface.</p>
<p>I decided to document my journey to this router unlocking process, since most of the documentation is in Italian and I also wanted to compile a vademecum for the future me in case I needed it.</p>
<h2>Hacking 101 - First steps</h2>
<p>A summary of the equipment you'll need to perform the feat:</p>
<ul>
<li>The router itself (duh!)</li>
<li>Its power supply (or a 18v/3A equivalent)</li>
<li>An ethernet cable</li>
<li>A Linux, Windows or Mac computer with an ethernet port (a USB adapter is good as well)</li>
<li>A working internet connection (different from the one you are configuring)</li>
</ul>
<h2>Hacking procedure</h2>
<h3>Check your firmware version</h3>
<p>Making things short, there are three types of firmwares that can be loaded on your router:</p>
<ul>
<li><strong>Type 1</strong>: you are halfway there, you can load a Type 2 and root from there</li>
<li><strong>Type 2</strong>: that is the firmware you want on the DGA4132, it is directly rootable, so most of the hassle is already done</li>
<li><strong>Type 3</strong>: complicated stuff, we won't consider this case in the scope of this guide</li>
</ul>
<p>In order to check which version you have, log in to the router interface (usually its http://192.168.1.1) and take note of the firmware version. It should be something like <code>2.1.0_003</code>.</p>
<p>Then go to the Hacking Technicolor Gateways <a href="https://hack-technicolor.readthedocs.io/en/latest/Repository/#tim-tim-hub">firmware page for DGA4132</a> and identify the firmware with the version you took note of before.</p>
<figure class="center"><img src="https://ricma.co/posts/tech/tutorials/hack-dga4132/dga4132-firmware-list.webp" alt="firmware repository dga4132 screenshot"></figure>
<p>Unfortunately, versions are not explicitly written into the table, but you should hover on the HTTP or Torrent links to compare. Once you identified your version, the first column will tell you which Type your firmware is and the second column will give you the Homeware version.</p>
<p><strong>Homeware</strong> is the name of Technicolor router OS. It is based on some version of OpenWrt, so it retains 90% of the compatibility. Below, there is a table explaining the forking.</p>
<table>
<thead>
<tr>
<th>Homeware</th>
<th>OpenWrt</th>
<th>DGA4132</th>
</tr>
</thead>
<tbody>
<tr>
<td>17</td>
<td>< 15</td>
<td><= 2.0.0</td>
</tr>
<tr>
<td>18(.3)</td>
<td>15.05.1</td>
<td>>= 2.1.0</td>
</tr>
<tr>
<td>19</td>
<td>r13941 (between 19 and 21)</td>
<td>>= 2.3.0</td>
</tr>
</tbody>
</table>
<p>If you obtained:</p>
<ul>
<li>Type 1 and your firmware version is >= 2.0.0: proceed with the method I am proposing below.</li>
<li>Type 1 and your firmware version is < 2.0.0: proceed with the method I am proposing below (but when noted follow the additional instructions).</li>
<li>Type 2: good to go, just skip the Type 2 firmware flashing and proceed to the actual rooting.</li>
<li>Type 3: outside the scope of this guide (if interested you can look <a href="https://www.ilpuntotecnico.com/forum/index.php/topic,79458.msg239670.html#msg239670">this forum topic</a>).</li>
</ul>
<p>Right now you are probably wondering what you should do if you obtained a <strong>???</strong> Type; well, probably nobody tested that version that well, so it is safer to treat it as a Type 3.</p>
<h3>Downloading firmwares</h3>
<p>Before starting to get the hands dirty, some files are needed on your local hard drive. I am dedicating a section to this, since it is not easy to get hold of them.
If you noticed, in the screenshot above, the HTTP download is marked with a <code>*</code> and that is because you can download firmwares over HTTP only if you are under TIM network.</p>
<p>In the contrary case, you should resort to Torrent. I believe there already are a ton of tutorials on how to set up a torrent client, so I won't be writing another.</p>
<p>You should download:</p>
<ul>
<li><a href="https://github.com/hack-technicolor/hack-technicolor/blob/master/torrents/vbnt-s/AGTHP_1.0.3_CLOSED.rbi.torrent?raw=true">1.0.3_CLOSED</a> (only if you currently are on a Type 1)</li>
<li><a href="https://github.com/kevdagoat/hack-technicolor/blob/master/torrents/vbnt-s/AGTHP_2.2.3_003_CLOSED.rbi.torrent?raw=true">2.2.3_CLOSED</a></li>
</ul>
<div class="note"><div class="note-title"> Note </div><div class="note-content"> You aren't going to need 1.0.3_CLOSED if you are already on a Type 2 firmware, since this is a Type 2 known to work and is needed for the firmare downgrade at next chapter, which you should not perform if you are already on Type 2. </div></div>
<h3>Changing firmware (only for Type 1)</h3>
<p>In order to change the firmware to a Type 2 firmware, such as the 1.0.3_CLOSED, it is necessary to perform the following steps:</p>
<ol>
<li>Reach to the back of your DGA4132 and take note of the "Access Key" written there, typically on the lower right.</li>
<li>Go to the router login page, that if you didn't change any settings is at http://192.168.1.1.</li>
<li>Once there, insert <code>admin</code> as username and your access key as password.</li>
<li>In the "Gateway" section of the interface you should be able to see the function to update your firmware manually.</li>
<li>From there just select the 1.0.3_CLOSED <code>.rbi</code> file that you downloaded earlier and proceed with the flashing.</li>
<li>Finally reset the DGA4132 to factory settings using the pinhole on the back.</li>
</ol>
<h3>Rooting</h3>
<p>The actual rooting process is very simple compared to all we did on the way here. You'll be using a tool called <a href="https://github.com/mswhirl/autoflashgui">AutoFlashGUI</a>.</p>
<p>AutoFlashGUI is written using the Python language, so a necessary step is to configure the Python environment in order to install the necessary dependencies. I won't guide you through the install of Python, there already are a lot of nice tutorials out there. This is the <a href="https://wiki.python.org/moin/BeginnersGuide/Download">official guide</a>. Be sure to install a recent version of Python (starting from Python 3.7) together with the included graphical library based on Tkinter.</p>
<p>Then, I'll assume a Python interpreter is installed, available in your <code>PATH</code> and you are running on something resembling a terminal (a Windows CMD, a Linux or Mac <code>bash</code> or even a simple <code>sh</code>).</p>
<p>First of all, let's begin by downloading the actual utility code clicking <a href="https://github.com/mswhirl/autoflashgui/archive/master.zip">here</a>. The decompress the archive to a folder of your choice. For this tutorial <code>~/download/autoflashgui</code> will be used.</p>
<p>Navigate to the aforementioned directory and create a <em>virtualenv</em> to contain all the dependencies:</p>
<pre class="language-shell"><code class="language-shell"><span class="token builtin class-name">cd</span> ~/donwload/autoflashgui<br>python <span class="token parameter variable">-m</span> venv .venv<br><span class="token builtin class-name">source</span> .venv/bin/activate<br>pip <span class="token function">install</span> <span class="token assign-left variable">robobrowser</span><span class="token operator">==</span><span class="token number">0.5</span>.3</code></pre>
<p>The you can finally start the program, from the very same terminal window:</p>
<pre class="language-shell"><code class="language-shell">python autoflashgui.py</code></pre>
<p>A window just like the following should appear.</p>
<figure class="center"><img src="https://ricma.co/posts/tech/tutorials/hack-dga4132/autoflashgui.webp" alt="screenshot of the autoflashgui utility"></figure>
<p>Be sure to have all configured as in the image:</p>
<ul>
<li>Select "Generic (Advanced DDNS)".</li>
<li>Use <code>192.168.1.1</code> as Target IP.</li>
<li>Username should be <code>admin</code>.</li>
<li>Password should be <code>admin</code> as well.</li>
<li>Be very sure the the "Flash firmware?" option is <strong>empty and deactivated</strong>.</li>
</ul>
<p>Finally just click the "Run" button and wait. Do not turn the router off or do anything else, just wait for the process to complete.</p>
<p>In order to check if everything went according to plan, we need to log in to the system using a secure remote shell called SSH. Since in 2023 a SSH client is available in most OSes as the <code>ssh</code> executable, I won't cover the installation process.</p>
<p>Unfortunately the Homeware OS does not use a full blown version of OpenSSH, but a lighter and smaller alternative called <a href="https://matt.ucc.asn.au/dropbear/dropbear.html">Dropbear</a>. Due to this reason, some more configuration is needed.</p>
<p>Under your home directory (user directory for the Windows folks) create the <code>.ssh</code> folder and inside of that a <code>config</code> file:</p>
<pre class="language-shell"><code class="language-shell"><span class="token function">mkdir</span> ~/.ssh<br><span class="token function">touch</span> ~/.ssh/config</code></pre>
<p>With whatever editor you like, write this contents to the file:</p>
<pre class="language-plaintext"><code class="language-plaintext">Host router<br> User root<br> HostName 192.168.1.1<br> HostKeyAlgorithms=+ssh-rsa<br> KexAlgorithms=+diffie-hellman-group1-sha1</code></pre>
<p>Now you should be able to access your router with the following command:</p>
<pre class="language-shell"><code class="language-shell"><span class="token function">ssh</span> router<br>root@192.168.1.1's password:</code></pre>
<p>If you obtain a prompt similar to the following, the rooting procedure went well:</p>
<pre class="language-plaintext"><code class="language-plaintext"><br>BusyBox v1.23.2 (2020-04-24 18:04:19 UTC) built-in shell (ash)<br><br> _______ __ __ __ <br> |_ _|.-----.----.| |--.-----.|__|.----.-----.| |.-----.----.<br> | | | -__| __|| | || || __| _ || || _ | _|<br> |___| |_____|____||__|__|__|__||__||____|_____||__||_____|__| <br> N E X T G E N E R A T I O N G A T E W A Y<br> --------------------------------------------------------------------<br> NG GATEWAY SIGNATURE DRINK<br> --------------------------------------------------------------------<br> * 1 oz Vodka Pour all ingredients into mixing<br> * 1 oz Triple Sec tin with ice, strain into glass.<br> * 1 oz Orange juice<br> --------------------------------------------------------------------<br><br><br>Software program:<br><br>Copyright � 2018 - Technicolor Delivery Technology SAS and/or its Group Company (Technicolor)<br><br>All Rights Reserved<br><br><br>This program contains proprietary information which is a trade secret of Technicolor<br>and also is protected by intellectual property as an unpublished work <br>under applicable Copyright laws/right of authorship. <br><br>This program is also subject to some patent and pending patent applications. <br>Technicolor� is registered trademark and trade name of Technicolor group company,<br>and shall not be used in any manner without express written from Technicolor. <br><br>The use of the program and documentation is strictly limited to your own internal<br>evaluation of the product embedding such program, unless expressly agreed otherwise<br>by Technicolor under a specific agreement. <br><br>Recipient is to retain this program in confidence and is not permitted to use<br>or make copies thereof other than as permitted in a written agreement with Technicolor,<br>unless otherwise expressly allowed by applicable laws. <br><br>Recipient is not allowed to make any copy, decompile, reverse engineer, disassemble,<br>and attempt to derive the source code of, modify, or<br>create derivative works of the program, any update, or any part thereof. <br><br>Any violation or attempt to do so is a violation of the rights of Technicolor.<br>If you or any person under your control or authority breach this restriction,<br>you may be subject to prosecution and damages.</code></pre>
<p>Now we can proceed to the next section, which is <em>bank planning</em>. The following sections are taken and directly paraphrased from the <a href="https://hack-technicolor.readthedocs.io">Hacking Technicolor Gateways</a> itself.</p>
<h3>Bank planning (<a href="https://hack-technicolor.readthedocs.io/en/stable/Hacking/PostRoot/">original</a>)</h3>
<p>The DGA4132 router has two "<em>banks</em>", that to say two zones of memory where two different firmware versions can lay and that you can boot from. In order to make use of all the available software and mods, you should maintain your router always in the optimal bank configuration.</p>
<p>The optimal bank plan should look something like this:</p>
<pre class="language-plaintext"><code class="language-plaintext">/proc/banktable/active<br>bank_1<br>/proc/banktable/activeversion<br>Unknown<br>/proc/banktable/booted<br>bank_2<br>/proc/banktable/bootedversion<br>xx.x.xxxx-...</code></pre>
<p>Summarizing: bank 1 should be active and left alone, bank 2 will be used to boot from and apply all the sweet software stuff.</p>
<p>To check your current bank plan, launch:</p>
<pre class="language-bash"><code class="language-bash"><span class="token function">find</span> /proc/banktable <span class="token parameter variable">-type</span> f <span class="token parameter variable">-print</span> <span class="token parameter variable">-exec</span> <span class="token function">cat</span> <span class="token punctuation">{</span><span class="token punctuation">}</span> <span class="token string">';'</span> <span class="token parameter variable">-exec</span> <span class="token builtin class-name">echo</span> <span class="token string">';'</span></code></pre>
<p>If the output does not match the above, just lunch the following very long script:</p>
<pre class="language-bash"><code class="language-bash"><span class="token comment"># Ensure two banks match in sizes</span><br><span class="token punctuation">[</span> <span class="token variable"><span class="token variable">$(</span><span class="token function">grep</span> <span class="token parameter variable">-c</span> bank_ /proc/mtd<span class="token variable">)</span></span> <span class="token operator">=</span> <span class="token number">2</span> <span class="token punctuation">]</span> <span class="token operator">&&</span> <span class="token punctuation">\</span><br><span class="token punctuation">[</span> <span class="token string">"<span class="token variable"><span class="token variable">$(</span><span class="token function">grep</span> bank_1 /proc/mtd <span class="token operator">|</span> <span class="token function">cut</span> -d<span class="token string">' '</span> <span class="token parameter variable">-f2</span><span class="token variable">)</span></span>"</span> <span class="token operator">=</span> <span class="token punctuation">\</span><br><span class="token string">"<span class="token variable"><span class="token variable">$(</span><span class="token function">grep</span> bank_2 /proc/mtd <span class="token operator">|</span> <span class="token function">cut</span> -d<span class="token string">' '</span> <span class="token parameter variable">-f2</span><span class="token variable">)</span></span>"</span> <span class="token punctuation">]</span> <span class="token operator">&&</span> <span class="token punctuation">{</span><br><span class="token comment"># Clone and verify firmware into bank_2 if applicable</span><br><span class="token punctuation">[</span> <span class="token string">"<span class="token variable"><span class="token variable">$(</span><span class="token function">cat</span> /proc/banktable/booted<span class="token variable">)</span></span>"</span> <span class="token operator">=</span> <span class="token string">"bank_1"</span> <span class="token punctuation">]</span> <span class="token operator">&&</span> <span class="token punctuation">{</span><br>mtd <span class="token parameter variable">-e</span> bank_2 <span class="token function">write</span> /dev/<span class="token variable"><span class="token variable">$(</span><span class="token function">grep</span> bank_1 /proc/mtd <span class="token operator">|</span> <span class="token function">cut</span> -d: <span class="token parameter variable">-f1</span><span class="token variable">)</span></span> bank_2 <span class="token operator">&&</span> <span class="token punctuation">\</span><br><span class="token builtin class-name">echo</span> Verifying <span class="token punctuation">..</span>. <span class="token operator">&&</span> <span class="token punctuation">\</span><br><span class="token punctuation">[</span> <span class="token variable"><span class="token variable">$(</span>sha256sum /dev/<span class="token punctuation">$(</span>grep bank_1 /proc/mtd <span class="token operator">|</span> <span class="token function">cut</span> -d: -f1<span class="token punctuation">)</span> /dev/<span class="token punctuation">$(</span>grep bank_2 /proc/mtd <span class="token operator">|</span> <span class="token function">cut</span> -d: -f1<span class="token punctuation">)</span> <span class="token operator">|</span> <span class="token function">cut</span> -d<span class="token string">' '</span> <span class="token parameter variable">-f1</span> <span class="token operator">|</span> <span class="token function">sort</span> <span class="token parameter variable">-u</span> <span class="token operator">|</span> <span class="token function">wc</span> <span class="token parameter variable">-l</span> <span class="token variable">)</span></span> <span class="token parameter variable">-eq</span> <span class="token number">1</span> <span class="token punctuation">]</span> <span class="token operator">||</span> <span class="token punctuation">\</span><br><span class="token punctuation">{</span> <span class="token builtin class-name">echo</span> Clone verification failed, retry<span class="token punctuation">;</span> <span class="token builtin class-name">exit</span><span class="token punctuation">;</span> <span class="token punctuation">}</span> <span class="token punctuation">}</span><br><span class="token comment"># Make a temp copy of overlay for booted firmware</span><br><span class="token function">cp</span> <span class="token parameter variable">-rf</span> /overlay/<span class="token variable"><span class="token variable">$(</span><span class="token function">cat</span> /proc/banktable/booted<span class="token variable">)</span></span> /tmp/bank_overlay_backup<br><span class="token comment"># Clean up jffs2 space by removing existing old overlays</span><br><span class="token function">rm</span> <span class="token parameter variable">-rf</span> /overlay/*<br><span class="token comment"># Use the previously made temp copy as overlay for bank_2</span><br><span class="token function">cp</span> <span class="token parameter variable">-rf</span> /tmp/bank_overlay_backup /overlay/bank_2<br><span class="token comment"># Activate bank_1</span><br><span class="token builtin class-name">echo</span> bank_1 <span class="token operator">></span> /proc/banktable/active<br><span class="token comment"># Make sure above changes get written to flash</span><br><span class="token function">sync</span><br><span class="token comment"># Erase firmware in bank_1</span><br>mtd erase bank_1<span class="token punctuation">;</span><br><span class="token comment"># Emulate system crash to hard reboot</span><br><span class="token builtin class-name">echo</span> c <span class="token operator">></span> /proc/sysrq-trigger<span class="token punctuation">;</span> <span class="token punctuation">}</span><br><span class="token comment"># end</span></code></pre>
<p>Now you router should slowly reboot. Once up again, launch the following again to check if the optimal bank configuration has been reached:</p>
<pre class="language-bash"><code class="language-bash"><span class="token function">find</span> /proc/banktable <span class="token parameter variable">-type</span> f <span class="token parameter variable">-print</span> <span class="token parameter variable">-exec</span> <span class="token function">cat</span> <span class="token punctuation">{</span><span class="token punctuation">}</span> <span class="token string">';'</span> <span class="token parameter variable">-exec</span> <span class="token builtin class-name">echo</span> <span class="token string">';'</span></code></pre>
<p>Let's now upgrade to a more recent version of the DGA4132 firmware.</p>
<h3>Upgrade to a recent firmware (<a href="https://hack-technicolor.readthedocs.io/en/stable/Upgrade/">original</a>)</h3>
<p>Since to root the devices, you probably have downgraded your device to an older version, now it is the time to safely update it, while retaining the root access.
Obviously this is not a mandatory step, but since routers in a home environment are often the last barrier to the Internet, the more updates the better.</p>
<p>In the "Downloading firmwares" section, I told you to download firmware version 2.2.3_CLOSED. That is because it is the last version still working with the stable version of Answel custom GUI that will be installed in the next chapter.</p>
<p>You will need to copy files to the devices and for that you need to use <code>scp -O</code> which tells <code>scp</code> to use the old SCP protocol instead of the newer SFTP, unsupported on Homeware.</p>
<p>As a first step, let's do a backup of the current and working configuration. SSH into the device and launch:</p>
<pre class="language-shell"><code class="language-shell"><span class="token function">tar</span> <span class="token parameter variable">-C</span> /overlay <span class="token parameter variable">-cz</span> <span class="token parameter variable">-f</span> /tmp/backup-<span class="token variable"><span class="token variable">$(</span><span class="token function">date</span> <span class="token parameter variable">-I</span><span class="token variable">)</span></span>.tar.gz <span class="token variable"><span class="token variable">$(</span><span class="token function">cat</span> /proc/banktable/booted<span class="token variable">)</span></span></code></pre>
<p>Then on your local machine SCP the backup:</p>
<pre class="language-shell"><code class="language-shell"><span class="token function">scp</span> <span class="token parameter variable">-O</span> router:/tmp/backup-<span class="token variable"><span class="token variable">$(</span><span class="token function">date</span> <span class="token parameter variable">-I</span><span class="token variable">)</span></span>.tar.gz <span class="token builtin class-name">.</span></code></pre>
<p>Now the updating process can start. I'll assume you have the <code>.rbi</code> file at <code>~/download/2.2.3_CLOSED.rbi</code>.
So, copy the firmware to the device <code>/tmp/</code> folder:</p>
<pre class="language-shell"><code class="language-shell"><span class="token function">scp</span> <span class="token parameter variable">-O</span> ~/download/2.2.3_CLOSED.rbi router:/tmp/new.rbi</code></pre>
<p>Then SSH into the device and extract it:</p>
<pre class="language-shell"><code class="language-shell"><span class="token function">cat</span> <span class="token string">"/tmp/new.rbi"</span> <span class="token operator">|</span> <span class="token punctuation">(</span>bli_parser <span class="token operator">&&</span> <span class="token builtin class-name">echo</span> <span class="token string">"Please wait..."</span> <span class="token operator">&&</span> <span class="token punctuation">(</span>bli_unseal <span class="token operator">|</span> <span class="token function">dd</span> <span class="token assign-left variable">bs</span><span class="token operator">=</span><span class="token number">4</span> <span class="token assign-left variable">skip</span><span class="token operator">=</span><span class="token number">1</span> <span class="token assign-left variable">seek</span><span class="token operator">=</span><span class="token number">1</span> <span class="token assign-left variable">of</span><span class="token operator">=</span><span class="token string">"/tmp/new.bin"</span><span class="token punctuation">))</span></code></pre>
<p>Erase all the current configuration from the device:</p>
<pre class="language-shell"><code class="language-shell"><span class="token function">rm</span> <span class="token parameter variable">-rf</span> /overlay/<span class="token variable"><span class="token variable">$(</span><span class="token function">cat</span> /proc/banktable/booted<span class="token variable">)</span></span></code></pre>
<p>Finally launch this big command to secure root access:</p>
<pre class="language-shell"><code class="language-shell"><span class="token function">mkdir</span> <span class="token parameter variable">-p</span> /overlay/<span class="token variable"><span class="token variable">$(</span><span class="token function">cat</span> /proc/banktable/booted<span class="token variable">)</span></span>/etc<br><span class="token function">chmod</span> <span class="token number">755</span> /overlay/<span class="token variable"><span class="token variable">$(</span><span class="token function">cat</span> /proc/banktable/booted<span class="token variable">)</span></span> /overlay/<span class="token variable"><span class="token variable">$(</span><span class="token function">cat</span> /proc/banktable/booted<span class="token variable">)</span></span>/etc<br><span class="token builtin class-name">echo</span> <span class="token parameter variable">-e</span> <span class="token string">"echo root:root | chpasswd<br>sed -i 's#/root:.*\<span class="token variable">$#</span>/root:/bin/ash#' /etc/passwd<br>sed -i -e 's/#//' -e 's#askconsole:.*\<span class="token variable">$#</span>askconsole:/bin/ash#' /etc/inittab<br>uci -q set \<span class="token variable"><span class="token variable">$(</span>uci show firewall <span class="token operator">|</span> <span class="token function">grep</span> <span class="token parameter variable">-m</span> <span class="token number">1</span> <span class="token punctuation">\</span><span class="token punctuation">$(</span>fw3 <span class="token parameter variable">-q</span> print <span class="token operator">|</span> <span class="token punctuation">\</span><br><span class="token function">egrep</span> <span class="token string">'iptables -t filter -A zone_lan_input -p tcp -m tcp --dport 22 -m comment --comment \"!fw3: .+\" -j DROP'</span> <span class="token operator">|</span> <span class="token punctuation">\</span><br><span class="token function">sed</span> <span class="token parameter variable">-n</span> <span class="token parameter variable">-e</span> <span class="token string">'s/^iptables.\+fw3: \(.\+\)\".\+/\1/p'</span><span class="token variable">)</span></span> | \<br>sed -n -e <span class="token entity" title="\"">\"</span>s/\(.\+\).name='.\+'$/<span class="token entity" title="\1">\1</span>/p<span class="token entity" title="\"">\"</span>).target='ACCEPT'<br>uci add dropbear dropbear<br>uci rename dropbear.@dropbear[-1]=afg<br>uci set dropbear.afg.enable='1'<br>uci set dropbear.afg.Interface='lan'<br>uci set dropbear.afg.Port='22'<br>uci set dropbear.afg.IdleTimeout='600'<br>uci set dropbear.afg.PasswordAuth='on'<br>uci set dropbear.afg.RootPasswordAuth='on'<br>uci set dropbear.afg.RootLogin='1'<br>uci set dropbear.lan.enable='0'<br>uci commit dropbear<br>/etc/init.d/dropbear enable<br>/etc/init.d/dropbear restart<br>rm /overlay/\<span class="token variable"><span class="token variable">$(</span><span class="token function">cat</span> /proc/banktable/booted<span class="token variable">)</span></span>/etc/rc.local<br>source /rom/etc/rc.local<br>"</span> <span class="token operator">></span> /overlay/<span class="token variable"><span class="token variable">$(</span><span class="token function">cat</span> /proc/banktable/booted<span class="token variable">)</span></span>/etc/rc.local<br><span class="token function">chmod</span> +x /overlay/<span class="token variable"><span class="token variable">$(</span><span class="token function">cat</span> /proc/banktable/booted<span class="token variable">)</span></span>/etc/rc.local<br><span class="token function">sync</span></code></pre>
<p>Now let the show begin. Initiate the flashing procedure:</p>
<pre class="language-shell"><code class="language-shell"><span class="token comment"># Erase and write new firmware into booted bank</span><br>mtd <span class="token parameter variable">-e</span> <span class="token variable"><span class="token variable">$(</span><span class="token function">cat</span> /proc/banktable/booted<span class="token variable">)</span></span> <span class="token function">write</span> <span class="token string">"/tmp/new.bin"</span> <span class="token variable"><span class="token variable">$(</span><span class="token function">cat</span> /proc/banktable/booted<span class="token variable">)</span></span><br><span class="token comment"># Emulate system crash to hard reboot</span><br><span class="token builtin class-name">echo</span> c <span class="token operator">></span> /proc/sysrq-trigger</code></pre>
<p>When the process ends, the device will crash and reboot. First thing to do once you regain SSH access to it, is change the root password using:</p>
<pre class="language-shell"><code class="language-shell"><span class="token function">passwd</span></code></pre>
<h3>Install Ansuel custom GUI (tch-nginx-gui)</h3>
<p>As a final step, a custom GUI unlocking most of the router functionality is needed. Luckily for us, Ansuel did a great job developing one. You can find it on the <a href="https://github.com/Ansuel/tch-nginx-gui">GitHub page</a>.</p>
<p>Making a long story short, first download the GUI from <a href="https://raw.githubusercontent.com/Ansuel/gui-dev-build-auto/master/GUI.tar.bz2">this page</a>. I'll assume the archive lies at <code>~/download/GUI.tar.bz2</code>.</p>
<p>Copy the archive to the device using SCP:</p>
<pre class="language-shell"><code class="language-shell"><span class="token function">scp</span> <span class="token parameter variable">-O</span> ~/download/GUI.tar.bz2 router:/tmp/GUI.tar.bz2</code></pre>
<p>Then SSH into the device and launch the following commands:</p>
<pre class="language-shell"><code class="language-shell">bzcat /tmp/GUI.tar.bz2 <span class="token operator">|</span> <span class="token function">tar</span> <span class="token parameter variable">-C</span> / <span class="token parameter variable">-xvf</span> -<br>/etc/init.d/rootdevice force</code></pre>
<p>Wait for the process to complete and reboot (if the device does not reboot by itself).</p>
<p>Congratulation the hard part is finished, your devices is rooter and its power completely unleashed. Have fun!</p>
<h2>A bonus step: SQM</h2>
<p>You probably noticed (or not, very luckily for you) that if you bomb router with packets, e.g. when someone else on the network is watching a 4K video, updating Windows or downloading something, the connection drops. That can be a real PITA if you are playing online or have a running download server.</p>
<figure class="center"><img src="https://ricma.co/posts/tech/tutorials/hack-dga4132/michael-scott-fast.webp" alt="the office michael scott fast meme"></figure>
<p>This issue is called <a href="https://www.bufferbloat.net/projects/bloat/wiki/More_about_Bufferbloat/#what-is-bufferbloat">bufferbloat</a> and affects a lot of routing devices. Read <a href="https://randomneuronsfiring.com/best-bufferbloat-analogy-ever/">Best Bufferbloat Analogy - Ever</a> to understand bufferbloat better.</p>
<p>The bad news is that you cannot really eliminate it, especially if you run a stock firmware. The good news is that since Homeware is basically OpenWrt, it is possible to install a package called SQM to mitigate bufferbloat. SQM stays for <strong>S</strong>mart <strong>Q</strong>ueue <strong>M</strong>anagement and is a term to group a series of algorithm used to manage packet queues (or really any queue) in a "nicer" way, considering package flow and congestion as parameters in the game.</p>
<h3>Test for bufferbloat</h3>
<p>Before pointing fingers, perform a bufferbloat test. There are some easy online tools for that:</p>
<ul>
<li><a href="https://www.waveform.com/tools/bufferbloat">Waveform</a>: it gives you a very informative score of your bufferbloat, but is a little biased due to wanting you to buy one of their devices.</li>
<li><a href="https://fast.com/">Fast</a>: an unbiased Netflix tool to do a speed test and measure bufferbloat, once you press the <em>Show more info</em> link.</li>
</ul>
<figure class="center"><img src="https://ricma.co/posts/tech/tutorials/hack-dga4132/waveform-bufferbloat-test.webp" alt="screenshot of waveform bufferbloat test after sqm applied"></figure>
<p>Once you identified bufferbloat as your culprit, proceed to apply the SQM fix.</p>
<h3>Configure OpenWrt packages for Homeware 18</h3>
<p>To install SQM, we can use the <code>opkg</code> package manager of OpenWrt. In the current state Homeware 18 is referencing an hardware branch that doesn't exist, so an <code>opkg update</code> will fail.</p>
<p>Luckily <a href="https://www.macoers.com/blog/antonio-macolino/repository_openwrt_homeware_18_brcm63xx_tch">Macoers</a> has provided some packages for the DGA4132 on Homeware 18.</p>
<p>SSH into the router as root.</p>
<p>Check that <code>/etc/opkg.conf</code> contains the following rows:</p>
<pre class="language-plaintext"><code class="language-plaintext">arch all 100<br>arch noarch 100<br>arch arm_cortex-a9 200<br>arch arm_cortex-a9_neon 300</code></pre>
<p>Then, download the following <code>IPK</code> packages and proceed to install them all:</p>
<pre class="language-shell"><code class="language-shell"><span class="token function">curl</span> <span class="token parameter variable">-k</span> https://repository.macoers.com/homeware/18/brcm63xx-tch/VANTW/base/openssl-util_1.0.2t-1_arm_cortex-a9_neon.ipk <span class="token parameter variable">--output</span> /tmp/openssl-util_1.0.2t-1_arm_cortex-a9_neon.ipk<br><span class="token function">curl</span> <span class="token parameter variable">-k</span> https://repository.macoers.com/homeware/18/brcm63xx-tch/VANTW/base/libopenssl_1.0.2t-1_arm_cortex-a9_neon.ipk <span class="token parameter variable">--output</span> /tmp/libopenssl_1.0.2t-1_arm_cortex-a9_neon.ipk<br><span class="token function">curl</span> <span class="token parameter variable">-k</span> https://repository.macoers.com/homeware/18/brcm63xx-tch/VANTW/packages/wget_1.19.5-4_arm_cortex-a9_neon.ipk <span class="token parameter variable">--output</span> /tmp/wget_1.19.5-4_arm_cortex-a9_neon.ipk<br>opkg <span class="token function">install</span> --force-overwrite /tmp/*.ipk</code></pre>
<p>Finally check that <code>/etc/opkg.conf</code> contains the following rows:</p>
<pre class="language-plaintext"><code class="language-plaintext">src/gz chaos_calmer_base_macoers https://repository.macoers.com/homeware/18/brcm63xx-tch/VANTW/base<br>src/gz chaos_calmer_packages_macoers https://repository.macoers.com/homeware/18/brcm63xx-tch/VANTW/packages<br>src/gz chaos_calmer_luci_macoers https://repository.macoers.com/homeware/18/brcm63xx-tch/VANTW/luci<br>src/gz chaos_calmer_routing_macoers https://repository.macoers.com/homeware/18/brcm63xx-tch/VANTW/routing<br>src/gz chaos_calmer_telephony_macoers https://repository.macoers.com/homeware/18/brcm63xx-tch/VANTW/telephony<br>src/gz chaos_calmer_core_macoers https://repository.macoers.com/homeware/18/brcm63xx-tch/VANTW/target/packages</code></pre>
<p>If it does, do nothing. In case it doesn't, the best strategy is to put them inside the <code>/etc/opkg/customfeeds.conf</code> file.</p>
<p>Finally launch a <code>opkg update</code>.</p>
<h3>Install SQM</h3>
<p>To install the OpenWrt SQM package do:</p>
<pre class="language-shell"><code class="language-shell">opkg <span class="token function">install</span> sqm-scripts</code></pre>
<p>Then enable it to start at boot and start it now:</p>
<pre class="language-shell"><code class="language-shell">/etc/init.d/sqm <span class="token builtin class-name">enable</span><br>/etc/init.d/sqm start</code></pre>
<h2>The fun part: trial and error</h2>
<p>Installing SQM is not enough. For it to be effective, you should apply the right configuration.</p>
<p>Open the <code>/etc/config/sqm</code> file and edit the contents to your liking. I will post my configuration below, you can take it as example. I don't really understand all the values there, I just edited the interface name and download and upload speed.</p>
<pre class="language-plaintext"><code class="language-plaintext">config queue 'wan'<br> option enabled '1'<br> option interface 'wanptm0'<br> option download '47500'<br> option upload '9020'<br> option qdisc 'fq_codel'<br> option script 'simple.qos'<br> option qdisc_advanced '0'<br> option ingress_ecn 'ECN'<br> option egress_ecn 'ECN'<br> option qdisc_really_really_advanced '0'<br> option itarget 'auto'<br> option etarget 'auto'<br> option linklayer 'none'</code></pre>
<p>To find the interface name, just launch this command:</p>
<pre class="language-shell"><code class="language-shell">uci get network.wan.ifname</code></pre>
<p>To populate download and upload speeds, I used a trial and error process.</p>
<ol>
<li>Detach all your devices from perfoming any relevant network operations.</li>
<li>Perform a speed test using <a href="https://fast.com/">Fast</a>. Take note of the download and upload speeds, e.g. 50Mbps and 10Mbps.</li>
<li>Populate <code>option download</code> and <code>option upload</code> with the obtained speed multiplied by 1000, e.g. 50000 and 10000.</li>
<li>Perform a <a href="https://www.waveform.com/tools/bufferbloat">Waveform bufferbloat test</a>. This is your baseline score, e.g. F.</li>
<li>Remove 1% from the uplink and downlink speeds. E.g. 49500 and 9900.</li>
<li>Reload the SQM service using <code>/etc/init.d/sqm restart</code>.</li>
<li>Retry from point 4, until you get better scores, e.g. A or A+.</li>
</ol>
<p>If you reach an upper bound and you can't improve your score anymore, you can try applying a different percentage for downlink and uplink speeds. For reference my optimum percentages were 95% of download speed and 82% of upload.</p>
<p>You will pay some speed, but your network will maintain its performance even when under heavy load.</p>
<h2>Useful links</h2>
<p>The following are the sources of my information. Some of the links you can find directly in the related paragraph.</p>
<ul>
<li><a href="https://hack-technicolor.readthedocs.io">Hacking Technicolor Gateways</a></li>
<li><a href="https://www.ilpuntotecnico.com/forum/index.php?topic=81542.0">ilpuntotecnico DGA4132 forum topic [ITA]</a></li>
<li><a href="https://www.ilpuntotecnico.com/forum/index.php/topic,78162.0.html">ilpuntotecnico DGA4132 unlock forum topic [ITA]</a></li>
<li><a href="https://www.ilpuntotecnico.com/forum/index.php/topic,79458.msg239670.html#msg239670">ilpuntotecnico DGA4132 Type 3 or ??? guide [ITA]</a></li>
<li><a href="https://www.ilpuntotecnico.com/forum/index.php/topic,81461.0.html">ilpuntotecnico Ansuel custom GUI forum topic [ITA]</a></li>
<li><a href="https://github.com/Ansuel/tch-nginx-gui">Ansuel custom GUI repository</a></li>
<li><a href="https://www.ilpuntotecnico.com/forum/index.php?topic=85190.0">SQM on DGA4132 [ITA]</a></li>
<li><a href="https://www.macoers.com/blog/antonio-macolino/repository_openwrt_homeware_18_brcm63xx_tch">OpenWrt packages on Homeware 18 [ITA]</a></li>
<li><a href="https://www.waveform.com/tools/bufferbloat">Waveform bufferbloat test</a></li>
</ul>
Bash | Tips & Tricks I would have wanted to know when I started2019-11-11T00:00:00Zhttps://ricma.co/posts/tech/tutorials/bash-tip-tricks/<figure class="center"><img src="https://ricma.co/posts/tech/tutorials/bash-tip-tricks/bash.webp" alt="screenshot of some terminal lines"></figure>
<p>When I started using the Bash (<strong>B</strong>ourne <strong>A</strong>gain) shell and producing my subsequent first scripts, I treated it just like the old plain <strong>B</strong>ourne shell, the one we all already love and use in quite a few environments. Fortunately, Bash is much more than it appears to the eye and could be a real game changer in the life of the average developer.</p>
<p>This article will give more emphasis to the scripting side of Bash, but the occasional concept can be adapted to be applied when used as a command launcher in an interactive way.</p>
<p>Regarding scripts, although the strict POSIX compatibility is sometimes required, preventing us from using Bash directly and reverting to the standard Bourne shell capabilities, it is often easier and quicker to use <em>bashisms</em> (Bash-only features) to write our scripts.</p>
<p>So below let's see some tricks I learned throughout my Bash adventure.</p>
<div class="note"><div class="note-title"> Note </div><div class="note-content"> Maybe, for some people this features are granted, but for me, and I suspect for a lot of people like me, at the time they were quite a discovery. Therefore if you are already more knowledgeable than me, great, let's have a chat, otherwise I hope all this will be useful to you. As always, feel free to let me know if I made some imprecisions somewhere. </div></div>
<h2>Interactive interpreter</h2>
<h3><code>!</code></h3>
<p>For interactive Bash use, I have only one small trick to remember: <code>!</code>. <code>!</code> is part of a bigger world called <a href="https://www.gnu.org/software/bash/manual/html_node/History-Interaction.html#History-Interaction"><em>history expansion</em></a>.</p>
<p>Long before the up arrow let you search in your history, there was a mean of referring to a past history line and, you guessed it, was <code>!</code>.</p>
<pre class="language-shell"><code class="language-shell">$ <span class="token operator">!</span><span class="token number">42</span> <span class="token comment"># this would execute the command at line 42 of your history</span></code></pre>
<p>What if we need to repeat a command? It is possible to refer to a number of lines relative to the current line. Summarized in one sentence: 'execute the command I typed <em>n</em> lines ago'.</p>
<pre class="language-shell"><code class="language-shell">$ <span class="token operator">!</span>-42 <span class="token comment"># this would print the command used 42 lines ago</span></code></pre>
<p>And arguably the most useful of all <code>!</code> shortcuts, it is possible to repeat command at last line.</p>
<pre class="language-shell"><code class="language-shell">$ <span class="token operator">!</span>-1<br>$ <span class="token operator">!</span><span class="token operator">!</span> <span class="token comment"># simpler version, synonym of '!-1'</span></code></pre>
<p>And <code>!!</code> can be used as a "variable". The classical example in this case is <code>sudo</code>:</p>
<pre class="language-shell"><code class="language-shell">$ <span class="token function">apt</span> <span class="token function">install</span> firefox<br>E: Could not <span class="token function">open</span> lock <span class="token function">file</span> /var/lib/dpkg/lock-frontend - <span class="token function">open</span> <span class="token punctuation">(</span><span class="token number">13</span>: Permission denied<span class="token punctuation">)</span><br>E: Unable to acquire the dpkg frontend lock <span class="token punctuation">(</span>/var/lib/dpkg/lock-frontend<span class="token punctuation">)</span>, are you root?<br>$ <span class="token function">sudo</span> <span class="token operator">!</span><span class="token operator">!</span><br>$ <span class="token function">sudo</span> <span class="token function">apt</span> <span class="token function">install</span> firefox </code></pre>
<h3>reverse-i-search (or reverse-search-history)</h3>
<p>There are a number of situations where so many commands has been typed, that it is impossible to remember them by name or by line. In this cases, it is possible to search through history incrementally, using some parts of the command as search key.</p>
<p>For example, let's suppose that we have to search for the command <code>find . -name "*.rst" -type f | python3 /usr/local/bin/scripts/pelican_importer.py</code> but we don't want to type it all by hand, incurring in the risk of errors and subsequent re-typing. It is possible to press <code>CRTL</code> + <code>R</code> to search:</p>
<pre class="language-shell"><code class="language-shell">$<br>bck-i-search: _</code></pre>
<p>Then type in the search key and press <code>CRTL</code> + <code>R</code> over to scroll through results:</p>
<pre class="language-shell"><code class="language-shell">$ <span class="token function">find</span> <span class="token builtin class-name">.</span> <span class="token parameter variable">-name</span> <span class="token string">"*.rst"</span> <span class="token parameter variable">-type</span> f <span class="token operator">|</span> python3 /usr/local/bin/scripts/pelican_importer.py<br>bck-i-search: find_</code></pre>
<p>When the command is the one we desire to execute, it is sufficient to press <code>Enter</code> to fire it.</p>
<h2>Bash scripts</h2>
<h3>Shebangs</h3>
<p>This one should already be common knowledge to every developer using POSIX systems, but every script should declare at its start the interpreter that is going to execute the actual code. This is accomplished using the so called <a href="https://en.wikipedia.org/w/index.php?title=Shebang_(Unix)&oldid=921706257"><em>shebang</em></a> line.
My personal receipt is:</p>
<pre class="language-bash"><code class="language-bash"><span class="token shebang important">#!/usr/bin/env bash</span></code></pre>
<p>That line should tell the current shell to execute the current script (if made executable with <code>chmod +x</code>) with the command written after the <code>!#</code> characters.
A disclaimer though, in some exotic environments there is no <code>/usr/bin/env</code> executable and thus the shebang line will be invalid. In such cases, we need to revert to:</p>
<pre class="language-bash"><code class="language-bash"><span class="token shebang important">#!/usr/bin/bash</span></code></pre>
<p>Or even:</p>
<pre class="language-bash"><code class="language-bash"><span class="token shebang important">#!/bin/bash</span></code></pre>
<p>By the way, shebangs are a general scripting "rule", therefore they do work with a number of different scripting languages, such as Python, Perl, PHP and JavaScript.</p>
<h3>Bash options</h3>
<p>Have you ever noticed Bash does not halt when an error happens? Or that it will happily use uninitialized variables?</p>
<p>Well, there is a solution to all this issues (even if they are not <em>real</em> issues) that involves Bash options. As our trusted manual says:</p>
<pre class="language-shell"><code class="language-shell">$ <span class="token function">man</span> <span class="token number">1</span> <span class="token function">bash</span></code></pre>
<blockquote>
<p>The options are off by default unless otherwise noted.</p>
</blockquote>
<p>We need to enable them one by one if we want to exploit their behavior.</p>
<p>For example, let's make some script up to show some feature.</p>
<pre class="language-bash"><code class="language-bash"><span class="token shebang important">#!/usr/bin/bash</span><br><br><span class="token builtin class-name">cd</span> /foo<br><span class="token function">ls</span></code></pre>
<p>Clearly this scripts changes directory to <code>/foo</code> and then tries to list its contents. If <code>/foo</code> doesn't exist, will <code>ls</code> be executed? Yes, it will. To prevent this behavior and exit if some command, simple or complex, throws an error, we need to use the <code>errexit</code> option:</p>
<pre class="language-bash"><code class="language-bash"><span class="token shebang important">#!/usr/bin/bash</span><br><span class="token builtin class-name">set</span> <span class="token parameter variable">-e</span> <span class="token comment"># enable errexit option</span><br><br><span class="token builtin class-name">cd</span> /foo<br><span class="token function">ls</span></code></pre>
<p>This time the shell is going to stop execution with a <code>cd: can't cd to /foo</code> error.</p>
<p>Another example (that YOU SHOULD <strong>NOT</strong> RUN):</p>
<pre class="language-bash"><code class="language-bash"><span class="token shebang important">#!/usr/bin/bash</span><br><span class="token builtin class-name">set</span> <span class="token parameter variable">-e</span><br><br><span class="token function">rm</span> <span class="token parameter variable">-rf</span> <span class="token variable">$prefix</span>/*</code></pre>
<p>Here <code>$prefix</code> is clearly undefined, so the command will expand to:</p>
<pre class="language-bash"><code class="language-bash"><span class="token shebang important">#!/usr/bin/bash</span><br><span class="token builtin class-name">set</span> <span class="token parameter variable">-e</span><br><br><span class="token function">rm</span> <span class="token parameter variable">-rf</span> /*</code></pre>
<p>In case you haven't understood the situation, this command, granted <code>root</code> privileges, will destroy your installation, even your machine in some situations. To prevent this, use the <code>nounset</code> option</p>
<pre class="language-bash"><code class="language-bash"><span class="token shebang important">#!/usr/bin/bash</span><br><span class="token builtin class-name">set</span> <span class="token parameter variable">-e</span><br><span class="token builtin class-name">set</span> <span class="token parameter variable">-u</span> <span class="token comment"># enable nounset option</span><br><br><span class="token function">rm</span> <span class="token parameter variable">-rf</span> <span class="token variable">$prefix</span>/*</code></pre>
<p>Finally an option useful during the script writing or debugging. Since a lot of expansions are taking place when Bash interprets your commands, a useful capability to have would be to be able to see the command after expansion has been performed. That's why the <code>xtrace</code> exists.</p>
<pre class="language-bash"><code class="language-bash"><span class="token shebang important">#!/usr/bin/bash</span><br><span class="token builtin class-name">set</span> <span class="token parameter variable">-e</span><br><span class="token builtin class-name">set</span> <span class="token parameter variable">-u</span><br><span class="token builtin class-name">set</span> <span class="token parameter variable">-x</span> <span class="token comment"># enable xtrace option</span><br><br><span class="token assign-left variable">prefix</span><span class="token operator">=</span><span class="token string">"Hello, world!"</span><br><span class="token builtin class-name">echo</span> <span class="token string">"This variable content: <span class="token variable">$prefix</span>"</span></code></pre>
<p>Once called, this will print out every command executed:</p>
<pre class="language-shell"><code class="language-shell">$ <span class="token function">bash</span> script.sh<br>+ <span class="token assign-left variable">prefix</span><span class="token operator">=</span>Hello, world<span class="token operator">!</span><br>+ <span class="token builtin class-name">echo</span> This variable content: Hello, world<span class="token operator">!</span><br>This variable content: Hello, world<span class="token operator">!</span></code></pre>
<p>Summing all up, I tend to begin my scripts with the following header:</p>
<pre class="language-bash"><code class="language-bash"><span class="token shebang important">#!/usr/bin/bash</span><br><span class="token builtin class-name">set</span> <span class="token parameter variable">-e</span><br><span class="token builtin class-name">set</span> <span class="token parameter variable">-u</span><br><span class="token builtin class-name">set</span> <span class="token parameter variable">-x</span><br><br><span class="token comment"># ...</span></code></pre>
<p>Then, when I finished writing them, I just comment out the <code>xtrace</code> option (or more elegantly disable it).</p>
<pre class="language-bash"><code class="language-bash"><span class="token shebang important">#!/usr/bin/bash</span><br><span class="token builtin class-name">set</span> <span class="token parameter variable">-e</span><br><span class="token builtin class-name">set</span> <span class="token parameter variable">-u</span><br><span class="token builtin class-name">set</span> +x <span class="token comment"># disable xtrace</span><br><br><span class="token comment"># ...</span></code></pre>
<h3>Expansions</h3>
<p>In the Bash world, <em>expansion</em> is a quite a scaring word, especially to a newcomer. Actually, there are just a couple rules to follow when we talk about expansion, or at least its common occurrences.</p>
<p>First, what is expansion? Expansion is a transformation that is performed on a number of constructs, after each line has been split into tokens. One example made earlier is:</p>
<pre class="language-bash"><code class="language-bash"><span class="token assign-left variable">prefix</span><span class="token operator">=</span><span class="token string">"Hello, world!"</span><br><span class="token builtin class-name">echo</span> <span class="token string">"This variable content: <span class="token variable">$prefix</span>"</span></code></pre>
<p>Here, the variable <code>$prefix</code> gets expanded replacing it with its content, so that the string <code>"This variable content: $prefix"</code> becomes <code>This variable content: Hello, world!</code>. Results of these kind of operations could be unintuitive at times, leading to a lot of common errors.</p>
<p>Let's start from variable expansion. It is possible to decide if expansion is desired in a string using double or single quotes: the first does get transformed, the second doesn't.</p>
<pre class="language-shell"><code class="language-shell">$ <span class="token assign-left variable">name</span><span class="token operator">=</span><span class="token string">"Riccardo"</span><br>$ <span class="token builtin class-name">echo</span> <span class="token string">"My name is <span class="token variable">$name</span>"</span><br>My name is Riccardo<br>$ <span class="token builtin class-name">echo</span> <span class="token string">'My name is $name'</span><br>My name is <span class="token variable">$name</span></code></pre>
<p>Also, let's reason on an example. Suppose we want to compose a string like <code>Name_Surname</code> (e.g. <code>Riccardo_Macoratti</code>), but we want the user to provide the name and surname.</p>
<pre class="language-bash"><code class="language-bash"><span class="token shebang important">#!/usr/bin/env bash</span><br><span class="token builtin class-name">set</span> <span class="token parameter variable">-e</span><br><span class="token builtin class-name">set</span> <span class="token parameter variable">-u</span><br><span class="token builtin class-name">set</span> +x<br><br><span class="token builtin class-name">echo</span> <span class="token parameter variable">-n</span> <span class="token string">"Name: "</span><br><span class="token builtin class-name">read</span> name<br><span class="token builtin class-name">echo</span> <span class="token parameter variable">-n</span> <span class="token string">"Surname: "</span><br><span class="token builtin class-name">read</span> surname<br><br><span class="token builtin class-name">echo</span> <span class="token string">"<span class="token variable">$name_</span><span class="token variable">$surname</span>"</span></code></pre>
<p>Easy enough, but when we try to execute the script, an error shows up:</p>
<pre class="language-shell"><code class="language-shell">$ <span class="token function">bash</span> script.sh<br>Name: Riccardo <br>Surname: Macoratti<br>name_: parameter not <span class="token builtin class-name">set</span></code></pre>
<p>It is because Bash doesn't know what variable to expand, <code>$name</code> or <code>$name_</code>, and chooses to expand the longest one, that is to say <code>$name_</code>, which is obviously unset. Preventing this behavior is easy, just wrap the variable name in curly brackets.</p>
<pre class="language-bash"><code class="language-bash"><span class="token shebang important">#!/usr/bin/env bash</span><br><span class="token builtin class-name">set</span> <span class="token parameter variable">-e</span><br><span class="token builtin class-name">set</span> <span class="token parameter variable">-u</span><br><span class="token builtin class-name">set</span> +x<br><br><span class="token builtin class-name">echo</span> <span class="token parameter variable">-n</span> <span class="token string">"Name: "</span><br><span class="token builtin class-name">read</span> name<br><span class="token builtin class-name">echo</span> <span class="token parameter variable">-n</span> <span class="token string">"Surname: "</span><br><span class="token builtin class-name">read</span> surname<br><br><span class="token builtin class-name">echo</span> <span class="token string">"<span class="token variable">${name}</span>_<span class="token variable">$surname</span>"</span></code></pre>
<pre class="language-shell"><code class="language-shell">$ <span class="token function">bash</span> script.sh<br>Name: Riccardo <br>Surname: Macoratti<br>Riccardo_Macoratti</code></pre>
<p>The second (and IMHO most useful) form of expansion is command expansion. It si the power of "transform every command output into a variable", accomplished with the syntax <code>$(command)</code>.</p>
<p>Let's say that we are in a hurry and need to perform a one-time task in the most time-efficient way we can think of. In this kind of situations, there is usually next to no time or interest to look for a clean solution on the manual or on the internet. For example, I tend to forget how to read a file in Bash.</p>
<pre class="language-shell"><code class="language-shell">$ <span class="token assign-left variable">file_contents</span><span class="token operator">=</span><span class="token variable"><span class="token variable">$(</span><span class="token function">cat</span> file.txt<span class="token variable">)</span></span></code></pre>
<p>Now <code>$file_contents</code> contains the contents of <code>file.txt</code>. Another classical example is caching. When a long computation is terminated and it is desirable to store the result in memory, that is the time for a command expansion.</p>
<pre class="language-shell"><code class="language-shell">$ <span class="token assign-left variable">cache</span><span class="token operator">=</span><span class="token variable"><span class="token variable">$(</span><span class="token function">find</span> / <span class="token parameter variable">-type</span> f <span class="token operator">|</span> <span class="token function">grep</span> <span class="token parameter variable">-e</span> <span class="token string">'^.+\.conf'</span><span class="token variable">)</span></span> <span class="token comment"># search for every .conf file in your root</span></code></pre>
<p>And yoy can see, command expansion leads the way to fun (and sometimes ugly...) one-liner, pipe expressions.</p>
<h3>Short-circuit boolean operators</h3>
<p>Every programmer worth of its name should know boolean operators and surely the most used are logical conjunction (∧), commonly called <em>and</em>, and logical disjunction (∨), commonly called <em>or</em>.</p>
<p>Bash unsurprisingly has them too and uses the <a href="https://en.wikipedia.org/wiki/Short-circuit_evaluation">short-circuiting</a> variant. Boolean expressions are usually composed of multiple boolean operations chained together in some way, by means of an operator. It can happen that the result of the boolean expression may be known just after evaluating the first operation. Let's think of this examples:</p>
<pre class="language-shell"><code class="language-shell">$ <span class="token assign-left variable">a</span><span class="token operator">=</span>true<br>$ <span class="token assign-left variable">b</span><span class="token operator">=</span>false<br>$ <span class="token variable">$b</span> <span class="token operator">&&</span> <span class="token builtin class-name">echo</span> <span class="token string">"no short-circuit here"</span><br>$ <span class="token variable">$a</span> <span class="token operator">||</span> <span class="token builtin class-name">echo</span> <span class="token string">"no short-circuit here"</span></code></pre>
<p>These strings won't be printed out, because Bash already knows that the result of the two expressions, just having evaluated <code>$b &&</code> or <code>$a ||</code>. In fact, <code>false && [𝑥]</code> evaluates to <code>false</code> for every <code>𝑥</code> and vice versa <code>true || [𝑥]</code> evaluates to <code>true</code> for every <code>𝑥</code>.</p>
<p>Now, consider that every simple or advanced set of commands executed leaves a return value that is between 0 and 255 and that <code>0</code> is <code>false</code> and everything else is <code>true</code>. We can take advantage of the short-circuit feature as a compact branching devices, read <code>if-else</code> construct. This two scripts are semantically equivalent:</p>
<pre class="language-bash"><code class="language-bash"><span class="token shebang important">#!/usr/bin/env bash</span><br><span class="token builtin class-name">set</span> <span class="token parameter variable">-e</span><br><span class="token builtin class-name">set</span> <span class="token parameter variable">-u</span><br><span class="token builtin class-name">set</span> +x<br><br><span class="token builtin class-name">echo</span> <span class="token parameter variable">-n</span> <span class="token string">"Number: "</span><br><span class="token builtin class-name">read</span> n<br><br><span class="token keyword">if</span> <span class="token punctuation">[</span><span class="token punctuation">[</span> <span class="token variable">$n</span> <span class="token parameter variable">-lt</span> <span class="token number">42</span> <span class="token punctuation">]</span><span class="token punctuation">]</span><span class="token punctuation">;</span> <span class="token keyword">then</span><br> <span class="token builtin class-name">echo</span> <span class="token string">"Less than 42"</span><br><span class="token keyword">else</span><br> <span class="token builtin class-name">echo</span> <span class="token string">"Greater or equal to 42"</span><br><span class="token keyword">fi</span></code></pre>
<pre class="language-bash"><code class="language-bash"><span class="token shebang important">#!/usr/bin/env bash</span><br><span class="token builtin class-name">set</span> <span class="token parameter variable">-e</span><br><span class="token builtin class-name">set</span> <span class="token parameter variable">-u</span><br><span class="token builtin class-name">set</span> +x<br><br><span class="token builtin class-name">echo</span> <span class="token parameter variable">-n</span> <span class="token string">"Number: "</span><br><span class="token builtin class-name">read</span> n<br><br><span class="token punctuation">[</span><span class="token punctuation">[</span> <span class="token variable">$n</span> <span class="token parameter variable">-lt</span> <span class="token number">42</span> <span class="token punctuation">]</span><span class="token punctuation">]</span> <span class="token punctuation">\</span><br> <span class="token operator">&&</span> <span class="token builtin class-name">echo</span> <span class="token string">"Less than 42"</span> <span class="token punctuation">\</span><br> <span class="token operator">||</span> <span class="token builtin class-name">echo</span> <span class="token string">"Greater or equal to 42"</span></code></pre>
<p>FYI: a lot of dynamically-typed languages are able to pull out this kind of technique, one over all JavaScript.</p>
Linux Day 20182018-11-12T00:00:00Zhttps://ricma.co/posts/tech/linux/linux-day-2018/<figure class="left background"><img src="https://ricma.co/posts/tech/linux/linux-day-2018/linuxday2018.webp" alt="linuxday logo 2018"></figure>
<p>Even this year, together with some organizative difficulties, the <a href="http://www.linuxday.it">Linux
Day</a> time has come. As every past few years, I
was part of the staff team and I held some talk for the people coming
by.</p>
<p>This year the general theme was <em>World Wild Web</em>, so I thought of doing
some presentation of what HTTPS actually is and why we should always try
to use it and search for it. That small lock that appears on every
browser is really tiny, but it does a lot of protection work on our
behalf.</p>
<p>The usual local associations took their place in the event organization
and hosting.
<a href="http://www.linuxvar.it/">LinuxVar</a>,
<a href="http://lifolab.org">LIFO</a> laboratory and
<a href="http://www.gl-como.it/">GL-Como</a> LUG joined their forces to bring some
content to the partecipants. For the fourth year, the fair location was
the <a href="http://www.faberlab.org">FaberLab</a> room in Tradate.</p>
<p>Unfortunately, this year no showroom of pratical exibitions or workshops
was there, but there were six talks in the whole afternoon. So, not bad
actually.</p>
<h1>My own talk</h1>
<p>The presentation slides are of course in Italian and you can view them
below.</p>
<div class="pdf"><object type="application/pdf" data="https://ricma.co/files/linuxday/2018/s-in-https.pdf?#zoom=page-width&pagemode=none"><p>PDF file cannot be displayed!</p></object></div>
<p>You can also download the presentation slide, in <a href="https://ricma.co/files/linuxday/2018/s-in-https.odp">ODP</a> or in <a href="https://ricma.co/files/linuxday/2018/s-in-https.pdf">PDF
format</a>.</p>
<h1>Resources</h1>
<p>If you want to see some photos of the event, you can find them on
<a href="https://social.gl-como.it/photos/gl-como">GL-Como Friendica page</a>.</p>
<p>Also, further information are on the deciated LinuxVar <a href="https://www.linuxvar.it/linuxday-sabato-27-ottobre-2018/">page</a>.</p>
Introduction to Machine Learning2018-03-23T00:00:00Zhttps://ricma.co/posts/talks/intro-machine-learning/<figure class="background"><img src="https://ricma.co/posts/talks/intro-machine-learning/perceptron.webp" alt="perceptron diagram"></figure>
<p>As I stated in some article before, in the LUG I use to attend, we give
some talks to try to share as much knowledge as possible, over our
current interests.</p>
<p>I always try to join these events, because they offer me a unique
occasion to train my presentation skills and to write down some of the
concepts I am currently looking into.</p>
<p>In this time period, I just finished a university lecture over some
machine learning concepts. Not that I consider myself an expert in this
field, but I feel confident enough to explain the basics to completely
agnostic people.</p>
<p>So I dediced to give an introductory talk about this topic. The talk
night took place the 21<sup>st</sup> of March, 2018. The talk has been
recorded on video (more info later).</p>
<h1>Presentation</h1>
<p>The presentation slides are of course in Italian and you can view them
below.</p>
<div class="pdf"><object type="application/pdf" data="https://ricma.co/files/linuxvar/intro_machine_learning/intro_machine_learning.pdf?#zoom=page-width&pagemode=none"><p>PDF file cannot be displayed!</p></object></div>
<p>You can also download the presentation slide, in <a href="https://ricma.co/files/linuxvar/intro_machine_learning/intro_machine_learning.odp">ODP format</a>
or in <a href="https://ricma.co/files/linuxvar/intro_machine_learning/intro_machine_learning.pdf">PDF format</a>.</p>
<h1>Video</h1>
<p>The video recording of the night is available on YouTube, through the
<a href="https://www.youtube.com/channel/UCoYyCUclcvKVnvyfgla4I0g">LinuxVar
channel</a>. (I
know the caption title of the video is wrong, but the presentation is
the right one)</p>
<div class="youtube"><iframe src="https://www.youtube-nocookie.com/embed/ihQgyewHw9c" title="YouTube video player" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen=""></iframe></div>
<p>Of course, if you have any questions, you can write me using one of the
contact badges on the page aside.</p>
Battle for the Net Neutrality2017-11-23T00:00:00Zhttps://ricma.co/posts/tech/events/net-neutrality/<figure class="center"><img src="https://ricma.co/posts/tech/events/net-neutrality/net-neutrality.webp" alt="fight for the net neutrality banner"></figure>
<p>I know, I am European and this battle should not be my battle, but let's
analyze things from another point of view.</p><figure class="left"><img src="https://ricma.co/posts/tech/events/net-neutrality/net-neutrality-archer.webp" alt="fight for the net neutrality meme"></figure><p></p>
<p>Internet is objectively America-centered, U.S.A. invented the Internet
and, as such, a great, perceivable part of the internet is on the hands
of the States. For this reason, Europe should take position on Net
Neutrality matter, because even if it seems a very far concern, it is
not, it will affect our lives too, the lives of the people on the other
side of the ocean as well.</p><figure class="right"><img src="https://ricma.co/posts/tech/events/net-neutrality/net-neutrality-cat.webp" alt="fight for the net neutrality meme"></figure><p></p>
<p>As a fellow Internet user, wether you are a kid of the manager of a
multinational society, you <strong>have to</strong> take you position and defend the
medium you are using.</p>
<p>I am not usually a person who shouts in real life, and neither I am on
the internet, but for this time I will make an exception:</p>
<p><strong>SAVE THE INTERNET, DEFEND NETWORK NEUTRALITY, DO YOUR PART!</strong></p>
<p>Even if you don't have any influence power, you can still do you part,
informing yourself and other on the matter. Here are some link that can
get you started:</p>
<ul>
<li><a href="https://www.battleforthenet.com/">Battle for the Net</a></li>
<li><a href="https://www.fightforthefuture.org/">Fight for the Future</a></li>
</ul>
<p>You don't have time or you don't feel like reading something? Here are
some video content that can get you instantly informed on you last
chanche to save the Internet as you know it.</p>
<p>This one is only some seconds long, directly from Fight for the Future.</p>
<div class="youtube"><iframe src="https://www.youtube-nocookie.com/embed/LYq_k_1MS4I" title="YouTube video player" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen=""></iframe></div>
<p>This one, instead, is from the inventor of the World Wide Web, Sir <a href="https://en.wikipedia.org/wiki/Tim_Berners-Lee">Tim
Berners-Lee</a>.</p>
<div class="youtube"><iframe src="https://www.youtube-nocookie.com/embed/5Gh0NIQ3yd0" title="YouTube video player" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen=""></iframe></div>
Codemotion Milan 20172017-11-15T00:00:00Zhttps://ricma.co/posts/tech/events/codemotion-2017/<figure class="background"><img src="https://ricma.co/posts/tech/events/codemotion-2017/codemotion.webp" alt="codemotion logo"></figure>
<p>Last saturday, I had the oportunity to visit this famous event which
took place in Milan, in a new location called
<a href="https://milan2017.codemotionworld.com/location/">BASE</a>, 6000 sqm, that
was the old offices of the Ansaldo.</p>
<p>This is publicized as the "greatest technical conference of Europe,
regarding software development". And, in my poor experience, it
completely was. They programmed two days of conferences and two days of
workshops. I attended only the last day of conference.</p>
<p>There, more than a hundred talks took place and all leader in the market
companies were there, offering a job or simply selling their products.</p>
<p>Among this forest of advertisemente, there were also a lot of skilled
presenters who showed the most interesting and up to date novelties of
the technology word.</p>
<p>The passwords were <em>Faas</em>, that is <a href="https://en.wikipedia.org/wiki/Function_as_a_service">Function as a
service</a>,
<em>serverless</em>, <em>microservices</em> and <em>containers</em>. Some of the content
taught also parallell and distributed computing, big and realtime data
and, ultimately, the
<a href="https://mesosphere.com/blog/smack-stack-new-lamp-stack/">SMACK</a> stack.</p>
<p>The most interesting talk, in my opinion, was the one about
<a href="https://en.wikipedia.org/wiki/Cascading_Style_Sheets">CSS</a>. I always
hated CSS and it seemes like learning Arabic to me. This talk opened my
eyes on its powers and the ability to complete supersede some functions
of Javascript. This is very specific, but while I was listening to the
presenter, my mind blew up for the magic he was showing us.</p>
<p>The presenter was <a href="https://twitter.com/makhbeth?lang=en">Davide Di
Pumpo</a> and the
<a href="https://www.slideshare.net/DavideDiPumpo/quella-sporca-dozzina-a-cascata">presetation</a>
(in Italian) it is about twelve cheats in CSS.</p>
<p>If you want more information on the event, you can find them on their
<a href="https://milan2017.codemotionworld.com/">site</a>. Maybe next year we will
meet there.</p>
<p>And, finally, a photo of my old laptop (which is slowly becoming a
sticker plate).</p><figure class="center"><img src="https://ricma.co/posts/tech/events/codemotion-2017/codemotion-pc.webp" alt="old pc with codemotion logo"></figure><p></p>
Linux Day 20172017-10-28T00:00:00Zhttps://ricma.co/posts/tech/linux/linux-day-2017/<figure class="left background"><img src="https://ricma.co/posts/tech/linux/linux-day-2017/linuxday2017.webp" alt="linuxday logo 2017"></figure>
<p>The fourth saturady of october has come, which means it is time for
<a href="http://www.linuxday.it">Linux Day</a>. As always I and the group I am a
member of organized the edition for the area of Varese, Lombardy.</p>
<p>We gave force to the usual collaboration with other local associations,
such as us, that is
<a href="http://www.linuxvar.it">LinuxVar</a>,
<a href="http://lifolab.org">LIFO</a> laboratory and
<a href="http://www.gl-como.it/">GL-Como</a> LUG. For the third year the decision
on the location fell on the <a href="http://www.faberlab.org">FaberLab</a> of
Tradate, a place very apt to organize this types of events, and home of
DIY hobbyists who like to tinker with 3D printing.</p>
<p>As every year some talks and some exhibitions of various proofs of
concept took place. The morning being reserved to presentations
regarding topics close to the new generations, such as Internet
security, decentralized social network sites and the powers of computer
science and open source.</p>
<h1>Me</h1>
<p>This year I gave a simple talk about Instagram (and all other social
network sites) dangers. You can find more info about the presentation
<a href="https://ricma.co/posts/talks/instagram-instaprivacy">here</a>.</p>
<h1>Resources</h1>
<p>If you want to see some photos (mainly of the necks of the public) of
the event, you can find them on <a href="https://social.gl-como.it/photos/gl-como">GL-Como Friendica
page</a>.</p>
<p>The resources used for quite all talks are available on the <a href="https://www.linuxvar.it/linux-2017/">LinuxVar
site</a>.</p>
Instagram: #instaprivacy2017-10-28T00:00:00Zhttps://ricma.co/posts/talks/instagram-instaprivacy/<figure class="background"><img src="https://ricma.co/posts/talks/instagram-instaprivacy/instagram.webp" alt="instaprivacy talk logo"></figure>
<p>In occasion of the <a href="https://ricma.co/posts/tech/linux/linux-day-2017">Linux Day 2017</a>, edition of
the province of Varese, I had the opportunity to give a talk about
privacy. The presentation should have been centered on speaking to young
people.</p>
<p>Differently from previous years, I made something different, more
philosofical and much less practical.</p>
<p>My main theme was Instagram, which is the most used social network
platform by young people, but in any case I was eyeing every major
social network platform. The aim was informing young people about the
dangers of putting their whole life at everyones availability and
ultimately telling them how it is possible for everyone able to exploit
the information they donated <em>gratis</em> online and all this at their
expense.</p>
<h1>Presentation</h1>
<p>The presentation is in Italian and you can view it below.</p>
<div class="iframe"><iframe src="https://ricma.co/raw/instaprivacy/index.html#1"></iframe></div>
<p>You can also
<a href="https://ricma.co/files/linuxday/2017/instaprivacy/instaprivacy.zip">download</a> the
presentation or <a href="https://ricma.co/raw/instaprivacy/index.html">watch it fullscreen</a>.</p>
<p>Of course, if you have any questions, you can write me using one of the contact badges on the page aside.</p>
Stack Overflow network analysis2017-06-12T00:00:00Zhttps://ricma.co/posts/tech/projects/stack-overflow/<figure class="background"><img src="https://ricma.co/posts/tech/projects/stack-overflow/stack-overflow.webp" alt="stack overflow logo"></figure>
<p>As we all know, a programmer always needs help from another fellow
programmer or sometimes just wants to reach easily the best
implementation of an algorithm.</p>
<p>For this purpose, <a href="https://stackoverflow.com">Stack Overflow</a> has been
created.</p>
<p>Stack Overflow is part of the <a href="https://stackexchange.com/">Stack
Exchange</a> network and at the time of writing
it counts 7.3 milion users, with more than 14 milions question asked and
22m of answers given (<a href="https://stackexchange.com/sites?view=list#traffic">more
here</a>).</p>
<p>We present a simple ans standard analysis of the Stack Overflow
constructed as follows:</p>
<ul>
<li>every <strong>node</strong> is a <strong>user</strong>;</li>
<li>every <strong>edge</strong> answers to the question <em>has answered to</em>;</li>
<li>an optional <strong>weight</strong> has been given if a user has answered more
than once to another user (but it was not used during the analysis).</li>
</ul>
<p>Below, the notebook with the complete analysis:</p>
<div class="iframe"><iframe src="https://ricma.co/raw/stack-overflow/notebook.html"></iframe></div>
<p>You can download it <a href="https://ricma.co/raw/stack-overflow/notebook.html">here</a>.</p>
<p>A presentation of the result obtained can be viewed below (also [download it]
(/files/uni/stack-overflow/presentation.pdf)).</p>
<div class="pdf"><object type="application/pdf" data="https://ricma.co/files/uni/stack-overflow/presentation.pdf?#zoom=page-width&pagemode=none"><p>PDF file cannot be displayed!</p></object></div>
Git in pratica2017-02-16T00:00:00Zhttps://ricma.co/posts/talks/git-in-pratica/<figure class="background"><img src="https://ricma.co/posts/talks/git-in-pratica/git-in-pratica.webp" alt="git in pratica logo"></figure>
<p>I already presented on this blog <a href="https://git-scm.com/">git</a>, the SCM
(<strong>S</strong>oftware, <strong>C</strong>onfiguration, <strong>M</strong>anager) of choiche. Last time,
I made a simple introdutory tutorial on the system, showing its
potential, but I didn't dwell enough on the everyday use. I decided to
organize another talk in which all day use and commands were the center
of the conversation.</p>
<h1>Video recap</h1>
<p>This time, I chose to record myself talking, instead of only providing
presentation material. So, here it is, the video recap of the evening.</p>
<div class="youtube"><iframe src="https://www.youtube-nocookie.com/embed/h2t1opDnd38" title="YouTube video player" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen=""></iframe></div>
<h1>Presentation</h1>
<p>The presentation being shown in the video is provided below.</p>
<div class="iframe"><iframe src="https://ricma.co/raw/git-in-pratica/presentation.html#1"></iframe></div>
<p>Download the
<a href="https://ricma.co/files/linuxvar/git_in_pratica/git_in_pratica.zip">presentation</a> or
<a href="https://ricma.co/raw/git-in-pratica/presentation.html">watch it fullscreen</a>.</p>
<h1>Useful information</h1>
<p>The shell used during the video stream is the <a href="https://fishshell.com/">fish
shell</a>.</p>
<p>If you desire an informative prompt about the situation of the git
repository in the current directory, you have a couple of viable
options.</p>
<ul>
<li>Bash
<ul>
<li><a href="https://github.com/git/git/blob/master/contrib/completion/git-prompt.sh">git-prompt.sh</a></li>
<li><a href="https://github.com/magicmonty/bash-git-prompt">bash-git-prompt</a></li>
</ul>
</li>
<li>Zsh
<ul>
<li><a href="https://github.com/olivierverdier/zsh-git-prompt">zsh-git-prompt</a></li>
<li><a href="https://github.com/robbyrussell/oh-my-zsh">oh-my-zsh</a></li>
<li><a href="https://github.com/git/git/blob/master/contrib/completion/git-prompt.sh">git-prompt.sh</a></li>
</ul>
</li>
<li>Fish
<ul>
<li><a href="https://github.com/fish-shell/fish-shell/blob/master/share/functions/__fish_git_prompt.fish">__fish_git_prompt.fish</a></li>
<li><a href="https://github.com/oh-my-fish/oh-my-fish">oh-my-fish</a></li>
</ul>
</li>
</ul>
<p>If you want to have the alias <code>hist</code>, in order to use the command <code>git hist</code> as in the video, you should download the file
<a href="https://ricma.co/files/linuxvar/git_in_pratica/gitconfig">gitconfig</a> and copy it at
<code>$HOME/.gitconfig</code>.</p>
Linux Day 20162016-10-29T00:00:00Zhttps://ricma.co/posts/tech/linux/linux-day-2016/<figure class="left"><img src="https://ricma.co/posts/tech/linux/linux-day-2016/linuxday2016.webp" alt="linuxday logo 2016"></figure>
<p>In this period of the year, the time has come for the <a href="http://www.linuxday.it">Linux
Day</a> for the area of Varese, Lombardy. This
edition we, <a href="http://www.linuxvar.it4">LinuxVar</a>,
<a href="http://lifolab.org">LIFO</a> laboratory and
<a href="http://www.gl-como.it/">GL-Como</a> LUGs, have decided to make it take
place another time at the <a href="http://www.faberlab.org">FaberLab</a> of
Tradate, an interesting place where anyone can transform its ideas into
a 3D printed reality.</p>
<p>As usual, some talks, workshop and projects took place. This year we
decided that not only the school were to partecipate at this event, but
also they were to be part of the protagonists. So some talks on Arduino
by students for students were organized.</p>
<p>Further information can be found directly on the dedicated <a href="https://www.linuxvar.it/linuxday-2016/">LinuxDay 2016 page</a>
on the LinuxVar site.</p>
<h1>LinuxVar</h1>
<figure class="right background"><img src="https://ricma.co/posts/tech/linux/linux-day-2016/linuxvar-0x10.webp" alt="linuxvar 0x10 cake"></figure>
<p>This year was also the 16th anniversary of the informal foundation of the LinuxVar LUG and the 10th from the official
declaration.</p>
<h1>Me</h1>
<p>I, personally, choose to build up a workshop on the GIMP, the GNU Image
Manuplator Program. Further information on the can be found
<a href="https://www.gimp.org/">here</a>.</p>
<p>A more descrptive and detailed explanation of the workshop is available
at this <a href="https://ricma.co/posts/talks/intro-gimp">page</a>, complete
with slides used to show it.</p>
<p>Some photos of the event can be, instead, downloaded
<a href="https://ricma.co/files/linuxday/2016/photos.zip">here</a>, on my file server.</p>
Introduction to GIMP: GNU Image Manipulator Program2016-10-22T00:00:00Zhttps://ricma.co/posts/talks/intro-gimp/<figure class="left"><img src="https://ricma.co/posts/talks/intro-gimp/gimp.webp" alt="gimp logo"></figure>
<p>Sometimes you just have to resize an image. Sometimes you want to edit a
couple of images. Sometimes you have to do a complete overhaul of a ton
of images.</p>
<p>Now, let me tell you the routine you have to follow; <strong>have</strong> Windows™,
go to your favorite graphic editor, Adobe, website and buy or "buy" a
copy of your favourite image editor, Photoshop.</p>
<p>But, let's say that the PC you have at hand is not capable of Windows,
it could have Linux or, eventually, Mac OS X. Or say that you don't own
the necessary amount of gold coins to buy (and not "buy") the upsaid
software.</p>
<p>A simple, easy and straightforward solution is to search for another
program. An example is GIMP, and to be honest it is <strong>the</strong> example of a
libre/open source solution. It can work on Windows, Linux and Mac OS X
and can handle the majority of use cases of the upcited Photoshop.</p>
<p>For this purpose, I proposed a workshop where I show the basics of the
GIMP, divided in fived practical use cases.</p>
<div class="iframe"><iframe src="https://ricma.co/raw/intro-gimp/presentation.html#1"></iframe></div>
<p>You can also view the presentation fullscreen <a href="https://ricma.co/raw/intro-gimp/presentation.html">here</a>.</p>
<p>If you are interested, you can also download a
<a href="https://ricma.co/files/linuxday/2016/intro_gimp/introduzione_gimp.zip">zip</a> containing
presentation and examples.</p>
Install Apache Hadoop 2.7 (on *buntu 16.04)2016-09-27T00:00:00Zhttps://ricma.co/posts/tech/tutorials/hadoop-16/<figure class="background"><img src="https://ricma.co/posts/tech/tutorials/hadoop-16/hadoop.webp" alt="apache hadoop logo"></figure>
<p>If you are interested in Hadoop, read more
<a href="https://hadoop.apache.org">here</a>.</p>
<p>For this tutorial, I'll use a VM with <strong>Ubuntu Server 16.04</strong>, 64 bit
version, relying on <strong>VirtualBox 5.1.4</strong> for the virtualization.</p>
<p>The guest system setup is as follows:</p>
<ul>
<li>All 2 cores of my i5-6200U</li>
<li>4096 MB of RAM (although 1024 MB should be enough)</li>
<li>A dinamically allocated 10 GB VDI hard disk (5 GB are the least)</li>
<li>Ubuntu Server 16.04 x64 ISO file (but every *buntu flavour should
be ok)</li>
</ul>
<h1>Notes</h1>
<p>When you read a line like this:</p>
<pre class="language-bash"><code class="language-bash">jdoe@farlands ~ $ <span class="token builtin class-name">echo</span> <span class="token string">"Hello, world!"</span></code></pre>
<p>I imply a <code>bash</code> prompt <strong>without</strong> root priviledges, where <code>jdoe</code> is
the username and <code>farlands</code> is the hostname.</p>
<p>On the other hand, when the line is like this:</p>
<pre class="language-bash"><code class="language-bash">farlands % <span class="token builtin class-name">echo</span> <span class="token string">"Hello, world!"</span></code></pre>
<p>I imply a <code>bash</code> prompt <strong>with</strong> root priviledges</p>
<p>Ok, let's start: run the guest os installation with default values and
let's jump to hadoop headaches.</p>
<h1>Update the guest system</h1>
<p>Open up a terminal and fire this commands to update repositories and
upgrade the emulated system.</p>
<pre class="language-bash"><code class="language-bash">farlands % <span class="token function">apt</span> update<br>farlands % <span class="token function">apt</span> upgrade <span class="token parameter variable">-y</span></code></pre>
<h1>Java 8</h1>
<p>We're going to use a precompiled and prepackaged version of Oracle Java
8 in the <a href="http://www.webupd8.org">Webupd8</a> repo, to avoid further
difficulties.</p>
<p>Open up the usual terminal and input:</p>
<pre class="language-bash"><code class="language-bash">farlands % <span class="token function">apt</span> purge openjdk*<br>farlands % add-apt-repository <span class="token parameter variable">-y</span> ppa:webupd8team/java<br>farlands % <span class="token function">apt</span> update<br>farlands % <span class="token function">apt</span> <span class="token function">install</span> <span class="token parameter variable">-y</span> oracle-java8-installer</code></pre>
<p>You can verify Java version by typing:</p>
<pre class="language-bash"><code class="language-bash">farlands % <span class="token function">java</span> <span class="token parameter variable">-version</span><br><span class="token function">java</span> version <span class="token string">"1.8.0_60"</span><br>Java<span class="token punctuation">(</span>TM<span class="token punctuation">)</span> SE Runtime Environment <span class="token punctuation">(</span>build <span class="token number">1.8</span>.0_60-b27<span class="token punctuation">)</span><br>Java HotSpot<span class="token punctuation">(</span>TM<span class="token punctuation">)</span> <span class="token number">64</span>-Bit Server VM <span class="token punctuation">(</span>build <span class="token number">25.60</span>-b23, mixed mode<span class="token punctuation">)</span></code></pre>
<p>If you read a similar output, you completed this step.</p>
<p>Next, we need to create the JAVA_HOME environmental variable, to give
hadoop the capability to find java executables.</p>
<pre class="language-bash"><code class="language-bash">farlands % <span class="token builtin class-name">echo</span> <span class="token string">"export JAVA_HOME=/usr"</span> <span class="token operator">>></span> /etc/profile<br>farlands % <span class="token builtin class-name">source</span> /etc/profile</code></pre>
<h1>Disable IPv6</h1>
<p>Apache Hadoop supports only IPv4, so let's disable IPv6 in the kernel
parameters.</p>
<p>Open the file <code>/etc/sysctl.conf</code>:</p>
<pre class="language-bash"><code class="language-bash">farlands % editor /etc/sysctl.conf</code></pre>
<p>And append to the end:</p>
<pre class="language-sh"><code class="language-sh"><span class="token comment"># Disable IPv6</span><br>net.ipv6.conf.all.disable_ipv6 <span class="token operator">=</span> <span class="token number">1</span><br>net.ipv6.conf.default.disable_ipv6 <span class="token operator">=</span> <span class="token number">1</span><br>net.ipv6.conf.lo.disable_ipv6 <span class="token operator">=</span> <span class="token number">1</span></code></pre>
<p>Then reboot:</p>
<pre class="language-bash"><code class="language-bash">farlands % <span class="token function">reboot</span></code></pre>
<h1>Configure SSH keys</h1>
<p>We want to run our setup on a different general purpose user, so we will
create a <code>hadoopuser</code> user and a <code>hadoopgroup</code> group.</p>
<pre class="language-bash"><code class="language-bash">farlands % addgroup hadoopgroup<br>farlands % adduser <span class="token parameter variable">-ingroup</span> hadoopgroup hadoopuser</code></pre>
<p>We need ssh access to our machine, so let's install and start an OpenSSH
server.</p>
<pre class="language-bash"><code class="language-bash">farlands % <span class="token function">apt</span> <span class="token function">install</span> <span class="token function">ssh</span><br>farlands % systemctl <span class="token builtin class-name">enable</span> <span class="token function">ssh</span><br>farlands % systemctl start <span class="token function">ssh</span></code></pre>
<p>Now we need to setup passwordless ssh, by means of crypto keys. In first
place, we change to the <code>hadoopuser</code> account, then we create the key
using RSA encryption and finally we authorize the key for the current
user.</p>
<pre class="language-bash"><code class="language-bash">farlands % <span class="token function">su</span> - hadoopuser<br>hadoopuser@farlands ~ $ ssh-keygen <span class="token parameter variable">-t</span> rsa <span class="token parameter variable">-P</span> <span class="token string">""</span><br>hadoopuser@farlands ~ $ <span class="token function">cat</span> ~/.ssh/id_rsa.pub <span class="token operator">>></span> ~/.ssh/authorized_keys<br>hadoopuser@farlands ~ $ <span class="token function">chmod</span> <span class="token number">600</span> ~/.ssh/authorized_keys<br>hadoopuser@farlands ~ $ ssh-copy-id <span class="token parameter variable">-i</span> ~/.ssh/id_rsa.pub localhost<br>hadoopuser@farlands ~ $ <span class="token function">ssh</span> localhost</code></pre>
<p>If no password were asked on ssh login, you successfully configured
passwordless ssh for user <code>hadoopuser</code>.</p>
<h1>Install Hadoop</h1>
<p>We are ready to install Hadoop. Unfortunately, it does not come
prepackaged, but we have to extract and move it to <code>/usr/local</code>.</p>
<pre class="language-bash"><code class="language-bash">farlands % <span class="token function">wget</span> http://it.apache.contactlab.it/hadoop/common/hadoop-2.7.3/hadoop-2.7.3.tar.gz<br>farlands % <span class="token function">tar</span> xzf hadoop-2.7.3.tar.gz<br>farlands % <span class="token function">rm</span> <span class="token parameter variable">-rf</span> hadoop-2.7.3.tar.gz<br>farlands % <span class="token function">mv</span> hadoop-2.7.3 /usr/local<br>farlands % <span class="token function">ln</span> <span class="token parameter variable">-sf</span> /usr/local/hadoop-2.7.3/ /usr/local/hadoop<br>farlands % <span class="token function">chown</span> <span class="token parameter variable">-R</span> hadoopuser:hadoopgroup /usr/local/hadoop-2.7.3/</code></pre>
<p>Now we need to configure some environmental variables, with the
<code>hadoopuser</code> account. Switch to that account and edit <code>~/.bashrc</code>:</p>
<pre class="language-bash"><code class="language-bash">hadoopuser@farlands ~ $ editor ~/.bashrc</code></pre>
<p>Append at the end:</p>
<pre class="language-sh"><code class="language-sh"><span class="token comment"># Hadoop config</span><br><span class="token builtin class-name">export</span> <span class="token assign-left variable">HADOOP_PREFIX</span><span class="token operator">=</span>/usr/local/hadoop<br><span class="token builtin class-name">export</span> <span class="token assign-left variable">HADOOP_HOME</span><span class="token operator">=</span>/usr/local/hadoop<br><span class="token builtin class-name">export</span> <span class="token assign-left variable">HADOOP_MAPRED_HOME</span><span class="token operator">=</span><span class="token variable">${HADOOP_HOME}</span><br><span class="token builtin class-name">export</span> <span class="token assign-left variable">HADOOP_COMMON_HOME</span><span class="token operator">=</span><span class="token variable">${HADOOP_HOME}</span><br><span class="token builtin class-name">export</span> <span class="token assign-left variable">HADOOP_HDFS_HOME</span><span class="token operator">=</span><span class="token variable">${HADOOP_HOME}</span><br><span class="token builtin class-name">export</span> <span class="token assign-left variable">YARN_HOME</span><span class="token operator">=</span><span class="token variable">${HADOOP_HOME}</span><br><span class="token builtin class-name">export</span> <span class="token assign-left variable">HADOOP_CONF_DIR</span><span class="token operator">=</span><span class="token variable">${HADOOP_HOME}</span>/etc/hadoop<br><span class="token comment"># Native path</span><br><span class="token builtin class-name">export</span> <span class="token assign-left variable">HADOOP_COMMON_LIB_NATIVE_DIR</span><span class="token operator">=</span><span class="token variable">${HADOOP_PREFIX}</span>/lib/native<br><span class="token builtin class-name">export</span> <span class="token assign-left variable">HADOOP_OPTS</span><span class="token operator">=</span><span class="token string">"-Djava.library.path=<span class="token variable">$HADOOP_PREFIX</span>/lib/native"</span><br><span class="token comment"># Java path</span><br><span class="token builtin class-name">export</span> <span class="token assign-left variable">JAVA_HOME</span><span class="token operator">=</span><span class="token string">"/usr"</span><br><span class="token comment"># OS path</span><br><span class="token builtin class-name">export</span> <span class="token assign-left variable"><span class="token environment constant">PATH</span></span><span class="token operator">=</span><span class="token environment constant">$PATH</span><span class="token builtin class-name">:</span><span class="token variable">$HADOOP_HOME</span>/bin:<span class="token variable">$JAVA_PATH</span>/bin:<span class="token variable">$HADOOP_HOME</span>/sbin</code></pre>
<p>Next, source <code>~/.bashrc</code> to apply changes.</p>
<pre class="language-bash"><code class="language-bash">hadoopuser@farlands ~ $ <span class="token builtin class-name">source</span> ~/.bashrc</code></pre>
<p>Now we need to edit <code>/usr/local/hadoop/etc/hadoop/hadoop-env.sh</code>:</p>
<pre class="language-bash"><code class="language-bash">farlands % editor /usr/local/hadoop/etc/hadoop/hadoop-env.sh</code></pre>
<p>And add this at the end:</p>
<pre class="language-sh"><code class="language-sh"><span class="token builtin class-name">export</span> <span class="token assign-left variable">JAVA_HOME</span><span class="token operator">=</span><span class="token string">"/usr"</span></code></pre>
<h1>Configure Hadoop</h1>
<p>Hadoop configuration is quite hard, because it has a lot of config
files. We need to navigate to <code>/usr/local/hadoop/etc/hadoop</code> and edit
these files:</p>
<ul>
<li><code>core-site.xml</code></li>
<li><code>hdfs-site.xml</code></li>
<li><code>mapred-site.xml</code> (needs to be copied from
<code>mapred-site.xml.template</code>)</li>
<li><code>yarn-site.xml</code></li>
</ul>
<p>They all are XML files with a top-level <code><configuration></code> node. For
clarity we report the configuration node only.</p>
<h2><code>core-site.xml</code></h2>
<pre class="language-xml"><code class="language-xml"><span class="token tag"><span class="token tag"><span class="token punctuation"><</span>configuration</span><span class="token punctuation">></span></span><br><span class="token tag"><span class="token tag"><span class="token punctuation"><</span>property</span><span class="token punctuation">></span></span><br> <span class="token tag"><span class="token tag"><span class="token punctuation"><</span>name</span><span class="token punctuation">></span></span>fs.default.name<span class="token tag"><span class="token tag"><span class="token punctuation"></</span>name</span><span class="token punctuation">></span></span><br> <span class="token tag"><span class="token tag"><span class="token punctuation"><</span>value</span><span class="token punctuation">></span></span>hdfs://localhost:9000<span class="token tag"><span class="token tag"><span class="token punctuation"></</span>value</span><span class="token punctuation">></span></span><br><span class="token tag"><span class="token tag"><span class="token punctuation"></</span>property</span><span class="token punctuation">></span></span><br><span class="token tag"><span class="token tag"><span class="token punctuation"></</span>configuration</span><span class="token punctuation">></span></span></code></pre>
<h2><code>hdfs-site.xml</code></h2>
<pre class="language-xml"><code class="language-xml"><span class="token tag"><span class="token tag"><span class="token punctuation"><</span>configuration</span><span class="token punctuation">></span></span><br><span class="token tag"><span class="token tag"><span class="token punctuation"><</span>property</span><span class="token punctuation">></span></span><br> <span class="token tag"><span class="token tag"><span class="token punctuation"><</span>name</span><span class="token punctuation">></span></span>dfs.replication<span class="token tag"><span class="token tag"><span class="token punctuation"></</span>name</span><span class="token punctuation">></span></span><br> <span class="token tag"><span class="token tag"><span class="token punctuation"><</span>value</span><span class="token punctuation">></span></span>1<span class="token tag"><span class="token tag"><span class="token punctuation"></</span>value</span><span class="token punctuation">></span></span><br><span class="token tag"><span class="token tag"><span class="token punctuation"></</span>property</span><span class="token punctuation">></span></span><br><br><span class="token tag"><span class="token tag"><span class="token punctuation"><</span>property</span><span class="token punctuation">></span></span><br> <span class="token tag"><span class="token tag"><span class="token punctuation"><</span>name</span><span class="token punctuation">></span></span>dfs.name.dir<span class="token tag"><span class="token tag"><span class="token punctuation"></</span>name</span><span class="token punctuation">></span></span><br> <span class="token tag"><span class="token tag"><span class="token punctuation"><</span>value</span><span class="token punctuation">></span></span>file:/usr/local/hadoop/hadoopdata/hdfs/namenode<span class="token tag"><span class="token tag"><span class="token punctuation"></</span>value</span><span class="token punctuation">></span></span><br><span class="token tag"><span class="token tag"><span class="token punctuation"></</span>property</span><span class="token punctuation">></span></span><br><br><span class="token tag"><span class="token tag"><span class="token punctuation"><</span>property</span><span class="token punctuation">></span></span><br> <span class="token tag"><span class="token tag"><span class="token punctuation"><</span>name</span><span class="token punctuation">></span></span>dfs.data.dir<span class="token tag"><span class="token tag"><span class="token punctuation"></</span>name</span><span class="token punctuation">></span></span><br> <span class="token tag"><span class="token tag"><span class="token punctuation"><</span>value</span><span class="token punctuation">></span></span>file:/usr/local/hadoop/hadoopdata/hdfs/datanode<span class="token tag"><span class="token tag"><span class="token punctuation"></</span>value</span><span class="token punctuation">></span></span><br><span class="token tag"><span class="token tag"><span class="token punctuation"></</span>property</span><span class="token punctuation">></span></span><br><span class="token tag"><span class="token tag"><span class="token punctuation"></</span>configuration</span><span class="token punctuation">></span></span></code></pre>
<h2><code>mapred-site.xml</code></h2>
<pre class="language-xml"><code class="language-xml"><span class="token tag"><span class="token tag"><span class="token punctuation"><</span>configuration</span><span class="token punctuation">></span></span><br> <span class="token tag"><span class="token tag"><span class="token punctuation"><</span>property</span><span class="token punctuation">></span></span><br> <span class="token tag"><span class="token tag"><span class="token punctuation"><</span>name</span><span class="token punctuation">></span></span>mapreduce.framework.name<span class="token tag"><span class="token tag"><span class="token punctuation"></</span>name</span><span class="token punctuation">></span></span><br> <span class="token tag"><span class="token tag"><span class="token punctuation"><</span>value</span><span class="token punctuation">></span></span>yarn<span class="token tag"><span class="token tag"><span class="token punctuation"></</span>value</span><span class="token punctuation">></span></span><br> <span class="token tag"><span class="token tag"><span class="token punctuation"></</span>property</span><span class="token punctuation">></span></span><br><span class="token tag"><span class="token tag"><span class="token punctuation"></</span>configuration</span><span class="token punctuation">></span></span></code></pre>
<h2><code>yarn-site.xml</code></h2>
<pre class="language-xml"><code class="language-xml"><span class="token tag"><span class="token tag"><span class="token punctuation"><</span>configuration</span><span class="token punctuation">></span></span><br> <span class="token tag"><span class="token tag"><span class="token punctuation"><</span>property</span><span class="token punctuation">></span></span><br> <span class="token tag"><span class="token tag"><span class="token punctuation"><</span>name</span><span class="token punctuation">></span></span>yarn.nodemanager.aux-services<span class="token tag"><span class="token tag"><span class="token punctuation"></</span>name</span><span class="token punctuation">></span></span><br> <span class="token tag"><span class="token tag"><span class="token punctuation"><</span>value</span><span class="token punctuation">></span></span>mapreduce_shuffle<span class="token tag"><span class="token tag"><span class="token punctuation"></</span>value</span><span class="token punctuation">></span></span><br> <span class="token tag"><span class="token tag"><span class="token punctuation"></</span>property</span><span class="token punctuation">></span></span><br><span class="token tag"><span class="token tag"><span class="token punctuation"></</span>configuration</span><span class="token punctuation">></span></span></code></pre>
<h2>Format namenode</h2>
<p>Next, we need to format the namenode filesystem with the following
command:</p>
<pre class="language-bash"><code class="language-bash">hadoopuser@farlands ~ $ hdf namenode <span class="token parameter variable">-format</span></code></pre>
<p>Search the output: if you can read a string like this:</p>
<pre class="language-sh"><code class="language-sh">INFO common.Storage: Storage directory /usr/local/hadoop/hadoopdata/hdfs/namenode has been successfully formatted.</code></pre>
<p>It's done.</p>
<h1>Start and stop services</h1>
<p>Now, the last thing to do is starting Hadoop services:</p>
<pre class="language-bash"><code class="language-bash">hadoopuser@farlands ~ $ start-dfs.sh<br>hadoopuser@farlands ~ $ start-yarn.sh</code></pre>
<p>To check the status of the services use the <code>jps</code> command:</p>
<pre class="language-bash"><code class="language-bash">hadoopuser@farlands ~ $ jps<br><span class="token number">26899</span> Jps<br><span class="token number">26216</span> SecondaryNameNode<br><span class="token number">25912</span> NameNode<br><span class="token number">26041</span> DataNode<br><span class="token number">26378</span> ResourceManager<br><span class="token number">26494</span> NodeManager</code></pre>
<p>To stop services, these are the commands:</p>
<pre class="language-bash"><code class="language-bash">hadoopuser@farlands ~ $ stop-dfs.sh<br>hadoopuser@farlands ~ $ stop-yarn.sh</code></pre>
<p>Congratulations, you made it!</p>
Introduction to Android programming2016-09-22T00:00:00Zhttps://ricma.co/posts/talks/intro-android/<figure class="right"><img src="https://ricma.co/posts/talks/intro-android/android.webp" alt="android logo"></figure>
<p>A recently but estabilished new entry into the computer and technology
world is mobile computing.</p>
<p>Having calculum resources, together with internet access and a plethora
of software to use at hand is not only comfortable, but is becoming more
and more essential to our everyday life.</p>
<p>The two major platform that have spread in this latest year are Apple's
iOS and Google's Android. Being a Linux enthusiast, for me Android is
the way to go.</p>
<p>Together with using this system I learned through the years to make some
little and useful nice applications, or better called "apps". Since I
learned the lesson "mobile programming is radically different from
traditional programming", I decided to give a small talk to help whoever
wanted to approach this world.</p>
<p>For the sake of completeness I put together three really simple, but
extremely useful in the real case examples.</p>
<div class="iframe"><iframe src="https://ricma.co/raw/intro-android/presentation.html#1"></iframe></div>
<p>You can also view the talk fullscreen <a href="https://ricma.co/raw/intro-android/presentation.html">here</a>.</p>
<p>If you are interested you can also download a
<a href="https://ricma.co/files/linuxvar/intro_android/introduzione_android.zip">zip</a> containing the full presentation.</p>
Introduction to Python 32016-06-01T00:00:00Zhttps://ricma.co/posts/talks/intro-python/<figure class="left"><img src="https://ricma.co/posts/talks/intro-python/python.webp" alt="python 3 logo"></figure>
<p>A language that is increasingly becoming more and more famous and prominent, both as a scripting language and a scientifical tool, is <a href="https://www.python.org/">Python</a>.</p>
<p>Python lets newcomers accomodate really quickly and easily. Discover it yourself!</p>
<p>During this talk, I'll provide a small introduction to basic concepts to become a real <em>pythonista</em>.</p>
<hr>
<div class="iframe"><iframe src="https://ricma.co/raw/intro-python/presentation.html#1"></iframe></div>
<p>You can also watch the presentation fullscren <a href="https://ricma.co/raw/intro-python/presentation.html">here</a>.</p>
<p>If you are interested you can download a <a href="https://ricma.co/files/linuxvar/intro_python/introduzione_python.zip">zip</a> containing the full presentation.</p>
Linux Presentation Day 20162016-05-01T00:00:00Zhttps://ricma.co/posts/tech/linux/linux-presentation-day-2016/<figure class="right background"><img src="https://ricma.co/posts/tech/linux/linux-presentation-day-2016/lpd-2016.webp" alt="linux presentation day logo 2016"></figure>
<p>A new (but not so revolutionary) event is born in Europe to advertise
the use of Linux and the concept of Open Source and Free Software: the
Linux Presentation Day. All European nations estabilished a day, the
30th of April, to organize some propaganda for the famouse operative
system, I like the most.</p>
<p>My LUG, <a href="http://linuxvar.it/">LinuxVar</a>, has decided to take an active
part in this day, but in its own classic style.We decided to spend this
day in a school, teaching to the students the power of open systems. We
chose the <a href="http://www.isiskeynes.it/">I.S.I.S Keynes</a> in <a href="http://www.openstreetmap.org/#map=19/45.77349/8.82783&layers=N">Gazzada
Schianno</a>,
Varese.</p>
<p>A group decided to present an acitivity based on
<a href="http://appinventor.mit.edu/explore/">AppInventor</a>, an MIT software
which allows to develop Android applications in a
<a href="https://scratch.mit.edu/">Scratch</a> fashion, dealing with visual blocks
for coding.</p>
<p>Me and my friend decided to give an introductory talk about Internet
traffic sniffing, so we presented principal Linux networking tools
together with <code>nmap</code> and Wireshark. My friend centered his attention on
a presentation over firewalls tassonomy and firewalls tasks.</p>
<div class="pdf"><object type="application/pdf" data="https://ricma.co/files/linuxday/2016p/analisi-rete.pdf?#zoom=page-width&pagemode=none"><p>PDF file cannot be displayed!</p></object></div>
<p>A copy of the presentation on traffic sniffing is available to download
<a href="https://ricma.co/files/linuxday/2016p/analisi-rete.pdf">here</a>.</p>
Young People and SNSs2015-10-26T00:00:00Zhttps://ricma.co/posts/talks/young-people-and-snss/<p>In an Internet reality populated by real
<a href="https://en.wikipedia.org/wiki/Virtuality_(philosophy)">virtualities</a>,
in which young people is completely absorbed in everyday life too, it is
becoming more and more fundamental to discuss and understand how young
people (13-20) use these new technologies and how much understand of
their possible dangers.</p>
<p>I ideated a small questionnaire to gather some data about what personal
informations are usually provided to social network sites by young
people and how they interact with this huge amount of data.</p>
<p>The questionnaire was aired on October 24, 2015 at the <a href="http://linuxvar.it/content/linux-day-2015">Linux Day 2015 of Varese</a> in the <a href="http://www.istitutosantelia.gov.it">ISISS Antonio Sant'Elia</a>, an Italian high school, featuring the students as questionee.</p>
<p>I took the opportunity and displayed the results in a small
presentation, where in the last slides I talked about Facebook T.O.S.
(<strong>T</strong>erms <strong>o</strong>f <strong>S</strong>ervice) as an example of social network site
licence agreement.</p>
<div class="iframe"><iframe src="https://ricma.co/raw/young-people-and-snss#1"></iframe></div>
<p>You cand view the presentation fullscreen <a href="https://ricma.co/raw/young-people-and-snss">here</a> or download it right <a href="https://ricma.co/files/linuxday/2015/questionario.zip">here</a>.</p>
<p>This, instead, is a chart of the results:</p>
<figure class="center"><img src="https://ricma.co/posts/talks/young-people-and-snss/questionnaire.webp" alt="questionnary aggregations displayed as image"></figure>Linux Day 20152015-10-23T00:00:00Zhttps://ricma.co/posts/tech/linux/linux-day-2015/<figure class="left background"><img src="https://ricma.co/posts/tech/linux/linux-day-2015/linuxday2015.webp" alt="linuxday logo 2015"></figure>
<p>This year the <a href="https://www.linuxvar.it/linux-2015/">LUG I usually
attend</a> and another
neighbour LUG, <a href="http://www.gl-como.it/v2015/linux-day-2015/">GL-Como</a>,
organized the 2015 edition of the <a href="http://www.linuxday.it">Linux Day</a> at
the <a href="http://www.istitutosantelia.gov.it">ISISS Sant'Elia</a> in Cantù, near
Como.</p>
<p>We organized some talks and workshops, together with a questionnaire to
make students see and try what the Linux and the open source communty
is.</p>
<p>I helped with the <a href="http://www.arduino.cc">Arduino</a> workshop and
completely designed the questionnaire about "<em>young people and the
Internet</em>", which the student have answered on an
<a href="http://www.ltsp.org">LTSP</a> (refer <a href="https://ricma.co/posts/talks/ltsp">here</a>
to some LTSP slides) post in a Linux adapted laboratory.</p>
<p>Furter and detailed information about presented questionnaire can be
viewed <a href="https://ricma.co/posts/talks/young-people-and-snss">here</a>.</p>
<p>Some photos are to be admired <a href="https://ricma.co/files/linuxday/2015/photos.zip">here</a> or
<a href="https://www.linuxvar.it/linux-2015/">here</a>.</p>
Install Apache Hadoop 2.7 (on *buntu 14.04)2015-10-20T00:00:00Zhttps://ricma.co/posts/tech/tutorials/hadoop-15/<figure class="background"><img src="https://ricma.co/posts/tech/tutorials/hadoop-15/hadoop.webp" alt="apache hadoop logo"></figure>
<p>If you are interested in Hadoop, read more
<a href="https://hadoop.apache.org">here</a>.</p>
<p>For this tutorial, I'll use a VM with <strong>Linux Mint 17.2 XFCE</strong>, 64 bit
version, relying on <strong>VirtualBox 5.0.6</strong> for the virtualization. (Just
to mention it, I'm running Windows 10, 64 bit, because my Arch
installation is currently broken)</p>
<p>The guest system setup is as follows:</p>
<ul>
<li>All 4 cores of my i7-4770k (but minimum is 2)</li>
<li>5120 MB of RAM (although 1024 MB should be enough)</li>
<li>A dinamically allocated 15 GB VDI hard disk (5 GB are the least)</li>
<li>Linux Mint 17.2 x64 DVD (but every *buntu flavour should be ok)</li>
</ul>
<h1>Notes</h1>
<p>When you read a line like this:</p>
<pre class="language-bash"><code class="language-bash">jdoe@farlands ~ $ <span class="token builtin class-name">echo</span> <span class="token string">"Hello, world!"</span></code></pre>
<p>I imply a <code>bash</code> prompt <strong>without</strong> root priviledges, where <code>jdoe</code> is
the username and <code>farlands</code> is the hostname.</p>
<p>On the other hand, when the line is like this:</p>
<pre class="language-bash"><code class="language-bash">farlands % <span class="token builtin class-name">echo</span> <span class="token string">"Hello, world!"</span></code></pre>
<p>I imply a <code>bash</code> prompt <strong>with</strong> root priviledges</p>
<p>Ok, let's start: run the guest os installation with default values and
let's jump to hadoop headaches.</p>
<h1>Update the guest system</h1>
<p>Open up a terminal and fire this commands to update repositories and
upgrade the emulated system.</p>
<pre class="language-bash"><code class="language-bash">farlands % <span class="token function">apt</span> update<br>farlands % <span class="token function">apt</span> upgrade <span class="token parameter variable">-y</span></code></pre>
<h1>Java 8</h1>
<p>We're going to use a precompiled and prepackaged version of Oracle Java
8 in the <a href="http://www.webupd8.org">Webupd8</a> repo, to avoid further
difficulties.</p>
<p>Open up the usual terminal and input:</p>
<pre class="language-bash"><code class="language-bash">farlands % <span class="token function">apt</span> purge openjdk*<br>farlands % add-apt-repository <span class="token parameter variable">-y</span> ppa:webupd8team/java<br>farlands % <span class="token function">apt</span> update<br>farlands % <span class="token function">apt</span> <span class="token function">install</span> <span class="token parameter variable">-y</span> oracle-java8-installer</code></pre>
<p>You can verify Java version by typing:</p>
<pre class="language-bash"><code class="language-bash">farlands % <span class="token function">java</span> <span class="token parameter variable">-version</span><br><span class="token function">java</span> version <span class="token string">"1.8.0_60"</span><br>Java<span class="token punctuation">(</span>TM<span class="token punctuation">)</span> SE Runtime Environment <span class="token punctuation">(</span>build <span class="token number">1.8</span>.0_60-b27<span class="token punctuation">)</span><br>Java HotSpot<span class="token punctuation">(</span>TM<span class="token punctuation">)</span> <span class="token number">64</span>-Bit Server VM <span class="token punctuation">(</span>build <span class="token number">25.60</span>-b23, mixed mode<span class="token punctuation">)</span></code></pre>
<p>If you read a similar output, you completed this step.</p>
<p>Next, we need to create the JAVA_HOME environmental variable, to give
hadoop the capability to find java executables.</p>
<pre class="language-bash"><code class="language-bash">farlands % <span class="token builtin class-name">echo</span> <span class="token string">"export JAVA_HOME=/usr"</span> <span class="token operator">>></span> /etc/profile<br>farlands % <span class="token builtin class-name">source</span> /etc/profile</code></pre>
<h1>Disable IPv6</h1>
<p>Apache Hadoop supports only IPv4, so let's disable IPv6 in the kernel
parameters.</p>
<p>Open the file <code>/etc/sysctl.conf</code>:</p>
<pre class="language-bash"><code class="language-bash">farlands % editor /etc/sysctl.conf</code></pre>
<p>And append to the end:</p>
<pre class="language-sh"><code class="language-sh"><span class="token comment"># Disable IPv6</span><br>net.ipv6.conf.all.disable_ipv6 <span class="token operator">=</span> <span class="token number">1</span><br>net.ipv6.conf.default.disable_ipv6 <span class="token operator">=</span> <span class="token number">1</span><br>net.ipv6.conf.lo.disable_ipv6 <span class="token operator">=</span> <span class="token number">1</span></code></pre>
<h1>Configure SSH keys</h1>
<p>We want to run our setup on a different general purpose user, so we will
create a <code>hadoopuser</code> user and a <code>hadoopgroup</code> group.</p>
<pre class="language-bash"><code class="language-bash">farlands % addgroup hadoopgroup<br>farlands % adduser <span class="token parameter variable">-ingroup</span> hadoopgroup hadoopuser</code></pre>
<p>We need ssh access to our machine, so let's install and start an OpenSSH
server.</p>
<pre class="language-bash"><code class="language-bash">farlands % <span class="token function">apt</span> <span class="token function">install</span> openssh-server<br>farlands % <span class="token function">service</span> <span class="token function">ssh</span> start<br>farlands % update-rc.d <span class="token function">ssh</span> defaults</code></pre>
<p>Now we need to setup passwordless ssh, by means of crypto keys. In first
place, we change to the <code>hadoopuser</code> account, then we create the key
using RSA encryption and finally we authorize the key for the current
user.</p>
<pre class="language-bash"><code class="language-bash">farlands % <span class="token function">su</span> - hadoopuser<br>hadoopuser@farlands ~ $ ssh-keygen <span class="token parameter variable">-t</span> rsa <span class="token parameter variable">-P</span> <span class="token string">""</span><br>hadoopuser@farlands ~ $ <span class="token function">cat</span> ~/.ssh/id_rsa.pub <span class="token operator">>></span> ~/.ssh/authorized_keys<br>hadoopuser@farlands ~ $ <span class="token function">chmod</span> <span class="token number">600</span> ~/.ssh/authorized_keys<br>hadoopuser@farlands ~ $ ssh-copy-id <span class="token parameter variable">-i</span> ~/.ssh/id_rsa.pub localhost<br>hadoopuser@farlands ~ $ <span class="token function">ssh</span> localhost</code></pre>
<p>If no password were asked on ssh login, you successfully configured
passwordless ssh for user <code>hadoopuser</code>.</p>
<h1>Install Hadoop</h1>
<p>We are ready to install Hadoop. Unfortunately, it does not come
prepackaged, but we have to extract and move it to <code>/usr/local</code>.</p>
<pre class="language-bash"><code class="language-bash">farlands % <span class="token function">wget</span> http://mirrors.muzzy.it/apache/hadoop/common/hadoop-2.7.1/hadoop-2.7.1.tar.gz<br>farlands % <span class="token function">tar</span> xzf hadoop-2.7.1.tar.gz<br>farlands % <span class="token function">rm</span> <span class="token parameter variable">-rf</span> hadoop-2.7.1.tar.gz<br>farlands % <span class="token function">mv</span> hadoop-2.7.1 /usr/local<br>farlands % <span class="token function">ln</span> <span class="token parameter variable">-sf</span> /usr/local/hadoop-2.7.1/ /usr/local/hadoop<br>farlands % <span class="token function">chown</span> <span class="token parameter variable">-R</span> hadoopuser:hadoopgroup /usr/local/hadoop-2.7.1/</code></pre>
<p>Now we need to configure some environmental variables, with the
<code>hadoopuser</code> account. Switch to that account and edit <code>~/.bashrc</code>:</p>
<pre class="language-bash"><code class="language-bash">hadoopuser@farlands ~ $ editor ~/.bashrc</code></pre>
<p>Append at the end:</p>
<pre class="language-sh"><code class="language-sh"><span class="token comment"># Hadoop config</span><br><span class="token builtin class-name">export</span> <span class="token assign-left variable">HADOOP_PREFIX</span><span class="token operator">=</span>/usr/local/hadoop<br><span class="token builtin class-name">export</span> <span class="token assign-left variable">HADOOP_HOME</span><span class="token operator">=</span>/usr/local/hadoop<br><span class="token builtin class-name">export</span> <span class="token assign-left variable">HADOOP_MAPRED_HOME</span><span class="token operator">=</span><span class="token variable">${HADOOP_HOME}</span><br><span class="token builtin class-name">export</span> <span class="token assign-left variable">HADOOP_COMMON_HOME</span><span class="token operator">=</span><span class="token variable">${HADOOP_HOME}</span><br><span class="token builtin class-name">export</span> <span class="token assign-left variable">HADOOP_HDFS_HOME</span><span class="token operator">=</span><span class="token variable">${HADOOP_HOME}</span><br><span class="token builtin class-name">export</span> <span class="token assign-left variable">YARN_HOME</span><span class="token operator">=</span><span class="token variable">${HADOOP_HOME}</span><br><span class="token builtin class-name">export</span> <span class="token assign-left variable">HADOOP_CONF_DIR</span><span class="token operator">=</span><span class="token variable">${HADOOP_HOME}</span>/etc/hadoop<br><span class="token comment"># Native path</span><br><span class="token builtin class-name">export</span> <span class="token assign-left variable">HADOOP_COMMON_LIB_NATIVE_DIR</span><span class="token operator">=</span><span class="token variable">${HADOOP_PREFIX}</span>/lib/native<br><span class="token builtin class-name">export</span> <span class="token assign-left variable">HADOOP_OPTS</span><span class="token operator">=</span><span class="token string">"-Djava.library.path=<span class="token variable">$HADOOP_PREFIX</span>/lib/native"</span><br><span class="token comment"># Java path</span><br><span class="token builtin class-name">export</span> <span class="token assign-left variable">JAVA_HOME</span><span class="token operator">=</span><span class="token string">"/usr"</span><br><span class="token comment"># OS path</span><br><span class="token builtin class-name">export</span> <span class="token assign-left variable"><span class="token environment constant">PATH</span></span><span class="token operator">=</span><span class="token environment constant">$PATH</span><span class="token builtin class-name">:</span><span class="token variable">$HADOOP_HOME</span>/bin:<span class="token variable">$JAVA_PATH</span>/bin:<span class="token variable">$HADOOP_HOME</span>/sbin</code></pre>
<p>Next, source <code>~/.bashrc</code> to apply changes.</p>
<pre class="language-bash"><code class="language-bash">hadoopuser@farlands ~ $ <span class="token builtin class-name">source</span> ~/.bashrc</code></pre>
<p>Now we need to edit <code>/usr/local/hadoop/etc/hadoop/hadoop-env.sh</code>:</p>
<pre class="language-bash"><code class="language-bash">farlands % editor /usr/local/hadoop/etc/hadoop/hadoop-env.sh</code></pre>
<p>And add this at the end:</p>
<pre class="language-sh"><code class="language-sh"><span class="token builtin class-name">export</span> <span class="token assign-left variable">JAVA_HOME</span><span class="token operator">=</span><span class="token string">"/usr"</span></code></pre>
<h1>Configure Hadoop</h1>
<p>Hadoop configuration is quite hard, because it has a lot of config
files. We need to navigate to <code>/usr/local/hadoop/etc/hadoop</code> and edit
these files:</p>
<ul>
<li><code>core-site.xml</code></li>
<li><code>hdfs-site.xml</code></li>
<li><code>mapred-site.xml</code> (needs to be copied from
<code>mapred-site.xml.template</code>)</li>
<li><code>yarn-site.xml</code></li>
</ul>
<p>They all are XML files with a top-level <code><configuration></code> node. For
clarity we report the configuration node only.</p>
<h2><code>core-site.xml</code></h2>
<pre class="language-xml"><code class="language-xml"><span class="token tag"><span class="token tag"><span class="token punctuation"><</span>configuration</span><span class="token punctuation">></span></span><br><span class="token tag"><span class="token tag"><span class="token punctuation"><</span>property</span><span class="token punctuation">></span></span><br> <span class="token tag"><span class="token tag"><span class="token punctuation"><</span>name</span><span class="token punctuation">></span></span>fs.default.name<span class="token tag"><span class="token tag"><span class="token punctuation"></</span>name</span><span class="token punctuation">></span></span><br> <span class="token tag"><span class="token tag"><span class="token punctuation"><</span>value</span><span class="token punctuation">></span></span>hdfs://localhost:9000<span class="token tag"><span class="token tag"><span class="token punctuation"></</span>value</span><span class="token punctuation">></span></span><br><span class="token tag"><span class="token tag"><span class="token punctuation"></</span>property</span><span class="token punctuation">></span></span><br><span class="token tag"><span class="token tag"><span class="token punctuation"></</span>configuration</span><span class="token punctuation">></span></span></code></pre>
<h2><code>hdfs-site.xml</code></h2>
<pre class="language-xml"><code class="language-xml"><span class="token tag"><span class="token tag"><span class="token punctuation"><</span>configuration</span><span class="token punctuation">></span></span><br><span class="token tag"><span class="token tag"><span class="token punctuation"><</span>property</span><span class="token punctuation">></span></span><br> <span class="token tag"><span class="token tag"><span class="token punctuation"><</span>name</span><span class="token punctuation">></span></span>dfs.replication<span class="token tag"><span class="token tag"><span class="token punctuation"></</span>name</span><span class="token punctuation">></span></span><br> <span class="token tag"><span class="token tag"><span class="token punctuation"><</span>value</span><span class="token punctuation">></span></span>1<span class="token tag"><span class="token tag"><span class="token punctuation"></</span>value</span><span class="token punctuation">></span></span><br><span class="token tag"><span class="token tag"><span class="token punctuation"></</span>property</span><span class="token punctuation">></span></span><br><br><span class="token tag"><span class="token tag"><span class="token punctuation"><</span>property</span><span class="token punctuation">></span></span><br> <span class="token tag"><span class="token tag"><span class="token punctuation"><</span>name</span><span class="token punctuation">></span></span>dfs.name.dir<span class="token tag"><span class="token tag"><span class="token punctuation"></</span>name</span><span class="token punctuation">></span></span><br> <span class="token tag"><span class="token tag"><span class="token punctuation"><</span>value</span><span class="token punctuation">></span></span>file:/usr/local/hadoop/hadoopdata/hdfs/namenode<span class="token tag"><span class="token tag"><span class="token punctuation"></</span>value</span><span class="token punctuation">></span></span><br><span class="token tag"><span class="token tag"><span class="token punctuation"></</span>property</span><span class="token punctuation">></span></span><br><br><span class="token tag"><span class="token tag"><span class="token punctuation"><</span>property</span><span class="token punctuation">></span></span><br> <span class="token tag"><span class="token tag"><span class="token punctuation"><</span>name</span><span class="token punctuation">></span></span>dfs.data.dir<span class="token tag"><span class="token tag"><span class="token punctuation"></</span>name</span><span class="token punctuation">></span></span><br> <span class="token tag"><span class="token tag"><span class="token punctuation"><</span>value</span><span class="token punctuation">></span></span>file:/usr/local/hadoop/hadoopdata/hdfs/datanode<span class="token tag"><span class="token tag"><span class="token punctuation"></</span>value</span><span class="token punctuation">></span></span><br><span class="token tag"><span class="token tag"><span class="token punctuation"></</span>property</span><span class="token punctuation">></span></span><br><span class="token tag"><span class="token tag"><span class="token punctuation"></</span>configuration</span><span class="token punctuation">></span></span></code></pre>
<h2><code>mapred-site.xml</code></h2>
<pre class="language-xml"><code class="language-xml"><span class="token tag"><span class="token tag"><span class="token punctuation"><</span>configuration</span><span class="token punctuation">></span></span><br> <span class="token tag"><span class="token tag"><span class="token punctuation"><</span>property</span><span class="token punctuation">></span></span><br> <span class="token tag"><span class="token tag"><span class="token punctuation"><</span>name</span><span class="token punctuation">></span></span>mapreduce.framework.name<span class="token tag"><span class="token tag"><span class="token punctuation"></</span>name</span><span class="token punctuation">></span></span><br> <span class="token tag"><span class="token tag"><span class="token punctuation"><</span>value</span><span class="token punctuation">></span></span>yarn<span class="token tag"><span class="token tag"><span class="token punctuation"></</span>value</span><span class="token punctuation">></span></span><br> <span class="token tag"><span class="token tag"><span class="token punctuation"></</span>property</span><span class="token punctuation">></span></span><br><span class="token tag"><span class="token tag"><span class="token punctuation"></</span>configuration</span><span class="token punctuation">></span></span></code></pre>
<h2><code>yarn-site.xml</code></h2>
<pre class="language-xml"><code class="language-xml"><span class="token tag"><span class="token tag"><span class="token punctuation"><</span>configuration</span><span class="token punctuation">></span></span><br> <span class="token tag"><span class="token tag"><span class="token punctuation"><</span>property</span><span class="token punctuation">></span></span><br> <span class="token tag"><span class="token tag"><span class="token punctuation"><</span>name</span><span class="token punctuation">></span></span>yarn.nodemanager.aux-services<span class="token tag"><span class="token tag"><span class="token punctuation"></</span>name</span><span class="token punctuation">></span></span><br> <span class="token tag"><span class="token tag"><span class="token punctuation"><</span>value</span><span class="token punctuation">></span></span>mapreduce_shuffle<span class="token tag"><span class="token tag"><span class="token punctuation"></</span>value</span><span class="token punctuation">></span></span><br> <span class="token tag"><span class="token tag"><span class="token punctuation"></</span>property</span><span class="token punctuation">></span></span><br><span class="token tag"><span class="token tag"><span class="token punctuation"></</span>configuration</span><span class="token punctuation">></span></span></code></pre>
<h2>Format namenode</h2>
<p>Next, we need to format the namenode filesystem with the following
command:</p>
<pre class="language-bash"><code class="language-bash">hadoopuser@farlands ~ $ hdfs namenode <span class="token parameter variable">-format</span></code></pre>
<p>Search the output: if you can read a string like this:</p>
<pre class="language-sh"><code class="language-sh">INFO common.Storage: Storage directory /usr/local/hadoop/hadoopdata/hdfs/namenode has been successfully formatted.</code></pre>
<p>It's done.</p>
<h1>Start and stop services</h1>
<p>Now, the last thing to do is starting Hadoop services:</p>
<pre class="language-bash"><code class="language-bash">hadoopuser@farlands ~ $ start-dfs.sh<br>hadoopuser@farlands ~ $ start-yarn.sh</code></pre>
<p>To check the status of the services use the <code>jps</code> command:</p>
<pre class="language-bash"><code class="language-bash">hadoopuser@farlands ~ $ jps<br><span class="token number">26899</span> Jps<br><span class="token number">26216</span> SecondaryNameNode<br><span class="token number">25912</span> NameNode<br><span class="token number">26041</span> DataNode<br><span class="token number">26378</span> ResourceManager<br><span class="token number">26494</span> NodeManager</code></pre>
<p>To stop services, these are the commands:</p>
<pre class="language-bash"><code class="language-bash">hadoopuser@farlands ~ $ stop-dfs.sh<br>hadoopuser@farlands ~ $ stop-yarn.sh</code></pre>
<p>Congratulations, you made it!</p>
Simple scene render in Blender2015-09-25T00:00:00Zhttps://ricma.co/posts/tech/projects/blender/<figure class="right"><img src="https://ricma.co/posts/tech/projects/blender/blender.webp" alt="blender logo"></figure>
<p>Blender is a 3D modeling tool which became famouse after its supporting
foundation, the <a href="http://www.blender.org/foundation/">Blender
Foundation</a>, produced some really
neat <a href="http://archive.blender.org/features-gallery/movies/index.html">3D animated
movies</a>,
the most famous being <a href="http://www.bigbuckbunny.org">Big Buck Bunny</a>.</p>
<p>Originally it shipped with a very imprecise renderer, with no basis on
physical laws and really, really inefficient. For this matter, it was
seen more as a toy, than a wannabe professional tool.</p>
<p>Then the Cycles engine appeared and all changed. It was the first open
source implmentation of a path tracer, ready to be modified to one's
needs. Some companies saw its potential and backed the project with
founds. Now the project is getting bigger and bigger and it is starting
to be used in a professional environment. The bidirectional path tracer
and the montecarlo extension are under development, so news are to be
expected.</p>
<p>I made a little test render, with an Egyptian scene, to provide a sample
of Cycles rendering engine powers. Here are the results (I know I am not
very good at it, but I'm still learning).</p>
<figure class="center"><img src="https://ricma.co/posts/tech/projects/blender/blender-render1.webp" alt="first render"></figure>
<figure class="center"><img src="https://ricma.co/posts/tech/projects/blender/blender-render2.webp" alt="second render"></figure>
<p>You can download the full resolution version of the
<a href="https://ricma.co/files/uni/blender/render-hi-1.webp">first</a> and
<a href="https://ricma.co/files/uni/blender/render-hi-2.webp">second</a> image, to use it as
wallpaper or anything you like, but caution, every image is 8 MB and I
serve the site on a slow connection...</p>
<p>My PC is only equipped with CPU rendering and, with a quality of 50 rays
for pixel, render has completed in about 3 hours and 20 minutes. If you
think you can do better here it is the <a href="https://ricma.co/files/uni/blender/project.tar.gz">blend
file</a>.</p>
La Nuit Derniére a Parìs2015-09-20T00:00:00Zhttps://ricma.co/posts/movies/la-nuit-derniere-a-paris/<p>As my last exam for the Digital Communication degree I chose to produce
a short film inspired by the work "<em>Nighthakws</em>", by <a href="https://en.wikipedia.org/wiki/Edward_Hopper">Edward
Hopper</a>.</p>
<p>If you want to know more about Hopper's work check out <a href="https://www.artsy.net/artist/edward-hopper">his
page</a> on
<a href="https://www.artsy.net/about">Artsy</a>, a promising online art gallery.</p><figure class="center"><img src="https://ricma.co/posts/movies/la-nuit-derniere-a-paris/nighthawks.webp" alt="nighthawks painting"></figure><p></p>
<p>The story is about two mafia bosses (one being a female) and a cop
protagonist who struggles to arrest them. In this journey, he will score
some triumphs and suffer some defeats.</p>
<p>If you're interested,
<a href="https://ricma.co/files/uni/la-nuit-derniere-a-paris/la-nuit-derniere-a-paris_script.pdf">here</a>
a copy of the script may be downloaded.</p>
<p>What remains to be said? Let's watch it.</p>
<div class="youtube"><iframe src="https://www.youtube-nocookie.com/embed/3djXnzmdaAU" title="YouTube video player" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen=""></iframe></div>
A codec evaluation test2015-09-17T00:00:00Zhttps://ricma.co/posts/tech/projects/codec-evaluation/<p>In 2015, we have reached a time where several efficient codecs for video compressing are available. Every one of them has its peculiarities as well as its drawbacks. Some it is more advanced than the other, such as in the case of H.265 and some belongs to a omnipresent past standard, which unfortunately is still much used: MPEG-2.</p>
<p>I elaborated a small comparison from the point of view of perceived quality. I chose to evaluate subjective quality, because it is what is sensed by users. An objective, sterile evaluation would have not given the same significant results.</p>
<p>I chose eight codecs, such as:</p>
<ul>
<li>MPEG-2</li>
<li>H.264</li>
<li>H.265</li>
<li>VP8</li>
<li>VP9</li>
<li>Theora</li>
<li>ProRes 422</li>
<li>Dirac</li>
</ul>
<p>To accomplish the example raw video compressione, I used the open source tool <a href="http://ffmpeg.org">ffmpeg</a>. I produced two versions of compression: one optimized for standard quality and one which provides high quality.</p>
<p>Uncompressed test scenes are at a size of 1920x1080 pixels, with a framerate of 50 Hz. They are to be found on the <a href="ftp://vqeg.its.bldrdoc.gov/HDTV/SVT_MultiFormat/1080p50_CgrLevels_SINC_FILTER_SVTdec05_/">VQEG FTP</a>, provided by the <a href="http://www.its.bldrdoc.gov/vqeg/vqeg-home.aspx">VQEG</a>.</p>
<div class="pdf"><object type="application/pdf" data="https://ricma.co/files/uni/codec-evaluation/codec_evaluation-results.pdf?#zoom=page-width&pagemode=none"><p>PDF file cannot be displayed!</p></object></div>
<p>Download the full article containing details and results of the evaluation <a href="https://ricma.co/files/uni/codec-evaluation/codec_evaluation-results.pdf">here</a>.</p>
Introduction to Git2015-05-18T00:00:00Zhttps://ricma.co/posts/talks/git-introduction/<figure class="center"><img src="https://ricma.co/posts/talks/git-introduction/git.webp" alt="git cvs logo"></figure>
<p>Git, THE content versioning system. Now it is a standard tool in the
swiss army knife of every programmer in the world, worthy of this name.
To the few, who are relatively new to programming and use other
inefficient systems to share and catalogue their code, it is essential
to fill the gap in their toolset.</p>
<p>Here I provided a (very) basic introduction to start using this
wonderful, essential tool.</p>
<p>For the sake of opennes both a <a href="https://ricma.co/files/linuxvar/intro_git/introduzione_git.odp">ODP
file</a> and <a href="https://ricma.co/files/linuxvar/intro_git/introduzione_git.pdf">PDF
file</a> is available.</p>
<div class="pdf"><object type="application/pdf" data="https://ricma.co/files/linuxvar/intro_git/introduzione_git.pdf?#zoom=page-width&pagemode=none"><p>PDF file cannot be displayed!</p></object></div>Trust & Self-disclosure in online interactions (focusing on young people)2015-05-02T00:00:00Zhttps://ricma.co/posts/talks/trust-self-disclosure/<p>By Riccardo Macoratti and Stanislao Vezzosi</p>
<h1>Bibliography</h1>
<ul>
<li>Bryce, J. and Fraser, J. (2013) "<em>The role of disclosure of personal information in the evaluation of risk and trust in young peoples' online interactions</em>", Computers in Human Behavior, 30(2014): 299-306.</li>
<li>Bryce, J. and Klang, M. (2009) "<em>Young people, disclosure of personal information and online privacy: Control, choice and consequences</em>", Information security technical report, 14(2009): 160–166.</li>
<li>Taddei, S. and Contena, B. (2012) "<em>Privacy, trust and control: Which relationships with online self-disclosure?</em>", Computers in Human Behavior, 29(2013): 821–826.</li>
</ul>
<h1>Sitography</h1>
<ul>
<li>Wikipedia, <a href="https://en.wikipedia.org/wiki/Trust_%28social_sciences%29">Trust (social sciences)</a></li>
<li>Wiktionary, <a href="https://en.wiktionary.org/wiki/trust">Trust</a></li>
</ul>
<h1>Slides</h1>
<p>Slides are made with <a href="https://prezi.com/">Prezi</a>, but PDF files are provided below the presentation.</p>
<h2>Introduction</h2>
<div class="iframe"><iframe src="https://prezi.com/embed/xno44xarjdce/?bgcolor=ffffff&lock_to_path=1&autoplay=0&autohide_ctrls=0#"></iframe></div>
<p><a href="https://ricma.co/files/uni/trust-self-disclosure/trust-self_disclosure-introduzione.pdf">Download</a></p>
<h2>Young people</h2>
<div class="iframe"><iframe src="https://prezi.com/embed/udsvkw2f68qb/?bgcolor=ffffff&lock_to_path=1&autoplay=0&autohide_ctrls=0#"></iframe></div>
<p><a href="https://ricma.co/files/uni/trust-self-disclosure/trust-self_disclosure-giovani.pdf">Download</a></p>
<h1>Questionary</h1>
<p>A summary for our questionary "<strong>Do computer science students trust SNSs?</strong>" is available as <a href="https://ricma.co/files/uni/trust-self-disclosure/trust_in_sns_questionary.pdf">PDF</a>.</p>
<div class="pdf"><object type="application/pdf" data="https://ricma.co/files/uni/trust-self-disclosure/trust_in_sns_questionary.pdf?#zoom=page-width&pagemode=none"><p>PDF file cannot be displayed!</p></object></div>
How do I used to run this site?2015-04-22T00:00:00Zhttps://ricma.co/posts/tech/server/<blockquote>
<p>Note that now the site is served through <a href="https://www.netlify.com/">Netlify</a>.
I am still concerned about privacy, but my connection is not so stable connection anymore, so...</p>
</blockquote>
<figure class="left"><img src="https://ricma.co/posts/tech/server/rpi3.webp" alt="raspberry pi 3 photo"></figure>
<p>I have never been a fan of giving away all my informations and
personally produced content to a service provider I don't completely
know and trust. I had a bad experience, when my virtual server provider
deleted all my files without my consent or any prior warning and,
remembering that, I actually prefer to handle my own data by myself.</p>
<p>In order to do that, I need some sort of association from an hostname to
my ISP provided dynamic IP. So I bought the domain you are seing on top,
mainly because its provider offered a dynamic DNS service included.
Before that, I used a third level free dynamic DNS service provided by
the <a href="http://linuxvar.it/content/dynamic-dns">LUG</a> (Linux User Group) I
attend.</p>
<p>Alas the Internet connection in my country isn't that great, but I,
personally speaking, cannot complain at all. I have an asymetric DSL
12 / 0.8 Mbps, quite enough for offering simple services such as HTTP and
git. I connect to the Internet by means of a cheap router that supports
high speed ethernet and a WLAN.</p>
<p>But the real star of this page is the server phisically providing this
service, a <a href="https://www.raspberrypi.org/products/raspberry-pi-3-model-b/">Raspberry
Pi 3</a>,
produced by <a href="https://www.raspberrypi.org/">Raspberry Foundation</a>. It is
an embedded, single board, but modestly high powered computer, backed by
an <a href="https://en.wikipedia.org/wiki/ARM_architecture#ARMv8-A">ARMv8</a>
processor and 1 GB of RAM, running my beloved <a href="https://www.archlinux.org/">Arch
Linux</a>, ARM version.</p>
<h1>Software</h1>
<figure class="right background"><img src="https://ricma.co/posts/tech/server/nginx.webp" alt="nginx logo"></figure>
<p>I chose <a href="https://www.nginx.com/">nginx</a> as web server, because it is
very light in terms of used resources and easy to configure, although I
currently don't use any server side scripting engine, like PHP or
Python. I plan to set up some Python FCGI in order to provide some small
services.</p>
<p>The site is, therefore, static, but not completely handwritten. As
stated in the footer at the bottom of every page, this site is generated
with the excellent static content generator
<a href="http://getpelican.com/">Pelican</a>.</p>
<blockquote>
<p>Ehm... Update, the site has now been ported to <a href="https://gohugo.io">Hugo</a>.</p>
</blockquote>
<blockquote>
<p>Uhm... Second update, the site has now been ported again to <a href="https://www.11ty.dev">Eleventy</a>.</p>
</blockquote>
Some short films2015-04-18T00:00:00Zhttps://ricma.co/posts/movies/short-films/<p>Ok, I know, I know... My directing, editing and producing ability is not at its finest, although I'm learning.
It is not my field, though, so I do not expect to improve much.</p>
<p>I had to realize two clips for a university exam.</p>
<p>One using the stop motion technique:</p>
<div class="youtube"><iframe src="https://www.youtube-nocookie.com/embed/AKndch7vk-E" title="YouTube video player" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen=""></iframe></div>
<p>And one using a chroma key footage:</p>
<div class="youtube"><iframe src="https://www.youtube-nocookie.com/embed/nhOYaf9BSEU" title="YouTube video player" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen=""></iframe></div>
<p>Quite amatorial, right? Well, it's a start.</p>
Wicd and Eduroam @ UNIMI2014-12-20T00:00:00Zhttps://ricma.co/posts/tech/tutorials/wicd-eduroam/<p><a href="http://wicd.sourceforge.net/">Wicd</a> is an awesome network configuration
manager: no clutter, small footprint and very, very simple (in the
UNIX/KISS way).</p>
<p>The only problem has come when I had to connect to my university
network, powered by
<a href="http://www.servizi.garr.it/index.php/it/eduroam">Eduroam</a>.</p>
<p>My institute has chosen to use WPA2 Enterprise with PEAP/MSCHAPV2
encryption.</p>
<p>To be able to connect with Wicd a configuration file, under path
<code>/etc/wicd/encryption/templates</code> shall be provided.</p>
<p>Go to that path and create a file (as root) named <code>eduroam-unimi</code> with
this content:</p>
<pre class="language-sh"><code class="language-sh"><span class="token assign-left variable">name</span><span class="token operator">=</span>Eduroam<br><span class="token assign-left variable">author</span><span class="token operator">=</span>Riccardo Macoratti<br><span class="token assign-left variable">version</span><span class="token operator">=</span><span class="token number">1.1</span><br>require identity *Name password *Pass<br>protected password *Pass<br>-----<br><span class="token assign-left variable">ctrl_interface</span><span class="token operator">=</span>/var/run/wpa_supplicant<br><span class="token assign-left variable">network</span><span class="token operator">=</span><span class="token punctuation">{</span><br> <span class="token assign-left variable">ssid</span><span class="token operator">=</span><span class="token string">"<span class="token variable">$_ESSID</span>"</span><br> <span class="token assign-left variable">scan_ssid</span><span class="token operator">=</span><span class="token variable">$_SCAN</span><br> <span class="token assign-left variable">key_mgmt</span><span class="token operator">=</span>WPA-EAP<br> <span class="token assign-left variable">eap</span><span class="token operator">=</span>PEAP<br> <span class="token assign-left variable">identity</span><span class="token operator">=</span><span class="token string">"<span class="token variable">$_IDENTITY</span>@studenti.unimi.it"</span><br> <span class="token assign-left variable">password</span><span class="token operator">=</span><span class="token string">"<span class="token variable">$_PASSWORD</span>"</span><br> <span class="token assign-left variable">phase1</span><span class="token operator">=</span><span class="token string">"peaplabel=0"</span><br> <span class="token assign-left variable">phase2</span><span class="token operator">=</span><span class="token string">"auth=MSCHAPV2"</span><br><span class="token punctuation">}</span></code></pre>
<p>Then open a console and give the command:</p>
<pre class="language-bash"><code class="language-bash">$ <span class="token builtin class-name">echo</span> <span class="token string">"eduroam-unimi"</span> <span class="token operator">>></span> /etc/wicd/encryption/templates/active</code></pre>
<p>Finally open wicd-client, highlight the connection and press
<em>Properties</em>. Select "Use encryption" and from the box select "Eduroam".
Insert username in the form <code>name.surname</code> and your webmail password.
Press <em>OK</em> and then <em>Connect</em>.</p>
<p>Enjoy the Internet!</p>
Linux Day 20142014-10-30T00:00:00Zhttps://ricma.co/posts/tech/linux/linux-day-2014/<figure class="left background"><img src="https://ricma.co/posts/tech/linux/linux-day-2014/linuxday2014.webp" alt="linuxday logo 2014"></figure>
<p>This year too (2014) a <a href="http://www.linuxday.it">Linux Day</a> edition for
the Varese area has been organized by the
<a href="https://www.linuxvar.it/linuxday-sabato-25-ottobre-2014/">LinuxVar</a> and
<a href="http://www.gl-como.it/">GL-Como</a> LUG and the <a href="http://lifolab.org">LIFO</a>
laboratory at the <a href="http://www.faberlab.org">FaberLab</a> of Tradate, an
interesting place where you can build up your ideas, make 3D and
ceramics printings and find someone who will teach you all these
goodies.</p>
<p>As usual, some talks, workshop and projects took place. But this year
there has been quite a substancial difference with respect to past
editions, because for the first time the fair will be targeted
exclusively to students.</p>
<h1>Me</h1>
<p>Personally I showed <a href="http://www.ltsp.org">LTSP</a>, a server-thin client
system for schools and organizations computer laboratories. We provided
a small lab-like structure with three posts and an LTSP server.</p>
<p>A more descrptive and detailed explanation of this system is present at
this <a href="https://ricma.co/posts/talks/ltsp">page</a>, complete with
slides used to show it.</p>
<p>Some photos of the event can be, instead, downloaded
<a href="https://ricma.co/files/linuxday/2014/photos.zip">here</a>, on my file server.</p>
LTSP: Linux Terminal Server Project2014-10-30T00:00:00Zhttps://ricma.co/posts/talks/ltsp/<figure class="background"><img src="https://ricma.co/posts/talks/ltsp/ltsp.webp" alt="ltsp logo"></figure>
<p><a href="http://www.ltsp.org/">LTSP</a> is a server-client technology built in order to fulfill the computing needs of small officies and educational environments.</p>
<p>The typical system is a dedicated network in which the server is a powerful elaborator and the clients (known as <strong>thin clients</strong>) are computers without rotative parts, such as a hard disk, with only a motherboard, a small amount RAM, a very modest CPU, GPU and I/O peripherals (monitor, keyboard and mouse).</p>
<p>The server provides computation power, network connection and a complete operative system, while clients only draw the graphics and handle I/O.</p>
<p>I made a quick and simple presentation of LTSP features, with a stress on how to build a LTSP system easily.</p>
<div class="pdf"><object type="application/pdf" data="https://ricma.co/files/linuxday/2014/ltsp.pdf?#zoom=page-width&pagemode=none"><p>PDF file cannot be displayed!</p></object></div>
<p>Slides can be downloaded <a href="https://ricma.co/files/linuxday/2014/ltsp.pdf">here</a> in PDF format and <a href="https://ricma.co/files/linuxday/2014/ltsp.odp">here</a> in ODP format.</p>