Wednesday, June 21, 2017

API

API
(Application Programming Interface)


 
HTTP

↬ HyperText Transfer Protocol.
↬ Rules for getting something from one place to another.
 
REST
Representational State Transfer.
↬ it must do the following:
  1. Separate the client from the server
  2. Not hold state between requests
  3. Use HTTP and HTTP methods 
The Four Verbs
  1. GET: retrieves information from the specified source
  2. POST: sends new information to the specified source.
  3. PUT: updates existing information of the specified source.
  4. DELETE: removes existing information from the specified source.
 
Anatomy of a Request
 
1) request line
2)header
3)body  
 
Authentication & API Keys
 
"APIs require authentication using a protocol called OAuth." 
Eg:
var apiKey = "FtHwuH8w1RDjQpOr0y0gF3AWm8sRsRzncK3hHh9";
 
XML 
(E xtensible Markup Language )

Sunday, June 11, 2017

SASS

SASS
↣ SASS:- Syntactically Awesome Stylesheet

Advantages of SASS

  • It allows writing clean CSS in a programming construct.
  • It helps in writing CSS quickly.
  • It is a superset of CSS, which helps designers and developers work more efficiently and quickly.
  • As Sass is compatible with all versions of CSS, we can use any available CSS libraries.
  • It is possible to use nested syntax and useful functions such as color manipulation, mathematics and other values.

Disadvantages of SASS

  • It takes time for a developer to learn new features present in this pre-processor.
  • If many people are working on the same site, then should use the same preprocessor. Some people use Sass and some people use CSS to edit the files directly. Therefore, it becomes difficult to work on the site.
  • There are chances of losing benefits of browser's built-in element inspector.

SASS Indented Syntax

SASS Indented syntax or just SASS is an alternative to CSS based SCSS syntax.
  • It uses indentation rather than { and } to delimit blocks.
  • To separate statements, it uses newlines instead of semicolons(;).
  • Property declaration and selectors must be placed on its own line and statements within { and } must be placed on new line and indented.
  Syntax

.myclass {
   color = red;
   font-size = 0.2em;
}
 
Do you want more information visit http://www.tutorialspoint.com/sass/
Thank you
  

JSON

JSON

JSON is a lightweight data-interchange format.
JSON :- JavaScript Object Notation

Sending Data

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

Receiving Data

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

JSON Syntax Rules

  • Data is in name/value pairs
  • Data is separated by commas
  • Curly braces hold objects
  • Square brackets hold arrays
