Category: programming
React: loop inside JSX code
If you are using React JS and want to add a component multiple times, maybe inserting it into some JSX code, you could think of using a for loop inside the return statement of your JSX. But this approach doesn’t work in JSX, as you should compose the returned value from the render function of … Continue reading “React: loop inside JSX code”
How to turn off ESLint rule via config file or via javascript
ESLint is fully configurable, so you are able to turn off linting rules. There are two ways for disabling rules: you can tell ESLint to do this from a Javascript comment or from a configuration file. How to turn off an ESLint rule from the .eslintrc config file To disable specific rules from the .eslintrc … Continue reading “How to turn off ESLint rule via config file or via javascript”
Javascript module pattern with constructor with arguments
As Douglas Crockford wrote on Javascript: the good parts, a module is a function or object that presents an interface but hides its state and implementation. I used indeed the module pattern once I needed encapsulation, i.e. to have a class method that had a public interface but that hid implementation details. In addition to encapsulation I … Continue reading “Javascript module pattern with constructor with arguments”
Javascript module pattern con costruttore con argomenti
Come scritto su Javascript: the good parts, un modulo è una funzione o un oggetto che presenta una interfaccia ma nasconde il suo stato e la sua implementazione. Ho infatti utilizzato il pattern module quando ho avuto la necessità di incapsulamento, cioè di avere un metodo di una classe che avesse una interfaccia pubblica ma … Continue reading “Javascript module pattern con costruttore con argomenti”
How to use React from the browser
React, as you probably know having reached this page, is a visualization framework created by Facebook. This small guide explains how to use react from the browser without any additional tool. Professional development with React nowadays includes the usage of npm (node package manager) to install packages like React and ReactDOM, and that of module bundlers … Continue reading “How to use React from the browser”
Iniziare con React: come usare React dal browser
React, come probabilmente saprete se siete giunti qui, è il framework per la visualizzazione creato da Facebook. Questa piccola guida spiega come utilizzare React dal browser senza l’uso di altri tool. Lo sviluppo professionale con React oggi come oggi prevede infatti l’uso di npm (node package manager) per l’installazione dei pacchetti come React e ReactDOM, … Continue reading “Iniziare con React: come usare React dal browser”
Canvas o SVG, come scegliere
Canvas ed SVG sono due tecnologie per il disegno disponibili all’interno di HTML 5. Come scegliere quale utilizzare? Meglio Canvas o SVG? C’è chi usa sempre l’uno o sempre l’altro, ma la scelta non è così semplice. Bisogna capire le caratteristiche dell’uno e dell’altro prima di decidere. Vediamo prima un po’ di storia, per capire … Continue reading “Canvas o SVG, come scegliere”
javax.net.ssl.SSLHandshakeException: “Remote host closed connection during handshake” opening an HTTPS page with HTMLUnit
While trying to fetch the HTTPS page https://portal.mvp.bafin.de/database/AnteileInfo/ using HTML Unit 2.23 under Java 7, Ubuntu Linux, I received the following exception: Remote host closed connection during handshake
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
Exception in thread "main" javax.net.ssl.SSLHandshakeException: Remote host closed connection during handshake at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:880) at sun.security.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1262) at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1289) at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1273) at org.apache.http.conn.ssl.SSLConnectionSocketFactory.createLayeredSocket(SSLConnectionSocketFactory.java:394) at org.apache.http.conn.ssl.SSLConnectionSocketFactory.connectSocket(SSLConnectionSocketFactory.java:353) at com.gargoylesoftware.htmlunit.httpclient.HtmlUnitSSLConnectionSocketFactory.connectSocket(HtmlUnitSSLConnectionSocketFactory.java:189) at org.apache.http.impl.conn.DefaultHttpClientConnectionOperator.connect(DefaultHttpClientConnectionOperator.java:141) at org.apache.http.impl.conn.PoolingHttpClientConnectionManager.connect(PoolingHttpClientConnectionManager.java:353) at org.apache.http.impl.execchain.MainClientExec.establishRoute(MainClientExec.java:380) at org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:236) at org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:184) at org.apache.http.impl.execchain.RetryExec.execute(RetryExec.java:88) at org.apache.http.impl.execchain.RedirectExec.execute(RedirectExec.java:110) at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:184) at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:71) at com.gargoylesoftware.htmlunit.HttpWebConnection.getResponse(HttpWebConnection.java:183) at com.gargoylesoftware.htmlunit.WebClient.loadWebResponseFromWebConnection(WebClient.java:1358) at com.gargoylesoftware.htmlunit.WebClient.loadWebResponse(WebClient.java:1275) at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:382) at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:304) at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:451) at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:436) at fetchers.bafin.SSLTest.main(SSLTest.java:16) Caused by: java.io.EOFException: SSL peer shut down incorrectly at sun.security.ssl.InputRecord.read(InputRecord.java:352) at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:861) ... 23 more |
The code was the following
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
import java.io.IOException; import java.net.MalformedURLException; import com.gargoylesoftware.htmlunit.FailingHttpStatusCodeException; import com.gargoylesoftware.htmlunit.WebClient; import com.gargoylesoftware.htmlunit.html.HtmlPage; public class SSLTest { public static void main(String[] args) throws FailingHttpStatusCodeException, MalformedURLException, IOException { final String URL = "https://portal.mvp.bafin.de/database/AnteileInfo/"; final WebClient wc = new WebClient(); // the code should be ok without the following line, // but even with it, it doesn't work // wc.getOptions().setSSLClientProtocols(new String[]{"TLSv1.1","TLSv1.2"}); final HtmlPage mainPage = wc.getPage(URL); } } |
The problem was solved upgrading to Java 8. I upgraded to Java 8 after reading Oracle’s blog about HTTPS … Continue reading “javax.net.ssl.SSLHandshakeException: “Remote host closed connection during handshake” opening an HTTPS page with HTMLUnit”
Hibernate/c3p0: apparent deadlock
The apparent deadlock message issued by c3p0, a connection pool manager of Hibernate, can sometimes be misleading. Most of the times, it is caused by connection errors. So, check your firewall, and, for Postgresql try the following command from the command line
1 |
psql -h host -U user db |
If this works, you should have no problem connecting to Postgresql. The … Continue reading “Hibernate/c3p0: apparent deadlock”
Create a production build using React JS
You probably saw some warnings that say you’re using React in development mode, and want to know how to create a production build using React. Why you get a warning of being in React development mode Normally you import React JS in your javascript ECMA 6 code with the following statements in a .js file … Continue reading “Create a production build using React JS”