PostgreSQL Run on Docker with Create User and Database

1.
docker pull postgres
2

docker run --name postgresdb -v /home/sudipto/Development/PostgresDb:/var/lib/postgresql/data -p 5432:5432 -e POSTGRES_PASSWORD=root -d postgres
3.

 docker inspect postgresdb

4.
docker exec -it postgresdb bash

5.
psql -U postgres -W

6.

CREATE USER user11 SUPERUSER PASSWORD '69use420';
7.
CREATE DATABASE pguser11db1;
8.
GRANT ALL PRIVILEGES ON DATABASE pguser11db1 TO user11; 
 


 


 
 

install & Remove nodeJs &npm at Ubuntu

Remove NodeJs & npm

cd /usr/local
sudo rm -r bin/node bin/npm include/node lib/node_modules share/man/man/node.1
cd
rm -r .npm
OR
sudo apt-get remove nodejs
sudo apt-get remove npm

Install Latest Version of NodeJs & npm

sudo apt-get update
sudo apt-get install nodejs
sudo apt-get install npm
node --version

Copy a whole website via Linux command

wget --recursive --no-clobber --page-requisites --html-extension --convert-links --restrict-file-names=windows --domains devitems.com --no-parent devitems.com/html/intensy-preview/


------------------------Or------------------------------------


wget --limit-rate=200k --no-clobber --convert-links --random-wait -r -p -E -e robots=off -U mozilla http://themesground.com/Superb/


SingleTon Design Pattern Java

Create a Java Application Project.

Post this 2 class file in root.

-------------File MainClass.java-----------------------------------------------------------------------------
package singleton;

public class MainClass {

    public static void main(String[] args) {

        MathHelper tmp = MathHelper.getInstance(12);
        MathHelper tmp2 = MathHelper.getInstance(14);
        MathHelper tmp3 = MathHelper.getInstance(16);

        tmp.demoMethod();
        tmp2.demoMethod();
        tmp3.demoMethod();
    }
}
------------------------------------------------------------------------------------------


-------------File MathHelper.java-----------------------------------------------------------------------------
package singleton;

public class MathHelper {

    private static int sNumber;
    private static MathHelper singleton;
    /* A private Constructor prevents any other * class from instantiating. */

    private MathHelper() {
    }

    /* Static 'instance' method */
    public static MathHelper getInstance(int number) {
        if (singleton == null) {
            sNumber = number;
            singleton = new MathHelper();
        }
        return singleton;
    }
    /* Other methods protected by singleton-ness */

    public static void demoMethod() {
        System.out.println("DemoMethod for singleton: Number= " + sNumber);
    }
}
------------------------------------------------------------------------------------------


Run MainClass.java file.

You got result
DemoMethod for singleton: Number= 12
DemoMethod for singleton: Number= 12
DemoMethod for singleton: Number= 12

Same result for every time.


It's can update private static variable 'sNumber' only first time by method ‘getInstance()’. Because then no object create yet. Only first time object is null. Then it’s creating a new object by considering current object is null and return it. At that time 'sNumber' able to update its value to 12.

After creating first time object, it will never able to create new object and can't update the 'sNumber'. It's return the same old object every time. And we got 12 , even we push new value when we get new object.