Enabling variable expansion on Linux HPC

Remember how we can auto complete the bash commands on terminal? and how double tab gives you all available options for a matching pattern? Saves a lot of time typing and searching for a command in Linux and increases your efficiency. It is also possible to do this with the variables, whether env (preset variables) or the custom variables that are initiated by the .bashrc file. To achieve this, simply add these 2 lines in your .bashrc file


shopt -s direxpand
shopt -s cdable_vars

How to move all CPAN installations from one perl version to another?

cpan as a built-in option for this purpose. First, create a bundle of all existing packages. For this, load the older perl version which will be the source for all cpan modules:

module load perl/5.22.1
perl -MCPAN -eautobundle

This will print all the CPAN modules that it puts in the bundle. Once complete, you’ll see:

Wrote bundle file
    /path/to/current/dir/Snapshot_2017_05_09_00.pm

Now, unload the older perl and load newer perl:

module purge
module load perl/5.24.0

And install modules:

perl -MCPAN -e 'install Bundle::Snapshot_2017_05_09_00'

It should install all CPAN modules in the bundle!

How to prevent SSH from disconnecting if it’s been idle for a while

If you’re using HPC, chances are that your University/Sysadmin has a policy about how long you can stay inactive with the established SSH connection. If you are frustrated with this automatic disconnections, here is a way to prevent this. You can either:

ssh -o "ServerAliveInterval 60" -X username@server.edu

or create a file in ~/.ssh/config with the following line:

ServerAliveInterval 60

This will enable ssh client keepalives. The above line will send an ssh keepalive every 60 seconds that will prevent network devices from considering the session as idle.

Source: https://superuser.com/a/699680/173980

How to insert word like comments in Overleaf/Latex documents?

There is a todo package that can be used for this purpose. Simply add these lines to your document and you can leave comments with \todo commands.

\usepackage{geometry}

The above package will be used in most documents, so no need to add it if its already there

\usepackage[colorinlistoftodos]{todonotes}

by default it will be on right, to put it on left (if you don’t have room beacuse of margins) use

\reversemarginpar

For commenting

\todo{this is an example comment}

Comments will be show as follows:

2017-08-17 21_17_08-Overleaf.png