Saturday, December 28, 2019

Check to travel to any destination



TravelDoc can determine whether you have the necessary documentation to travel to any destination, or whether you will need additional documentation such as a visa for your journey.


https://www.traveldoc.aero/



Also, this:
https://www.iatatravelcentre.com/passport-visa-health-travel-document-requirements.htm


Tuesday, December 24, 2019

Verify sha256 checksum



How to verify sha256 checksum:


So, you have filename(whose checksum needs to be verified) and
its checksum file as filename-CHECKSUM.

# ls  -l
filename
filename-CHECKSUM


You can use the command
# sha256sum    -c   filename-CHECKSUM.

Where -c stands for:
  -c, --check          read SHA256 sums from the FILEs and check them


Thursday, December 19, 2019

Decode using base64



To  decode the file

# base64 --decode /tmp/encoded.txt > /tmp/decoded.txt


To  decode the content

# echo "value to decode" |  base64 -d





Cloning private repo in github



For cloning private repo, use the following format:

git clone git@github.com:username_whatever/reponame_whatever.git

--
Please note you need to have ssh key added in your github account.

Follow this:
https://help.github.com/en/github/authenticating-to-github/adding-a-new-ssh-key-to-your-github-account
--


Tuesday, December 10, 2019

Sunday, November 24, 2019

Franklin India mutual fund details



To check Franklin India mutual fund details use this link:

https://accounts.franklintempletonindia.com/guest/#/loginmaster/panDetails


Note: check https for the certificate details to ensure franklintempletonindia.com

--

For HDFC use this:
https://investor-web.hdfcfund.com/dashboard

--

For ICICI use this:
https://www.icicipruamc.com

-- 

Wednesday, October 16, 2019

Check whether a machine is virtual machine



How to check whether a machine is virtual machine?

--
$ hostnamectl status

if the output shows  "Chassis: vm" , it is virtual machine.

For physical machine it shows something like "Chassis: laptop"
--

Another command to try
$  systemd-detect-virt

--

source:
https://www.ostechnix.com/check-linux-system-physical-virtual-machine/


Friday, October 4, 2019

LinchPin tool



LinchPin is a simple and flexible hybrid cloud orchestration tool. Its intended purpose is managing cloud resources across multiple infrastructures. These resources can be provisioned, decommissioned, and configured all using declarative data and a simple command-line interface.
Documentation:



GitHub link:




Thursday, September 26, 2019

Avoid showing a/b prefix in git diff



Set the config option diff.noprefix:
$ git config --global diff.noprefix true    # All repos
$ git config diff.noprefix true             # Current repo

Backups done right - restic



restic
  - a backup program that is fast, efficient and secure.


Web: https://restic.net

github: https://github.com/restic/restic

Documentation: https://restic.readthedocs.io/en/stable/

Quickstart: https://restic.net/#quickstart



Thursday, September 19, 2019

Vagrant + libvirt in Fedora


Vagrant
 
   from https://www.vagrantup.com

--

