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'); | |
} |
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
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
#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
function sortObjectByKeys(obj, recursive = false) { | |
const keys = Object.keys(obj).sort(); | |
let sorted_obj = {}; | |
keys.forEach(key => { | |
sorted_obj[key] = obj[key]; | |
if (recursive && isObject(sorted_obj[key])) { | |
sorted_obj[key] = sortObjectByKeys(sorted_obj[key]); | |
} |
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
/** | |
* Converst function into yieldable | |
* @param {Function} | |
* @return {Function} yieldable callback | |
*/ | |
function yieldable (func) { | |
return function () { | |
let args = [].slice.call(arguments); | |
let ctx = this; | |
return function (done) { |
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
var mc = 12 // maximum columns | |
var m = 2 // margin in % | |
var scw = (100 - (m * (mc - 1))) / mc | |
var str = ` | |
.row, | |
.column { | |
box-sizing: border-box; | |
} | |
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
/** | |
* Simple object validation | |
*/ | |
const typeOf = require('just-typeof') | |
const validateEmail = require('./utils/helpers/strings/validateEmail') | |
const RULES = { | |
/** | |
* Type of the value | |
* @param {mixed} value |
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
const typeOf = require('just-typeof') | |
/** | |
* Update object values recursively | |
* @param {Object} obj | |
* @param {Function} handler | |
* @returns {Object} - new object | |
*/ | |
const updateObjectValuesRecursively = (obj, handler) => { | |
const newObj = {} |
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
{ | |
// Place your global snippets here. Each snippet is defined under a snippet name and has a scope, prefix, body and | |
// description. Add comma separated ids of the languages where the snippet is applicable in the scope field. If scope | |
// is left empty or omitted, the snippet gets applied to all languages. The prefix is what is | |
// used to trigger the snippet and the body will be expanded and inserted. Possible variables are: | |
// $1, $2 for tab stops, $0 for the final cursor position, and ${1:label}, ${2:another} for placeholders. | |
// Placeholders with the same ids are connected. | |
// Example: | |
"context": { | |
"scope": "javascript,typescript", |
OlderNewer