Sunday, August 4, 2019

PAST TENSE

Past Tense
We know about the three types of tenses that are used in English Grammar namely Past Tense, Present Tense and Future Tense. Each of these tenses is actually verbs that are used to indicate the occurrence of an event or action at a particular time. Today, let us learn and understand more about the Past Tense and its different types.

Simple Past Tense
The simple past tense is used to indicate or describe something that happened or existed in the past. The situations or conditions to use a simple past tense is to:
  • describe an action, event or condition that occurred in the past or at a specified time
  • refer or describe an action that has been completed and there is no time mentioned.
  • describe an action or occurrence of an event that is done repeatedly and regularly.
  • describe a state of mind in the past or a feeling that was felt in the past.
  • refer to someone who has died
  • describe events that have occurred in quick succession in the past.

Formulating the Simple Past Tense Verb
To formulate the simple past tense verb, we add ‘- ed’. For verbs ending in ‘e’, we add ‘-d’ and. However, there are some simple past tense verbs such as cut, put, set etc which remain the same in the present and past tense. 
Examples are,
  1. He worked at the Cheesecake Factory.
  2.  I often brought my lunch to school.
  3. Learn about Simple Present Tense and Simple Future Tense


Past Continuous Tense
Past continuous tense is used to indicate an ongoing event in the past. Other conditions where past continuous tense is used are:
  1. To show that someone is in the middle of an action.                                                                 Example: I was calling him when he came home.                                                              
  2. Is used to describe an action taking place when another occurred.                                           Example: While they were painting the door, I was painting the windows.                                  
  3. For an action that was taking place in the past when an interrupted action happened.             Example: While he was working on his laptop, he fell asleep
Formulating the Past Continuous Tense
The past continuous tense is formed using the past tense of the verb to be(was/were) and the present participle verbs ending in -‘ing’.  These two tenses can be used together to indicate that an action happened while another was in progress.



Past Perfect Tense
The past perfect tense in a sentence or conversation describes an event that happened in the past before another event in the simple past tense was completed in the past. The situations where a Past Perfect Tense is used are to:
  1. indicate an event that has occurred and been completed in the past.                                                 Example: Meenu had borrowed money from the bank to buy her new car.                                                           
  2. describe an event or action which happened before a definite time in the past.                                 Example: We had cleaned up the terrace before the watchman arrived.                                  
  3. describe an action that happened in the past before another action took place.                                 Example: We had reached their house after the dinner was over.                                              
  4. Past Perfect Tense is also used to describe a state. Example: Their wives had become good friends at the wedding. A very important use of the Past Perfect Tense is that it is used to clarify which event happened earlier when two actions were completed in the past.            Example: I had read those books that you bought for me.

Formulating the Past Perfect Tense
The past perfect tense is formed with the past tense of the auxiliary verb have i.e which is had and the past participle of the main verb.



Past Perfect Continuous Tense
This tense is used to describe actions that were going on in the past up until another action in the past happened. They are often used in the following situations:
  • For an action that has occurred over a period of time having begun in the past.
  • To describe an action which started and finished in the past before another past action.
  • It is also regularly used in the reported speech where the present perfect continuous tense becomes past perfect continuous tense.
  • Unlike the past continuous and past perfect tenses, past perfect continuous tense is not used to indicate state, state of mind or feelings.
 Examples:
  1. I had been studying.
  2. It had been raining hard for several hours and the streets got flooded.
  3. If it had not been raining, we would have gone to the park.
  4. Learn more about Present Perfect Continous Tense and Future Perfect Continous Tense


Formulating the Past Perfect Continuous Tense
This tense is formed with the past perfect tense of the verb ‘to be’, which is ‘had been’ and the present participle of the verb i.e ‘-ing’.

Saturday, August 3, 2019

PRESENT TENSE

Simple Present Tense

The simple present is a verb tense with two main uses. We use the simple present tense when an action is happening right now, or when it happens regularly (or unceasingly, which is why it’s sometimes called present indefinite). Depending on the person, the simple present tense is formed by using the root form or by adding ‑s or ‑es to the end.

How do we make the Simple Present Tense?
subject + auxiliary verb + main verb

