How to find the public IP of your linux node without using an external DNS server

Without much ado:

#Get the public IP for the network in use
#This IP will be accessible through this gateway if the gateway is open to the Internet accessible from the Internet as well

#Get the gateway address
gatewayIP=`ip route | grep default | awk '{print $3}'`

#Find the public IP for the network
ip route get $gatewayIP | awk '{print $5}'

#If you want to know the public IP open to the Internet you can do
#ip route get | awk '{print $5}' # is an IBM nameserver

The idea is to use the Gateway of your network to find the IP accessible from your network. i.e public to your network. If the Gateway is open to the Internet that will be the public IP in general as well.


How to setup FREE HTTPS for your website -- including a free CA certificate


You will find a lot of information in bits and pieces all over the Internet, too much technical jargon peppered all over. If you do not know how https works, do not worry. It is not hard to setup https. Lets say the https setup encrypts stuff between browser and the website and move on to set up https for your website. The keys are a couple of files needed to encrypt your website and these keys need to be signed by CA or the certificate authority in order for browsers to recognise that traffic is properly encrypted. I will use nginx web server and centos7 operating system to show how https can be setup. If you use a different webserver like apache or os like ubuntu look up corresponding instructions elsewhere. So here go the steps:
1. Get a free CA signed certificate 2. Update your web server to use the certificates and enable https 3. Setup certificate renewal and optimize and secure your https website
1. Get a free CA signed…

Pageant for Mac - Using Jump Server on Mac

If you use putty on windows, you probably used pageant to store multiple keys, ssh to jump server and then ssh to your work machine. If you ended up on Mac for some reason and you have a production situation, there is no reason to panic. Mac systems have Keychain - a software that manages your keys including ssh keys. There are 3 steps to use it for jumping.

1. Add your ssh keys to Keychain. 2. Create an ssh  config file to access jump terminal
3. Agent forwarding
1. Adding keys If you had ppk/putty keys you need to convert them. If you have ssh keys then you can add them without converting. I had puttygen on my mac. If you were using Windows machine, you can convert ppk keys to ssh key on Windows and then add on Mac.

I had two keys - if you have only one that is fine. puttygen user_rsa.ppk -O private-openssh -o user_rsa.key puttygen jump.ppk -O private-openssh -o jump.key
If a window pops up then DO NOT hit generate key. 
1. Load your private key and then 
2. Go to Conversions tab and exp…



Installing Ubuntu and Fixing Boot, Software Centre Issues

Installing Ubuntu 12.04
As long as you do not choose to screw your windows partition explicitly default installation should work fine. The problems starts later on however! I trust you on this part and proceed further directly to problems.

Boot Problems
The grandchildren of linux have the same old boot loader problems that their grandmother RedHat 2-6.0x had! What happens is you will not see an option to boot to Linux, stuff directly goes to Windows or whatever else you have on you computer.

sudo grub-install /dev/sda

Hit enter the problem should now be solved.

Software Centre
The Canadian server seems to be sleeping so you may get this error.

W:Failed to fetch  Unable to connect to
E:Some index files failed to download. They have been ignored, or old ones used instead.

Open Software Centre and choose Edit -> Software Sources and …

Perl Script to find intersection of lines in two files

#/* Author : ~rAGU () */
# /*Descripation: A script to find the intersection set of the lines in two text files */
# /* when one of the file is a subset of the other */
# /* */
# 2004

open(SET, @ARGV[0]);
$isInSubset = 0;
$count = 0;

while ($lineInSet = )

    #$lineInSet = ~s / ^ \s * (.* ? )\ s * $ / $1 / ;
    $counts = 0;

    open(SUBSET, @ARGV[1]);

    while ($lineInSubset = )
        #$lineInSubset = ~s / ^ \s * (.* ? )\ s * $ / $1 / ;

        if ($lineInSet eq $lineInSubset)
            $isInSubset = 1;

    }#End subset loop close(SUBSET);

    if ($isInSubset == 0)
        print "$lineInSet";
    $isInSubset = 0;

}#End of set loop

close(SET);# /* End of the program */

Using Regular Expressions for Program Transformation

I have been investigating the problem of practical code transformation to deal with small changes that have to be made across a large collection of programs in different programming languages. So the problem is not to transform a program entirely but doing small transformations to a large set of programs that too when we have C, Perl, Java etc source programs in that set. This has practical application in software development, code refactoring and testing. A lot of cost savings in software testing is possible if test the suits are well maintained and are automagically transformed using some method. I used a method and published findings on which is rather a full system explanation of what I described here in 2011 There are some interesting obstacles to transforming programs. I will try to explain as well as understand some of them through this post.
When we want to transform a set of programs in different languages what we are dealing with is a bunch of Context Free Grammars (…