Find on different collections to create a document using mongoose

Posted in IT StuffTagged , ,

I need to query multiple collections to prepare a MongoDB document and then save it using Mongoose and NodeJS. The solution is to use async.parallel I have two source collections, Robot, Target and the destination collection Activity. For first, async must be added: var async = require(’async’);var async = require(‘async’); then: async.parallel({   robotFind: function(cb)….

How to use Spring DataSource bean as data source for Log4j 2 JDBC appender

Posted in IT StuffTagged , ,

I would like to log log4j2 messages into a relational database using the datasource defined on application context and initialized using spring using log4j 2.10. One possibility is to add a JDBC appender inside log4j2 xml configuration but, Log4j is initialized before Spring so, dataSource won’t be available at runtime so the only solution is….

Warning about SSL connection when connecting to MySQL database

Posted in IT StuffTagged ,

After a recent update of mySql, I get this warning: WARN: Establishing SSL connection without server’s identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn’t set. For compliance with existing applications not using SSL the verifyServerCertificate property is set to….

Convert timestamp long to normal date format

Posted in IT StuffTagged

One simply way to convert a Long time stamp into a formatted string is (time paramter is Long timestamp): Date date = new Date(time); Format format = new SimpleDateFormat("yyyy MM dd HH:mm:ss"); return format.format(date);Date date = new Date(time); Format format = new SimpleDateFormat("yyyy MM dd HH:mm:ss"); return format.format(date); These packages must be included. import java.sql.Date;….

Date based query using milliseconds (Java long) time on MongoDB

Posted in IT StuffTagged

Let’s suppose I need to search all records that match a date condition. On MongoDB I’ve a bunch of data like this: { "_id" : "9ed3b937-0f43-4613-bd58-cb739a8c5bf6", "userModels" : { "5080" : { "generated_date_timestamp" : NumberLong(1413382499442), "model_id" : 5080, }, } "values" : {} }{ "_id" : "9ed3b937-0f43-4613-bd58-cb739a8c5bf6", "userModels" : { "5080" : { "generated_date_timestamp" :….

Gap di competenze per Industria 4.0

Posted in Financial, IT StuffTagged

«Non vedo un rischio di disoccupazione maggiore provocato dalle tecnologie, il saldo non sarà negativo», spiega ancora l’economista Ocse che però vede una minaccia nell’aumento delle diseguaglianze – «sia come stipendi che come prospettive di carriera» – tra chi ha competenze adeguate e chi no: «I lavori intermedi già negli ultimi venti anni sono stati colpiti,….

The Noble Art of Maintenance Programming

Posted in IT StuffTagged

Yes, I am a big fan of code readability and refactoring. I always have in mind this: Everyone knows that debugging is twice as hard as writing a program in the first place. So if you’re as clever as you can be when you write it, how will you ever debug it? – Brian Kernighan….

Delete Files Older Than x Days on Linux

Posted in IT StuffTagged

Command Syntax find /folder/files* -mtime +15 -exec rm {} \;find /folder/files* -mtime +15 -exec rm {} \; The first argument is the path to the files. This can be a path, a directory, or a wildcard as in the example above. The second argument, -mtime, is used to specify the number of days old that….

How do I fix a 65535 bytes limit Stacktrace?

Posted in IT StuffTagged ,

It is possible that after an upgrade you may encounter this error on some of the more complex pages and root cause provided by tomcat console is : To solve the issue you need to locate the file [Tomcat_Home]/conf/web.xml and search the file for ‘JspServlet’. This should return an xml node of containing some values…..

How to kill all processes with a given (partial) name?

Posted in IT StuffTagged ,

Usually I open more than on instance of tail -f to monitor my application, so, to kill all with one single command I can use this: ps -ef | grep tail | grep -v grep | awk ‘{print $2}’ | xargs kill -9ps -ef | grep tail | grep -v grep | awk ‘{print $2}’….