gpg: can’t connect to the agent: IPC connect call failed

If you are getting this error on Windows WML Ubuntu 20.04, then the shortest answer is that you made a mistake and should’ve installed 18.04 LTS instead ( at least for now – because this won’t be the last issue you run into .. )

Should you still insist on using 20.04, then all you have to do is uninstall the gpg that comes installed by default and install gnupg1 package instead

sudo apt remove gpg
sudo apt install gnupg1

Laravel in subdirectory – nginx vhost setup

Big credit goes to Hamid Naghipour on stackoverflow for this helpful piece of code https://stackoverflow.com/questions/27785372/config-nginx-for-laravel-in-a-subfolder

Let’s say we have a domain test.sk and we want to install 2 separate laravel installations in subfolders /2018 and 2019/.

Here is a basic setup that works


server {
    listen 80;
    server_name test.sk;	
    root /storage/web/test;


	location /2018 {

		alias /storage/web/test/2018/public;
		try_files $uri $uri/ @nested2018;
	        satisfy any;
	        allow all;
	        index index.php;

		location ~ \.php$ {
	        try_files $uri =404;
	        fastcgi_pass 127.0.0.1:9000;
	        index index.php;
	        fastcgi_index index.php;
	        fastcgi_param SCRIPT_FILENAME $request_filename;
	        include fastcgi_params;
		}
	}

	location @nested2018 {
		rewrite /2018/(.*)$ /2018/index.php?/$1 last;
	}


	location /2019 {

		alias /storage/web/test/2019/public;
		try_files $uri $uri/ @nested2019;
	        satisfy any;
	        allow all;
	        index index.php;

		location ~ \.php$ {
	        try_files $uri =404;
	        fastcgi_pass 127.0.0.1:9000;
	        index index.php;
	        fastcgi_index index.php;
	        fastcgi_param SCRIPT_FILENAME $request_filename;
	        include fastcgi_params;
		}
	}

	location @nested2019 {
		rewrite /2019/(.*)$ /2019/index.php?/$1 last;
	}


    location / {
    	rewrite ^(.*)$ https://$server_name/2018$1 permanent;
    }

}

Sort files by time modified

If you are editing multiple files on remote server and then you need to produce a release list, e.g. list of modified files, use this

find . -type f -printf '%T@ %P\n' | sort -n | awk '{print $2}'

You will get the latest files at the bottom of produced list.

Make Git ignore Mode changes

Sometimes I get tons of changes when doing git diff – even though I haven’t changed any of those files. This is then causing merges and issues when pulling new commits.

Solution that always works for me is to ignore change to file modes. E.g. permission changes.

git config core.fileMode false

Insightly CRM API can’t add a new TAG

If you are one of the unlucky ones in need of working with Insightly API, you have probably noticed there’s no way to create a TAG under Contact endpoint.

If you follow the documentation, you probably do a CURL request similar to this:


        $username = 'xxxxx'; // api key
        $ch = curl_init('https://api.insightly.com/v3.0/Contacts/');

        curl_setopt($ch, CURLOPT_HTTPHEADER, [
            'Content-Type: application/json',
            'Authorization: Basic '. base64_encode($username)
        ]);

        $dataString = json_encode(array(
            'FIRST_NAME' => 'First',
            'LAST_NAME' => 'Last',
            'EMAIL_ADDRESS' => 'test@test.sk',
            "TAGS" => array(
                array("TAG_NAME" => "TEST")
            )
        ));

        curl_setopt($ch, CURLOPT_POST, 1);
        curl_setopt($ch, CURLOPT_POSTFIELDS, $dataString);
        curl_setopt($ch , CURLOPT_HEADER, 1);
        curl_setopt($ch , CURLOPT_TIMEOUT, 30);
        curl_setopt($ch , CURLOPT_RETURNTRANSFER, TRUE);
        $return = curl_exec($ch );

        $header_size = curl_getinfo($ch, CURLINFO_HEADER_SIZE);
        $header = substr($return, 0, $header_size);
        $body = substr($return, $header_size);

And all you get in return is 400 Bad Request!
Even if you try to update existing Contact using https://api.insightly.com/v3.0/Contacts/{ID}/Tags endoing you won’t have any more luck.

The solution is simple – go back to 2.3 endpoints – the exact same post data works on 2.3!

Insightly has done a really poor job on their API ..

Bottom line – change https://api.insightly.com/v3.0/Contacts/ to https://api.insight.ly/v2.3/Contacts/