There are three important exceptions:

1. For positive sentences, we do not normally use the auxiliary.
2. For the 3rd person singular (he, she, it), we add s to the main verb or es to the auxiliary.
3. For the verb to be, we do not use an auxiliary, even for questions and negatives.

Look at these examples with the main verb like: 



Present Continuous Tense
This tense is used to describe a continued or ongoing action at the present time. It expresses an action which is in progress at the time of speaking and has not yet been completed. The Present Continuous Tense is, therefore, used in the following conditions:
  • As mentioned above, it is used for an action that is occurring at the time of speaking
  • When an action in the future is mentioned without specifying when it will occur
  • When we talk about a planned or arranged event or action that is set to take place at a specified time in the future.
  • It is also used in conditions where the action or event is occurring but not necessarily while we speak
  • It is used in a changing situation
  • With adverbs such as ‘always’ which describe an action that happens frequently.
Formulating the Present Continuous Tense
It is formed from the present tense of the auxiliary verb ‘to be’ and the present participle of the verb ‘-ing’. 
Examples are,
  1. The noise is beginning to give me a headache.
  2. I am complaining to his mother about him.
  3. Why aren’t you doing your homework, Ravi?


Present Perfect Tense
The Present Perfect Tense is used in case of repeated actions, in those actions where the time is not important, and actions that began in the past but are not finished yet and will probably finish in the present as we speak. The Present Perfect Tense can be used in the following scenarios:


  • It is commonly used in actions or events that began in the past and have continued into the present
  • They are used to show an action that has been completed
  • To indicate a time period that has not yet finished
  • This tense is often used with phrases that begin with “This is the first” or “second time” and so on.
  • Is used to describe or express an action that is repeated in the past
  • Used to indicate or describe actions that have been completed in the recent past
Formulating the Present Perfect Tense

To form the present perfect tense, we need to use the simple present tense of the auxiliary verb ‘have’ or ‘has’ based on whether the noun being referred to is plural or singular. The auxiliary verb is then followed by the past participle of the verb. It can also be written as: have/has + past participle. 
Let us see some examples,


  1. We have known each other for a very long time.
  2.  There have been many contenders for this role.
  3. Has there ever been a war during your lifetime?
  4. I have just eaten.
  5. We have had the same car for 8 years.

Present Perfect Continuous Tense

This tense is generally used to describe or indicate an event that is going on at this moment. 

The Present Perfect Continuous Tense is used in the following conditions:


  • It is used to describe an event that began in the past and is continuing into the future
  • An activity or event that began in the past and is now over(just recently completed or over)
  • It is also used when there is no mention of time.

Formulating the Present Perfect Continuous Tense
The present perfect continuous tense is made up of two parts:

The present perfect tense of the verb ‘to be’: ‘have been’ or ‘has been’  and
The present participle of the main verb ‘-ing.

Some examples of present perfect continuous tense are,


  1. My hands are very dirty as I have been painting the walls.
  2. They have been trying to contact her.
  3. I have been working for them for the last seven months.
  4. The party has been going on all night


ER DIAGRAM

ER Diagram

What is the ER Model?

The ER or (Entity Relational Model) is a high-level conceptual data model diagram. Entity-Relation model is based on the notion of real-world entities and the relationship between them.

ER modeling helps you to analyze data requirements systematically to produce a well-designed database. So, it is considered a best practice to complete ER modeling before implementing your database.


History of ER models

ER diagrams are a visual tool which is helpful to represent the ER model. It was proposed by Peter Chen in 1971 to create a uniform convention which can be used for relational database and network. He aimed to use an ER model as a conceptual modeling approach.


What is ER Diagrams?

Entity relationship diagram displays the relationships of entity set stored in a database. In other words, we can say that ER diagrams help you to explain the logical structure of databases. At first look, an ER diagram looks very similar to the flowchart. However, ER Diagram includes many specialized symbols, and its meanings make this model unique.





Facts about ER Diagram Model:
  • ER model allows you to draw Database Design
  • It is an easy to use graphical tool for modeling data
  • Widely used in Database Design
  • It is a GUI representation of the logical structure of a Database
  • It helps you to identifies the entities which exist in a system and the relationships between those entities

