C++ mongodb development with nvim or Visual Studio Code in Fedora Linux

I watched this interesting Video from C++ creator Bjarne Stroustrup:

Learning and teaching modern C++.

In this video, Bjarne mentions what hard is to start interesting projects in C++ such as GUIs and Database development mainly because of lack of tools easy to use, specifically at 37:50 he stresses that for his undergrad students, when trying to do GUI development “the greatest problem was to get the GUI library installed”. “It is painful”.

Historically, C or C++ development has been difficult, add different compilers, operating systems, libraries, build systems and tools all of them different between them.

In this post I did a “quick” exercise to tests those sentences. My first try was to setup an environment to develop C++ with GTK+, spoiler alert: It was not quick, it was not easy even for me having experience in the C/C++ world. My second try was with mongodb library in Fedora Linux. In this post I will show the setup I have to work and be more productive with this “kind” of development. The first challenge was to get an editor providing intellisense auto completion and source code browsing

In previous posts I showed how to setup Neovim to provide C++ intellisense using Programming Language Server (PLS) with Coc plugin. I did not realize that for third party libraries you need to do further setup.

There are 2 ways to use intellisense for third party libraries with PLS and Coc plugin: clangd and ccls. I tried with ccls and I was not able to make it work, so I stuck with clangd. After many tries I got to use Intellisense with Neovim for mongodb libraries

Nvim coc-clangd. MondoDB intellisense..

I did the same for Visual Studio Code:

Visual Studio Code. MongoDB intellisense

I have used most of the time vi for code editing, but now we have more options, so I setup both nvim and Visual Studio Code. Nvim I like to use it for quick browsing, code editing. For something more complex I would use Visual Studio Code Editor.

Visual Studio Code vs Nvim advantages:

What I really like from Visual Studio Code is that I can jump to system libraries and third parties source code definition. I can do similar with ctags or rtags in Neovim but in Visual Studio Code is out of the box.

Extensions are more friendly in Visual Studio Code than the ones for the Coc plugin in Neovim. Setup is harder in Neovim.

Debugging is also out of the box with Visual Studio Code. When using only vim I’m used to use gdb.

C++ debugging with gdb. mongocxx::uri

How it goes with Visual Studio Code integrated debugger:

C++ debuging with gdb, but inside Visual Studio Code!

Setting up libraries and IDE for third party libraries in C++ is not easy. That is the C++ world! For the libraries setup

sudo dnf install mongo-c-driver-devel
sudo dnf install mongo-cxx-driver-bsoncxx-devel
sudo dnf install boost-devel
sudo dnf install mongo-cxx-driver-devel

To compile:

g++ -g --std=c++17 mongodb_main.cpp `pkg-config libmongoc-1.0 --cflags` `pkg-config libmongocxx` --cflags --libs -o mongodb_mai

For the Neovim setup, Install COC and coc clang extension. Install clangd Language Server of course as well.

For Neovim I had to create compile_commands.json file.

compile_commands.json

For Visual Studio I had to create c_cpp_properties.json:

c_cpp_properties.json

Enjoy!

DevOps Testing with Ruby RSpec Selenium and Capybara using Docker-Compose

I watched LinkedIn training “DevOps Foundations” with Carlos Nunez instructor. In section 3 he shows the use of RSpec and Capibara. I’ll extend a little bit as that section assumes a lot of things from the instructor side.

Step number 1 launches a Docker container with the Nginx web server. That is ok. Then he starts a second container which is Selenium.

Both containers use docker-compose. Nginx is launched with a Docker file. Selenium is not, instead just a raw image is downloaded.

Instructor launches a third container, which contains Rspec and Capybara. This container is specified again with a docker file

What is omitted is an explanation of Selenium, Capybara and RSpec. So let’s start.

Selenium is a web browser instance with an API tailored to be run from a container. The image used here also has a VNC server which is useful when using containers.

Capybara is a Test Framework with support to multiple languages.

RSpec is the ruby DSL.

Why we are using this combo is not explained.

Let’s see my containerfs launched with docker-compose:


Customize your terminal with Oh-my-zsh for Fedora

I have customized my Linux Terminals. Terminals I use are Terminator and Terminology. I use zsh Shell and Oh-My-Zsh framework to add some cool functionality.

For instance, a cool prompt with git integration. I see a git notification in the prompt telling me that 1 file was modified and 11 files are not tracked. It is a summary from git status.

Cool command line plus git integration.

Nice Icons showing folders and file types …

Cool icons associated to files

Tab completion. Type tab key to complete path. You can use arrow keys to navigate files and folders.

Tab completion and navigation.

Command line Fuzzy finder. Type Ctrl-r in terminal then type command to look for. You will get a list of previous commands typed before associated to search.

Type Ctrl-r then pattern. You have option to navigate with arrow keys

Plugins. The git plugin, for instance, shows me all the options for git when typing git then Tab Tab.

Git plugin shows git sub commands.

Use it with tmux!

Tmux adds nice footer

Quick steps to achieve this setup.

Install zsh

Install nerd and awesome fonts

Install oh-my-zsh

Install powerlevel10k

Install syntax highlighting and autosuggestion

install fzf then run install

More about fzf here:h