Skip to content

Instantly share code, notes, and snippets.

brettz9 / detectEnv.js
Last active Feb 13, 2021
Detecting Node version for Node-based configs. Hope to integrate into an [mrm]( task.
View detectEnv.js
'use strict';
// Todo: Move to own repo
* You can use this in your `.eslintrc.js` as follows...
* @example
* 'use strict';
brettz9 / resolve.js
Last active Apr 23, 2020
Promise-based `resolve`
View resolve.js
import resolve from './resolve.js';
await resolve('tap', { basedir: __dirname });
const _resolve = require('resolve');
const resolve = (path, opts = {}) => {
// eslint-disable-next-line promise/avoid-new
return new Promise((resolve, reject) => {
// eslint-disable-next-line promise/prefer-await-to-callbacks
brettz9 / .eslintignore
Last active Feb 26, 2020
Disabling of mostly stylistic rules when applying eslint-config-ash-nazg (for linting other projects or node_modules); should split these out within ash-nazg; also has overrides used for linting others' projects
View .eslintignore
# dist
# very unfortunately, it seems this can't be overridden apparently
# per
# "ESLint always ignores files in /node_modules/* and /bower_components/*"
brettz9 / hyperJML.js
Last active Jan 19, 2021
hyperhtml wrapper (not currently put to use or tested)
View hyperJML.js
/* globals hyperHTML, jml, Interpolator */
// Relies on getInterpolator of Jamilih:
'use strict';
window.hyperJamilih = (() => {
const map = new Map();
const {bind: hyper} = hyperHTML;
View pug-i18n.js
'use strict';
// Todo: Move to own repo
const {i18n} = require('intl-dom');
const walk = require('pug-walk');
const fileFetch = require('file-fetch');
global.fetch = fileFetch; // For `intl-dom`
jq -r '.dependencies,.devDependencies|keys[]' package.json | while read line; do \
printf "$line: "
[ "$(npm show "$line" | grep -ic 'DEPRECATED')" != "0" ] && \
printf "\e[1;31m""DEPRECATED\n""\e[0m" || \
printf "\e[1;32m""not deprecated.\n""\e[0m"
brettz9 / .npmrc
Last active Sep 28, 2019
My current npmrc config
View .npmrc
; Can get this file by `npm config edit` but doing so causes loss of some comments; better go get at `/Users/brett/.npmrc`
; Filed
; Off topic, but good info on migrating global npm for nvm:
; Also off topic: `npm star` not working
; Let\'s just try this and disable if ends up too oppressive (useful to
brettz9 /
Last active Sep 27, 2019
Set up and use Atom as npm editor for `npm edit` command

Use -a flag to add project without opening new window:

npm config set editor 'atom -a'

Use npm edit . to open the current project (just a lightly better habit than calling atom -a directly in case changing editor).

Also allows adding, e.g., npm edit depOfCurrentPackage into Atom.

brettz9 /
Last active May 12, 2019
Sourcetree Custom action to open in Terminal *tab*; need `chmod 0755` enable SourceTree in `System Preferences->Security & Privacy->Privacy->Accessibility`; note: implementing as an application did not seem to work from within Sourcetree
dir=$(dirname "$1")
scr=$(cat <<EOF
on run {}
set directory to "$dir"
set newTab to (application "Terminal" is running)
tell application "Terminal"
View timeout.js
const timeout = (delay) => {
// eslint-disable-next-line promise/avoid-new
return new Promise((resolve) => {
setTimeout(() => {
}, delay || 0);