Saturday, March 26, 2022

Restore postgres database backup

<postgres database server installation bin directory location>/psql -U <database username> -W -h <database server ip or localhost> -p <database port> -d <database name where backup will be restored> -f <backup file location>

For Example:

/usr/pgsql-13/bin/psql -U test -W -h 127.0.0.1 -p 5432 -d test_db -f test_db.sql


Note : 

Follow below steps and then restore the database backup:

1. Take backup of an existing database. (See how to take backup through command line Postgres database back up)

2. Create a database through PgAdmin or command line or using any postgres database editor

3. Create user for that database and provide rights to database with that user.

4. Now, Restore the backup taken.


For any clarification, write in comment box. I will be happy to help you.

Friday, March 25, 2022

Back up of Postgres Database from Command Line


<location of postgres installation bin directory>/pg_dump -U <username> -h <server ip address or localhost> -p <port of database> -W -d <database name for which backup needed> > <backupfilename>.sql

Example:

/u01/postgres/9.6/bin/pg_dump -U testuser -h 127.0.0.1 -p 5452 -W -d test_db > test_db_bkp.sql

Friday, September 28, 2018

Generally asked MEAN stack question - Part 3

1. Difference b/w Promise and Callback.
2. Difference b/w Promise and Observer.
3. What is event loop in node js.
4. Difference b/w call, apply and bind.
5. What is middleware in express js.
6. What is JWT and authorization and authentication
7. Difference b/w angular js and angular
8. How to pass data from a component to another component
9. What is aggregate and reduceMap in mongo DB.
10. What is event emitter and why we use event emitter.
11. What is socket.io.
12. What is docker and hosting platform for node
13. What is prototype and why we use prototype.

Saturday, September 8, 2018

Generally asked MEAN stack question part 2

Questions:

1. Digest cycle https://www.youtube.com/watch?v=SYuc1oSjhgY

2. $watch,$watchCollection and $watchGroup

3. How change detection work in angular js

4. Why we use link from CDN

5. What is blocking and non-blocking in node

6. $ajax callback, Complete and Done.

7. {{}} and ng-Bind

8. $httpclient

9. Closure function in javascript

10. Directive lifecycle in angular

11. How change detection work in angular

12. Component lifecycle hooks

13. Difference b/w onChange and doChange

14. Difference b/w constructor and onInit

15. Which type of work we do in constructor and which type of work we do in onInit

16. What is the use of $resource

17. prototype in javascript

18. Inheritance in javascript

19. scope life cycle

20. $digest loop

21. Difference b/w javascript and node js

Sunday, September 2, 2018

Generally Asked MEAN Stack Interview Question

Question:
1. What is callback with example and scenario?
2. What is Promise with example and scenario?
3. What is async and await.
4. What is closure and what we achieve through it.
5. undefined and not defined.
6. Difference b/w var, let and const.
5. ES5 and ES6 Difference.
6. How change detection work in Angular JS and Angular?
7. How lazy load functionality can be implemented in angular js.
8. What is two way data binding.
9. Event Loop in Node Js.
10. JWT in express Js.
11. Session Management in Node/Express Js.
12. Difference b/w SOAP API and Rest API and detail explanation with example.
13. Http methods and returned http status code and message in diff-2 scenarios like system error, validation error and successful.
14. Middleware, its usage and examples.
15. Difference and example of synchronous and asynchronous functions.
16. MAX five salary.
17. Unique records.
18. []% result.
19. Competitive programming question.
20. Full flow of a project.
21. Always have updates of latest thing in the particular technology.
22. Online Practical Questions of Node Js, Angular Js, Angular, Aptitude, Psychometric, SQL Questions.



Some Links:

http://quizbucket.org/nodejs-quiz-questions?page=1

https://www.toptal.com/nodejs/interview-questions

https://www.toptal.com/javascript/interview-questions

https://www.codementor.io/nihantanu/21-essential-javascript-tech-interview-practice-questions-answers-du107p62z

http://mcqstack.com/nodejs/nodejs.html

http://www.tutorialsteacher.com/online-test/nodejs-test

https://www.restapitutorial.com/resources.html

Sunday, October 29, 2017

Javascript Data Types

There are two basic data type in javascript:

Note:

  1. Javascript variable are dynamic type. It means when we assign value to javascript variable then data type of that variable will depend on the type of value the variable holds.
  2. typeOf operator is used to find the data type of the variable.

Primitives
  1. string
  2. boolean
  3. number
  4. undefined
Non Primitives
  1. object
  2. function
string: When we declare a variable by assigning the value to the variable in single quotes i.e. ' ' or in double quotes "". then that variable become of string type.

Example: 

var name="abc";
or
var name='abc';


boolean: When we declare a variable by assigning the value to the variable true/false then that variable becomes of boolean type.

Example:

var flag = true;
or
var flag = false;

number: When we declare a variable by assigning the integer or floating value to the variable then that variable becomes of number type.

Example:

var salary=5000;

var salary=5000.543;

var salary=5.324e+2;

var salary= 5.324e-4;

undefined: When we declare a variable and does not assign any value to it then then that variable becomes of undefined type.

Example:

var name;

Non Primitive:

object: Object data type variables are reference type.

Example:

var name=null; //null is a keyword and its type is object.

var myArr=[1,2,"5"]; // data type of the array is object

var obj={ firstName : 'shshi' , lastName: 'sharma'};

 Note: 

  1.   In javascript we declare object with key-value pair. 
  2.   Key name can be any value. We can use key name as valid string value.
  3.   Value can be any valid javascript supported data type.
function: When we declare a function and assign function into a variable then data type of the variable becomes function.

Example:

var myFunc=function (){
      alert("hello");
}

Hope it helpful to know about javascript data type.

