Skip to content

Instantly share code, notes, and snippets.

Brett Zamir brettz9

Block or report user

Report or block brettz9

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
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`
View check-deprecated-packages.sh
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"
done
@brettz9
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 https://npm.community/t/npm-config-edit-reformats-file-stripping-user-comments/10287
; Off topic, but good info on migrating global npm for nvm:
; https://github.com/nvm-sh/nvm#migrating-global-packages-while-installing
; Also off topic: `npm star` not working
; https://npm.community/t/npm-star-shows-a-star-but-npm-stars-doesnt-list-any-stars-thereafter/10284
; Let\'s just try this and disable if ends up too oppressive (useful to
@brettz9
brettz9 / atom-edit-command.md
Last active Sep 27, 2019
Set up and use Atom as npm editor for `npm edit` command
View atom-edit-command.md

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

ATOM:

  • Menu Caption: Open in Atom
  • Script to run: /usr/local/bin/atom
  • Parameters: -n false -a $REPO

Terminal:

  • Menu Caption: Open in Terminal Tab
  • Script to run: /Applications/TerminalTab.sh
  • Parameters: Parameters: $REPO/$FILE
View open-in-sourcetree.coffee
fs = require('fs')
path = require('path')
{CompositeDisposable} = require 'atom'
ProjectPathListView = require './project-path-list-view'
getActiveFilePath = () ->
document.querySelector('.tree-view .selected')?.getPath?() ||
atom.workspace.getActivePaneItem()?.buffer?.file?.path
@brettz9
brettz9 / before.js
Created Sep 28, 2018 — forked from harto/before.js
Mocha before() & beforeEach() execution order with nested describe()
View before.js
'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);
});
@brettz9
brettz9 / Table-of-Contents.md
Last active Sep 27, 2019
Gist Table of Contents (focusing for now on still useful items or at least interesting experiments); also may organize info on repos
View Table-of-Contents.md
You can’t perform that action at this time.