(Also see [remarkable][], the markdown parser created by the author of this cheatsheet)
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
{ | |
// Editor | |
// Controls whether the editor shows CodeLens. | |
"diffEditor.codeLens": false, | |
// When enabled, the diff editor ignores changes in leading or trailing whitespace. | |
"diffEditor.ignoreTrimWhitespace": true, | |
// Timeout in milliseconds after which diff computation is cancelled. Use 0 for no timeout. |
adapted from this blog
# YAML
name: Jon
# YAML
object:
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 Collection = require('../lib/collection'); | |
const collection = new Collection(); | |
collection.use(loader()); | |
const filter = file => file.extname === '.txt'; | |
const contents = file => fs.readFileSync(file.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
(async function() { | |
const handlebars = require('handlebars'); | |
const engine = require('./examples/support/engine'); | |
const Assemble = require('./'); | |
const app = new Assemble(); | |
app.engine('hbs', engine(handlebars)); | |
const pages = app.create('pages'); | |
const layouts = app.create('layouts', { kind: 'layout' }); |
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 countdown = (msgFn, fn, count = 3, interval = 500) => { | |
let timer = setInterval(() => { | |
process.stdout.write('\u001b[?25l'); | |
process.stdout.write('\u001b[2K\r'); | |
process.stdout.write(msgFn(count)); | |
if (count-- === 0) { | |
process.stdout.write('\u001b[?25h'); | |
process.stdout.write('\u001b[2K\r'); | |
clearInterval(timer); | |
fn(); |
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 { Suite } = require('benchmark'); | |
const argv = require('minimist')(process.argv.slice(2)); | |
const cycle = (e, newline) => { | |
process.stdout.write('\u001b[G'); | |
process.stdout.write(` ${e.target}` + (newline ? '\n' : '')); | |
}; | |
function bench(name) { | |
const suite = new Suite() |
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 cp = require('child_process'); | |
const Koa = require('koa'); | |
const app = new Koa(); | |
const cmds = { linux: 'xdg-open', win32: 'start chrome', darwin: 'open' }; | |
const open = cmds[process.platform]; | |
const PORT = 3000; | |
// response | |
app.use(ctx => { | |
ctx.body = 'Hello Koa'; |
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 replace = async (input, regex, replacer) => { | |
// we need to remove the 'g' flag, if defined, so that all replacements can be made | |
let flags = (regex.flags || '').replace('g', ''); | |
let re = new RegExp(regex.source || regex, flags); | |
let index = 0; | |
let match; | |
while ((match = re.exec(input.slice(index)))) { | |
let value = await replacer(...match); | |
index += match.index; |
NewerOlder