Skip to content

Instantly share code, notes, and snippets.

View maksbd19's full-sized avatar

Mahbub Alam maksbd19

View GitHub Profile
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
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);
}
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 = {};
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] = [];
}
const hash = {};
// 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!'))
@maksbd19
maksbd19 / .gitignore
Created August 15, 2017 04:42 — forked from octocat/.gitignore
Some common .gitignore configurations
# Compiled source #
###################
*.com
*.class
*.dll
*.exe
*.o
*.so
# Packages #
$ 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
-- 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 */;
<?php
// if you need a settings page where you want to put the upload images button
add_action( 'admin_menu', 'register_media_selector_settings_page' );
function register_media_selector_settings_page() {
add_submenu_page( 'options-general.php', 'Media Selector', 'Media Selector', 'manage_options', 'media-selector', 'media_selector_settings_page_callback' );
}
// this is the callback for the uploader button. You can use anywhere