Setting NODE_ENV=production causes these libraries and tools to behave as follows:
npm:
installwill not install devDependenciesshrinkwrapwill not install devDependenciesprunewill remove devDependencies
yarn:
| #!/usr/bin/env bash | |
| # MIT © Sindre Sorhus - sindresorhus.com | |
| # git hook to run a command after `git pull` if a specified file was changed | |
| # Run `chmod +x post-merge` to make it executable then put it into `.git/hooks/`. | |
| changed_files="$(git diff-tree -r --name-only --no-commit-id ORIG_HEAD HEAD)" | |
| check_run() { | |
| echo "$changed_files" | grep --quiet "$1" && eval "$2" |
| // the main app file | |
| import express from "express"; | |
| import loadDb from "./loadDb"; // dummy middleware to load db (sets request.db) | |
| import authenticate from "./authentication"; // middleware for doing authentication | |
| import permit from "./authorization"; // middleware for checking if user's role is permitted to make request | |
| const app = express(), | |
| api = express.Router(); | |
| // first middleware will setup db connection |
Setting NODE_ENV=production causes these libraries and tools to behave as follows:
npm:
install will not install devDependenciesshrinkwrap will not install devDependenciesprune will remove devDependenciesyarn:
| // selection range | |
| var range = window.getSelection().getRangeAt(0); | |
| // plain text of selected range (if you want it w/o html) | |
| var text = window.getSelection(); | |
| // document fragment with html for selection | |
| var fragment = range.cloneContents(); | |
| // make new element, insert document fragment, then get innerHTML! |
Finding this took me longer than it should have, probably because I was impatiently looking for "timeststamp" instead of "milliseconds of the Unix epoch". For future searchers, Luxon uses the methods DateTime.fromMillis and DateTime.valueOf.
// Create a Luxon DateTime from a JS Unix timestamp
const ts = new Date().getTime(); // 1516717417146
const dt = DateTime.fromMillis(ts); // { ts: 2018-01-23T09:23:37.146-05:00 ...
console.log(dt.valueOf()); // 1516717417146| // polyfill window.getMatchedCSSRules() in FireFox 6+ | |
| if ( typeof window.getMatchedCSSRules !== 'function' ) { | |
| var ELEMENT_RE = /[\w-]+/g, | |
| ID_RE = /#[\w-]+/g, | |
| CLASS_RE = /\.[\w-]+/g, | |
| ATTR_RE = /\[[^\]]+\]/g, | |
| // :not() pseudo-class does not add to specificity, but its content does as if it was outside it | |
| PSEUDO_CLASSES_RE = /\:(?!not)[\w-]+(\(.*\))?/g, | |
| PSEUDO_ELEMENTS_RE = /\:\:?(after|before|first-letter|first-line|selection)/g; | |
| // convert an array-like object to array |
| 'use strict'; | |
| describe('mocha before hooks', function () { | |
| before(() => console.log('*** top-level before()')); | |
| beforeEach(() => console.log('*** top-level beforeEach()')); | |
| describe('nesting', function () { | |
| before(() => console.log('*** nested before()')); | |
| beforeEach(() => console.log('*** nested beforeEach()')); | |
| it('is a nested spec', () => true); | |
| }); |
| /** | |
| * Chunkify | |
| * Google Chrome Speech Synthesis Chunking Pattern | |
| * Fixes inconsistencies with speaking long texts in speechUtterance objects | |
| * Licensed under the MIT License | |
| * | |
| * Peter Woolley and Brett Zamir | |
| */ | |
| var speechUtteranceChunker = function (utt, settings, callback) { |
sprintf`There are ${0} monkeys in the ${1}.`( '10', 'tree' );
// > There are 10 monkeys in the tree.
const linkTemplate = sprintf`<a href="${0}" ${2}>${1}</a>`;
linkTemplate('/contact/', 'Contact Us');
linkTemplate('https://example.com', 'Open Preview', 'target="_blank"');| // Microrouter based on history.pushState. | |
| // All thrills, no frills. | |
| // Usage: | |
| // | |
| // var h = urlstate(callback); | |
| // h.push('#foo') | |
| function urlstate(callback) { | |
| // Since `history.pushState` doesn't fire `popstate`, we can use this function | |
| // instead. Will update history state and call `callback` with currently | |
| // showing `url`. |