Skip to content

Instantly share code, notes, and snippets.

@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 / 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 / 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 / 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 / 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 / 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 / jasmine.scss
Created May 5, 2017 01:04
Repeating a selector
@import './repeat.scss'
#{repeat('.jasmine-passed', 15)} a {
color: aliceblue !important;
}
@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 / 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 / inline.coffee
Created January 26, 2017 20:04
Refactors of inline code
class AssignmentScheduleDayCell extends FormattedHoursCell
className: ->
classes = []
possibleMinutes = @model.get('possible_work_day_minutes')[@date]
globalMinutes = @model.get('global_scheduled_minutes')[@date]
if globalMinutes > possibleMinutes && @model.get('scheduled_minutes')[@date]
classes.push('overallocated')