Eg: 
JSON Strings
{ "name":"Dilani" }

 JSON Numbers
{ "age":19}  

 JSON Objects
{
"employee":{ "name":"Dilani", "age":19, "city":"Jaffna" }
}
 


 Arrays
{
"employees":[ "Dilani", "Api", "Mino" ]
}
 


 JSON Booleans
{ "sale":true
 
JSON null
{ "middlename":null }

Data Types

  • a string
  • a number
  • an object (JSON object)
  • an array
  • a boolean
  • null
JSON values cannot be one of the following data types:
  • a function
  • a date
  • undefined

Stringify

var myJSON = JSON.stringify(arr);

 

 

 

 

 

 

 


MongoDB & Node.js

MongoDB & Node.js


⇰ Creating a Database

var MongoClient = require('mongodb').MongoClient;
var url = "mongodb://localhost:27017/<dbname>";

MongoClient.connect(url, function(err, db) {
  if (err) throw err;
  console.log("Database created!");
  db.close();
});


⇰ Creating a Table

var MongoClient = require('mongodb').MongoClient;
var url = "mongodb://localhost:27017/<dbname>";

MongoClient.connect(url, function(err, db) {
 if (err) throw err;
 db.createCollection("<tablename>"function(err, res) {
  if (err) throw err;
 console.log("Table created!");
 db.close();
  });
});

⇰ Insert Into Table

var MongoClient = require('mongodb').MongoClient;
var url = "mongodb://localhost:27017/<dbname>";

MongoClient.connect(url, function(err, db) {
 if (err) throw err;
 var myobj = [
  { name: 'Dilani', address: 'Karainagar'},
  { name: 'Inthu', address: 'Jaffna'}
  ];

  db.collection("<tablename>").insert(myobj, function(err, res) {
  if (err) throw err;
  console.log("Number of records inserted: " + res.insertedCount);
  db.close();
  });
});

⇰ Select One

var MongoClient = require('mongodb').MongoClient;
var url = "mongodb://localhost:27017/<dbname>";

MongoClient.connect(url, function(err, db) {
  if (err) throw err;
  db.collection("<tablename>").find({}).toArray(function(err, result) {
    if (err) throw err;
    console.log(result);
    db.close();
  });
});

⇰ Filter the Result

var http = require('http');
var MongoClient = require('mongodb').MongoClient;
var url = "mongodb://localhost:27017/<dbname>";

MongoClient.connect(url, function(err, db) {
  if (err) throw err;
  var query = { address: "Karanagar" };  db.collection("<tablename>").find(query).toArray(function(err, result) {
    if (err) throw err;
    console.log(result);
    db.close();
  });
});

⇰ Sort the Result

var http = require('http');
var MongoClient = require('mongodb').MongoClient;
var url = "mongodb://localhost:27017/<dbname>";

MongoClient.connect(url, function(err, db) {
  if (err) throw err;
  var mysort = { name: 1 };  db.collection("<tablename>").find().sort(mysort).toArray(function(err, result) {
    if (err) throw err;
    console.log(result);
    db.close();
  });
});


⇰ Delete Record

var http = require('http');
var MongoClient = require('mongodb').MongoClient;
var url = "mongodb://localhost:27017/<dbname>";

MongoClient.connect(url, function(err, db) {
  if (err) throw err;
  var myquery = { address: 'Mountain 21' };  db.collection("<tablename>").remove(myquery, function(err, obj) {
    if (err) throw err;
    console.log(obj.result.n + " document(s) deleted");
    db.close();
  });
});


⇰ Drop Collection

var MongoClient = require('mongodb').MongoClient;
var url = "mongodb://localhost:27017/mydb";

MongoClient.connect(url, function(err, db) {
  if (err) throw err;
  db.collection("customers").drop(function(err, delOK) {
    if (err) throw err;
    if (delOK) console.log("Table deleted");
    db.close();
  });
});

⇰ Update Document

var MongoClient = require('mongodb').MongoClient;
var url = "mongodb://127.0.0.1:27017/mydb";

MongoClient.connect(url, function(err, db) {
  if (err) throw err;
  var myquery = { address: "Karanagar" };
  var newvalues = { name: "Inthu", address: "Karanagar" };
  db.collection("customers").update(myquery, newvalues, function(err, res) {
    if (err) throw err;
    console.log(res.result.nModified + " record updated");
    db.close();
  });
});

Nodejs

Node Js


  • Node.js is a very powerful JavaScript-based framework
  • It is used to develop I/O intensive web applications like video streaming sites, single page applications, and other web applications.
  • Node.js is an open source, cross-platform runtime environment for developing server side and networking applications.
  • Node.js applications are written in JavaScript, and can be run within the Node.js runtime on OS X, Microsoft Windows, and Linux.


Concepts

⇉ console.log("Hello World!");
O/P Hello World!

  • The files you create with your editor are called source files and contain program source code. The source files for Node.js programs are typically named with the extension ".js".
  •  if you want dwd nodejs server visit this page
https://nodejs.org/download/

var http = require("http");

http.createServer(function (request, response) {

   // Send the HTTP header 
   // HTTP Status: 200 : OK
   // Content Type: text/plain
   response.writeHead(200, {'Content-Type': 'text/plain'});
   
   // Send the response body as "Hello World"
   response.end('Hello World\n');
}).listen(8081);

// Console will print the message
console.log('Server running at http://127.0.0.1:8081/');
Now execute the main.js to start the server as follows −
$ node main.js
Verify the Output. Server has started.
Server running at http://127.0.0.1:8081/
do you want more information visit http://www.tutorialspoint.com/nodejs/

Wednesday, June 7, 2017

28th class at 26.06.2017

Today is uki 28th class

Today discuss our in class exercise.
exercise1
1) use music
db
2) db.creteColletion("songdetails")
3) db.songdetails.insert(song_name:"thaniye thaniye", flim:"rhythm",music_derctor:"A.R.Rahuman", singer:"shankar mahadeven")
4) db.songdetails.find().pretty()
5) db.songdetails.find({music_director:"A.R.Rahman"},{song_name:1,_id:0})
6) db.songdetails.find({music_director:"A.R.Rahman",singar:"Unnikirishnan"},{song_name:1,_id:0})
7) db.songdetails.remove({songname:"roja poonthoddam"})
8) db.songdetails.insert(song_name:"Etho thechcha", flim:"Anjaan",music_derctor:"A.R.Rahuman", singer:"Aniruth")
9) db.songdetails.find({singar:"Harikaran", flim:"Minsara kannavu"},{song_name:1,_id:0})
10) db.songdetails.find({},{singar:1,_id:0})
 

