Skip to content

Instantly share code, notes, and snippets.

View meherhowji's full-sized avatar
👋
Hello Friend!

Meher Ranjan Howji meherhowji

👋
Hello Friend!
View GitHub Profile
@meherhowji
meherhowji / recursive-binary-search.js
Last active February 4, 2019 09:25
Recursive Binary Search in JavaScript
sortedList = [11, 24, 33, 64, 95, 106, 217, 228, 299, 310]
const getMid = (low, high) => {
return Math.floor((high + low) / 2)
}
const recursiveBS = (list, item, low, high) => {
(!low && !high ) && (low = 0, high = list.length - 1)
let found = false
@meherhowji
meherhowji / iterative-binary-search.js
Last active February 4, 2019 09:50
Iterative Binary Search in JavaScript
const sortedList = [1,2,3,4,5,6,9,11,12,13,14,15,16,17,18,19,20]
const binarySearch = (list, item) => {
let low = 0
let high = list.length - 1
let guess = null
while(low <= high) {
let mid = Math.floor((high + low)/2)
guess = list[mid]
@meherhowji
meherhowji / post-receive
Last active March 16, 2018 17:46 — forked from lemiorhan/post-receive
Post-receive hook to deploy the code being pushed to production branch to a specific folder
#!/bin/bash
target_branch="gh-pages"
working_tree="/home/meherranjan/aerosailor.com"
while read oldrev newrev refname
do
branch=$(git rev-parse --symbolic --abbrev-ref $refname)
if [ -n "$branch" ] && [ "$target_branch" == "$branch" ]; then