Install libvirt and qemu:
   dnf -y install qemu libvirt libvirt-devel ruby-devel gcc
  source: https://github.com/vagrant-libvirt/vagrant-libvirt#possible-problems-with-plugin-installation-on-linux
    Install vagrant:
        https://www.vagrantup.com/docs/installation/index.html
        https://www.vagrantup.com/downloads.html


    Install vagrant plugin for libvirt:
    vagrant plugin install vagrant-libvirt
    --
    To list all the plugins:
      vagrant plugin list

    To repair the plugins if you run into issues:
     vagrant plugin repair

    To update the plugin:
      vagrant plugin update 
    --
    First init the Vagrantfile
    vagrant init fedora/29-cloud-base

    // Note: You can check whether the corresponding image present here
    // https://app.vagrantup.com/fedora

    --

    // without any specific OS:
    vagrant init

    You need to update Vagrant file with specific OS before proceeding.

    --
    To create and configure and to bring up the VM
    vagrant up --provider=libvirt

    --

    You can find your downloaded box here:
    ls ~/.vagrant.d/boxes/

    --

    vagrant status
    // only for current directory
    --

    vagrant global-status
    // global for this user
    --

    vagrant halt  <id>

    id is received in global-status command above
    --

    To start again:
    vagrant provision

    or  you can run the same command as:
    vagrant up --provision 

    You can also avoid running it by
    vagrant up --no-provision 

    --
    // To login
    vagrant ssh

    --

    // To destroy specific box

    vagrant destroy

    // Note, the above will not remove the box from the system (from backend). 
    // To remove it you can use

    vagrant box remove  

    --

    // remembers the state saving the state of VM
    vagrant suspend

    // To resume back
    vagrant resume

    --

    // To stop:
    vagrant halt
    --

    // List all the boxes in your system:
    vagrant box list

    --

    // To share files between host and VM

    // option in Vagrantfile
      config.vm.synced_folder "../data", "/vagrant_data"

    Here ../data => directory in Host
    /vagrant_data => directory in VM

    Ensure you have working NFS server in host.
    Also, udp=y in /etc/nfs.conf in the host machine.

    --

    vagrant reload ->  vagrant halt + vagrant up

    // along with provision
    vagrant reload --provision

    --

    // provider specific changes in Vagrantfile
       vb.memory = "value"
       vb.cpus = "value"

    --

    // to package a new vagrant box
    vagrant package

    --

    Refer this gist for additional info:
     


    Wednesday, September 11, 2019

    Wednesday, September 4, 2019

    xz file extraction



    Just like using "unzip" command for zip files, you can use "unxz "   for xz files.

    No need to remember -xJf   option ;)


    Wednesday, August 21, 2019

    git push - set current branch only



    Set only the current working branch to be pushed:

    git config --global push.default simple
    


    Monday, August 19, 2019

    bash completion for aliases



    For alias like  gv = gvim, bash completion don't work.

    Following link helps to setup bash completion to work for alias too.

    https://github.com/cykerway/complete-alias


    It is two step process:

    From the above link get bash_completion.sh and do

    1. cat bash_completion.sh >> ~/.bash_completion



    Now, add the below linke in ~/.bash_completion: 

    2. complete -F _complete_alias gv 

    Tuesday, August 13, 2019

    Using escape sequence within yaml



    I'll note that the key to using escape sequences within YAML, is for you to use ' to quote the line, and " inside for the args.

      - debug:
          msg: '{{ ks_iso_volume_id | regex_replace("\s", "\\x20") }}'

    From: https://github.com/ansible/ansible/issues/52868#issuecomment-469287200



    Note:
    Actual error faced:
    ERROR! Syntax Error while loading YAML.

      found unknown escape characte






    Tuesday, August 6, 2019

    Article on "how to be influenced by others" by Roger Schwarz



    Interesting article about being influenced:

     “Are you open to being influenced on this issue? I’m asking because I want to use your time and my time efficiently. If you’re not open to being influenced, just let me know and I’ll drop it. If you’re open to being influenced, then would you be willing to tell me what would lead you to consider changing your mind? That will help me quickly focus only on the factors you consider relevant. If I don’t have any information about those factors, I’ll let you know. How does that sound?” 

    https://hbr.org/2016/08/how-leaders-can-help-others-influence-them


    Friday, June 28, 2019

    Get the specific release where your commit is merged



    In a specific release your commit is merged. 
    So, how do you get the specific release in which your PR is merged ?

    1. first get the commit hash of the PR.

    2. Then , try this:

    git tag --contains <commit id>


    The lowest one in the above command's output is where your commit is first merged.

    Thanks for the tip Niels!

    Wednesday, June 26, 2019

    vim variables to set for ansible




    vim variables to set for ansible

    vim
    :set ai ts=2 sw=2  et

    ai  => autoindent
    ts  => tabstop=2
    sw => shiftwidth=2
    et => expandtab


    Remember it using "aits sweet"  :) 

    --

    set cursorline

    --

    autocmd   FileType   yaml    setlocal    ai ts=2 sw=2  et  

    --


    Adding a new patch to rpm based package


    Adding a new patch to rpm based package

    --

    Setting up rpmbuild environment : 

    mkdir ~/rpmbuild

    cd ~/rpmbuild

    mkdir -p ~/rpmbuild/{BUILD,BUILDROOT,RPMS,SOURCES,SPECS,SRPMS,}

    cp v1.1.0.tar.gz     *.patch     /root/rpmbuild/SOURCES/

    --

    # Clone the package
    git clone <your package name>


    # first build it with current sources and patches:
    rpmbuild -bb  <package name>.spec  --noclean

    Note: prior to the above step, clean the *older* sources if present :
        rm -rf /root/rpmbuild/SOURCES/*

    # cd to the source code
    cd /home//rpmbuild/BUILD/<package name>

    # initialize git
    git init .

    # add all
    git add .

    # make initial commit
    git commit -s "initial"

    # making your new changes
    // now make changes.

    git add    <new files/ patched files>

    # commit the changes
    git commit -s "give relevant comment here"

    # create a patch
    git format-patch -1

    # Now copy the patch to  source location and make relevant changes in  <package name>.spec.

    # Now you can build the rpm package with this new patch as well .

    -----------


    Friday, April 26, 2019

    Print signed pdf documents (with verified signature)




    pdf documents are digitally signed and sometimes you want to get printouts of same with valid digital signature.

    So, how it can be done:

    ========================
    Open the (signed) pdf document.


    Click on the signature with "yellow question mark"

    It opens up signature validation status.

      There is "signature properties" , click on it.


    Click "show certificate" here.

    There is "Trust" tab in "show certificate". click on "Add to trusted identities".
     -> OK.

    Now, you click on "validate signature".

    The "yellow question mark" becomes "green tick mark".

    Now, your printout will reflect the "green tick mark".
    ========================

    Tuesday, April 2, 2019

    How to cleanly remove network (created by libvirtd)

    How to cleanly remove  network (created by libvirtd)

    // list all net devices
    virsh net-list --all



    // make it inactive
    virsh net-destroy  



    // Now it is be in inactive state, but not removed - so, remove it using
    virsh net-undefine



    Tuesday, March 26, 2019

    Monday, March 25, 2019

    virtual kubelet

    Virtual Kubelet is a very interesting project.

    https://github.com/virtual-kubelet/virtual-kubelet

    will try this and write.

    For now, you can find more info. here:
    https://github.com/virtual-kubelet/virtual-kubelet/blob/master/README.md

    tini - a init for containers

    --

    https://github.com/krallin/tini

    https://github.com/krallin/tini/blob/master/README.md

    --

    How ?
    Add Tini to your container, and make it executable. Then, just invoke Tini and pass your program and its arguments as arguments to Tini.


    Why?

    This will help to run Tini with PID 1 and avoid signal handling issues.


    Refer the README for details.

    ==

    Another related project is : supervisord

    Ref: http://supervisord.org/

    -- 

    Friday, March 22, 2019

    How a function changed from beginning - git trick




    Come across this nice git trick  to know how a function evolved:

    git log -L :<Function_name>:<Filename>


    So,  it start with the first edition of the function followed by all changes done within the function.

    Monday, March 18, 2019

    Create docker image from running container



    So, what is a docker container?

    It is running(executing) docker image.

    You made some changes in the docker container - maybe by yum installation / by editing some files.
    You can create a new image out of this specific docker container .

    How ?

    // get docker id
    # docker ps
    <docker id>

    // create new image out of the above docker container
    # docker commit <docker id>  <new_name>

    // check the resulting image
    # docker images | grep <new_name>

    Sunday, March 17, 2019

    git - show the changes across commits




    // show the actual changes for a file.
    # git log -p <filename>

    Ignoring the filename will show all the changes across commits.
    # git log -p

    Tuesday, March 12, 2019

    Using podman in lieu of docker



    --

    In 2015, Docker, Red Hat, CoreOS, SUSE, Google, and other leaders in the Linux containers industry created the Open Container Initiative in order to provide an independent body to manage the standard specifications for defining container images and the runtime. In order to maintain that independence, the containers/image and containers/storage projects were created on GitHub.


    https://github.com/containers/image

      image is a set of Go libraries aimed at working in various way with containers' images and container image registries.

    https://github.com/containers/storage

      storage is a Go library which aims to provide methods for storing filesystem layers, container images, and containers. A containers-storage CLI wrapper is also included for manual and scripting use.

    --

    podman == docker

    // To pull the image
    podman pull fedora

    image gets stored in ~/.local/share/containers/

    --

    Podman will default to searching through registries listed in the registries.conf file

    --

    // To run the image
    podman run -it fedora bash

    // check in another terminal
    podman ps

    // check the images
    podman images

    podman push fedora docker-daemon:fedora:latest

    leaving out docker-daemon above, will push to docker hub. (which will error out).

    To pull from docker's to podman

    # podman pull docker-daemon:fedora:latest
    --
    podman useful in k8s environment:

     podman generate kube --help

    NAME:

       podman generate kube - Generate Kubernetes pod YAML for a container or pod



    USAGE:

       podman generate kube [command options] CONTAINER|POD-NAME



    DESCRIPTION:

       Generate Kubernetes Pod YAML



    OPTIONS:

       --service, -s  generate YAML for kubernetes service object

    --



    podman pod

    NAME:

       podman pod - Manage container pods.



    Pods are a group of one or more containers sharing the same network, pid and ipc namespaces.





    USAGE:

       podman pod command [command options] [arguments...]



    COMMANDS:

         create        Create a new empty pod

         exists        Check if a pod exists in local storage

         inspect       displays a pod configuration

         kill          Send the specified signal or SIGKILL to containers in pod

         pause         Pause one or more pods

         ps, ls, list  List pods

         restart       Restart one or more pods

         rm            Remove one or more pods

         start         Start one or more pods

         stats         Display percentage of CPU, memory, network I/O, block I/O and PIDs for containers in one or more pods

         stop          Stop one or more pods

         top           Display the running processes of containers in a pod

         unpause       Unpause one or more pods



    OPTIONS:

       --help, -h  show help

    --

    podman build  - can build images over Dockerfile

    --

    Buildah can be described as a superset of commands related to creating and managing container images and, therefore, it has much finer-grained control over images. Podman’s buildcommand contains a subset of the Buildah functionality. It uses the same code as Buildah for building.

    --

    The most powerful way to use Buildah is to write Bash scripts for creating your images—in a similar way that you would write a Dockerfile.
    --

    K8s moved to CRI-O based on OCI runtime, no need for docker daemon.

    no need to install docker on any host in k8s cluster.

    k8s could call CRI-O and it could call runC directly.

    --

    buildah


    • much finer control over creating image layers.

    Buildah run is not same as podman run command.

    buildah run is for running specific commands in order to help build a container image

    buildah run dnf -y install nginx

    k8s solved runtime issue with CRI-O and runC

    build problem with Buildah.

    But, Docker still required. why? Debugging.

    In order to avoid to install docker , use podman .

    podman solves two problems -


    • operator to examine container and images with commands they are familiar with.



    • developers the same tools.




    So, docker user, developer, operator all can make use of podman.

    --

    Source:
    https://developers.redhat.com/blog/2019/02/21/podman-and-buildah-for-docker-users/


    Sunday, March 3, 2019

    Reclaim space in gmail - delete archive'd messages


    Running out of space in Gmail?

    You could check the archived messages in Gmail and delete them to get some space back.


    -

    gmail is by default provided with 15GB storage space (which is shared with google drive and google photos as well).

    -


    I have written some Gmail filters to move not so important messages to archive. Even this archive is counted towards storage space. By means of freeing up the archive, we could reclaim space.


    How to get archived messages?

    Search in gmail with following:
    has:nouserlabels -in:Sent -in:Chat -in:Draft -in:Inbox   

    This will show all archived messages.


    Now, you can add more filters and delete them something like
    has:nouserlabels -in:Sent -in:Chat -in:Draft -in:Inbox    from:Amazon 



    Select the messages (use select all option which pops up) delete them and delete the files from "Trash" as well.


    has:nouserlabels -in:Sent -in:Chat -in:Draft -in:Inbox   -in:important 


    Select the messages (use select all option which pops up) delete them and delete the files from "Trash" as well.


    You should be able to see the reclaimed space :)

    Tuesday, February 19, 2019

    xargs command usage



    Example on find all executables (ELF) and delete them in current directory:


    find $PWD -type f | xargs file | grep "ELF.*executable" | awk -F: '{print $1}' | xargs  "rm"

    Here, xargs is used which converts input into arguments to a command.

    for example:

    • xargs file ->  file  <filename>
    • xargs rm ->  rm  <filename> 


    --
    find . -type f
    - type f  ->  "find" only of file type.
    --

    Friday, February 8, 2019

    Setting timer using google


    Set timer using google:



    So, you have a web meeting in 13 minutes and wants to get remainder about it.



    Just google this:

    "set timer for 13 minutes"





    You can go and work on any window but gets an alarm post 13 minutes.

    Tuesday, February 5, 2019

    Ilayaraja song :)


    Ilayaraja song :)



    Composer: Ilaiyaraja Singers: SPB - S Janaki


    ஆ: பூ பூ பூ பூ பூத்த சோலை
    பூ பூ பூ பூ மாதுளை
    பூ பூ பூ பூ பூத்த சோலை
    பூ பூ பூ பூ மாதுளை

    பெ: பூ பூ பூ புல்லாங்குழல்
    பூ பூ பூ பூவின் மடல்

    ஆ: பூ பூ பூ பூவை மனம்
    பூ பூ பூ பூங்காவனம்

    பெ: பூ பூ பூ பூஜை தினம்

    ஆ: பூ பூ பூ புதிய சுகம் பொழிந்திடும்

    பெ: பூ பூ பூ பூ பூத்த சோலை
    பூ பூ பூ பூ மாதுளை
    பூ பூ பூ பூ பூத்த சோலை
    பூ பூ பூ பூ மாதுளை


    [ இசை ]

    பெ: காற்றினில் கான மழை
    கலகலத்து வீசுது காதல் அலை..
    பாட்டினில் பாச வலை
    பலவிதத்தில் பாடுது பாவை நிலை...

    ஆ: மூச்சினில் ஓடிய நாதமென
    முழுவதும் கீதமென..

    பெ: முடி முதல் அடி வரை மோகமென
    தொடர்கிற தாகமென

    ஆ: பார்த்தொரு பார்வையில் பாடல் எழ
    பாவையின் மேனியில் கூடல் விழ

    பெ: பாராத விழி ஏங்கிட ஏங்கிட
    பாடலை பாடி வர பல சுகம் பெற
    பூ பூ பூ பூ பூத்த சோலை
    பூ பூ பூ பூ மாதுளை
    பூ பூ பூ பூ பூத்த சோலை
    பூ பூ பூ பூ மாதுளை

    ஆ: பூ பூ பூ புல்லாங்குழல்
    பூ பூ பூ பூவின் மடல்

    பெ: பூ பூ பூ பூவை மனம்
    பூ பூ பூ பூங்காவனம்

    ஆ: பூ பூ பூ பூஜை தினம்

    பெ: பூ பூ பூ புதிய சுகம் பொழிந்திடும்

    ஆ: பூ பூ பூ பூ பூத்த சோலை
    பூ பூ பூ பூ மாதுளை
    பூ பூ பூ பூ பூத்த சோலை
    பூ பூ பூ பூ மாதுளை

    [ இசை ]


    ஆ: நேற்றொரு கோலமடி
    நேசமிது போட்டது பாலமடி
    ஏத்துது பாரமடி
    இரு விழிகள் எழுதிய கோலமடி

    பெ: இரவுகள் முழுவதும் தலைவன் மடி
    இனிமைகள் இணைந்தபடி

    ஆ: உறவுகள் உணர்வுகள் உயர்ந்தபடி
    உடலது நனைந்தபடி

    பெ: வார்த்தையை கூடிய வாசனையே
    வந்தணை உன் துணை எந்தனையே

    ஆ: வாடாத ஒரு வாலிபம் வாலிபம்
    வாசலில் வந்தபடி... வரம் கொடுத்தது...
    பூ பூ பூ பூ பூத்த சோலை
    பூ பூ பூ பூ மாதுளை
    பூ பூ பூ பூ பூத்த சோலை
    பூ பூ பூ பூ மாதுளை

    பெ: பூ பூ பூ புல்லாங்குழல்
    பூ பூ பூ பூவின் மடல்

    ஆ: பூ பூ பூ பூவை மனம்
    பூ பூ பூ பூங்காவனம்

    பெ: பூ பூ பூ பூஜை தினம்

    ஆ: பூ பூ பூ புதிய சுகம் பொழிந்திடும்

    பெ: பூ பூ பூ பூ பூத்த சோலை
    பூ பூ பூ பூ மாதுளை
    பூ பூ பூ பூ பூத்த சோலை
    பூ பூ பூ பூ மாதுளை

    Sunday, February 3, 2019

    3 levels of switching off systemd service


    3 levels of switching off systemd service

    1.
     only stop the service, on the next boot it *may* be autostarted
    # systemctl stop <service>

    2.
    Disable autostart on next reboot

    # systemctl disable <service>


    3.
    Disable on steroids :)
      - this is permanent change.
      - user won't be able to start the service either manually or even as a dependency of other units.
    # systemdctl mask <service>


    Ref:   http://0pointer.de/blog/projects/three-levels-of-off

    Monday, January 28, 2019

    Reset application preference in Fedora



    Reset application preference in Fedora :

    --
    For example for gedit editor:

    dconf reset -f /org/gnome/gedit/

    --

    You can reset other applications like terminal, nautilus, etc., check it out using:

    dconf list /org/gnome/ -> list the applications whose preference can be reset.

    --


    Thursday, January 17, 2019

    Reverting a patch

    First create patch using
    // here I consider last patch applied:
    # git format-patch -1
    Then  revert a patch using below command.
    # git apply -R  your_patch_file.patch
    make further changes in the files directly and start commiting,pushing the changes.

    Wednesday, January 16, 2019

    Monday, January 14, 2019

    Pause in ansible playbook waiting for user intervention



    How to use sleep in playbook ?

    ---
    - hosts: webservers
      tasks:
      - name: install tftp
        yum: pkg=tftp state=installed
        failed_when: False
      - pause: minutes=5


    --
    - pause: minutes=5

    --

    It shows the option
    Pausing for 300 seconds
    (ctrl+C then 'C' = continue early, ctrl+C then 'A' = abort)


    So, C to continue early and A to abort. 

    --

    This can be used for ansible debugging.
    We can exit a playbook after a (debugging) role.