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,….

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….

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…..

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….

Install MySQL server with Docker Compose

Posted in IT StuffTagged ,

Inside a new directory, create a data directory and docker-compose.yml with these rows: To start the container, run docker-compose up -d. To stop & remove the container, run docker-compose down. To connect from a MySql client use this:

Warning: setlocale: LC_CTYPE: cannot change locale (UTF-8): No such file or directory

Posted in IT StuffTagged

After a recent Ubuntu update, I get this error. What finally helped was putting to the file /etc/environment: LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8 For some reason, it was missing. The outputs for locale and other commands appeared like the variables were properly defined. In other words, don’t take for granted all the basic stuff is declared where….

How to fix a locale setting warning from Perl and/or *nix bash?

Posted in IT StuffTagged ,

Perl is sometime called by a *nix script and, after an update I get recently this warning message (in particular when I run apt or npm command): perl: warning: Setting locale failed. perl: warning: Please check that your locale settings: LANGUAGE = (unset), LC_ALL = (unset), LC_CTYPE = "UTF-8", LANG = "en_US.UTF-8" are supported and….