Author: adiyatmubarak

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

https://github.com/Homebrew/legacy-homebrew/issues/31760#issuecomment-60114392

Advertisements

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

Reference: https://stackoverflow.com/a/37938036/1936697

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.

Reference: https://stackoverflow.com/a/1676672/1936697

Adding Sublime Text Command in OSX Terminal

Create a symbolic link from sublime text installation.

$ ln -s "/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl" /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

Reference: https://stackoverflow.com/a/31771252/1936697