Java: Pass By Value or Pass By Reference

Posted in IT StuffTagged

Data is shared between functions by passing parameters. Now, there are 2 ways of passing parameters: Passing by value: this method copies the value of actual parameter. The called function creates its own copy of argument value and the use it inside the code. As soon as the work is done on the copied value,….

Return Distinct Values for an Array Field

Posted in UncategorizedTagged

The following example returns the distinct values for the field sizes from all documents in the Collection1 collection: This will be the expected result: Distinct, as for relational database, finds the distinct values for a specified field across a single collection or view and returns the results in an array.

Algorithm complexity and Big O notation

Every system transform data into output and that’s why is important to understand the efficiency of our algorithms and data structures according to each solution.  Big O Notation measures the efficiency of an algorithm according to its time and space complexities. The input size of a function can increase linearly and we should be aware….

SARS-CoV-2 e Disinfezione delle strade

Posted in Minerbe

TL;DR (se avete fretta, cosa che è assolutamente errata quando ci si deve informare, saltate subito alla parte finale con scritto MORALE). Torno sull’argomento. Fin da subito mi sono schierato contro questa pratica inquinate e pericolosa ricevendo anche qualche critica ma, ho troppo rispetto per la mia comunità per prendere decisioni che accontentano e portano….

Spring 4+ with Ehcache 3.x

Posted in IT StuffTagged , ,

This post describes an example of using Ehcache with a Spring MVC application deployed on Tomcat (not using Spring boot). It is a legacy app that needs to be upgraded. The dependencies are: Application context must be updated in this way: The method must be annotated with @Cacheable so that Spring will handle the caching. As a result….

React.js: fill options of Autocomplete with API results

Posted in IT StuffTagged ,

The autocomplete is a normal text input enhanced by a panel of suggested options.  Autocomplete is a feature that helps in predicting the rest of the word typed by a user. Autocomplete is helpful from the user as well as the user experience perspective. It makes users happy by saving their time and also by….

Mongo Replica set with docker-compose

Posted in IT StuffTagged ,

A replica set in MongoDB is a group of mongod processes that maintain the same data set. Replica sets provide redundancy and high availability and are the basis for all production deployments. Replication provides redundancy and increases data availability. With multiple copies of data on different database servers, replication provides a level of fault tolerance against the loss of a single database….

Java: Sort a list of objects according to matching string/pattern

Posted in IT StuffTagged

I need to sort a list of objects in which the matching items come up and others will go down so. For instance, a list of objects on which all the labels are in alphabetical order except for all the values that start with P that will be put on the top of the list…..

Global warming e inquinamento in genere

Posted in GlobalWarming, Minerbe

L’ecologia mi sta a cuore, il pericolo che corriamo è concreto. Sensibilizzare le masse su tale pericolo è fondamentale e lottare perché si trovi una soluzione è quantomeno doveroso. È giusto però puntualizzare alcune cose. È facile andare in piazza e gridare cosa non ci stia bene; no nucleare, no trivelle, no global warming, no esperimenti sulla….

Import SQL file using pgAdmin

Posted in IT StuffTagged

I have a docker Postgres image and I want to import the data from another Postgres db. The first thing I have done is to create a pg_dump on the remote server and then I have tried to import it. The problem is that output generated is simple SQL file and, if I import this….