Read more to know more ! about world, people, places !

Read more to know more ! about world, people, places !

The more that you read, the more things you will know. The more that you learn, the more places you\'ll go. More »

Books are soul mate to any one !

Books are soul mate to any one !

Books are the plane, and the train, and the road. They are the destination, and the journey. They are home. More »

Spend few time to know the world from others experiences too !

Spend few time to know the world from others experiences too !

No matter how busy you may think you are, you must find time for reading, or surrender yourself to self-chosen ignorance More »

Books will never leave you alone !

Books will never leave you alone !

That perfect tranquility of life, which is nowhere to be found but in retreat, a faithful friend and a good library More »

Sharing of thoughts, feeling begin with reading/writing !

Sharing of thoughts, feeling begin with reading/writing !

The best moments in reading are when you come across something – a thought, a feeling, a way of looking at things – which you had thought special and particular to you. Now here it is, set down by someone else, a person you have never met, someone even who is long dead. And it is as if a hand has come out and taken yours More »

 

How to install node/nodejs using source code in ubuntu 14.04/16.04/18.04 server

Sometimes installing from ppa’s/source-lists will not be working smoothly, in that case install using source can be better and easy one option. Installation of nodejs on ubuntu or any linux flavour from source is easy. You need to just follow below steps. Steps are below.

Steps-

1. Download it from source distribution list.

https://nodejs.org/en/download/current/

or simply by using below commands on terminal.

wget https://nodejs.org/dist/v11.3.0/node-v11.3.0.tar.gz

2- untar the downloaded file.

tar -xzf node-v11.3.0.tar.gz

3. move to unzipped directory

cd node-v11.3.0

4. Configure source code dependencies, To generate makefile from makefile.in

./configure

5. issue make command, uses make file to build program.

make

6. issue make install command, uses makefile to to install program.

make install

It will complete the installation process, now you can check the node installed version using below command.

node -v

For more details you can refer to https://nodejs.org/en/

An analysis of DNA profiling bill 2018

DNA profiling” is not a new term for all, because we have studied during school time. It is a technique by which individuals can be identified and compared via their respective DNA profiles. But now it is taking the form of  legislation  in India in the DNA profiling bill 2018 . Recently union cabinet passes it. Originally it was conceptualised  by late former PMof  India Atal Bihari  Vajapyee . The drafting of then bill began first in 2007 and then in 2012.This bill was prepared by Department Of  Biotechnology to form National  DNA bank and DNA profiling board ,which will collect data from offenders ,suspects, missing person ,unidentified dead bodies in crime cases like homicide, sexual assault, adultery .

The government of India made decision due to PIL filed by a NGO Lokniti     Foundation, known as Lokniti   Foundation vs Union of India, stating that that India does not have a national bank data bases to address the issues of thousands of unclaimed dead bodies in India that are represent annually. In the wake of this PIL Supreme Court asked the court government to address the issue and A.P Shah Committee was formed and recommended the following guidelines:

Citizens can appeal against the retention of data.
Citizens under trial can request a second sample to be taken.
Sample must be taken after consent in case of  victims and suspects.
Bodies collecting analysing and storing DNA data should be made to release an annual report, detailing their practices and organisational structure.  

In case of any breach or misuse of data it will carry a punishment of up to 3years and 1 lakh as a fine.

The bill provides a index such as crime scene index, suspect index, undertrials  index, offender index and missing person index. This bill made an effort to protect the compulsion or pressure to obtain a DNA sample from the arrest person without its consent but with some exception. Such exception is unclear in the bill. In case if suspect /criminal refuses to give its consent for DNA sample then by magistrate approval it can be taken, but sample can also be taken from a witness from a crime scene or want to locate their missing relative or in similar instances in which they can volunteer in writing, to offer their DNA sample for a specific purpose.

But amidst of all this ,bill facing certain criticism specifically with respect to privacy matters. DNA is the key to all information . In Putta Sammy vs Uoi,the Supreme Court held that privacy in fundamental right under Article 21and hence overruled the M.P Sharma case 1958 and Kharak Singh case 1961, where the Apex Court held that privacy is not a Fundamental right under Article 21 of part 3 of the Indian Constitution. The biggest problem to regulate this bill in practical is that India don’t have proper data protection law at present.. Many experts believe that this DNA bank will not have any improvement in conviction rates, where it is so adopted by other countries.

The biggest challenge is that we need DNA examiners and expert, even our enforcement agency must need regular training regarding how to take sample and preserve it because the rate of contamination is very high if not handled properlyand it may lead to wrong investigation. India need to spend money on developing world class laboratory. No doubt  this bill help to provide fast criminal administration justice but at the same time concern of privacy of individuals.

Pawan Kumar Sharma

Practicing lawyer

B.Sc honours’ Medical Biotechnology (Amity University)

LLB, CLC (Delhi University)

How to Import and export databases in mysql using terminal

mysql-database

Today I will be detailing about how to export/import large database file in mysql through terminal.

Export From a Database
To export a database from mysql trough terminal.

1- open console.
2- issue below command

