Skip to content

Instantly share code, notes, and snippets.

@malulleybovo
malulleybovo / quickSort.js
Created March 21, 2019 01:09
Implementation of Randomized Quick Sort Algorithm
// Sorts array in ascending order
function quickSort(arr) {
if (arr == null
|| !Array.isArray(arr)) return;
mQuickSort(arr, 0, arr.length);
function mQuickSort(arr, startIdx, endIdx) {
if (endIdx - startIdx <= 1) return;
if (endIdx - startIdx == 2 && arr[0] > arr[1]) {
var t = arr[1];
// Made as proof of concept - malulleybovo@2019
// A simple and fair array shuffle algorithm
var randomizeArray = function(arr) {
if (arr == null || !Array.isArray(arr)) return [];
arr = arr.slice(0);
var randArr = [];
while (arr.length > 1) {
randArr.push(arr.splice(
Math.floor(Math.random() * arr.length), 1));
@malulleybovo
malulleybovo / iLog.js
Created November 28, 2017 23:16
iLog - Intelligent Logger that personalizes console.log, console.warn, console.error, and console.info
/**
* iLog : intelligent logger.
* Supports : .log(), .warn(), .error(), and .info()
* Configuring :
* Change iLogCfg to your fit.
* Supports color changes and enable/disable stack trace for each of the log functions
* Use :
* console.ilog('my comment');
* -> my comment
* console.ilog(myVar1, myVar2, [more...]);