This file contains hidden or 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
(***************************************************) | |
(* scilla version *) | |
(***************************************************) | |
scilla_version 1 | |
(***************************************************) | |
(* associated library *) | |
(***************************************************) |
This file contains hidden or 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
// Empty |
This file contains hidden or 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
zip -9 -r archive.zip ./node_modules index.js (will compress everything in node modules folder as well as index.js) into a file called archive.zip |
This file contains hidden or 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
$.ajax({ | |
url: "http://localhost:33460/api/Account/userinfo", | |
dataType: 'json', | |
data: { | |
foo: 'bar' | |
}, | |
success: function(data, status) { | |
return console.log("The returned data", data); | |
}, | |
beforeSend: function(xhr, settings) { xhr.setRequestHeader('Authorization','Bearer ' + tokenString ); } //set tokenString before send |
This file contains hidden or 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 greedyKnapsack(weights, values, totalItems, capacity) { | |
//set some default values | |
var curKnapsackWeight = 0, | |
sackValue = 0; | |
//iterate through the collection | |
for(var i = 0; i < totalItems && curKnapsackWeight <= capacity; i++) { | |
/* | |
if the current weight is less than or equal to what we can | |
add to the knapsack, then we add it. else it will be too |
This file contains hidden or 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 MinimumCoinChange(cointypes) { | |
//save the coin types in coins | |
this.coins = cointypes; | |
this.numCoinTypes = this.coins.length; | |
} | |
MinimumCoinChange.prototype = { | |
/* | |
pass cent amount to this function | |
*/ |
This file contains hidden or 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
/* | |
O(n^3) solution | |
*/ | |
function maxSubarraySum(arr) { | |
//store the length of array | |
var aLen = arr.length, | |
//set the current max sum to zero | |
maximumSum = 0; | |
//Outter Loop | |
for(var i = 0; i < aLen; i++) { |
This file contains hidden or 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
/* | |
* USING DYNAMIC PROGRAMMING: | |
*/ | |
/* | |
ARRAY HELPER FUNCTION | |
Array extension by Douglas Crockford Javascript The Good Parts (O’Reilly, p. 64). | |
This helps you create a multi dimensional array of size ROW & COLS and allows you | |
to initialize the array with values |
This file contains hidden or 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
/* | |
* USING RECURSION | |
*/ | |
function LCS(S1, m, S2, n) { | |
var finalResult; | |
//define base case. if the length of either strings are zero, | |
//then no need to continue return 0 | |
if(m === 0 || n === 0) { | |
finalResult = 0; |
This file contains hidden or 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 knapsack(itemsNumber, capacity, weights, values) { | |
var finalResult; | |
if(itemsNumber === 0 || capacity === 0) { | |
finalResult = 0; | |
} else if(weights[itemsNumber] > capacity) { | |
finalResult = knapsack(itemsNumber - 1, capacity, weights, values); | |
} else { | |
var dontPutInKnapsack = knapsack(itemsNumber - 1, capacity, weights, values); |
NewerOlder