java

Java 11 Ubuntu setup Part 2

Quick addion of the things around Java 11 that is required to get your enviroment ready for development. See part one on the Java 11 installation first: Part 1

Eclipse Run Swarm

This will just quickly show you how to run a Wildfly Swarm application in Eclipse and also allow you to easily run the debugger.

Singleton with arguments

Had a very unusual requirement where I needed to share singleton between projects that requires initialization arguments. These arguments are different based on what server it is started. In applications using CDI this was very easy but not all where using CDI and a lot of the projects where not under my control they where simply using the lib. Thread safty was also a concern and I wanted to avoid using synchronized. Here is the solution I came up with.

Into the Future Thread - Part 2

Continuing with execution flow of Futures and thread. See Part 1 if you have not. I would like to highlight when future.get() completes in different scenarios. Firstly I know it is not best practice to use Futures in this way but I think it is still important to understand how the internals work.

Into the Future Thread - Part 1

Just wanted to highlight what thread is used in regards to Java Futures in Java 8. The flow of execution. Basicly the differences between the normal and Async function in futures.

Dagger 2 Maven Config

Just a quick post on how to setup Dagger 2 with maven to compile without messing with eclipse settings. Just remember to include target/generated-sources to your class-path.

RuntimeException: wrong class format

I have a very old project still running on Jboss 6 AS, it has been on the TODO list to write but since it is of low importance, only used internally and it just works.

Hibernate fetching strategies

Fetching strategies are used to optimize the SQL generated by Hibernate. Using Object Relational Mapping (ORM) tools does have a overhead for the all the benefits it provides but this can be reduced by understanding it.

Jetty Embedded adding CORS Filter

How to add Cross-origin resource sharing (CORS) filter to a embedded Jetty server. Jetty comes with a CORS filter that is easy to use. Add the following to you maven:

MySQL/MariaDB data not available in second application

This is a interesting issue I found using Hibernate. You have 2 independent application both using the same database. What I found that if one application submits a value to the database the second application does not see the updated/new entry. If you use direct SQL on the database the changed/new entry is visible and the same is true if you use the JDBC directly without hibernate.

ThreadPoolExecutor gotcha with unbounded queue

Something I have now seen a few times in projects is people not being aware of how ThreadPoolExecutor works. When creating a ThreadPoolExecutor you have to arguments to set minPoolSize, maxPoolSize, keepAliveTime and workQueue. Now the gotcha is in when the ThreadPoolExecutor creates a new thread for execution especially when using unbounded size Queues. For example when looking at this ThreadPoolExecutor constructor:

Implementing Java Comparable

Implementing the Comparable interface in Java give the object a natural ordering, as in makes it Sortable. The comparable interface only has one method:

Guava LoadingCache invalidate call while loading?

I have a application that needs to pull data from the database do some calculations (This takes a second or two) then returns. I have been using Guava’s LoadingCache to do this. The problem came in when a user makes a change to the source data which in effect invalidates the calculation results. Easy solution just invalidate. But what happens if the data is modified during the calculation process. For example you have 2 threads, Thread 1 calls get on the loading cache then during the Loading process in Thread 1, Thread 2 calls invalidate since the underlying data has changed. Is the data invalidated or is the invalid/stale data stored in the cache?

Hiding data on a Excel Spreadsheet using POI

I had a requirement where I needed to hide some meta data in Excel Spreadsheet. Instead of using hidden row/columns/cells I used Custom Properties. Custom properties is a map in the Spreadsheet file where you can store key/value data. I found this much safer than hiding the data on the sheets since users could delete/corrupt the data very easily.

Back to Top ↑

maven

Java 11 Ubuntu setup Part 2

Quick addion of the things around Java 11 that is required to get your enviroment ready for development. See part one on the Java 11 installation first: Part 1

Dagger 2 Maven Config

Just a quick post on how to setup Dagger 2 with maven to compile without messing with eclipse settings. Just remember to include target/generated-sources to your class-path.

Back to Top ↑

db

JOOQ MySQL/MariaDB and the duplicate column name

Hit a interesting issue today using MariaDB with JOOQ. I have a project that can be configured to use different underlying databases depending on client requirements and I use JOOQ to simplify this for me. One of the tables are structured as follow:

Enable SQL log in MySQL/MariaDB

When using a ORM like hibernate it is always a good idea to check what SQL is generated/executed. This is how you enable a log of the SQL executed on the MySQL/MariaDB server:

MySQL/MariaDB data not available in second application

This is a interesting issue I found using Hibernate. You have 2 independent application both using the same database. What I found that if one application submits a value to the database the second application does not see the updated/new entry. If you use direct SQL on the database the changed/new entry is visible and the same is true if you use the JDBC directly without hibernate.

Back to Top ↑

mysql

Hibernate fetching strategies

