Skip to content

Instantly share code, notes, and snippets.

def binary_search(target, list)
position = (list.count / 2).floor
mid = list[position]
return mid if mid == target
if(mid < target)
return binary_search(target, list.slice(position + 1, list.count/2))
else
return binary_search(target, list.slice(0, list.count/2))
@mario4000
mario4000 / async-foreach.js
Created October 8, 2017 02:08 — forked from atinux/async-foreach.js
JavaScript: async/await with forEach()
const waitFor = (ms) => new Promise(r => setTimeout(r, ms))
const asyncForEach = (array, callback) => {
for (let index = 0; index < array.length; index++) {
await callback(array[index], index, array)
}
}
const start = async () => {
await asyncForEach([1, 2, 3], async (num) => {
await waitFor(50)
@marceloag
marceloag / FontAwesome CDN
Last active January 31, 2023 17:01
FontAwesome CDN
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.4.0/css/font-awesome.min.css" rel="stylesheet">