Giovanni Bricconi

My site on WordPress.com

La mia esperienza con lo SPID e la carta d’identità elettronica

leave a comment »

Vivere all’estero comporta non poche complicazioni, specialmente quando bisogna avere a che fare con la pubblica amministrazione. Quando ho dovuto rinnovare la carta d’identità al consolato, e mi hanno spiegato dello SPID, e la cosa mi ha fatto molto piacere.

Molto tempo fa, una decina di anni, avevo cercato di ottenere un codice di accesso al sito dell’INPS e mi ricordo che era stato molto complicato, e che avevo dovuto aspettare una lettera inviata per posta. Avevo ricevuto un estratto conto dei versamenti pensionistici e mi mancava un anno di contributi. Chiaramente non è una cosa urgente da sistemare, visto tutto il tempo che mi manca prima della pensione, ma prima o poi avrei dovuto perderci del tempo. Avevo anche mandato una raccomandata con della documentazione, ma non avevo mai ricevuto una risposta.

Ovviamente dopo tutto questo tempo il vecchio codice é andato perso, e lo SPID mi ha dato una speranza di riuscire a sistemare la cosa, senza dovermi presentare fisicamente in uno sportello in Italia.

Finalmente in ferie, ho trovato un’oretta di tempo per occuparmi della questione, e tentare almeno di fare il login sul sito dell’INPS. Cercando su google ho trovato un articolo di Aranzulla: come ottenere le credenziali SPID. L’ho letto sommariamente una sera, e l’unica cosa che mi ricordavo é che poste italiane ha una app che permette di ottenere lo SPID facilmente.

Bene quindi tentativo numero uno, cercare su appstore l’applicazione PosteID e provare a usarla. Ho cercato nei documenti della carta d’identità elettronica ed ho recuperato la prima e la seconda metà del pin della carta. La prima metà mi era stata data al consolato, la seconda è arrivata per posta con la carta stessa.

Va bene la sicurezza, ma se mi davate il codice in una volta sola, alla domanda, visto che tanto senza carta non ci fai nulla, forse sarebbe stato un po’ più semplice. Comunque, con carta e codici in mano provo a usare PosteID.

Una breve spiegazione descrive cosa fare, basta fare un paio di scelte e ci si ritrova ad inserire il pin della carta e provare a leggerne il contenuto appoggiandola al telefono. Tutto semplice no? Invece errore di lettura della carta, senza altre spiegazioni. Sarà che la mia carta è stata rilasciata all’estero e avrà qualche cosa particolare, in qualche campo? Non è dato saperlo… ho fatto qualche altro tentativo sperando di non avere bloccato la carta, almeno con il PIN ti danno anche il PUK.

Ovviamente avendo dimenticato tutto quello che Salvatore Aranzulla diceva nel suo articolo, ho iniziato a cercare in google ed ho trovato una pagina con una lunga lista di fornitori di identità SPID, se quello delle poste non va bene per me magari qualche altro mi avrebbe potuto aiutare: la lista si trova su come scegliere tra i gestori di identità digitale.

Ho iniziato a scaricare applicazioni sul telefono, ArubaOTP, poi SielteSPID e SielteID.

Prima ho provato con Aruba, ma non ho capito come fare con la carta di identità elettronica, e non ho un lettore di carte per il mio pc… quindi ho lasciato stare.

Nella lista di fornitori c’era banca intesa, ho provato a vedere cosa proponevano, ma non voglio pagare e voglio usare la carta di identità elettronica, dopo una o due pagine ho lasciato perdere.

Dalla lista o provato a vedere qualche fornitore meno noto, ho scelto a caso Sielte, e provato a registrarmi. La procedura è un po’ complicata, e ti si chiede di marcare come letto alcuni documenti di cui uno di 96 pagine vabbè. Tutto andava abbastanza bene sino a quando mi chiedono di inserire una foto non solo della carta di identità ma anche della tessera sanitaria. Per un residente in Italia non è un problema, ma io non ho più una tessera sanitaria perché risiedo all’estero. Ho lasciato perdere.

Stavo per provare Namiral, è su una loro pagina ho finalmente letto che la zecca dello stato ha una applicazione che si chiama CieID, apposta per la carta di identità elettronica. Proviamo.