Tuesday, June 6, 2017

26th class at 24.05.2017 and 27th class at 25.05.2017

Today is uki 26th class.
mongodb comments 
** db.<collection name>.remove({age:25})

{if will delete all the documents equal to age is 25 } 

** db. <collection name>.update({name:"raja"},{$set:{name:"ravi"}})

{update to raja name is changed to ravi} 


 RDBMS Where Clause Equivalents in MongoDB
To query the document on the basis of some condition, you can use following operations



The aggregate() Method

Syntax
Basic syntax of aggregate() method is as follows:
>db.COLLECTION_NAME.aggregate(AGGREGATE_OPERATION)



OR in MongoDB

Syntax
To query documents based on the OR condition, you need to use $or keyword. Following
is the basic syntax of OR −




AND in MongoDB

Syntax
In the find() method, if you pass multiple keys by separating them by ',' then MongoDB
treats it as AND condition. Following is the basic syntax of AND −

>db.mycol.find({key1:value1, key2:value2}).pretty()
thankyou



Friday, June 2, 2017

25th class at 23.05.2017

Today is uki 25th class.

Today we studied MongoDB. This is database language.  

some commands
** show dbs
{data bases show}
** use <database name>
{use database}
** db
{go to database}
**db.createCollection(name)
{creae new collection}
** db.<collection name>.insert({name:"dilai",age:22})
{insert data}
** db.<collecion name>.find()
{show detail}
**db.dropDatabase()
{delete database}
** show collection
{show the collections}
** db.<collection name>.drop()
{delete table}
** db.<collection name>.find({age:22},{name:1,_id:0})
{It will print the name of persons whose age is 22}
**db.<collection name>.find().pretty()
{print the details pretty formate}
I will be meet tommorw more than commands
bye......

23rd at class at 19.05.2017

Today is uki 23rd class.

Today is studied jQuery

 




 1st we install jquery file so visit http://jquery.com/download/ and download.
then we are colled my file 

<head>
<script src="jquery-3.2.1.min.js"></script>
</head>
 
 useing this way. 

Syntax
$(document).ready(function(){

   // jQuery methods go here...

});


some examples  
 * document hide
 $("#hide").click(function(){
    $("p").hide();
});


* document show
$("#show").click(function(){
    $("p").show();
});


 then we make simple website

bye......
 

Thursday, June 1, 2017

22nd class at 18.05.2017

Today is uki 22nd class
Today dived 4 group and give four titles and present about the topic. 
1) Data type
<p id="demo"></p>
<script>
var x=15
"valvo";
document.getElementById("demo").innerHTML = x;
</script>

2)Variables
<script>
var price1=5;
var price2=6;
var total=price1+price2

3)For loop
var i
for(x=0; x<10; i++)
{text="the number is "+x+"<br>";}
document.wite(text);

4)Array
var furits=["banana","Orange","Apple"];

5)Arry sort
var name=["shama","dilani","janu"];
name.sort();

var name=["shama","dilani","janu"];
name.reversing();

var number=[12, 36,85,2,89,25];
  number.sort(function(a,b){retrna-b)};

var number=[12, 36,85,2,89,25];
  number.sort(function(a,b){retrn b-a)};

4) Ramdom
var point=[40,45,98,56,85,65];
pont.sort(function(a,b){return 0.5-math.random()});

5)Function
function f.Name(){
}

6)Condition
if(1<18){
documet.wirte("hello")
}
else
{
document.write("haii")

thankyou next i meet jQuery bye......

21st class at 17/05.2017

Today is uki 21st class. 
Today is 1 month anniversary in uki.life. I got an award is best blogger writer. So I feel very happiness. Then I studies Javascript.  

While loop

Syntax
while (condition) {

code block to be executed

}

Eg: 1)

while (a < 5) {
    text += "number is " + a;
    a++;
}

output:

number 1

number2

number3

number4

Do/While Loop

Syntax

do {
    code block to be executed
}
while (condition); 

Eg: 2)

do {
    text += "number " + a;
    a++;
}
while (a< 5);  

output:

number 1

number2

number3

number4

more example coding

1) i=1;
a=1;
while(a<=10)
{
    i=i*3;
  document.write("The number is "+"   3"+"<sup>"+a+"</sup>"+"  =  "+i+"<br>" );
a++;
}
2)i=0;
var text=""
do{
  text+= "<br>The number is "+i;
  i++;
}
while(i<10);
  document.getElementById("demo").innerHTML=text;
Thankyou

meet tommorrow bye..........