This weekend, someone asked me for help with a specific file. He has an Audi and wanted to upgrade his GPS maps. But all he has was an 8 KB downloader file with a JNLP extension. When opening the file, he gets an error that says that the extension is not recognized. First, I’ll give you Oracles explanation of JNLP:…
God Mode in Windows
There is a method to activate a kind of God Mode in Windows Vista and above. With this simple hack, you get a folder that is containing all possible control panels and settings in Windows. Follow the next steps to enable God Mode:
How to create a stream from an iterator in java 8
Hi guys! In this post I’ll show you how to convert an java iterator to a java 8 stream. The code is really simple:
1 2 3 4 |
public static <T> Stream<T> iteratorToStream(final Iterator<T> iterator, final boolean parallell) { Iterable<T> iterable = () -> iterator; return StreamSupport.stream(iterable.spliterator(), parallell); } |
Just copy paste this static method in any class you like. It’s generic so you can use this method for all types of iterators. Enjoy!
How to fix Unirest General SSLEngine problem
I tried to post data to a rest service using Unirest (unirest.io). But when I tried to post to an HTTPS url, I got the following error:
1 2 3 |
javax.net.ssl.SSLHandshakeException: General SSLEngine problem PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target |
To fix this, you could use the following code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
private CloseableHttpAsyncClient createSSLClient() { TrustStrategy acceptingTrustStrategy = new TrustStrategy() { @Override public boolean isTrusted(X509Certificate[] arg0, String arg1) throws CertificateException { return true; } }; SSLContext sslContext = null; try { sslContext = SSLContexts.custom().loadTrustMaterial(null, acceptingTrustStrategy).build(); } catch (Exception e) { LOGGER.error("Could not create SSLContext"); } return HttpAsyncClients.custom() .setHostnameVerifier(SSLConnectionSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER) .setSSLContext(sslContext).build(); } |
Then, you need to execute the code below before useing Unirest itself:
1 |
Unirest.setAsyncHttpClient(createSSLClient()); |
Hopefully this works for you too. Enjoy
How to create a vertx fat-jar with maven
If you use Vertx, It could be helpful to create a jar or war where Vertx is included. If you use maven. You can add the following code in your pom.xml:
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 30 |
<build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-shade-plugin</artifactId> <version>2.4.1</version> <executions> <execution> <phase>package</phase> <goals> <goal>shade</goal> </goals> <configuration> <transformers> <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer"> <manifestEntries> <Main-Class>io.vertx.core.Starter</Main-Class> <Main-Verticle>com.laurenthinoul....ApplicationMainClass</Main-Verticle> </manifestEntries> </transformer> </transformers> <artifactSet /> <outputFile>${project.build.directory}/${project.artifactId}-${project.version}-fat.jar</outputFile> </configuration> </execution> </executions> </plugin> </plugins> </build> |
If you integrated Spring, you need to add extra transformers. You can use the following code in your pom.xml for that:
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 30 31 32 33 34 35 36 37 38 39 40 41 42 |
<build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-shade-plugin</artifactId> <version>2.4.1</version> <executions> <execution> <phase>package</phase> <goals> <goal>shade</goal> </goals> <configuration> <transformers> <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer"> <manifestEntries> <Main-Class>io.vertx.core.Starter</Main-Class> <Main-Verticle>com.laurenthinoul....ApplicationMainClass</Main-Verticle> </manifestEntries> </transformer> <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer"> <resource>META-INF/spring.handlers</resource> </transformer> <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer"> <resource>META-INF/spring.schemas</resource> </transformer> <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer"> <resource>META-INF/spring.tooling</resource> </transformer> </transformers> <artifactSet /> <outputFile>${project.build.directory}/${project.artifactId}-${project.version}-fat.jar</outputFile> </configuration> </execution> </executions> </plugin> </plugins> </build> |
Don’t forget to change ‘com.laurenthinoul….ApplicationMainClass’ to…
How to delete duplicate rows in SQL
To find and delete duplicate rows from a table, you can execute the query below. Note that this is for Oracle. You can use it for other databases but you need to change the ‘rowid’ then.
1 2 3 4 5 6 7 8 9 |
delete from table_name A where a.rowid > any ( select B.rowid from table_name B where A.column_name = B.column_name ); |
You need to change the ‘table_name’ by your table name an the ‘column_name’ by your column you want to check on. To explain…
How to update all outdated homebrew software
Updating your outdated homebrew software can simply be done by the following command:
1 |
brew update && brew upgrade `brew outdated` |
How to enable CORS in Solr
If you are using Solr with Angular or something like that. The browser can be anoying about cross site scripting. To enable CORS in Solr you just have to add the code below in solr-x.x.x/server/solr-webapp/webapp/WEB-INF/web.xml (x.x.x stands for the solr version). Just after the <web-app> tag.
How to use play framework behind a proxy
In this post, I’ll show you how to configure the play’s framework activator to work behind a proxy.
How to solve DbProviderFactories section can only appear once per config file error
Once upon a time, there was a program called ‘Agresso’. It uses the .NET framework. When I started the program and wanted to log in. I got the following error message: DbProviderFactories section can only appear once per config file error. -.-‘ After some research, I discovered it was a bug in the .NET framework. (not surprising me :p). Now,…