This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const key_var = 'TEXT_ANALYTICS_SUBSCRIPTION_KEY'; | |
if (!process.env[key_var] && !config[key_var]) { | |
throw new Error('please set/export the following environment variable: ' + key_var); | |
} | |
const subscription_key = process.env[key_var] || config[key_var]; | |
const endpoint_var = 'TEXT_ANALYTICS_ENDPOINT'; | |
if (!process.env[endpoint_var] && !config[endpoint_var]) { | |
throw new Error('please set/export the following environment variable: ' + endpoint_var); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let get_language = async function (documents) { | |
let body = JSON.stringify(documents); | |
let url = endpoint + pathForLanguages; | |
let params = { | |
headers: { | |
'Content-Type': 'application/json', | |
'Ocp-Apim-Subscription-Key': subscription_key | |
} | |
}; | |
let data = await axios.default.post(url, body, params) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//fetch wishes using axios | |
//for each wish, get data, perform language analysis on it | |
const axios = require('axios'); | |
const {get_language, get_sentiments} = require('./cognitives'); | |
module.exports = async function (context, req) { | |
let dataUrl = 'https://christmaswishes.azurewebsites.net/api/Wishes'; | |
try { | |
let getData = await axios.default.get(dataUrl); | |
let data = getData.data; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function hello(i) { | |
if (i < 0) return; // base case | |
console.log(i); | |
hello(--i); // recursive call | |
} | |
hello(5) // output: 5 4 3 2 1 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let i = 5; // I've chosen an arbitrary number | |
while (i > 0) { | |
console.log(i--); | |
} | |
// output: 5 4 3 2 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function fact(n) { | |
if (n == 1) return n; // base case | |
return n * fact(n - 1); // recursive call | |
} | |
// fact(5) analysis - output = 120 | |
fact(5) | |
5 * fact(4) | |
5 * (4 * fact(3)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function hello(i) { | |
if (i < 0) return; // base case | |
console.log(i); | |
hello(--i); // recursive call | |
} | |
hello(5); // output: 5 4 3 2 1 0 | |
function hello(i) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
hello(5) | |
hello(4) | |
hello(3) | |
hello(2) | |
hello(1) | |
hello(0) | |
hello(-1) | |
--- | |
console.log(-1) // and other statements left | |
console.log(0) // and other statements left |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* eslint-disable no-console */ | |
require('dotenv').config(); | |
const cluster = require('cluster'); | |
const jwt = require('jsonwebtoken'); | |
const backgroundJobHandler = require('background_job_handler'); | |
const app = require('./appREST'); | |
const rpc = require('./appRPC'); | |
const { DB } = require('./api/models'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export class Digraph { // exported so we can use it in topological sort | |
constructor(v) { | |
this.v = v; // initialize the number of vertices | |
this.e = 0; // and edges | |
this.adj = {}; // this object contains thevertices connected to each vertex. | |
} | |
addEdge(v, w) { | |
if (!adj[v]) adj[v] = []; // check if the vertex already exist, if not, created it | |
adj[v].push(w); // push the connecting edge vertex to its array of vertices |
OlderNewer