Skip to content

Instantly share code, notes, and snippets.

@hisabimbola
hisabimbola / gist:3815fdbb726ff0a99f3e
Created May 24, 2015 11:27
Output the times the hour and minute hand of a clock makes a right angle in a day
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
}
@hisabimbola
hisabimbola / breadFirstSearch.js
Last active September 18, 2019 22:45
8-puzzle solution using breadth-first method
'use strict';
var endTime,
startTime,
counted = 0,
counter = 1000,
allSuc = [],
hash = {},
values = new Array(1000000),
size = 0;
@hisabimbola
hisabimbola / aStar.js
Last active August 29, 2015 14:22
Solution to n-puzzle using a-star algorithm
'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 / idastar.js
Created June 16, 2015 14:57
Solution to 8-puzzle using iterative deepening depth first search
'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 / script
Created September 2, 2016 06:12
Add extensions to Google Contacts
=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 / update_multiple_repos_npm_modules.sh
Created September 2, 2016 15:25
Bulk update all npm modules of several repos
#!/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 / after_res_hooks.js
Created September 5, 2017 08:32 — forked from pasupulaphani/after_res_hooks.js
Mongoose connection best practices
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 / gmail.ts
Created February 3, 2023 19:38
group emails by sender
import { promises as fs } from 'fs';
import * as path from 'path'
import { authenticate } from '@google-cloud/local-auth';
import { gmail_v1, google } from 'googleapis'
import { JSONClient } from 'google-auth-library/build/src/auth/googleauth';
import { OAuth2Client } from 'google-auth-library';
const SCOPES = ['https://mail.google.com/'];
// The file token.json stores the user's access and refresh tokens, and is
// created automatically when the authorization flow completes for the first