Skip to content

Instantly share code, notes, and snippets.

@wickedrahul
wickedrahul / levenEarlyExit.js
Last active Jan 6, 2020
Levenshtein Distance with Early Exit
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"
}
@wickedrahul
wickedrahul / NGINX conf for proxy.conf
Last active Dec 6, 2018
NGINX conf for proxy.conf
View NGINX conf for proxy.conf
server{
location ^~ /Api1/ {
proxy_pass http://<ipAdressOfApi1>:<port number>";
}
location ^~ /Api2/ {
proxy_pass http://<ipAdressOfApi1>:<port number>";
}
}
@wickedrahul
wickedrahul / My Component Using proxy conf
Last active Feb 21, 2018
MyComponentUsingProxyConf.ts
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
}
}
@wickedrahul
wickedrahul / myService.ts
Last active Feb 21, 2018
My Service for angular proxy routing
View myService.ts
@Injectable()
export class MyService {
getBaseUrl(){
return "http://localhost:4000/"
}
}
@wickedrahul
wickedrahul / myComponent.ts
Last active Feb 21, 2018
My Service for proxy routing
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 {