Wow, la spiegazione era super chiara, ci sono addirittura immagini che spiegano come mettere la carta di identità e dove appoggiare il telefono, e consigli su come tenere fermo il telefono. Inserisco il pin e… questa volta viene letta correttamente! Tutto questo mi ha preso almeno un ora. Ho spento tutto ed oggi ho provato ad accedere al sito dell’INPS.

Incredibile ma vero, sono riuscito a entrare sul sito, perché accanto all’icona dello SPID c’era anche quella della carta di identità elettronica, e quindi ho potuto usare l’app della Zecca. Ancora più incredibile, ora nel mio estratto conto ci sono tutti i versamenti, anche quelli che mancavano; oggi è proprio una giornata fortunata!

Bene, i comuni non possono fare questo servizio di identità, perché fanno già molti servizi. Si è quindi creato tutto un ecosistema privato di fornitori di accesso, ma non è per nulla semplice scegliere quello giusto. Per fortuna c’è rimasta la Zecca di Stato, un grazie incredibile a voi!

Ora mi tocca solo aspettare il 2047 per andare in pensione

Written by Giovanni

August 27, 2022 at 12:55 pm

Posted in Varie

My new friend: the electricity counter

leave a comment »

Let me introduce my new friend, the electricity counter:

My electricity counter

The green block on the upper-left, here in France, is called Linky. Its display is just 2 text lines, quite synthetics, but I have found them useful. There is a lot of bla bla about the contract, but pushing and pushing the buttons it has finally shown something interesting.

It is capable of displaying the instantaneous power consumption and the maximum power provided within a period. It’s not clear how long the time period is, but it has been a piece of valuable information. Are you wondering why?

I just searched on the internet for electricity prices and I have found a table like this on the site https://electricite.net/edf/tarifs

Puissance
souscrite
Abonnement annuel TTC
3 kVA103.49€
6 kVA136.12€
9 kVA169.89€
12 kVA204.03€

The second column gives you the price that you have to pay yearly to have a certain amount of power available to you. If you exceed that level, the green box will cut the electricity… an unpleasant experience.

When I arrived here I have been provided a 12kVA subscription, bit I was quite convinced it was an excessive one; the green box has given me the confirmation. My maximum power consumption is far below 12kVA, and I have managed to save some money stepping to 9kVA. I need some more checks but I am pretty sure I don’t need more than 6kVA, so I can save about 70 euros per year. I am very happy to have spent some time looking at my green friend. For reference, in Italy nearly everybody has 3.5kVA, but they cook using gas…

The third column gives the price by kWh used, and here you get super easily lost in marketing traps. Every company provides its way to compute the rate, and some are very complicated. I have been suggested to chose a rate wich makes you pay different prices during the night and the weekend. I had to take some bills and do some calculations with open office, but I realized that:

1 I am not disciplined enough to use a lot of electricity during the night

2 I have to pay a special subscription to have time-based rates, and I spend more than what I save

It may seem complicated, but if you resist to the temptation of finding the more economical rate on the market, and you just analyze 2/3 mainstream offers, you will be able to check your subscription too in just a couple of hours.

I said above that my green friend also show the instantaneous power consumption. When I was playing with it was a weekend, and at home there was nothing special switched-on. No air conditioning, nothing cooking, no oven, no dishwasher…. an the box was telling me: you are using 2300W. What??? With nothing turned on!!

You can see in the picture that the electric cabinet is filled with switches, each of them excludes something: the problem is that it is not at all clear what it does exclude, and there are no indications on the switches.

I started playing with the switches until I have found one that tuned off about 1800W consumption. I did not have idea at all of what I had turned off, it has taken a day to discover it. This in the end what I have found after some experiments:

The water boiler has not been wired correctly: it should be on a specific circuit, working only during the night. In my house it was running randomly all the day, making my electricity consumption explode.

The cooking plate is consuming 200W just for being connected to the electricity, even if it is turned off! Just turning off its switch made me save the equivalent of 2 old very bright bulbs working all the day.

The air conditioning, like the cooking plate, consumes also if it is turned off… so during spring and autumn there is no need to keep it connected, and its switch can be turned off.

I was quite bored of experimenting and there is not so much I can do to save more electricity, so that is enough for me. I won’t do more experiments but the time spent was definitively worth it.

Written by Giovanni

August 18, 2022 at 1:35 pm

Posted in Varie

Rainy days

leave a comment »

