Skip to content

Instantly share code, notes, and snippets.

@naganowl
naganowl / coffeeReplace.sh
Last active February 17, 2017 19:02
Replacing leading newlines from a text editor find/replace
# Get the files changed in SHA
git diff-tree --no-commit-id --name-only -r <SHA> > theFiles
# Inline replace and backup file (b/c of Mac) for leading newlines
xargs -0 -n 1 sed -ie '/./,$!d'< <(tr \\n \\0 <theFiles)
# Same as above, but for trailing newlines
find . -type f -name '*.coffee' -exec sed -ie -e :a -e '/^\n*$/{$d;N;};/\n$/ba' {} \;
# Remove the backup files (assuming only Coffee files changed)
@naganowl
naganowl / file-delete.sh
Created February 22, 2017 23:48
Find the commit when a file was deleted
git log --diff-filter=D --summary | grep -B 10 -A 10 "delete mode 100644 app/assets/javascripts/backbone/features/task-tracker/details/layouts/main.coffee"
@naganowl
naganowl / jasmine.scss
Created May 5, 2017 01:04
Repeating a selector
@import './repeat.scss'
#{repeat('.jasmine-passed', 15)} a {
color: aliceblue !important;
}
@naganowl
naganowl / circle.yml
Created June 28, 2017 21:35
Updating `yarn` in CircleCI
general:
artifacts:
- "log"
- "npm-debug.log"
- "yarn-error.log"
machine:
node:
version: 6.10.1
@naganowl
naganowl / git-remove.sh
Created June 29, 2017 23:02
Remove new (untracked) files from working directory
git status --porcelain | cut -c4- | xargs rm
@naganowl
naganowl / call-apply.js
Last active August 4, 2017 21:58
Applying a call in JS
// Invoke the first argument (needs to be a function), with `1` as the `this` context and `2` as the argument
console.log.call.apply(a => a, [1, 2]) // -> 2
console.log.call.apply(function(a,b) { return this.ab + a + b; }, [{ab: 19}, 2, 3]) // -> 24
@naganowl
naganowl / grabEmails.js
Created March 14, 2018 21:17
Grab emails on an expanded distribution list within Google Calendar
([]).map.call(document.querySelectorAll('[data-hovercard-id]'), (el) => { return el.getAttribute('data-hovercard-id'); } )
@naganowl
naganowl / better-csv.sh
Created April 30, 2018 17:43
Better CSVs in CLI
column -s, -t < csv_file.csv | less -#2 -N -S
@naganowl
naganowl / check-git-diff.js
Created May 24, 2018 22:04
Check for abnormal line differences on the Files tab for a GitHub PR
([]).map.call(document.querySelectorAll('.diffstat.tooltipped'), (n) => {
const linesChanged = +n.innerHTML.match(/^\d+/)[0];
if(linesChanged > 100) {
// Log the line delta and the name of the file.
console.log(n, n.parentNode.querySelector('a'));
}
return linesChanged;
});
@naganowl
naganowl / tags.md
Created May 25, 2018 22:26
Differences b/w Git vs. npm tags

There is a difference b/w a prerelease tag associated to a package version (https://docs.npmjs.com/misc/semver#prerelease-tags) and a package's distribution tag upon publish (https://docs.npmjs.com/cli/dist-tag#purpose).

Thus, given the URL schemas dictated by https://docs.npmjs.com/files/package.json#git-urls-as-dependencies it be possible to publish an npm package with both a prerelease tag on a version and a distribution tag to give two options for targetting within a library

The RFC behind the new semver notation specifies just a prerelease tag. It be worthwhile to publish some sort of distribbution tag to avoid clobbering the default latest tag that npm uses