Skip to content

Instantly share code, notes, and snippets.

Avatar

Abimbola Idowu hisabimbola

View GitHub Profile
@hisabimbola
hisabimbola / after_res_hooks.js
Created Sep 5, 2017 — forked from pasupulaphani/after_res_hooks.js
Mongoose connection best practices
View after_res_hooks.js
var db = mongoose.connect('mongodb://localhost:27017/DB');
// In middleware
app.use(function (req, res, next) {
// action after response
var afterResponse = function() {
logger.info({req: req}, "End request");
// any other clean ups
@hisabimbola
hisabimbola / update_multiple_repos_npm_modules.sh
Created Sep 2, 2016
Bulk update all npm modules of several repos
View update_multiple_repos_npm_modules.sh
#!/usr/bin/env zsh
if [[ -z "$1" ]] then
# Update to cd into the dir of your organization folder/dir
DIR=~/source
else
DIR="$1"
fi
CURRENT_DIR=`pwd`
@hisabimbola
hisabimbola / script
Created Sep 2, 2016
Add extensions to Google Contacts
View script
=IF(LEN(REGEXREPLACE(IF(LEN(SUBSTITUTE(AL1," ","")) = 11,SUBSTITUTE(AL1," ",""),""),"^0","+234")) = 14,REGEXREPLACE(IF(LEN(SUBSTITUTE(AL1," ","")) = 11,SUBSTITUTE(AL1," ",""),""),"^0","+234"),AL1)
@hisabimbola
hisabimbola / idastar.js
Created Jun 16, 2015
Solution to 8-puzzle using iterative deepening depth first search
View idastar.js
'use strict';
var goalState = [1, 2, 3, 4, 5, 6, 7, 8,0];
var startTime,
endTime,
counter = 100,
counted = 0,
checked = 0,
goalMap = {},
size,
@hisabimbola
hisabimbola / aStar.js
Last active Aug 29, 2015
Solution to n-puzzle using a-star algorithm
View aStar.js
'use strict';
var goalState = [0, 1, 2, 3, 4, 5, 6, 7, 8];
var hash = {},
openList = [],
startTime,
endTime,
solved = false,
steps = 0,
counter = 100,
@hisabimbola
hisabimbola / breadFirstSearch.js
Last active Sep 18, 2019
8-puzzle solution using breadth-first method
View breadFirstSearch.js
'use strict';
var endTime,
startTime,
counted = 0,
counter = 1000,
allSuc = [],
hash = {},
values = new Array(1000000),
size = 0;
@hisabimbola
hisabimbola / gist:3815fdbb726ff0a99f3e
Created May 24, 2015
Output the times the hour and minute hand of a clock makes a right angle in a day
View gist:3815fdbb726ff0a99f3e
var totalSecInAClock = 24 * 60 * 60
function cal (sec) {
var hours = Math.floor(sec / 3600);
var minutes = Math.floor((sec - (3600 * hours)) / 60);
var seconds = Math.floor((sec - (3600 * hours))) % 60;
return {
hours: hours,
minutes: minutes,
seconds: seconds
}