Today it has finally rained, it was a long time since it didn’t happen. Just some minutes, not so much, some thunders, but it is good it finally happened. Some weeks ago I have got a letter from the local water supply company: it is now forbidden to irrigate gardens and grasses. You can irrigate just orchards and vegetable gardens.

My grass is all dead and many plants started dying, it is really a pity seeing all the garden becoming yellow and brown. Mine is not that big, I give water just to strawberries, my 2 cherry trees, and the olive.

It is summer, it is always a bit like this, the strange thing was that also during the spring I had to start irrigating the garden. I feel this very strange: I come from a rainy place, and giving water in winter or spring is really weird for me. This is the reason I started reading more about climate change: it is real, and I can see it clearly in my backyard.

I have found this site: Observation météorologique historiques France (SYNOP). It gives many data about the weather in France, where I live. I did not play much with it online, I just dared download the full historical archive with the plan of playing a bit with it later.

It has been a mistake, as the file is huge and my time is little, and I don’t have at home the right tools. In the end I just checked the nearest place next to my home and extracted the data of 2022, 2017, and 2012. A couple of awk and grep commands to get Nice data, and I imported all in open office, no funny tools like spark, jupyter or R (but maybe one day…). Some weird numbers here and there (did a cat go to drink in the tool that measures rain? -0.1 mm rain I don’t understand how it is possible).

This is the result, just a pivot table in open office.

I do not know how the yellow line will become during the rest of the year, but you see the difference in autumn and in April is something that made me wow.

Let me know if it is the same next to you…or if it is the opposite: it would be good to discover a place where to go when the south of France will become an arid desert.

Written by Giovanni

July 29, 2022 at 5:50 pm

Posted in Varie

Normandy’s shores

leave a comment »

The last time I have written about climate change was about Miami (FL): a name known everywhere in the world but still 12 hours and a half away from home. Some time ago I was watching TV news, and they were speaking about Normandy, which is just 1’000 Km from here; non yet in my barn house but much closer compared to Miami.

I have always heard of Normandy because of the second world war, the Omaha beach landing, and tourism. Living in France, Normandy is often presented as a beautiful place to visit, with many small villages and beautiful views. For instance the Mont-Saint-Michel

Photo by mies1951 from Pixabay

Just search for “mont-saint-michel rechauffement climatique” (mont-saint-michel climate warming) and you will find various articles telling that the streams around the village will be modified and the shores eroded. For instance Erosion en Bretagne : la baie du Mont-Saint-Michel au bord de la submersion ? and Changement climatique : menace sur la baie du Mont-Saint-Michel tell that the tide will increase, and this is not negligible.

Searching a bit more I have found a map on En Normandie, 428 communes menacées par la montée des eaux: it makes reference to an official publication from Insee (french national institute of statistics). The risk of flooding within 100 years concerns 122’000 inhabitants and may dangerous industrial plants, for instance nuclear reactors.

In 2021 a new law has been established: majors will have to maintain 30 years and 100 years of horizon plans showing which places will be impacted in their villages. In 30 years zone, it will be forbidden to make new buildings. It will be possible to build in the 100 years zone, but the community will be able to oblige their destruction in case of increased danger. You can read this article: Bretagne. 41 communes vont devoir s’adapter à l’érosion. The list of impacted villages is published on this official site Décret n° 2022-750 du 29 avril 2022

The same holds also for another region, Brittany, just close to Normandy. This page on the prefecture site has many links about it Adaptation des territoires aux évolutions du littoral.

The idea that you buy one house next to the sea and somebody then declares that it will be flooded within 30 years, or that you will be asked to destroy it is quite frightening. 30 years is a long period but not that long in the end. Everybody should contribute to limiting these changes, in the end everybody will suffer somehow, not just Miami’s or Normandy’s inhabitants.

Written by Giovanni

July 7, 2022 at 6:57 pm

Posted in Varie

Me and the climate

leave a comment »

This is the first of a series of articles about climate change, how I feel about it, and what I am doing on my own.

About six months ago I watched “Before the flood” by Leonardo di Caprio: it dates of 2016 but was somehow available on Disney Plus, and I do not know how I have found the time to look at it. Usually, my daughter monopolizes the tv, but not that evening.

if you are curious about the film, you can have a look on Wikipedia to know more, or just watch it. It is a documentary, it is not super exciting but it was telling about surprising things about climate change. I do not remember many episodes but one was about Miami and attracted my attention.