mysqldump -u <username> -p <application_db>  >  <appdb>.sql

e.g. mysqldump -uroot -p application_database  >  application.sql


Import To Database

There are two ways to do the same.

First Method

Assuming you’re on a Linux or Windows console:

1- Open console
2- issue below command

mysql -u <username> -p <database_name> < <filepath/filename.sql>

e.g  mysql -uroot -p application_db   < /abhishek/application_database.sql

It will prompt for password and do the job, You may see an idle screen while import is being done there.
There will be no status displayed untill it reaches to end of script.

You may also provide the password directly in the same line as below.

mysql -u <username> -p<dbuserpassword> <database_name> < <filepath/filename.sql>

e.g  mysql -uroot -pabhishek  application_db   < /abhishek/application_database.sql

It will work exactly similar to above provided it will not ask for password, as we have already provided in command.

Second Method

1- Open console
2- start mysql interactive mode as below

mysql -u<database_username> -p

e.g. mysql -uroot -p

It will prompt for password, provide password of mysql user and proceed to step 3.

3- select database in which file will be imported. (Assuming database name is application_db)

use <database_name>

use application_db

4- issue below command to import. (assuming here test.sql is our file to import)

source  <path_to_sqlfile_test.sql>

e.g. source  /path_to_sqlfile/test.sql

It will show the status too, while import script is running there. In this second approach seems more better than the first one as user is aware of its current progress of import.

git pull vs git fetch

git pull — Incorporates changes from a remote repository into the current branch. In its default mode,

In the simple terms, git pull does a git fetch followed by a git merge.

More precisely, git pull runs git fetch with the given parameters and calls git merge to merge the retrieved branch heads into the current branch. With –rebase, it runs git rebase instead of git merge.

You can do a git fetch at any time to update your remote-tracking branches under refs/remotes/<remote>/.

A git fetch, operation never changes any of your own local branches under refs/heads, and is safe to do without changing your working copy.

A git pull is what you would do to bring a local branch up-to-date with its remote version, while also updating your other remote-tracking branches.

 

SSH vs PuTTY vs VNC

As many of us have heard about the terms like SSH, Putty, VNC . Let’s see how to they differ with each other.

SSH is a protocol for encrypted connections between computers(For making connections, ssh client needs to be installed on local computer, and ssh server needs to be installed at remote computer) . Its simple to use, SCP command is also based on ssh, with help of ssh one can perform task over remote computer.

PuTTY is a free implementation of SSH and Telnet for Windows and Unix platforms, along with an xterm terminal emulator.

PuTTY is a GUI terminal emulator (able to run shells, which in turn run commands), while the usual SSH application is a shell (not a terminal emulator). PuTTY has been ported to Unix (and Unix-like) systems as pterm.

As a best practice, keys are recommends over passwords. PuTTY is the terminal client but you can get a couple of other tools from the same author. PSFTP and PSCP offer secure file transfers. These tools are as easy to use as PuTTY and work pretty much the same way.

VNC exports a whole session, desktop and all, while ssh will run a single program and show its windows on your workstation.

The VNC server exports a session that survives even when you disconnect your screen, and you can reconnect to it later with all the windows open etc. This is not possible with an ssh X tunnel, since when your X server dies, the windows go away.

File Permissions In Linux

Linux-File-Permissions

In Linux(like ubuntu/cent/fedora/kali etc.) and Unix, everything is a file. Directories are files, files are files and devices are files. Devices are usually referred to as a node, however, they are still files. All of the files on a system have permissions that allow or prevent others from viewing, modifying or executing. If the file is of type Directory then it restricts different actions than files and device nodes. The super user “root” has the ability to access any file on the system. Each file has access restrictions with permissions, user restrictions with owner/group association. Permissions are referred to as bits.

There are three types of access restrictions:

Permission | Action  | chmod option
read       | (view)  | r or 4
write      | (edit)  | w or 2
execute    |(execute)|x or 1

There are also three types of user restrictions:

User  | ls command output
owner | -rwx------
group |----rwx---
other |-------rwx

Folder/Directory Permissions

Directories have directory permissions. The directory permissions restrict different actions than with files or device nodes.
Permission | Action                           | chmod option
read       | (view contents, i.e. ls command) | r or 4
write      | (create or remove files from dir)|w or 2
execute    | (cd into directory)              | x or 1

  • read allows viewing the directories contents, i.e. ls command
  • write allows creating new files or deleting files in the directory. (Note: write access for a directory allows deleting of files in the directory even if the user does not have write permissions for the file!)
  • execute restricts or allows changing into the directory, i.e. cd command

State Pattern – Design Pattern

The state pattern allows an object to alter its behavior. When its internal states changes, the object itself will appear to change its class

This pattern encapsulates states in to separate classes and delegate to the object representing current state.

Change in class is done by using composition over the base class (in our example Context Class’s property currentState)

Here, what we are trying to do is that attaching a subclass behavior based on previous actions performed on that object (In our case it will be Context class’s currentState property object assigned, that we will see in our example ).

<?php