Why use ER Diagrams?
Here, are prime reasons for using the ER Diagram

  • Helps you to define terms related to entity relationship modeling
  • Provide a preview of how all your tables should connect, what fields are going to be on each table
  • Helps to describe entities, attributes, relationships
  • ER diagrams are translatable into relational tables which allows you to build databases quickly
  • ER diagrams can be used by database designers as a blueprint for implementing data in specific software applications
  • The database designer gains a better understanding of the information to be contained in the database with the help of ERP diagram
  • ERD is allowed you to communicate with the logical structure of the database to users

Components of the ER Diagram
This model is based on three basic concepts:

  • Entities
  • Attributes
  • Relationships



WHAT IS ENTITY?


A real-world thing either living or non-living that is easily recognizable and nonrecognizable. It is anything in the enterprise that is to be represented in our database. It may be a physical thing or simply a fact about the enterprise or an event that happens in the real world

An entity can be place, person, object, event or a concept, which stores data in the database. The characteristics of entities are must have an attribute, and a unique key. Every entity is made up of some 'attributes' which represent that entity.


Relationship

Relationship is nothing but an association among two or more entities.Entities take part in relationships. We can often identify relationships with verbs or verb phrases.


Attributes

It is a single-valued property of either an entity-type or a relationship-type.
For example, a lecture might have attributes: time, date, duration, place, etc.
An attribute is represented by an Ellipse





Simple attribute  ;--  Simple attributes can't be divided any further. For example, a student's contact number. It is also called an atomic value


Composite attribute:-- It is possible to break down composite attribute. For example, a student's full name may be further divided into first name, second name, and last name.


Derived attribute:-- This type of attribute does not include in the physical database. However, their values are derived from other attributes present in the database. For example, age should not be stored directly. Instead, it should be derived from the DOB of that employee.


Multivalued attribute:-- Multivalued attributes can have more than one values. For example, a student can have more than one mobile number, email address, etc

Weak Entities
A weak entity is a type of entity which doesn't have its key attribute. It can be identified uniquely by considering the primary key of another entity. For that, weak entity sets need to have participation.

Cardinality

Defines the numerical attributes of the relationship between two entities or entity sets.
Different types of cardinal relationships are:
  1. One-to-One Relationships
  2. One-to-Many Relationships
  3. May to One Relationships
  4. Many-to-Many Relationships

1.One-to-one:

One entity from entity set X can be associated with at most one entity of entity set Y and vice versa.

Example: One student can register for numerous courses. However, all those courses have a single line back to that one student.

2.One-to-many:

One entity from entity set X can be associated with multiple entities of entity set Y, but an entity from entity set Y can be associated with at least one entity.

3. Many to One

More than one entity from entity set X can be associated with at most one entity of entity set Y. However, an entity from entity set Y may or may not be associated with more than one entity from entity set X.

4. Many to Many:

One entity from X can be associated with more than one entity from Y and vice versa

ER- Diagram Notations
ER- Diagram is a visual representation of data that describe how data is related to each other.



Sunday, July 14, 2019

JSON





  • JSON: JavaScript Object Notation.
  • JSON is a syntax for storing and exchanging data.
  • JSON is text, written with JavaScript object notationJSON


The JSON object, available in all modern browsers, has two very useful methods to deal with JSON-formatted content: parse and stringify. JSON.parse() takes a JSON string and transforms it into a JavaScript object. JSON.stringify() takes a JavaScript object and transforms it into a JSON string.


  1. When exchanging data between a browser and a server, the data can only be text.
  2. And we can convert any JavaScript object into JSON, and send JSON to the server.
  3. We can also convert any JSON received from the server into JavaScript objects.
  4. This way we can work with the data as JavaScript objects, with no complicated parsing and translations.

convert to JSON :-

const myObj = {
 name: 'Skip',
 age: 2,
 favoriteFood: 'Steak'
};
const myObjStr = JSON.stringify(myObj);
console.log(myObjStr);
// "{"name":"Skip","age":2,"favoriteFood":"Steak"}"
console.log(JSON.parse(myObjStr));
// Object {name:"Skip",age:2,favoriteFood:"Steak"}


