Outside Links collection

Sometimes you find just the right resources that fulfill certain need and nothing much should be added to them, in those cases I will just collect them on this page and add short comment why is this so.

Xdebug with VSCode and DrupalVM

After installing xdebug as extension to VS Code there is simple config you need to do to make it work with DrupalVM and debug. Create debug profile in standard VS code way and add this

Add JS code to header tag of html

Reading docs about drupal_add_js you might think you can add JS to header of html, but only thing you can choose is header or footer of your theme (as region), to add JS to header tag, you need to use 

Properly setup redirects from www to non-www on nginx

In many online tutorials you will find just few lines like 

server {
    server_name www.example.com;
    return 301 $scheme://example.com$request_uri;
}

but actually you need much more, you need to include SSL certificates, otherwise you will get message about insecure site so you should have this

How to encode json with drupal_http_request in drupal 7

In lots of places you will see how to use drupal_http_request with drupal_http_build_query used on data, which is fine if you want to build regular query data (like the ones you have in URLs when using GET) but if you want to send JSON, you shouldn't use that, instead you need  json_encode function on data.