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
// Fork of https://gist.github.com/alexreardon/8833460 | |
function addWindowEvent(event, fn) { | |
const existing = window[event] | |
if (typeof existing !== 'function') return fn | |
return function () { | |
existing.apply(window, arguments) | |
fn.apply(window, arguments) | |
} | |
} |
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 fs = require('fs') | |
const path = require('path') | |
const content = fs.readFileSync(path.resolve(__dirname, 'zmd-with-code.md'), 'utf-8') | |
// https://regex101.com/r/nIlW1U/6 | |
const PATTERN = /^([A-Za-z \t]*)```([A-Za-z]*)?\n([\s\S]*?)```([A-Za-z \t]*)*$/gm | |
function findCodeBlocks(block) { | |
let matches | |
let errors = [] |
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
// via https://github.com/vatesfr/xen-orchestra/tree/a1c0d82889dbf40aebb87d6e486dc12fee49adbc/%40vates/async-each | |
const noop = Function.prototype | |
class AggregateError extends Error { | |
constructor(errors, message) { | |
super(message) | |
this.errors = errors | |
} | |
} |
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
// https://github.com/Schniz/factoree | |
/** | |
* Creates a strict factory | |
* | |
* @param defaults the default values that would appear on all instances | |
*/ | |
function factory(defaults) { | |
return attributes => { | |
const data = Object.assign(Object.assign({}, defaults), attributes); | |
const proxy = new Proxy(data, { |
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
// via https://github.com/suchipi/without-comments/blob/main/index.js | |
function trimComments(content, commentToken = "#") { | |
const startRegex = new RegExp(`^${commentToken}`); | |
const endRegex = new RegExp(`${commentToken}.*$`, "g"); | |
return content | |
.split("\n") | |
.map((line) => { | |
// remove comment lines | |
if (startRegex.test(line.trim())) return ""; |
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
// https://github.com/RajikaKeminda/multi-search/blob/main/index.js | |
// https://multi-search.vercel.app/ | |
// https://codesandbox.io/s/upbeat-goldberg-mzvzqz?from-embed=&file=/src/App.js | |
function singleKeyFilter(list, query, key) { | |
let querySanitizer = String(query).trim().toLowerCase(); | |
return list.filter( | |
(i) => String(i[key]).toLowerCase().indexOf(querySanitizer) > -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
<html> | |
<head> | |
<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script> | |
<script type="text/javascript"> | |
const DEFAULT_ACTIVITY_TIME_IN_DAYS = 14 | |
google.charts.load('current', { 'packages': ['gantt'] }) | |
google.charts.setOnLoadCallback(drawChart); | |
function daysToMilliseconds(days) { |
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 path = require('path') | |
const getCacheInfo = require('whats-in-the-cache') | |
const NETLIFY_CACHE_DIR = '/opt/build/cache' | |
const MY_BUILD_DIR = path.resolve('build') | |
const CACHE_MANIFEST_PATH = path.join(MY_BUILD_DIR, 'cache-output.json') | |
getCacheInfo({ | |
cacheDirectory: NETLIFY_CACHE_DIR, | |
outputPath: CACHE_MANIFEST_PATH, |
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
// https://github.com/substack/parse-messy-time/blob/master/index.js | |
var months = [ | |
'January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', | |
'September', 'October', 'November', 'December' | |
]; | |
var days = [ | |
'Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday' | |
]; |
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
// https://github.com/fastify/fastify/blob/224dc104260ad26f9baa0e46962f917963d41fe5/fastify.js#L711 | |
// https://twitter.com/matteocollina/status/1493198259212406784 | |
/** | |
* These export configurations enable JS and TS developers | |
* to consumer fastify in whatever way best suits their needs. | |
* Some examples of supported import syntax includes: | |
* - `const fastify = require('fastify')` | |
* - `const { fastify } = require('fastify')` | |
* - `import * as Fastify from 'fastify'` | |
* - `import { fastify, TSC_definition } from 'fastify'` |