Skip to content

Instantly share code, notes, and snippets.

View JGYaniv's full-sized avatar
👍

Jonathan Gil Yaniv JGYaniv

👍
  • New York, NY
View GitHub Profile
//////////////////////////////////////////////////////////////////////////////////////////////////////////
// Part 1: Media Recorder //
//////////////////////////////////////////////////////////////////////////////////////////////////////////
const blobs = [];
let recorder;
async function startRecording() {
const stream = await navigator.mediaDevices.getUserMedia({ audio: true });
def mergeSort(arr)
return arr if arr.length < 2
newArr = []
mid = arr.length / 2
merge mergeSort(arr[0...mid]), mergeSort(arr[mid..-1])
end
def merge(arr1, arr2)
@JGYaniv
JGYaniv / bubble-sort-gist.rb
Created February 17, 2020 14:13
bubble sort w/proc arg
def bubbleSortProc(arr, proc=Proc.new {|x, y| x > y }) #add optional proc arg
#iterates through the array, inspecting two adjacent elements and swapping place based on the sorting algorithm
return arr if arr.count < 2
(arr.length - 1).times do |i|
x, y = arr[i], arr[i+1]
if proc.call(x, y)
arr[i+1], arr[i] = x, y
end
end