The episode on Miami was describing the county plan about sea water raising. Some parts of the city are impacted, more and more, and they decided to rebuild part of the infrastructure in more elevated places. For sure this will require a lot of money and will impact many people that will have to relocate their activities.

So a real town, very known in the world, is so impacted that had to start a huge project to reduce the climate change impact. It has been quite easy to find the official site with many details on what they are doing: https://www.miamidade.gov/global/economy/resilience/sea-level-rise-flooding.page

There is a 3D model showing where the impacts will be, and a mini guide explaining what will be the problems. This is a picture taken from this guide

impacts of rising sea level

So it is a real, huge project, with many people and money behind it – as you can read on their site. This made the climate change problem much more concrete for me.

The surprising thing for me was also that you do not fight the cause of the problem, just try to adapt to its consequences. By the way what else could do Miami’s citizens: they cannot just fix the problem for everybody else.

After this episode, and others that I will describe in other posts, I started thinking at what I can do about climate change. I don’t believe that politics will find a solution to the problem, for a simple reason: it is so cheaper to continue living as we do today until we have to pay personally for the damages. We all love to pay the least possible for everything we need, and fossils energy sources are so inexpensive compared to other sources.

As a really selfish individual, I will change what I can, and I will talk about it. It won’t be a huge contribution, but at least I am not just passively watching to what is happening.

Written by Giovanni

June 19, 2022 at 5:55 pm

Posted in Varie

jep/428 Java Structured Concurrency

leave a comment »

Well it is a lot of time I do not develop concurrent code in Java, but reading this JEP has been really nice and I hope it will find its way to an official feature.

An example is given, where one task spawns 2 parallel threads. If everything goes fine we are all happy, but if one of the threads gets interrupted it is easy to have some leaks. For instance if one of the sub-threads fails, also the second thread should be killed and the parent thread interrupted.

Manually coding this seems complicated, and difficult to test. The StructuredTaskScope they propose seems good to solve many problem, event though the syntax is a bit cumbersome

Response handle() throws ExecutionException, InterruptedException {
    try (var scope = new StructuredTaskScope.ShutdownOnFailure()) {
        Future<String>  user  = scope.fork(() -> findUser()); 
        Future<Integer> order = scope.fork(() -> fetchOrder());

        scope.join();          // Join both forks
        scope.throwIfFailed(); // ... and propagate errors

        // Here, both forks have succeeded, so compose their results
        return new Response(user.resultNow(), order.resultNow());
    }
}

Also they propose to modify the thread dumps to make evident the problems caused by subtask failures.

I hope you will enjoy reading JEP 428: Structured Concurrency (Incubator)

Written by Giovanni

June 3, 2022 at 1:21 pm

Posted in Varie

Remote environments, my bad

leave a comment »

Yep, working in local with a virtual machine. The same old story, it’s better to develop on linux but you need all the funny windows tools so I have a virtual machine running all the day.

This is not a real problem, all works well and with X11 terminal all looks pretty nice.

The problem comes when you need complicated stuff and you cannot get them on your virtual machine and you have to run tests on a remote enviornment.

You need a vpn to connect, and you need to pass through a jump server to access the environment, this for security. Of course you do not want to allow access to many services from outside, but all becomes quite annoying.

You need a new shell, new login, put the password, the second factor authentication, you are then in and you do your stuff. I never had the occasion but I think certificates could help here, and just have the pain of entering the 2nd factor to continue working. It is not the case right now and I have to do that.

Then the development environment is local, and I compile locally some file, in the vm. Then the connection is quite slow and I try to move just the minimum to the remote environment. So another scp with a lot of passwords to put.

Then I do my test in remote, I fix something, and I try again. Of course I am speaking of development/staging environments

One thing I would like to try is to have the full development environment as pod in kubernetes, right next to the staging environment. In this way I could connect once to it, and just use the UI from there. This would really simplify a lot my life.

In the end I am already working on a virtual machine, it does not change much for me if it runs here on my laptop or far far away in a data center.

Written by Giovanni

April 26, 2022 at 3:58 pm

Posted in Varie

spark-shell

leave a comment »

This page to remember of the first contact with the spark shell and the basic commands to use