Sending Data:-
If you have data stored in a JavaScript object, you can convert the object into JSON, and send it to a server:

var myObj = {name: "John", age: 31, city: "New York"};
var myJSON = JSON.stringify(myObj);
window.location = "demo_json.php?x=" + myJSON;

 Recieving Data:-

If you receive data in JSON format, you can convert it into a JavaScript object:

var myJSON = '{"name":"John", "age":31, "city":"New York"}';
var myObj = JSON.parse(myJSON);
document.getElementById("demo").innerHTML = myObj.name;
 Storing Data:-

When storing data, the data has to be a certain format, and regardless of where you choose to store it, the text is always one of the legal formats.
JSON makes it possible to store JavaScript objects as text.
// Storing data:
myObj = {name: "John", age: 31, city: "New York"};
myJSON = JSON.stringify(myObj);
localStorage.setItem("testJSON", myJSON);

// Retrieving data:
text = localStorage.getItem("testJSON");
obj = JSON.parse(text);
document.getElementById("demo").innerHTML = obj.name;

Why use JSON?

Since the JSON format is text only, it can easily be sent to and from a server, and used as a data format by any programming language.

JavaScript has a built in function to convert a string, written in JSON format, into native JavaScript objects:

JSON.parse()

So, if you receive data from a server, in JSON format, you can use it like any other JavaScript object.


What is JSON?

JSON stands for JavaScript Object Notation
JSON is a lightweight data-interchange format
JSON is "self-describing" and easy to understand
JSON is language independent

JSON Values

In JSON, values must be one of the following data types:


  • a string
  • a number
  • an object (JSON object)
  • an array
  • a boolean
  • null


In JavaScript, values can be all of the above, plus any other valid JavaScript expression, including:

a function
a date
undefined

In JSON, string values must be

In jSON:- { "name":"John" }
In js  :- { name:'John' }


JSON Uses JavaScript Syntax

Because JSON syntax is derived from JavaScript object notation, very little extra software is needed to work with JSON within JavaScript.

With JavaScript you can create an object and assign data to it, like this:

var person = { name: "John", age: 31, city: "New York" };

The same way JavaScript objects can be used as JSON, JavaScript arrays can also be used as JSON.

JSON.Parse() 
A common use of JSON is to exchange data to/from a web server.
When receiving data from a web server, the data is always a string.
Parse the data with JSON.parse(), and the data becomes a JavaScript object.



JSON From the Server
You can request JSON from the server by using an AJAX request

As long as the response from the server is written in JSON format, you can parse the string into a JavaScript object.

EX:
var xmlhttp = new XMLHttpRequest();
xmlhttp.onreadystatechange = function() {
  if (this.readyState == 4 && this.status == 200) {
    var myObj = JSON.parse(this.responseText);
    document.getElementById("demo").innerHTML = myObj.name;
  }
};
xmlhttp.open("GET""json_demo.txt"true);
xmlhttp.send();



Parsing Dates

Date objects are not allowed in JSON.

If you need to include a date, write it as a string.

You can convert it back into a date object ter:


Parsing Functions

Functions are not allowed in JSON.

If you need to include a function, write it as a string.

You can convert it back into a function later:

JSON.Stringify()
A common use of JSON is to exchange data to/from a web server.

When sending data to a web server, the data has to be a string.

Convert a JavaScript object into a string with JSON.stringify()

JSON.OBJECT


JSON objects are surrounded by curly braces {}.

JSON objects are written in key/value pairs.

Keys must be strings, and values must be a valid JSON data type (string, number, object, array, boolean or null).

Keys and values are separated by a colon.

Each key/value pair is separated by a comma.


myObj = "name":"John""age":30"car":null };
x = myObj.name;

Arrays as JSON objects


Arrays in JSON are almost the same as arrays in JavaScript.

In JSON, array values must be of type string, number, object, array, boolean or null.

In JavaScript, array values can be all of the above, plus any other valid JavaScript expression, including functions, dates, and undefined.

{
"name":"John",
"age":30,
"cars":[ "Ford""BMW""Fiat" ]
}

JSON PHP

A common use of JSON is to read data from a web server, and display the data in a web page.

