override and final in C++

override and final are two new qualifiers introduced in C++11. The use of these qualifiers is optional. They are meant to be used with virtual methods to show the intention of the method. The compiler uses these qualifiers to check if your intention matches the actual ground truth in your code and throws a compile error if it does not. Thus, it helps to catch bugs earlier at compile time.

  • When you specify override for a method, you are indicating to the compiler that this is a virtual method and it is overriding a virtual method with the same signature in one of the base classes that the current class inherits from. If the method is not inheriting from any virtual method with the same signature, the compiler throws an error. Thus if you made a mistake in the function signature while defining this method, you would not have caught it unless you used this qualifier.

  • When you specify final for a method, you are indicating that this is a virtual method and that no class that inherits from the current class can override this method. If any method tries to override this method in an inherited class, the compiler throws an error.

  • If override or final are used with non-virtual methods, the compiler throws an error.

  • These qualifiers are specified after the function input arguments and should be specified after const if the virtual method is a const method. If you put these qualifiers before a const, you will get a weird error with GCC that gives no hint that this is because of the order of qualifiers is wrong!

  • These qualifiers are to be specified only with the method declaration. If you try to use them with the method definition, the compiler will throw an error.

  • You can specify override final for a method, but it is the same as using final.

  • override is not allowed to be used with the base virtual method. This is for the obvious reason that the base virtual method is the first virtual method and it is not overriding any other method.

  • final can be used with the base virtual method. This can be used to specify that the first base virtual method cannot be overridden in any inherited class.

This code example shows how to use these qualifiers:


KAlgebra is a simple graphing calculator for Linux. It is a good replacement to using an actual graphing calculator. I find it useful to plot functions instead of using SageMath, which can be an overkill for just plotting.

  • It can be installed easily from Ubuntu repositories:
$ sudo apt install kalgebra
  • I usually just switch to the 2D plot mode and add my function. KAlgebra checks if the expression is correct as you type and indicates error. If expression is correct, then it shows the graph preview right below. If you press Enter after the expression, it is plotted in the main 2D plot window. More functions can be added by clicking the Add tab in the bottom-right corner.

  • As you move the mouse inside the 2D plot window, KAlgebra shows the X and Y coordinate values in the bottom-left corner. It also shows the tangent to the curve as you move your mouse along the curve.

Tried with: KAlgebra 15.12.3 and Ubuntu 16.04

Sensible plugin for Vim

Sensible is a super simple plugin for Vim by Tim Pope. It is nothing but a set of sensible settings for your vimrc. It is a great way to start off on a new system where you do not have access to your fully featured vimrc. I only wish he explained some of the choices he made for the options in this file.

If I have a local account on the remote or new computer, I find it far easier to just replicate my vimrc, and other dot files, using GNU Stow.

Selenium error on geckodriver


I updated Ubuntu packages, which included Firefox and I updated Selenium using pip3 cause that also depends on the Firefox version. But running my existing Python scripts that use Selenium popped this error:

FileNotFoundError: [Errno 2] No such file or directory: 'geckodriver'


Firefox now provides the geckodriver as a separate binary. You can download the version matching your OS and CPU here. Unzip the file and place the binary anywhere that is in your PATH. Your Python scripts should work now.


Tried with: Firefox 49, Selenium 3.0.1 and Ubuntu 16.04

Trailing slash in symbolic link

I recently noticed something strange when creating a symbolic link to a directory:

$ ln -s foo_dir/ slink_to_dir
$ ls -l
drwxrwxr-x 2 ashwin ashwin 4.0K 2016-10-05 21:37 foo_dir/
lrwxrwxrwx 1 ashwin ashwin    7 2016-10-10 21:47 slink_to_dir -> foo_dir//

Notice the double slash (one extra slash) in the destination of the symbolic link.

In fact, you can add multiple slashes and they all show up with one extra slash:

$ ln -s foo_dir/// slink_to_dir
$ ls -l
drwxrwxr-x 2 ashwin ashwin 4.0K 2016-10-05 21:37 foo_dir/
lrwxrwxrwx 1 ashwin ashwin    7 2016-10-10 21:47 slink_to_dir -> foo_dir////

Turns out that this is the standard working of the ln command. If you are pedantic, you can keep it clean by never specifying a slash when creating a symbolic link using ln:

$ ln -s foo_dir slink_to_dir