// class being called to test our program
class Test
{
    public $context ;
    
    
    public function testnow()
    {
        $this->context = new Context;

        $this->context->requestOne();    // Could be any methods
        $this->context->requestTwo();

        print_r($this->context);
        $this->context->requestOne();    // Could be any methods

        // here you may see the changes in underlying classes on execution of any mathod 
        // if it tries to change it's current state, and change in state of current object will be responsible for changing the underlying state class.
        
    }
    
}


//Context   -- main class being called

Class Context {
    
    public State $StateA;
    public State $StateB;
    public State $StateC;
    public State ... ;// More state classes may involve depend on the behavior of game.

    public State $currentState; // depicting the current state of a Game
    
    public function __construct()
    {
         $this->StateA = new StateA($this);
         $this->StateB = new StateB($this);
         $this->StateC = new StateC($this);
         ...

         $this->currentState = new StateA($this); // suppose default state initailly
    }
    
    function requestOne()
    {
        ...
        $this->currentState->requestOne(); // will be calling the methods of 'currentState' assigned class, may be any of state classes.
    }

    function requestTwo()
    {
        ...
        $this->currentState->requestTwo(); // will be calling the methods of 'currentState' assigned class, may be any of state classes.
    }

    function requestThree()
    {
        ...
        $this->currentState->requestThree(); // will be calling the methods of 'currentState' assigned class, may be any of state classes.

    }

}



interface State
{
    // All these methods needs to be implemented by the class
    public function requestOne();
    public function requestTwo();
    public function requestThree();
} 


//Whenever there is a request made using class Context, its request mthod delegate(propagetes) to state subclass (e.g. StateA) , to handle the behavior of object.


class StateA implements State {

    public function requestOne()
    {
        ...
        ...
        //changing state classes if there needed
    }


    public function handleTwo()
    {
        ...
        ...
        //changing state classes if there needed
    }


    public function handelThree()
    {
        ...
        ...
        //changing state classes if there needed
    }

}

//Similarly for other classes like StateB, StateC, and so on..


class StateB implements State 
{
    
    // All methods similar to method StateA class methods
    // and additional methods may exist there too.
}

This kind of a pattern can be useful in designing Games especially, where an object behavior changes based on its previous operations.

Hope that make a little bit clear.

Composite Pattern – Design Pattern

Composite-pattern

Composite-pattern

Consider Iterator Pattern, this behaves very well if all items in a collection are equal kind, But it lacks when it comes to iterate over such a collection where all items or a few can contain a nested structure(Tree structure).

To traverse a tree, We need to visit every node(may contain further node or leaf) and leaf. So here we come of with another pattern named Composite Pattern. That works perfectly with Iterator pattern to make the job of Iteration simple for a client without knowing about underlying structure of every object in collection(Aggregate), whether it’s node or a leaf. In simple terms we can say that it will help to provide the interface that will be common for both nodes as well as leaf items, client has not to worry about object structure, that is being passed.

The Composite pattern allows you to compose objects into tree structure,to represent part-whole hierarchies. Composite lets treat individual objects and compositions of objects uniformly.

Here part-whole term is referring to each node(either a leaf or a node connected with other nodes as a parent)

Using composite structure, we can apply the same operation over both Composites(here NODEs) and individual(here LEAF) objects.

In short we are ignoring the difference between Composites(NODE) and individual(LEAF).

Iterator Pattern – Design Pattern

The Iterator Pattern provides a way to access the elements of an aggregate object sequentially without exposing its underlying representation.

The iterator pattern allows traversal of elements of an aggregate without exposing the underlying implementation.

It also places the task of traversal on the iterator object, not on the aggregate, which simplifies the aggregate interface and implementation, and places the responsibility where it should be.

one thing to notice here

Aggregate or Collection means just a group of objects, they might be stored in very different data structures like lists, arrays, hashmaps, vectors etc.

This pattern comes in the scenario when we have a different kind of collections, and we need to traverse over them in a different class, class separate from implementing collections data.

below is diagram explaining iterator pattern.

iterator-pattern

iterator-pattern

Anonymous function or Lambda function

An anonymous function is simply a function with no name.

A Lambda is an anonymous function that can be assigned to a variable or passed to another function as an argument. If you are familiar with other programming languages like Javascript etc., you will be very familiar with anonymous functions.

// Regular function
function dosomething () {
return “Hello there”;
}

Function can be called something like:

echo dosomething();
// Returns “Hello there”

An anonymous function has no name so you would define it like this:

// Anonymous function
function () {
return “Hello there”;
}

How to use Ananymous functions –

Because the function has no name, you can’t call it like a regular function.

// assiging to variable, Anonymous/lamda function

$dosomething = function () {
return “Hello there”;
}

// Calling Ananymous function
echo $dosomething();
// Returns “Hello there”

To use the anonymous function, we need to assign it to a variable and then call that variable as a function.

You could also pass the function to another function, like this:

// Pass Ananymous\Lambda to another regular function
function anotherfunction ($dosomething){
echo $dosomething();
}

// Calling function
anotherfunction(function(){
return “Hello there”;
});