This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <math.h> | |
#include <stdbool.h> | |
bool binarySearch(int value, int values[], int n) | |
{ | |
// Memorize the offset of a half rather then create an array on each iteration | |
int offset = 0; | |
int divider = n; | |
while (divider > 0) { | |
divider = round((divider + 1) / 2); // round up |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Show hidden characters
{ | |
"bootstrapped": true, | |
"in_process_packages": | |
[ | |
], | |
"installed_packages": | |
[ | |
"AutoBackups", | |
"AutoFileName", | |
"Babel", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function listModuleChildren (parent_path) { | |
const parent_mod = require.cache[parent_path] | |
let children = [] | |
;(function run (mod) { | |
if (mod.children.length) { | |
for (let i = 0; i < mod.children.length; i++) { | |
const id = mod.children[i].id | |
if (!children.includes(id)) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Removes comments and trailing commas from JSON | |
*/ | |
function fixJSON(str) { | |
return str | |
// remove comments | |
.replace(/\/(?:\*{2,}\s[\s\S]+?|\*[^\*]+?)\*\/|([\s;])+\/\/.*$/gm, '') | |
// remove trailing commas | |
.replace(/,+\s*(\}|\])/g, '$1'); | |
} |
NewerOlder