Anyway, even if you use the extra slashes they have no effect either since Unix (and Linux) allow and ignore the multiple slashes in a path.

Tried with: Ubuntu 16.04


Choqok is a microblogging client for KDE that supports Twitter and a couple of other microblogging services no one actually uses (identi.ca and GNU Social).

  • Installing it from a PPA is easy:
$ sudo add-apt-repository ppa:adilson/experimental
$ sudo apt update
$ sudo apt install choqok
  • Choqok is a very basic Twitter client. It supports multiple Twitter accounts, viewing your timeline, retweeting and tweeting.

  • By default only the latest 20 tweets are shown and new tweets are checked every 10 minutes. This can be increased in the settings.

  • It does autocompletion when typing Twitter handles, not just for folks you follow!

  • It does not show the number of retweets or likes of tweets.

  • Conversations can be viewed by clicking the rightmost up-arrow below the tweet (visible only if it is part of a conversation). The conversation opens in a new window.

Tried with: Choqok 1.5 and Ubuntu 16.04

EmojiOne Picker

I can finally stop complaining about the absence of a emoji picker for Linux. Now there is the EmojiOne Picker! It is a simple picker application based on the awesome emoji set of EmojiOne.

  • Installing from PPA is the easiest way to get it:
$ sudo add-apt-repository ppa:ys/emojione-picker
$ sudo apt update
$ sudo apt install emojione-picker
  • To use just type EmojiOne Picker at the Dash. Note that it takes a few seconds to load and finally settles down in the system tray area with a smiley face. Right-click on it to get the fully detailed list of emoji. Click on any one and it will be copied to your clipboard for easy pasting into any app or website.

  • In Settings, I like to choose the Low end computer mode which reduces the number of emoji and thus makes loading and usage of this app faster.

Tried with: EmojiOne Picker 0.1 and Ubuntu 16.04

How to autocomplete path in Vim insert mode

Vim path autocomplete in insert mode
Vim path autocomplete in insert mode

It is useful to be able to autocomplete a path to a directory or filename while typing code or script files. This helps in ensuring that there are no mistakes and the path is correct. Thankfully, Vim has an autocompletion feature for typing path in insert mode! It calls this feature as file name completion.

  • Ctrl-x Ctrl-f: This is the shortcut to autocomplete path in insert mode. Start typing a path (absolute or relative) and use this keyboard shortcut. You will see a dropdown menu filled with the next entries from the filesystem that can be used to fill the path.

  • Ctrl-n or Ctrl-p: Shortcuts to move up and down the entries in the autocomplete dropdown menu. If you move off the top or bottom of the dropdown menu, you get the empty entry.

  • Absolute path: Any path that you begin typing with a slash is autocompleted as an absolute path.

  • Relative path: This is any path that does not begin with a slash. They are autocompleted too. Note that they will use the directory that Vim was launched from (PWD) as the root.

  • Hidden files or directories: I found that this was autocompleted only if I typed the first period and then used Ctrl-x Ctrl-f.

Tried with: Vim 7.4 and Ubuntu 14.04

How to install and use Git LFS

Large File Storage (LFS) is an extension to Git to handle large files. This is usually used to store binaries or graphics or video game assets.

  • Install: The easiest way is to install a package from the LFS repository:
$ curl -s https://packagecloud.io/install/repositories/github/git-lfs/script.deb.sh | sudo bash
$ sudo apt install git-lfs
  • Use: To fetch the files from a remote repository to local repository and checkout a large file:
$ git lfs fetch
$ git lfs checkout foobar.bin

This replaces the foobar.bin which was a placeholder with the actual large file fetched from the remote repository (which should also have LFS support, like Github for example).

Tried with: Git 2.9 and Ubuntu 14.04

Trailing slash in rsync

RSync has some different and confusing behavior depending on whether you put a trailing slash on the source directory or not.

  • No trailing slash on source directory: this copies the source directory itself as a subdirectory into the destination directory.

For example:

$ rsync -a /some/path/foobar .
$ ls
  • Trailing slash on source directory: this copies the contents inside source directory into the destination directory.

For example:

$ rsync -a /some/path/foobar/ .
$ ls

You do not see such confusing behavior with cp or mv. I guess rsync has this because it is usually used for synchronizing the contents of two directories but it is also sometimes used to copy over directories.