scala> spark
res0: org.apache.spark.sql.SparkSession = org.apache.spark.sql.SparkSession@4e0139
scala> val flx = spark.read.parquet("file:///home/me/flx.parquet")
scala> flx.columns
res1: Array[String] = Array(MessageID,...
scala> flx.select("MessageID").show(10,false)
scala> import org.apache.spark.sql.functions._
scala> flx.select("MessageID","B").where(col("MessageID") !== col("B")).show(5,false)
scala> flx.select("X").where(col("X")==="").count()
res20: Long = 13066

but if you want to use custom logic in the where clause seems you have to go back to RDD

val myfile=spark.read.parquet("file:///myfile.parquet")
import org.apache.spark.sql.functions._
import scala.util.parsing.json.JSON
myfile.rdd.filter( row => JSON.parseFull(row.getString(4)).isEmpty).count()

The above code checks and ount how many malformed JSON values you have in column 4… maybe there is a way to use column names instead of numbers but this is to be continued

Written by Giovanni

April 1, 2022 at 2:13 pm

Posted in Varie

Traveling with Camel in the Java-verse

leave a comment »

Sometimes I feel like Alice in Wonderland, you never know what is going to happen and which strange beast I am going to face.

Today’s beast is Camel: I have nothing against it, I barely know what it is, but I have just seen another episode of “I am a bored developer, let me try a new framework. One day it will be useful”

So in Camel you have a RouteBuilder, inside the route a message is delivered to all the Handler registered. There is an xml configuration file where you can define beans with spring

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:camel="http://camel.apache.org/schema/spring"
       xsi:schemaLocation="
       http://www.springframework.org/schema/beans classpath:/org/springframework/beans/factory/xml/spring-beans-4.3.xsd
       http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd">

  <!-- camelContext is the Camel runtime, where we can host Camel routes -->
  <camel:camelContext xmlns="http://camel.apache.org/schema/spring">
    <camel:routeBuilder ref="routerBuilder"/>    
  </camel:camelContext>
  
  <bean id="routerBuilder" class="MyRouteBuilder"/>
  <bean id="A" class="AClass"/>
  <bean id="B" class="BClass"/>
</beans>

So this create a context, 3 beans and the first one is the route builder. Inside MyRouteBuilder you can

		from("timer://simpleTimer?period={{timer}}")
		.to("bean:A")
		.to("bean:B");

so you can tell that the source event to process is just a timer that is expiring, then the 2 handlers have to be invoked.

Quite overkill to use a framework like Camel to just do periodically a couple of calls. At least this time the beast I faced was not so difficult to understand.

Many thanks to https://www.baeldung.com/apache-camel-intro that always provide good short articles to understand quickly what is going on.

Written by Giovanni

March 29, 2022 at 11:53 am

Posted in Varie

PyTorch Anaconda and root ca certificates

leave a comment »

Unfortunately, or fortunately depending from which point you look at the problem, here we have a tool installed on all pc that intercepts and filters all the http and https traffic, the idea is to prevent access to unwanted sites, places where there can be malware, non business related sites…

I still do not understand why I can access facebook from here, but anywhay this kind of tool is problematic when you try to use some developer tools that do something about security.

For instance I am trying to install pytorch, and to do that I need to install anaconda, and once done that I need to download many packages.

Anaconda is good at finding what you need to install, but it detects that there is this “man in the middle” tool that is spying all the traffic. It sees that there is something wrong in the signed certificates that are using with the tls connection.

Only option is to add this tool root certificate authority inside the trusted root certificates authority.

First step is to obtain the root ca certificates in pem format, you must save them as files ending with .crt extension

openssl s_client -showcerts -servername wikipedia.org -connect wikipedia.org:443

It will show the pem fcertificates chain, you need to pick the last one, that is the root certificate.

If you want to see the certificate content you can use

openssl x509 -in pem3.crt -text #where pem3 is the certificate I saved

I followed a tutorial on ubuntu, https://ubuntu.com/server/docs/security-trust-store. For the root user it works perfectly fine, but not for my user

finally with this command

curl-config --ca

I have been able to understand that the location used from curl and anaconda is not the one from the ubuntu os. anaconda must have installed some new version for its purposes and the curl with my account was not working.

So I linked

ln -s /etc/ssl/certs/ca-certificates.crt cacert.pem

inside

$HOME/anaconda3/ssl

and something magic happened, now I can use curl with the man in the middle tool.

Written by Giovanni

March 22, 2022 at 12:21 pm

Posted in Varie