SpaceBox – Docker Development Box on SpaceVim

I have created SVIM which is a dockerized version of VIM. However, some of the most imporant plugins I was using is no longer maintained for VIM but are compatible and focussed on NVIM. Thus, I switched to SpaceVim. Despite there is an official Docker of SpaceVim, it is lacking the support of languages as required tools are missing in the docker particularly Go lang hints. Hence, I created my own version of SpaceVim and I ensured that all the stuff I use is working properly. If you are PHP developer, JavaScript developer, Golang Coder or even if you create simple HTMLs – you have everything you need. I haven’t focused on Java or alike line languages like scala or for that matter Objective C. This is ideally for the Web Developer and not for the Mobile App Developer. Though, feel free to send a PR. I am calling it SpaceBox – a dockerized SpaceVim

Why should you use SpaceBox?

How to use it?

alias vbox='docker run -ti -e TZ=Asia/Kolkata -e DISPLAY=$DISPLAY -v /tmp/.X11-unix:/tmp/.X11-unix -e TMPDIR="/tmp/" -e TERM=xterm -e GIT_USERNAME="Your Name" -e GIT_EMAIL="YourEmail@Stealer.com"  --rm -v /etc/timezone:/etc/timezone:ro -v $HOME/tmp/:/tmp/ -v ~/.ssh:/home/spacevim/.ssh -v $(pwd):/home/spacevim/src varunbatrait/spacebox'

Enable CORS with Credentials in Nginx

You must have noticed that when enable cors with “*”, it doesn’t allow credential to pass. Solution to this is pretty simply, you just need to list all of your domains in configuration. My approach is to have a separate file for each domain.

Directory Structure:

./conf/site-enabled/<site-name>
./conf/cors/<site-name>

Configuration

Assuming that site-name is webapplicationconsultant.com and I want to enable credentials for varunbatra.com along it itself – This is how it goes:

#./conf/cors/webapplicationconsultant.com


set $cors '';
if ($http_origin ~ '^https?://(varunbatra\.com|webapplicationconsultant\.com)') {
        set $cors 'true';
}

if ($cors = 'true') {
        add_header 'Access-Control-Allow-Origin' "$http_origin" always;
        add_header 'Access-Control-Allow-Credentials' 'true' always;
        add_header 'Access-Control-Allow-Methods' 'GET, POST, PUT, DELETE, OPTIONS' always;
        add_header 'Access-Control-Allow-Headers' 'Accept,Authorization,Cache-Control,Content-Type,DNT,If-Modified-Since,Keep-Alive,Origin,User-Agent,X-Requested-With' always;
        # required to be able to read Authorization header in frontend
        #add_header 'Access-Control-Expose-Headers' 'Authorization' always;
}

if ($request_method = 'OPTIONS') {
        # Tell client that this pre-flight info is valid for 20 days
        add_header 'Access-Control-Max-Age' 1728000;
        add_header 'Content-Type' 'text/plain charset=UTF-8';
        add_header 'Content-Length' 0;
        return 204;
}
#./conf/site-enabled/webapplicationconsultant.com

server {
	listen 443 ssl;
	server_name webapplicationconsultant.com;
....	
        location / {
                include "./../cors/webapplicationconsultant.com";
                try_files $uri @app;
	}
	location @app {
...
	}
}

Important Visuals Hacks in VIM

1. Numbering

VIM is not improved without custom configuration. It varies from a developer to developer but everyone will agree on having line-numbers.

set number

But do you know that you can move between lines by doing following:

: +2 ---> Two lines Below
: -2 ---> Two lines Above

Because of this and because of the fact that Y/D J/K all goes with numbers, you must be interested in showing numbers relative to the cursor.

set relativenumber
VIM Relative numbers!

2. Highlight Current Line and Column

If you are working in tabs/windows, it is a bit frustrating to mover your cursor every time just to find where are you typing! Following two lines will make your life a bit easier.

set cursorline        "highlight current line                                                                                                                            
set cursorcolumn      "highlight current column

3. Highlight Searches

Can you spot the difference between two searches? – Of course “set” is highlighted in the second screen. Here is how I did it:

set hlsearch
set incsearch