This chapter will teach you how to exchange JSON data between the client and a PHP server.

PHP has some built-in functions to handle JSON.

Objects in PHP can be converted into JSON by using the PHP function json_encode():


Saturday, July 6, 2019

JQuery

Image result for Jquery
jQuery is a JavaScript Library.  jQuery greatly simplifies JavaScript programming. 

What is jQuery?
jQuery is a lightweight, "write less, do more", JavaScript library.
The purpose of jQuery is to make it much easier to use JavaScript on your website.
jQuery takes a lot of common tasks that require many lines of JavaScript code to accomplish, and wraps them into methods that you can call with a single line of code.
jQuery also simplifies a lot of the complicated things from JavaScript, like AJAX calls and DOM manipulation

The jQuery library contains the following features:

  • HTML/DOM manipulation
  • CSS manipulation
  • HTML event methods
  • Effects and animations
  • AJAX
  • Utilities

Why jQuery?
There are lots of other JavaScript frameworks out there, but jQuery seems to be the most popular, and also the most extendable.


Many of the biggest companies on the Web use jQuery, such as:

  1. Google
  2. Microsoft
  3. IBM
  4. Netflix

There are several ways to start using jQuery on your web site. You can:

  • Download the jQuery library from jQuery.com
  • Include jQuery from a CDN, like Google

 jQuery from a CDN

<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
</head>


jQuery Syntax

The jQuery syntax is tailor-made for selecting HTML elements and performing some action on the element(s).
Basic syntax is: $(selector).action()

  • A $ sign to define/access jQuery
  • A (selector) to "query (or find)" HTML elements
  • A jQuery action() to be performed on the element(s)Examples:
  1. $(this).hide() - hides the current element.
  2. $("p").hide() - hides all <p> elements.
  3. $(".test").hide() - hides all elements with class="test".
  4. $("#test").hide() - hides the element with id="test"

MongoDB

Image result for mongodb



What is MongoDB-----:-

MongoDB is a document database with the scalability and flexibility that you want with the querying and indexing that you need

⧫    MongoDB stores data in flexible, JSON-like documents, meaning fields can vary from document to document and data structure can be changed over time

⧫ The document model maps to the objects in your application code, making data easy to work with

⧫ You can make developments easily


Why Use MongoDB?

📄  Document Oriented Storage − Data is stored in the form of JSON style documents.

📄  Index on any attribute

📄  Replication and high availability

📄  Auto-sharding

📄  Rich queries

📄  Fast in-place updates

📄  Professional support by MongoDB

Where to Use MongoDB?

  • Big Data
  • Content Management and Delivery
  • Mobile and Social Infrastructure
  • User Data Management
  • Data Hub

In sql data save as table Mongodb saves as collections.










Basic Commands for the MongoDB

Installation Commands (Ubuntu) :

#1
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 9DA31620334BD75D9DCB49F368818C72E52529D4


#2
echo "deb [ arch=amd64 ] http://repo.mongodb.com/apt/ubuntu bionic/mongodb-enterprise/4.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-enterprise.list

#3
sudo apt-get update

#4
sudo apt-get install -y mongodb-enterprise


How to Start 




#Step 1: Start MongoDB  .
sudo service mongodb start
 #Stop MongoDB
sudo service mongodb stop
#  To Start the Server
sudo mongo
# To Start the Client
sudo mongod



Basic Commands 



1. Finding the current database you’re in 

db 

2. Listing databases

Show dbs



3. Go to a particular database
use Database_name

4. Creating a Database
use Database_name     :- use command used for both action

5. Creating a Collection
db.createCollection("myCollection")


6. Inserting Data
db.myCollection.insert({"name": "john", "age" : 22, "location": "colombo"})
 db.myCollection.insertOne(i      {       "name": "navindu",        "age": 22      })
 db.myCollection.insertMany([      {        "name": "navindu",         "age": 22      },         {        "name": "kavindu",  "age": 20      },    { "name": "john doe",  "age": 25,        "location": "colombo"}     ])
7. Querying Data
db.myCollection.find()
 db.myCollection.find().pretty()

