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
8 <-- fibonacci(5); <---------------------------- first call to get the 5th element of Fibonacci series | |
5 <-- fibonacci(5-1); <-------------------- recursive call to fibonacci(4) | |
3 <-- fibonacci(4-1); <-------------- recursive call to fibonacci(3) | |
2 <-- fibonacci(3-1); <-------- recursive call to fibonacci(2); | |
1 <-- fibonacci(2-1); <--- recursive call to fibonacci(1); base case: return `1` immediately | |
1 <-- fibonacci(2-2); <--- recursive call to fibonacci(0); base case: return `1` immediately | |
1 <-- fibonacci(3-2); <-------- recursive call to fibonacci(1); base case: return `1` immediately | |
2 <-- fibonacci(4-2); <-------------- recursive call to fibonacci(2) | |
1 <-- fibonacci(2-1); <-------- recursive call to fibonacci(1); base case: return `1` immediately | |
1 <-- fibonacci(2-2); <-------- recursive call to fibonacci(0); base case: return `1` immediately |
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 fibonacci(n){ | |
// the base case: when the `n` is 1 or less then the number would be `1` | |
if(n <= 1){ | |
return 1; | |
} | |
// otherwise we would want to get the previous | |
// two numbers and add them up. | |
return fibonacci(n-1) + fibonacci(n-2); | |
} |
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
const fs = require('fs'); | |
const path = require('path'); | |
const dbFilePath = path.join(__dirname, 'db.json'); // path to the json file where we are storing our hash data | |
const MAX_TRY_COUNT = 5; // Maximum numebr of attempts in case of failure | |
let readTryCount = 0; // hold the read try count | |
let writeTryCount = 0; // hold the write try count | |
const hash = {}; |
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
const hash = {}; | |
// to get the value for a particular index | |
const get = index => typeof hash[index] !== "undefined" ? hash[index] : null; | |
// add a new value in a particular index | |
const set = (index, data) => { | |
if( typeof hash[index] === "undefined"){ | |
hash[index] = []; | |
} |
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
const hash = {}; |
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
// https://stackoverflow.com/questions/55320737/how-to-wait-for-a-promise-to-resolve-or-reject-then-move-to-next-command#55320737 | |
// your original code | |
const validatePreconditions = ({ exitOnFailure = true } = {}) => { | |
let portSuccess = true | |
checkIfPortIsAvailable(3000).then((val) => portSuccess = val , (err) => console.log("DEBUG1:",err)) | |
console.log("DEBUG2:",portSuccess) | |
if (! portSuccess && exitOnFailure) { | |
logger.error(colors.red('Exiting due to unsatisfied precondition!')) |
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
# Compiled source # | |
################### | |
*.com | |
*.class | |
*.dll | |
*.exe | |
*.o | |
*.so | |
# Packages # |
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
$ cd ~ | |
$ sudo curl -sS https://getcomposer.org/installer | sudo php | |
$ sudo mv composer.phar /usr/local/bin/composer | |
$ sudo ln -s /usr/local/bin/composer /usr/bin/composer | |
then you can run | |
$ sudo composer install |
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
-- MySQL dump 10.13 Distrib 5.6.35, for osx10.9 (x86_64) | |
-- | |
-- Host: localhost Database: student_test | |
-- ------------------------------------------------------ | |
-- Server version 5.6.35 | |
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; | |
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; | |
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; | |
/*!40101 SET NAMES utf8 */; |
NewerOlder