integrate matomo in your Angular project

I wanted to share the easiest way to integrate in an angular project (tested with angular 7) with zero external package.

Add following structure to angular project

├── analytics
│  ├── conf
│  │  ├── matomo.conf.local.js
│  │  ├── matomo.conf.staging.js
│  │  └──
│  ├── matomo.conf.js
│  └── matomo.js

Put your matomo provided script in matomo.js and :
– delimit with: if(matomoEnabled){ ... }.
– replace the matomo url with variable matomoUrl.
– replace the matomo site id by variable matomoSiteId.

if (matomoEnabled) {
  console.log("init matomo { matomoEnabled: " + matomoEnabled + ", matomoUrl: " + matomoUrl + ", matomoSiteId: " + matomoSiteId + " }");
  var _paq = window._paq || [];
  /* tracker methods like "setCustomDimension" should be called before "trackPageView" */
  (function() {
    var u=matomoUrl;
    _paq.push(['setTrackerUrl', u+'matomo.php']);
    _paq.push(['setSiteId', matomoSiteId]);
    var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
    g.type='text/javascript'; g.async=true; g.defer=true; g.src=u+'matomo.js'; s.parentNode.insertBefore(g,s);
} else {
  console.log("matomo disabled");

In matomo.conf.js:


Copy matomo.conf.js content to matomo.conf.staging.js and and fill with environment values.

Then import matomo.js and matomo.conf.js with angular.json:

"angular": {
  "build": {
    "options": {
      "scripts": [

Finally use file replacements in angular.json:

"configurations": {
  "prod": {
    "fileReplacements": [
        "replace": "src/analytics/matomo.conf.js",
        "with": "src/analytics/conf/matomo.conf.local.js"

enable CORS with spring

CORS could be enabled with spring programmatically. One of the ways to enable it is to add mapping to CorsRegistry like so:

public WebMvcConfigurer corsConfigurer() {
  return new WebMvcConfigurerAdapter() {
    public void addCorsMappings(CorsRegistry registry) {

migrate local docker images to a remote docker host

A. New remote host
– install docker
– setup simple configuration to let docker daemon be accessible from other machines:
Edit /etc/default/docker, and add following line

DOCKER_OPTS=”-H tcp://″

– restart docker daemon

sudo service docker restart

With systemd systems (trusty and vivid), we must add new file :
with following content:

ExecStart=/usr/bin/docker -d $DOCKER_OPTS

And then restart socker.

Now, when trying :

docker ps

we’ll got error:

Get http:///var/run/docker.sock/v1.19/containers/json: dial unix /var/run/docker.sock: no such file or directory. Are you trying to connect to a TLS-enabled daemon without TLS?

That’s because docker client try to connect to file socket by default. So, from now, we must specify which host to connect to when running docker client. Like so :

docker -H localhost:2375 ps
# or
docker -H ps
# or
simply docker -H :2375 ps

Ok, but it’s annoying to specify the host all the time !
So, the solution is to define an environment variable DOCKER_HOST:


then we can just run :

docker ps

B. Local host

We must set environment variable DOCKER_HOST like following (assume host machien ip is


C. transfer images from local docker host to remote docker host
Now, to move all local images to the new docker host, we have to make it in three steps :
1. under local machine: export images as tar files

docker -H “” save -o /tmp/myimage.tar myimage

2. transfer tar files from local machine to the remote one (with scp for example)

scp /tmp/myimage.tar user@

3. under remote machine: load images

docker load -i /tmp/myimage.tar

Hope this help

nginx as reverse proxy

I’m working on dockerizing several projects with docker-compose. And, I automated checkout from git repository and building projects,
One of maven projects inherits from parent pom the url of nexus repository. And unfortunately, nexus server was moved to a new url. This fails maven build, because it can’t download artifacts from old nexus url.

While I have no time to fix nexus url in parent pom and recompile all depending projects. And while I’m rushed to run and validate my docker-compose. I’m looking for rapid solution.

We can simply use hosts to redirect old url to the new one. But in my case, it’s not possible because the old url contains a port number.

new url:

So, I use nginx as reverse proxy to solve problem:

Step1: install nginx

$ sudo apt-get install nginx

Step2: nginx configuration
create /etc/nginx/conf.d/witr.conf with following content

server {
listen 8080;
location / {
proxy_redirect off;

Step3: locally redirect server name
edit /etc/hosts and add new entry

Step4: restart nginx

service nginx restart

Finally : run my automated build. On download, maven will ask oldurl:8080. hosts will redirect to nginx. Nginx will redirect to newurl. And maven will be able to download artifacts and build will not fail.

known trouble when using aapt

You have trouble using aapt. And following error is raised : Cannot run program “/opt/Android/Sdk/build-tools/22.0.1/aapt”: error=2, No such file or directory.
You are probably using aapt which is a 32bit application under a 64bit running ubuntu.
To get it working, simply install :

sudo apt-get install lib32stdc++6 lib32z1

access to a dockerized apache from local mochine

Get ubuntu

docker pull ubuntu:vivid

Start ubuntu container

docker run -ti ubuntu:vivid /bin/bash

Install apache

root@54a954be4ca3:/# apt-get install apache2

Type CTRL+P then CTRL+Q : this will exit the shell without killing the process
Now in the local machine, check out the container name

docker ps

Save the container with its apache installed (suppose your container name is happy_pasteur)

docker commit -a “witr ” -m “install apache2” happy_pasteur witr/myapache

Stop the container

docker stop happy_pasteur

Start apache in new container “myapache” and bind ports

docker run -d -p 9999:80 witr/myapache /usr/sbin/apache2ctl -D FOREGROUND

Finally browse http://localhost:9999

VT-x is being used by another hypervisor .. Please disable the KVM

while starting my VM using vagrant, I have following error :

The guest machine entered an invalid state while waiting for it
to boot. Valid states are ‘starting, running’. The machine is in the
‘poweroff’ state. Please verify everything is configured
properly and try again.

If the provider you’re using has a GUI that comes with it,
it is often helpful to open that and watch the machine
, since the
GUI often has more helpful error messages than Vagrant can retrieve.
For example, if you’re using VirtualBox, run `vagrant up` while the
VirtualBox GUI is open.

So, I edit my Vagrantfile and uncomment gui

   config.vm.provider "virtualbox" do |vb|
     vb.gui = true

Then I start my vm using VirtualBox. I have the following error :
VT-x is being used by another hypervisor … Please disable the KVM

what to do ?
1. see if kvm is running and is used

witr@serv:~$ lsmod | grep kvm
kvm_intel 143592 3
kvm 459835 1 kvm_intel

here kvm is used by one consumer (kvm_intel) and kvm_intel is used by 3 consumers.

2. stop kvm consumers
In my case it’s the android emulator i have launched from AndroidStudio which causes problem. I stop emulator.

3. restart vm
that’s all