Setup plugin manager for vim on fedora 28

Vim is one of the tool that must have in any unix like system. One of the reason for using vim is the customization and the plugins that can be used depending on the needs. To install plugins on vim, I’m using vim-plugin from junegunn/vim-plug.

Check vim version

In fedora vim already installed, but you might want to check the version just in case yours behind of the newest version.

$ vim --version

Update vim

Update vim to the newest, for better experience

$ sudo dnf update vim

Setup plugin manager for vim

Setting up vim-plug, this will be downloaded the plugin and put it inside ~/.vim/ autoload directory:

$ curl -fLo ~/.vim/autoload/plug.vim --create-dirs \
    https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim

Open ~/.vimrc, and put these lines at the bottom of the file. Between the lines of call plug#begin(‘~/.vim/plugged’) and call plug#end(), are the plugins that you want to install.

...
...
call plug#begin('~/.vim/plugged')
Plug 'junegunn/vim-easy-align'
Plug 'itchyny/lightline.vim'
Plug 'scrooloose/nerdtree'
Plug 'tpope/vim-fugitive'
Plug 'airblade/vim-gitgutter'
Plug 'Valloric/MatchTagAlways'
call plug#end()

Save, and restart vim config without restart:

:w
:so ~/.vimrc

Update plugin

After the vim-plug has been setup, now we can easily install these plugin that has been listed inside ~/.vimrc by this command:

:PlugInstall

Finally, let vim-plug installing these plugins

All set!

 

 

Install TeamViewer On Fedora 28, Easy setup

Installing rpm package can be tricky, sometimes dependecies that required are not met.

I’ve experienced this when installing TeamViewer for fedora 28. Here’s just another snippet to installing the TeamViewer on fedora 28 with nice and easy.

Download teamviewer from the source:

$ wget https://download.teamviewer.com/download/linux/teamviewer.x86_64.rpm

Install the dependencies and the rpm target:

$ sudo dnf install qt5-qtwebkit qt5-qtquickcontrols -y
$ sudo rpm -i teamviewer.x86_64.rpm

How to delete stucked Route53 zone created by ECS service discovery

It happens when I tried to delete the NS that created by ECS service directory, then this error shows up:

The resource hostedzone/Z1OWcan only be managed through servicediscovery.amazonaws.com (arn:aws:servicediscovery:us-east-1:561660628307:namespace/ns-c6lvlchj2gbcsobc)

If there are services hanging around the in the NS you can’t delete then you could try:

$ aws servicediscovery list-services
$ aws servicediscovery delete-service --id=
$ aws servicediscovery delete-namespace --id=

pip error after upgrade: ImportError: cannot import name ‘main’

Sometimes pip can be really sucks, after upgrade the pip version, then you call it afterwards, it will fail somehow.

$ pip install --user --upgrade pip
Collecting pip
  Using cached https://files.pythonhosted.org/packages/0f/74/ecd13431bcc456ed390b44c8a6e917c1820365cbebcb6a8974d1cd045ab4/pip-10.0.1-py2.py3-none-any.whl
Installing collected packages: pip
Successfully installed pip-8.1.1
You are using pip version 8.1.1, however version 10.0.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
ImportError: cannot import name 'main'
$ pip
Traceback (most recent call last):
  File "/usr/bin/pip3", line 9, in 
    from pip import main
ImportError: cannot import name 'main'

The problem is easily can be resolved by doing this:

$ hash -d pip

NerdTree command cheatsheet

Install NerdTree : http://chrisstrelioff.ws/sandbox/2014/05/29/install_and_setup_vim_on_ubuntu_14_04.html

ctrl+ww move cursor back to list directory
gt next tab
gT previous tab

Enable html syntax:

au BufReadPost *.ezt set syntax=html

Nerdtree setup alike:

let g:netrw_banner = 0
let g:netrw_liststyle = 3
let g:netrw_browse_split = 4
let g:netrw_altv = 1
let g:netrw_winsize = 25
augroup ProjectDrawer
  autocmd!
  autocmd VimEnter * :Vexplore
augroup END

Open vertical term :vert term
Resize vertical term :vert resize +5

Alembic set autogenerate model

Alembic create revision autogenerate with comment:

$ alembic -c dev.ini revision --autogenerate -m "adding some tables"

Check upgrade script:

$ cat alembic/versions/123xxx_xxx.py

Alembic upgrade metadata with version

$ alembic -c dev.ini upgrade 123xxx

Alembic upgrade metadata with latest version

$ alembic -c dev.ini upgrade head

 

Setup Systemd Service on Ubuntu 16.04

$ sudo vim /etc/systemd/system/myservice.service
[Unit]
Description=Run the service

[Service]
User=ubuntu
# change the workspace
WorkingDirectory=/usr/local/src

#path to executable. 
#executable is a bash script which calls jar file
ExecStart=/usr/local/src/somescript

SuccessExitStatus=143
TimeoutStopSec=10
Restart=on-failure
RestartSec=5

[Install]
WantedBy=multi-user.target
$ sudo vim /usr/local/src/somescript
#!/bin/sh

java -jar /some/file.jar
sudo systemctl daemon-reload
sudo systemctl enable myservice.service
sudo systemctl start myservice
sudo systemctl status myservice

 

Install MySQL on Ubuntu And Skip the Password Prompt

When you install mysql on Ubuntu (I use 16.04), it requires you to fill the admin password for the first time before finishing the installation. This prompt will wait the user input until you fill the password.

This trick is very helpful if you want to install mysql in Dockerfile, and skipping the password prompt:

$ export DEBIAN_FRONTEND=noninteractive
$ sudo -E apt-get -q -y install mysql-server