Thanks for reading.

Sunday, November 20, 2016

State Management in asp.net- Part 3


Cookies:


It is a client side state management technique. Cookies are created at client hard drive by browser. When a user visit the website first time, server gets the request and send the cookies information to browser and browser write the information into hard drive of client machine. When user visits website again the cookies information is read by the browser from client machine if exists and sent to the server.

Cookies are two types:

  1.   Persistent: If we store information in cookie with an expiration date then it is called persistent cookie. Means the information stored in cookie will expire after that expiration time.

  2.  Non-Persistent: We store information in cookie without expiration date. Means the information stored in cookie will be stored till user is using the same browser. Use non persistent cookie for the information that is secure.

Let us understand it with an example:

Cookies_Demo2.aspx:

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Cookies_Demo2.aspx.cs" Inherits="Cookies_Demo2" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        Name: <asp:TextBox ID="txtName" runat="server"></asp:TextBox>
        Password:<asp:TextBox ID="txtPassword" runat="server"></asp:TextBox>
        <asp:Label ID="lblResult" runat="server"></asp:Label>

        <asp:Button ID="btnSubmit" runat="server" OnClick="btnSubmit_Click" Text="Submit"/>
    </div>
    </form>
</body>
</html>

Cookies_Demo2.aspx.cs:

using System;

public partial class Cookies_Demo2 : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Request.Cookies["name"] != null)
        {
            txtName.Text = Request.Cookies["name"].Value.ToString();
        }
        if (Request.Cookies["password"] != null)
        {
            txtPassword.Text = Request.Cookies["password"].Value.ToString();
        }
       
    }
    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        Response.Cookies["name"].Value = txtName.Text;
        Response.Cookies["password"].Value = txtPassword.Text;
        Response.Cookies["name"].Expires = DateTime.Now.AddMinutes(10);
        Response.Cookies["password"].Expires = DateTime.Now.AddMinutes(10);
        lblResult.Text = "Request send successfully.";
    }
}

Here in the above example when user will click on “Submit” button after entering the user name and password server will create cookies “name” and “password” using the “Response” object.
If you want to make cookie as persistent the use the “Expires” property and set the value as mentioned above.

Now, close the browser and open it with same URL. If you open it within 10 minutes then information stored in cookie will assigned into the “txtName” and “txtPassword”. But after 10 minutes it will destroy.

Important Notes:

   1.   Use cookies for small size of information. Cookie size cannot be more than 4KB i.e. 4096 bytes
   2.   20 cookies are allowed per domain.




Monday, November 14, 2016

State Management in asp.net- Part 2


View State: 

It is one of client side state management technique.

When a user sends a request to server and response came back to the user then we need to maintain the data send by the user. In view state, state information is maintained in the page level. In the page state information is stored in the hidden field. In the hidden field value is stored in the form of hashed string. In case the length of hash string exceed by some fixed length then another hidden field is created and so on. Programmatically it uses the “Dictionary Object” i.e. key and value pair to store the data in view state.

By using view state we can maintain the page data when user sends the request of same page multiple times. Means we can maintain the data of a page till that page is active.

Asp.net maintains the state information of the asp.net controls and page by default.

Here let us see the example of storing information in view state and retrieving it back:

Default.aspx:

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" EnableEventValidation="false" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    Hello!!! this is home page
        <asp:TextBox ID="txtName" runat="server"></asp:TextBox>
        <asp:Button ID="btn" Text="Submit" runat="server" OnClick="btn_Click"/>
        <asp:Label ID="lbl" runat="server" BackColor="Yellow"></asp:Label>
        <asp:Label ID="lbl2" runat="server"></asp:Label>
    </div>
    </form>
</body>
</html>


Default.aspx.cs:

using System;

public partial class _Default : System.Web.UI.Page
{
    string name = "abc";
    protected void Page_Load(object sender, EventArgs e)
    {

        lbl.Text = name;

        if (ViewState["Name"] != null)
        lbl2.Text = ViewState["Name"].ToString(); // Getting stored information from          //view state
    }

    protected void btn_Click(object sender, EventArgs e)
    {
        ViewState["Name"] = name + txtName.Text; //Storing information in view state
        name = name + txtName.Text;
    }
}


    1.       Enter the value in textbox and click the submit button. It will store the “value stored in the name variable + value entered into the textbox”.

    2.       Again click on “Submit” button.

    3.       See the value of “ViewState["Name"]”. Also check the value stored into the “name” variable.




Sunday, November 13, 2016

State Management in asp.net - Part 1

State Management in Asp.net:

State Management: To manage the state of Web Pages/ User Data we use the state management technique. The reason to manage state is that browser and HTTP/HTTPs are stateless. Each time when user send request to the web server a new object of the page is created.

We can manage the state at different level:

     1.       Control Level: All controls in asp.net have automatic state management.
     2.       Object or Variable Level: For variable in a page need object or variable level state management.
     3.       Single or Multiple Page Level: In case of page requests
     4.       User Level: Manage state as long as user is active on the application.
     5.       Application Level: Manage state irrespective of user. It will be available to all users.
     6.       Application to Application Level: Manage state among multiple applications.

We can manage the state in asp.net in the following ways:

     1.       Client Side State Management: In this type of state management all information related to state are stored at client machine or in the page user is looking into. Server does not store any information b/w client to server round trip.

There are multiple ways to manage state at client side:

a)      View State

b)      Control State

c)       Hidden Field

d)      Cookies

e)      Query String

    2.       Server Side State Management: In this type of state management all information related to state are stores at server machine. Server sends less information to client.

a)      Application State

b)      Session State

There are three modes (ways) to manage Session State:

i)                    In Proc
ii)                   State Server
iii)                 SQL Server