Tuesday 19 March 2019

AWS Rekognition for beginners

aws rekognition for beginners

Question: What is Amazon Rekognition?
Amazon Rekognition makes it easy to add image/video analysis to your applications.


Question: What different data we can get from Rekognition?
--Detect Objects and scenes that appear in photo/video.
--Face-based user verification.
--Detect Sentiment such as happy, sad, or surprise
--Unsafe Content Detection
--Celebrity recognition
--Text detection
--Rekognition can work on millions of photo.


Question: Give simplest example of working of Rekognition.
Each time a person arrives at your home, your door camera can upload a photo of the visitor to Amazon S3,
triggering a Lambda function that uses Rekognition API operations to identify your guest, and display the data on screen/mobile.



Question: Give some use case for Rekognition?
--Searchable image and video libraries
--Face-based user verification App
--Get the Sentiment and demographic analysis
--Detect the Unsafe Content Detection from photo/video
--Detect the Celebrity recognition
--Get the Text detection From photo/video


Question: What we can get from Rekognition for photos?
--Label detection
--Face detection and comparison
--Celebrity recognition
--Image moderation
--Text in image detection


Question: What we can get from Rekognition for videos?
--Labels
--Faces
--People
--Celebrities
--Suggestive and explicit adult content


Question: Recommendations for Stored and Streaming video?
https://docs.aws.amazon.com/rekognition/latest/dg/recommendations-camera-stored-streaming-video.html


Question: Give useful links for rekognition?

Get understanding
https://docs.aws.amazon.com/rekognition/latest/dg/what-is.html

Run sample code online (Require login)
https://ap-south-1.console.aws.amazon.com/rekognition/home?region=ap-south-1#/label-detection

API Docs
https://docs.aws.amazon.com/aws-sdk-php/v3/api/api-rekognition-2016-06-27.html


Question: What are different type of commands detection for videos.
Labels - StartLabelDetection - GetLabelDetection
People - StartPersonTracking - GetPersonTracking
Faces - StartFaceDetection - GetFaceDetection
Celebrities - StartCelebrityRecognition - GetCelebrityRecognition
Detect adult content - StartContentModeration-GetContentModeration




Question: What are different limitation by video Rekognition?
Video must be available in S3
Video must be H.264 codec.
File format must be MPEG-4 and MOV
Max filesize is 8GB


Monday 4 March 2019

Node JS Interview Questions and Answers

Node JS Interview Questions and Answers

Question: What is callback?
A callback function is called at the completion of a given task.


Question: What Are Arrow Functions?
Arrow functions – also called "fat arrow" functions, are a more concise syntax for writing function expressions.

Examples
const multiplyES6 = (x, y) => { return x * y };
const phraseSplitterEs6 = phrase => phrase.split(" ");
var docLogEs6 = () => { console.log(document); };



Question: What is JSON.stringify()?
JSON.stringify() method converts a JavaScript object to a JSON string.


Question: What is Handlebars view engine in nodejs?
Handlebars.js is templating engine in NodeJS.


Question: What is an error-first callback?
Error-first callbacks are used to pass errors and data.
You have to pass the error as the first parameter, and it has to be checked to see if something went wrong.


Question: What are Promises?
The Promise object represents the event completion or failure of an asynchronous operation, and its resulting value.
function readFile(filename, enc){
  return new Promise(function (resolve, reject){
    fs.readFile(filename, enc, function (err, res){
      if (err) reject(err);
      else resolve(res);
    });
  });
}



Question: What is callback hell in Node.js?
Callback hell is the result of heavily nested callbacks that make the code not only unreadable but also difficult to maintain.


Question: What is the role of REPL in Node.js?
Full form of REPL is Read Eval print Loop.


Question: Explain chaining in Node.js?
Chaining is a mechanism whereby the output of one stream is connected to another stream as input.


Question: How to access the GET parameters after ? in Express?
req.query.name;



Question: What is buffer module?
Buffer class provides instances to store binary data similar to an array of integers.


Question: How we exporting a Module?
We use export for exporting the module.
exports.sayHelloInEnglish = function() {
    return "Hello, how are you?";
};



Question: What is meaning of tilde and caret?
the tilde(~) matches the most recent minor version.
the caret(^) matches the most recent major version.


Question: How to access 2nd argument when passed in command line?
process.argv.slice(3,4); //two=222



Question: What is Yargs?
Yargs helps to parsing arguments of command line tools.



Question: What is Async?
Async is a utility module which provides straight-forward, powerful functions for working with asynchronous JavaScript.
async.map(['file1','file2','file3'], fs.stat, function(err, results) {
    // results is now an array of stats for each file
});



Question: How to use expressJs in Node
var express = require('express');
var app = express();

//Add cookie to express
var cookieParser = require('cookie-parser');
app.use(cookieParser());

//Add session to express
var session = require('express-session');
app.use(session({
    secret: 'XEDDKJKXD',
    name: 'testname',
    proxy: true,
    resave: true,
    saveUninitialized: true
}));

//Add static path
app.use(express.static('public'))

//Add "Parse JSOn" to express
var bodyParser = require('body-parser')
app.use(bodyParser.json());       // to support JSON-encoded bodies
app.use(bodyParser.urlencoded({// to support URL-encoded bodies
    extended: true
}));

//Add middleware to express
app.use(function (req, res, next) {
  //console.log('Time2222:', Date.now())
 res.header("Access-Control-Allow-Origin", "*");
  res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept");
   
  next()
})


//Add https to expresJs
var https = require('https');
var privateKey  = fs.readFileSync('public/cert/server.key', 'utf8');
var certificate = fs.readFileSync('public/cert/georama.crt', 'utf8');
var caCertificate = fs.readFileSync('public/cert/chain.crt', 'utf8');

var credentials = {key: privateKey, cert: certificate, ca: caCertificate};
var httpsServer = https.createServer(credentials, app);   


Question: How to start node on port?
httpsServer.listen(config['SERVERPORT'],function() {
    console.log('https listening on *:' + config['SERVERPORT']);
});



Question: How to connect socket with https?
var io = require('socket.io')(httpsServer);



Question: What is underscore module in nodeJS?
Underscore is a JavaScript library that provides a whole mess of useful functional programming helpers without extending any built-in objects.
console.log(_.each([1, 2, 3], function(value, key){
     console.log(key+'>>'+value)
 }));



Question: What Are Core Features Of Express Framework?
1) Allows to set up middlewares to respond to HTTP Requests.
2) Defines a routing.
3) Dynamically render HTML Pages.


Question: Give simple example of ExpressJS?
var app = require('express')();
var http = require('http').Server(app);

app.get('/listing', function (req, res) {   
   res.send('This is listing API'); 
});

http.listen('8080', function() {
    console.log('listening on *:8080');
});



Question: What are different Middleware?
1) Application-level middleware
2) Router-level middleware
3) Error-handling middleware
4) Built-in middleware
5) Third-party middleware