Using Windows 10? Have a look here

Ensure you check this link if you use Windows 10 and an SSD hard disk on your system

Mark, Copy, Paste in vim

Found an interesting link for marking a certain portion of text, and to copy & paste it in the same file.

Clipboard copy

As a follow up to the previous article on setup of VNC server and client, I believe that it would be very easy to copy and paste between the client and the server windows. Hence I found this link that can help you setup exactly that.

FreeBSD, VNC, Gnome, et. al.

Some of us use Windows as our work environment, while some of us use GNU/Linux. And yet, some of us use FreeBSD. Now assuming you are to ssh to your remote Linux or Unix server with your account and work, the most popular option is to use Putty. However the major disadvantage of an SSH session is that they are non-persistent. Hence once you restart your PC or there is a change in the network, your Putty session has to be restarted, which means you get a fresh shell/terminal and you might be lost as to where you stopped the last time.

Now fret not, since there is a better way. The option is to use VNC or NoMachine or similar tools. What these do is that there is a server running on your remote session (Linux/BSD) in this case and there is a client/viewer application on the machine on which you work on. The client-server application work such that the server transmits graphical information (i.e. each pixel of your remote session) to the client which is displayed to the user. Cool right! It is something similar to Microsoft Remote Desktop, though I have no idea if they work in the same way!

Now normally your FreeBSD machine or VM would just have console access without any GUI. So the first step is to enable Gnome (or KDE) on your FreeBSD VM. Connect to your VM using Putty, and compile XOrg first.

cd /usr/ports/x11/xorg
make install

Once this is completed, repeat the same for


under the x11 folder.

Similarly if you find any other apps missing on your FreeBSD, just google for the ported source code and compile and install the same.

Ex. vim can be found at /usr/ports/editors/vim

In case you come across a situation where the installation requires any file and its not able to find it through any of its online sources, you will need to copy the file to folder directed, which is usually


You can download the necessary file on you working PC,

is a popular portal to download the missing files, though there are plenty of others.

Use WinSCP to copy the file to your FreeBSD VM. Download and install WinSCP on your working PC, specify the IP address of you VM in WinSCP for an SCP session, and provide your credentials. Once WinSCP starts, you can just copy paste files to your remote VM/machine using your mouse!


Then head over to your home directory on your remote machine, and edit the file


and add the below lines

/usr/local/bin/gnome-session &

Restart your remote machine/VM and proceed to start the VNC server with the following command.

vncserver -geometry <width>x<height>

You will be provided a URL which you can copy and paste in your local PC’s VNC viewer. You will be prompted to set a password on your first login (which you will need for every login) and viola, you have a GUI based remote VM/machine based on FreeBSD.

FreeBSD usually defaults to C Shell, hence make any changes to the shell config in the file




may need to be edited to enable few things at the system startup.



Outlook Notifications

Most of us rely on MS Outlook for our e-mails, mainly at work. And if you would like to have a clutter free Inbox, and that is where Outlook rules come to the rescue. But there is one caveat, once a rule runs in the background and certain e-mails are directed to different folders instead of Inbox, you stop getting notifications on your desktop for new mail arrival. Well, there is a workaround for this, and it is to create another rule for all incoming messages with an action to display a desktop alert. Have a look at the below link for a step-by-step tutorial on how to enable this under the section “Configure the Mail Alert to monitor al folders; not just the Inbox”.

Nitty Gritties of variables and functions

Declaration and Definition

In simple terms, the main difference between declaration and definition is that declaration mentions the type and structure of a variable or a function. Whereas definition allocates memory for a variable or function.

int add(int a, int b);

is a function prototype and is a function declaration. This line has not allocated any storage for the function in the code segment of the program.

int add(int a, int b)
    return a+b; 

is a function definition for which storage is allocated in the code segment of the program.

Similarly it is possible to declare or define variables.

int a = 10;

int b;

Now in this case, both the above statements are definitions, the only difference being that a is initialized with value 10 whereas b has no initial value. It means both have storage allocated in the data segment of the program. However if you want to specify a variable declaration without allocating memory on the data segment, you have to prefix the extern keyword.

extern int c;
extern int d = 10;

If the variable is prefixed with extern and has no initializer, it is a variable declaration. However explicitly initializing the external variable with a value becomes a definition, which means storage is allocated for it. Hence in the above statements, c is a declaration and d is a definition with storage allocated.

Now comparing the function and variable declaration, you might be wondering why there is no extern prefix for a function declaration. The fact is that extern keyword is automatically pre-appended to a function declaration even if the user doesn’t specify it.

int add(int a, int b);
extern int add(int a, int b);

Hence the add declaration written by the programmer is automatically upgraded to a declaration with extern prefix by the compiler.

Now coming to the scope of variables and functions, the following always holds:

  • Function and variable declarations have external linkage, i.e. they are visible outside the file they are declared in. (They have ‘extern’ prefix, remember)
  • Function and variable definition have internal linkage, i.e. they are visible only in the file they are defined.


The const keyword in C/C++ specifies whether the variable/object can be changed or not. If it’s a const in a function, it just means that the variable or object may not be changed. The const keyword mentioned after a function definition or declaration takes it a step further. It means that the function may not modify any variable or object in its definition.

However in C++, const_cast casting can be used to cast away the const’ness of the variable and allow it to be changed. This however means that the programmer is surely knowing what he/she is doing with the variable.

If however the programmer is sure that the variable might be changed in a const function, it may be mentioned as mutable. It simply means that the variable or object may be changed in a const function.

Constant Folding

Constant folding is a concept in C++ where the value of a const variable is directly entered in the symbol table during compilation and the variable is not used. This is a compiler optimization only in C++. Do note that storage is compulsorily allocated for const in C.

So what about the scope of const variables? The following statements hold in this case:

  • In C++, const variables have internal linkage, mainly because they are folded and no storage is allocated for them in the data segment.
  • In C++, const variables which have a declaration using extern, have external linkage, because usage of extern keyword makes it visible outside the program file, hence storage is allocated in the code segment.
  • In C, const variables always have storage allocated in the code segment and have external linkage.


Now when a novice programmer is asked the question, what is the use of a static variable, the reply usually is “It is used when the value of the variable has to persist across function calls”

Now when a variable is defined in a function, it is stored in the stack of the function call. So how does a variable value persist if the function is called repeatedly? Shouldn’t the function stack be pushed and unwound based on each function call? The answer here is that static variables or functions are never part of a function stack. They are stored in the global variables area of the program and this is how the value persists, this is how they can be accessed directly without a class object. The only difference is that when a variable in a function is static, its location is that of global variables, but its scope is confined only to the block where it is defined.

Hence the lifetime of static variables or functions is the lifetime of the file it is present in. It also means, destructors of static objects are called when the program ends and not when the function in which it is defined exits!

Reference:┬áThinking in C++ – Bruce Eckel