MariaDB: Fix “Can’t read dir of ‘/usr/local/etc/my.cnf.d'” on OSX


Fixing Git: refusing to merge unrelated histories

I have a new project and I add git repo later on after the project finished.
After setup remote repo to my project, I got this kind of error when pulling data from the repository.

fatal: refusing to merge unrelated histories

The problem fixed by adding this argument to git command “–allow-unrelated-histories”.

$ git pull upstream master --allow-unrelated-histories


Comment And Uncomment Lines in Vim

I used to use IDE and I’m sure all of you familiar with command Ctrl + / or Cmd + / to add comment to your codes.

And here is how to bring that magic to VIM. Put these following lines to your .vimrc

" Commenting blocks of code.
autocmd FileType c,cpp,java,scala let b:comment_leader = '// '
autocmd FileType sh,ruby,python let b:comment_leader = '# '
autocmd FileType conf,fstab let b:comment_leader = '# '
autocmd FileType tex let b:comment_leader = '% '
autocmd FileType mail let b:comment_leader = '> '
autocmd FileType vim let b:comment_leader = '" '
noremap ,cc :silent s/^/=escape(b:comment_leader,'\/')/:nohlsearch
noremap ,cu :silent s/^\V=escape(b:comment_leader,'\/')//e:nohlsearch

Now you can select your text and type ,cc to comment and ,cu to uncomment.


Adding Sublime Text Command in OSX Terminal

Create a symbolic link from sublime text installation.

$ ln -s "/Applications/Sublime" /usr/local/bin/subl

Then you can use this command to open text file or folder.

$ subl .  # Open current directory
$ subl path/to/file.txt