8. Updating documents
db.myCollection.update({age : 20}, {$set: {age: 23}})
db.myCollection.update({name: "navindu"}, {$unset: age});

9. Removing a document
db.myCollection.remove({name: "navindu"});

10. Removing a collection
db.myCollection.remove({});




Some  Funtions















Connecting method With Database and server



Image result for mongodb

Thursday, July 4, 2019

            Nodejs                                    
 

↦Node.js is an open-source server environment
↦Node.js allows you to run JavaScript on the server.

Its help to the user to connect the server and Database  likely it works as an intermediate

 A lot of youth aspires to be a most sought after software developer and so goes on to learn the required programming skills to match to the current market and industrial needs. They have broadly two choices to make
To Be A Front-End Developer
To Be A Back-end Developer.

Node js is a backend develop language. if you want to become a Back-end Developer so you have to study this. It's really hard but if you study hard you will get it soon.

This server-side application directly interacts with the database via an application programming interface (API), which pulls, saves, or changes data.
 Node.js which is the most sought after backend scripting language in the current technology market and is becoming the preferred language options for back-end programmers.

Node.js an asynchronous event-driven JavaScript runtime, which is designed to build scalable network applications. It can handle many concurrent connections at a time, where when connection request are made concurrently for each connection a callback is fired. If there is no task to be performed Node will go to sleep.

History of Node.js

Node.js was first conceived in 2009 by Ryan Dahl and was developed and maintained by Ryan which then got sponsored and supported by Joyent. Dahl was not happy the way Apache Http server used to handle a lot of concurrent connections and the way code was being created which either blocked the entire process or implied multiple execution stacks in the case of simultaneous connections. This leads him to create a Node.js project which he went on to demonstrate at the inaugural European JSConf on November 8, 2009. He used Google Google’s V8 JavaScript engine, an event loop, and a low-level I/O API in his project which won lots of hearts and a standing ovation.

Here is how Node.js handles a file request:


  1. Sends the task to the computer's file system.
  2. Ready to handle the next request.
  3. When the file system has opened and read the file, the server returns the content to the client.
What Can Node.js Do?

  1. Node.js can generate dynamic page content
  2. Node.js can create, open, read, write, delete, and close files on the server
  3. Node.js can collect form data
  4. Node.js can add, delete, modify data in your database.

How to install Node.js on ubuntu

Step #1:
sudo apt-get update

Step #2:
sudo apt-get install build-essential libssl-dev

Step #3:
sudo curl https://raw.githubusercontent.com/creationix/nvm/v0.33.11/install.sh | bash

Step #4 (if no curl):
sudo apt-get install curl
https://raw.githubusercontent.com/creationix/nvm/v0.33.11/install.sh | bash

Step #4:
source ~/.profile

Step #5:
nvm --version

Step #6:
nvm install 6.16.0

Step #7:
nvm ls

Step #8:
node --version

Step #9:
npm --version

to install nodemon
:--npm install -g nodemon


                            


Basic commands  for the Nodejs

exports.log =               {
    console: function(msg)  {
        console.log(msg);  },
    file: function(msg)     {
        // log to file here }
                            }
to export module for define by user

some modules:
http               :   http includes classes, methods  to create Node.js http server.
url                 :   url module includes methods for URL resolution and parsing.
querystring   :  querystring module includes methods to deal with query string.
path              :   path module includes methods to deal with file paths.
fs                  :     fs module includes classes, methods, and events to work with file I/O.
util                :   util module includes utility functions useful for programmers.


to create server:

var http = require('http');         // 1 - Import Node.js core module

var server = http.createServer(function (req, res) { } );   
 // 2 - creating server //handle incomming requests here..

Url module:

var url = require('url');
var adr = 'http://localhost:8080/default.htm?year=2017&month=february';
var q = url.parse(adr, true);

console.log(q.host);             //returns 'localhost:8080'
console.log(q.pathname);    //returns '/default.htm'
console.log(q.search);         //returns '?year=2017&month=february'

var qdata = q.query;            //returns an object: { year: 2017, month: 'february' }

console.log(qdata.month); //returns 'february'



Express

In this tutorial, we will also have a look at the express framework. This framework is built in such a way that it acts as a minimal an...