View levenEarlyExit.js
function create2DArray(a, b){ | |
var arr = new Array(b+1) | |
for(let x=0; x<arr.length; x++){ | |
arr[x] = new Array(a+1) | |
} | |
return arr; | |
} | |
var performanceMeasureCtr = 0; //Counts the number of time the inner loop will be running |
View LevenshteinDistance.js
//Create a 2D array in Javscript | |
function create2DArray(a, b){ | |
var arr = new Array(b+1) | |
for(let x=0; x<arr.length; x++){ | |
arr[x] = new Array(a+1) | |
} | |
return arr; | |
} | |
var performanceMeasureCtr = 0; //Counts the number of time loop will be running | |
function levenshtein(str1, str2){ |
View gist:457707bfafd5e0b5321c2c10d019bd84
//ES5 | |
var body = req.body | |
var rat = body.rat, | |
mouse= body.cat, | |
house= body.house, | |
chair= body.chair; | |
//ES6 | |
var {rat, mouse, house, chair} = req.body; |
View My Component Usingproxy conf.ts
import { Component, OnInit } from '@angular/core'; | |
import { MyService } from '/myService.service'; | |
@Component({ | |
selector: 'app-MyComponent-interface', | |
templateUrl: './MyComponent.component.html', | |
styleUrls: ['./MyComponent.component.css'] | |
}) | |
export class MyComponent implements OnInit { |
View NG proxy routing start config
"scripts": { | |
"start": "ng serve –proxy-config proxy.conf.json" | |
} |
View NGINX conf for proxy.conf
server{ | |
location ^~ /Api1/ { | |
proxy_pass http://<ipAdressOfApi1>:<port number>"; | |
} | |
location ^~ /Api2/ { | |
proxy_pass http://<ipAdressOfApi1>:<port number>"; | |
} | |
} |
View My Component Using proxy conf
import { Component, OnInit } from '@angular/core'; | |
import { MyService } from '/myService.service'; | |
@Component({ | |
selector: 'app-MyComponent-interface', | |
templateUrl: './MyComponent.component.html', | |
styleUrls: ['./MyComponent.component.css'] | |
}) | |
export class MyComponent implements OnInit { |
View proxy.conf.json
{ | |
"/Api1": { | |
"target": "http://<ipAdressOfApi1>:<port number>", | |
"secure": false | |
}, | |
"/Api2":{ | |
"target": "http://<ipAdressOfApi2>:<port number>", | |
"secure": false | |
} | |
} |
View myService.ts
@Injectable() | |
export class MyService { | |
getBaseUrl(){ | |
return "http://localhost:4000/" | |
} | |
} |
View myComponent.ts
import { Component, OnInit } from '@angular/core'; | |
import { MyService } from '/myService.service'; | |
@Component({ | |
selector: 'app-MyComponent-interface', | |
templateUrl: './MyComponent.component.html', | |
styleUrls: ['./MyComponent.component.css'] | |
}) | |
export class MyComponent implements OnInit { |