Sunday, September 18, 2016

Node basics

How to parse command line arguments in nodejs?

>node test.js hi hello cool

test,js
var cmdArgs = process.argv.slice(2);
console.log(cmdArgs); //prints ["hi","hello","cool"]

How to write a reusable module and how to import it in test.js?

myreusablemodule.js
module.exports = {
      sayHello : function(){
           console.log("Hello, how u doing?");
     }
};

test.js
var rModule = require("./myreusablemodule"); //returns whatever is assigned to module.exports
console.log(rModule.sayHello());

>node test.js

Explain about event driven programming in nodejs?

In an event driven programming, there is a main loop that listens for events, and then triggers a callback function when one of these events is detected.
Read more here: https://www.tutorialspoint.com/nodejs/nodejs_event_loop.htm

Give an example of event driven programming in nodejs?

All you need to remember is on and emit.

test.js
var events = require("events");
var eventsEmitter = new events.EventEmitter();
var mycustomeventassocfunction = function(){
      console.log("i am the response from mycustomeventassocfunction");
};
eventsEmitter.on("mycustomevent",mycustomeventassocfunction);

eventsEmitter.emit("mycustomevent");

>node test.js

How does the async functions work in nodejs?

Events and callbacks help nodejs to support concurrency.
database.query('something', function(err, result) {
  if (err) handle(err);
  doSomething(result);
});
The async function query takes callback function as the last parameter and the callback function takes err as the first parameter.
Read more here: https://www.tutorialspoint.com/nodejs/nodejs_event_loop.htm

What are the global objects in nodejs?

You don't have to require/include the global objects in nodejs programs. For example, console, process, __filename, __dirname, etc.

Read more here: https://www.tutorialspoint.com/nodejs/nodejs_global_objects.htm

test.js
console.log(__filename);

>node test.js

Friday, September 9, 2016

Cross-Origin Resource Sharing (CORS)


  • Say, web site a.com has some data that b.com site wants to access.
  • Web browser's same origin policy won't allow that happen.
  • If a.com supports CORS requests (that are made by sites like b.com) by adding a few special response headers, b.com can access the data.
  • CORS (Cross-Origin Resource Sharing) is a W3C spec that allows cross-browser communication from the browser. By building on top of the XMLHttpRequest object, CORS allows developers to work with the same idioms as same-domain requests. Read more in this html5rocks tutorial by Monsur Hossain!

Tuesday, August 30, 2016

Learn SQL queries on Oracle database

  • Go to http://sqltest.net/
  • Select Oracle 11g from the drop down on the right side of the black navigation bar.
  • Use these practice queries from this site.

Friday, August 19, 2016

Statistical Analysis System (SAS)


  • What does SAS stands for?
    • Statistical Analysis System
  • Who was the founder of SAS?
    • Jim Goodnight
  • How long SAS been around?
    • Around 30 years
  • What do you do with SAS software?
    • Gather, massage and manage the data, analyze the data, generate reports based on data.
  • What is the SAS software comprised of?
    • SAS Server to collect and save data, SAS Applications such as Enterprise Guide, SAS add-on for Microsoft Office, SAS Web Report Guide.
  • What are the SAS data access products?
    • SAS/ACCESS products that run on SAS Server.
  • Where can you download SAS software at free of cost?
  • What is a task in Enterprise Guide?
    • Tasks are the built-in wizards of Enterprise Guide.
  • Name couple of Enterprise Guide tasks?
    • Query Builder, Graphs, Reports, etc.
  • Why do you use charts in SAS?
    • To summarize the data.
  • Explain the basic mathematical terms mean, median, mode, range and give an example?
    • Mean is the average of all given numbers
    • Median is the middle number in the given numbers when arranged from smallest to largest
    • Mode is the number that appears the most in the given numbers
    • Range is the difference between the largest and smallest numbers in the given numbers
    • Let's find mean, median, mode, range of the given numbers 10, 18, 11, 11, 15
    • Mean: (10+18+11+11+15) / 5 = 13
    • Median: put the numbers in order: 10,11,11,15,18...and pick the middle number, 11
    • Mode: most appeared number is 11
    • Range: 18 (largest number) - 10 (smallest number) = 8
  • List some of the top pharmaceutical companies in USA?
  • Name some of the top clinical research organizations (CRO)?
    • Qunitiles, Covance, Parexel, Icon, INC, PPD, inVentiv, PRA, CRLI, WuXi
  • Name some of the top health foundations?
    • Bill & Melinda Gates Foundation, Robert Wood Johnson Foundation, Kresge Foundation, Nemours, W.K.Kellogg Foundation, Kaiser Parmanente.
  • Where can I learn more about Clinical Studies?
  • What are the clinical trial phases?
  • What is an IND Application?
    • IND stands for Investigational New Drug.
    • The drug sponsors file IND application to get the exemption from FDA to ship the experimental drug across the state lines (the intention is to use the drug in animal studies and human clinical trials). 
    • IND Application should have information in 3 broad areas: Animal Pharmacology and toxicity studies, Manufacturing information, Clinical Protocols and investigator information.
    • There are 3 IND types: Investigator IND, Emergency use IND, Treatment IND
    • Once the IND is submitted, the sponsor must wait 30 calendar days before initiating any clinical trials.
    • Read more at fda.gov
  • What is NDA Application?
    • NDA stands for New Drug Application.
    • The drug sponsors file NDA application with FDA to get the approval to sell the drug.
    • The data collected from IND becomes part of NDA.
    • Read more at fda.gov
  • What is the format of a proc step? (See for more details: http://www2.sas.com/proceedings/sugi29/256-29.pdf)

Thursday, July 28, 2016

Content Security Policy

What is Content Security Policy?


CSP defines the Content-Security-Policy HTTP header that allows you to create a whitelist of sources of trusted content, and instructs the browser to only execute or render resources from those sources. Even if an attacker can find a hole through which to inject script, the script won’t match the whitelist, and therefore won’t be executed.

Read more: http://www.html5rocks.com/en/tutorials/security/content-security-policy/