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 delayPromise(delay, value) { | |
console.time(); | |
// using built-in Promise constructor-function/class. | |
return new Promise(function(resolve) { | |
setTimeout(function() { | |
console.timeEnd(); | |
resolve(value); | |
}, delay); | |
}); | |
} |
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
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" |
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
// | |
// Selection Sort Implementation | |
// | |
function selectionSort (unsortedArray) { | |
if (unsortedArray.length <= 1) { | |
return unsortedArray; | |
} | |
for (let i = 0; i < unsortedArray.length; 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
// | |
// Bubble Sort Implementation | |
// | |
function bubbleSort (unsortedArray) { | |
if (unsortedArray.length <= 1) { | |
return unsortedArray; | |
} | |
for (let i = 0; i < unsortedArray.length; 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
// | |
// Merge Sort Implentation (Recursion) | |
// | |
function mergeSort (unsortedArray) { | |
// No need to sort the array if the array only has one element or empty | |
if (unsortedArray.length <= 1) { | |
return unsortedArray; | |
} | |
// In order to divide the array in half, we need to figure out the middle |
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 removeUrlParameter(url, param) { | |
if (typeof URLSearchParams !== 'undefined') { | |
// modern browsers | |
var r = new URL(url); | |
r.searchParams.delete(param); | |
return r.href; | |
} else { | |
// IE version | |
return url.replace(new RegExp('^([^#]*\?)(([^#]*)&)?' + parameter + '(\=[^&#]*)?(&|#|$)' ), '$1$3$5').replace(/^([^#]*)((\?)&|\?(#|$))/,'$1$3$4') | |
} |
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
// 1 | |
```javascript | |
function sum(a) { | |
return function(b) { | |
return function(c) { | |
return a + b + c; | |
}; | |
}; | |
} | |
``` |
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
// - WAIT FOR ME! - I PROMISE. | |
// resolve NESTED promises waiting for inner promises | |
function nestedPromisesThatresolveAfter4Seconds() { | |
return new Promise(resolve => { | |
setTimeout(() => { | |
setTimeout(() => { | |
console.log('setTimeout1') | |
resolve('Promise resolved'); | |
}, 4000); | |
console.log('setTimeout2') |
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
-- Remove the history from | |
rm -rf .git | |
-- recreate the repos from the current content only | |
git init | |
git add . | |
git commit -m "Initial commit" | |
-- push to the github remote repos ensuring you overwrite history | |
git remote add origin [email protected]:<YOUR ACCOUNT>/<YOUR REPOS>.git |
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
// We no longer need the "use strict" directive since | |
// all ECMAScript modules implicitly use strict mode. | |
import * as config from "./config.json"; | |
app.listen(config.server.nodePort, () => { | |
console.log(`Listening on port ${config.server.nodePort} ...`); | |
}); |