Fetching strategies are used to optimize the SQL generated by Hibernate. Using Object Relational Mapping (ORM) tools does have a overhead for the all the benefits it provides but this can be reduced by understanding it.

Enable SQL log in MySQL/MariaDB

When using a ORM like hibernate it is always a good idea to check what SQL is generated/executed. This is how you enable a log of the SQL executed on the MySQL/MariaDB server:

MySQL/MariaDB data not available in second application

This is a interesting issue I found using Hibernate. You have 2 independent application both using the same database. What I found that if one application submits a value to the database the second application does not see the updated/new entry. If you use direct SQL on the database the changed/new entry is visible and the same is true if you use the JDBC directly without hibernate.

Back to Top ↑

git

Ungit the ultimate tool for git

Ungit is the easiets way to use GIT. It is great tool that visiually represents your repository and completly removes the learning curve with GIT. It uses node.js and is available via npm.

Bluk update GIT master location

The server hosting the GIT repository has moved to an new domain name. Now is very painfull to update manually so here is quick command to find all the GIT config files and replace the old domain name with the new domain name.

Back to Top ↑

solidity

Deploy Solidity Contract

This tutorial will show you how to deploy a solidity contract to Ropsten (Test Net).

Truffle Expected Throw Test

When creating test cases to test your solidity code you will need to test conditions that causes throws. This will show you how to write those tests in javascript.

Solidity Truffle Quickstart

This quick and dirty tutorial will show you how to create Ethereum Smart Contract project using truffle framework.

Back to Top ↑

cypto

Deploy Solidity Contract

This tutorial will show you how to deploy a solidity contract to Ropsten (Test Net).

Truffle Expected Throw Test

When creating test cases to test your solidity code you will need to test conditions that causes throws. This will show you how to write those tests in javascript.

Solidity Truffle Quickstart

This quick and dirty tutorial will show you how to create Ethereum Smart Contract project using truffle framework.

Back to Top ↑

jsp

Seam parameter as date

When using Seam Gen to setup basic pages from the persistence objects where a primary key is a date or one of the keys in the combined primary key is a date you will run into this error: “value must be a date” This is due to the date converter not working properly when seam is parsing the page parameters. By default it just performs a toString causing the page parameter to be populated as follow:

Back to Top ↑

seam

Seam parameter as date

When using Seam Gen to setup basic pages from the persistence objects where a primary key is a date or one of the keys in the combined primary key is a date you will run into this error: “value must be a date” This is due to the date converter not working properly when seam is parsing the page parameters. By default it just performs a toString causing the page parameter to be populated as follow:

Back to Top ↑

arduino

5×5 LED Cube

The 5×5 LED cube project version 1.0 is working!

I am making use of 4 shift registers 74CH595N to control the 25 columns and 5 P2N2222A NPN Transistor to select a layer. Currently I am writing the cube state for a layer out every 7ms.

Back to Top ↑

linux

Email alerts on login

This quick tutorial will show you how to get email alerts when any user logs into your Linux box.

Back to Top ↑

docker

Back to Top ↑

poi

Hiding data on a Excel Spreadsheet using POI

I had a requirement where I needed to hide some meta data in Excel Spreadsheet. Instead of using hidden row/columns/cells I used Custom Properties. Custom properties is a map in the Spreadsheet file where you can store key/value data. I found this much safer than hiding the data on the sheets since users could delete/corrupt the data very easily.

Back to Top ↑

excel

Hiding data on a Excel Spreadsheet using POI

I had a requirement where I needed to hide some meta data in Excel Spreadsheet. Instead of using hidden row/columns/cells I used Custom Properties. Custom properties is a map in the Spreadsheet file where you can store key/value data. I found this much safer than hiding the data on the sheets since users could delete/corrupt the data very easily.

Back to Top ↑

macgyver

Fixing the mouse

I have been using a Evoluent VerticalMouse 4 now for just over a year and have really grow to like it up until a few weeks ago where it would only work when it felt like it. Fiddling around with the cable I realized there was a connection problem in the cable. After doing some searching it seems like a common problem.

Back to Top ↑

mariadb

JOOQ MySQL/MariaDB and the duplicate column name

Hit a interesting issue today using MariaDB with JOOQ. I have a project that can be configured to use different underlying databases depending on client requirements and I use JOOQ to simplify this for me. One of the tables are structured as follow:

Back to Top ↑

vaadin

Back to Top ↑

jira

Back to Top ↑

swarm

Eclipse Run Swarm

This will just quickly show you how to run a Wildfly Swarm application in Eclipse and also allow you to easily run the debugger.

Back to Top ↑

jboss

Eclipse Run Swarm

This will just quickly show you how to run a Wildfly Swarm application in Eclipse and also allow you to easily run the debugger.

Back to Top ↑

3D Printer

Back to Top ↑