Avoid “permission denied” error when using docker in docker

When having the following message:

Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Get http://%2Fvar%2Frun%2Fdocker.sock/v1.38/images/json: dial unix /var/run/docker.sock: connect: permission denied

you need to assure that the user running in the container has the correct uid and gid than a user on the host with access to docker. That means that into the container  the user must belong to the docker group in the host.

You can use the docker parameter –group-add to the docker command to enforce that the user running in docker is also added into the given GID

docker run -d -v /var/run/docker.sock:/var/run/docker.sock -p --group-add 999 ...

Automatic update of js and html files while developing war applications

To automatic update client contents of a war app without to redeploy, it is just needed to copy changed files into the correct exploded war location.

To automaticallay perform the copy just use:

onchange 'path/to/watched/src/' -- cp -Rf path/to/watched/src/ /path/to/exploded/war/files

you can install onchange with npm:

npm -g install onchange

Solve Intellij Idea “Finished, saving caches” latency

Just include the following line in your /etc/hosts file:       localhost     <your hostname goes here>.local

And for IPv6 resolving, the same:

::1             localhost     <your hostname goes here>.local



Replace to upper/low case with regex

\U$1 will set all chars contained into group $1 to upper case.

\U$1 will set the first char of the group $1 to upper case.

\L$1 will set all chars contained into group $1 to upper case.

\l$1 will set the first char of the group $1 to lower case.


SOME_TEXT against regex _([a-z]+) replaced by \l$1 will produce SOME_tEXT

SOME_TEXT against regex _([a-z]+) replaced by \L$1 will produce SOME_text



Capturing arguments with mockito

EncryptedFileInfo info = cut.storeEncryptedFile(encryptionSecret, plainContents, fileName);

ArgumentCaptor<byte[]> argument = ArgumentCaptor.forClass(byte[].class);

verify(cut).createFileAndAdd(eq(fileName), argument.capture());
byte[] encryptedContent = argument.getAllValues().get(0);

Where intercepted method is:

void createFileAndAdd(String fileName, byte[] encryptedContents);