Skip to content

Instantly share code, notes, and snippets.

View GrayedFox's full-sized avatar
👣
Maken tracks, one step at a time.

Che Fisher GrayedFox

👣
Maken tracks, one step at a time.
View GitHub Profile
@GrayedFox
GrayedFox / getSlackIds.js
Created April 23, 2019 08:58
Get all Slack Member IDs of a Channel
// Open up the desired channel in the Slack web interface and run the following to generate display name/id pairs
const channelMembers = members = document.querySelectorAll('#channel_page_all_members div a')
const idNamePairs = {}
members.forEach( (div) => {
const name = div.children[2].firstElementChild.innerHTML
idNamePairs[name] = div.getAttribute('data-member-id')
})
@GrayedFox
GrayedFox / okr-alignment-models.js
Created March 27, 2019 13:27
OKR Alignment Models
// Architectural Assumptions
// * Objectives don't align to other Objectives, they should be aspirational/motivational and unique
// * The total progress of an Objective averages this.keyResultsProgress + linked.keyResultsProgress
// * Mapping key results to parent KRs is strictly optional (although that is sort of the point!)
// * KRs may inherit multiple alignments but can only ever align themselves to a single parent
// For a good answer as to why we want one-to-many see the answer of "Can I align to multiple
// objectives?" taken from here: https://www.perdoo.com/blog/okr-and-alignment/
// Note: linking cells in sheets is trivial, so that gets around typical inheritance type problems.
@GrayedFox
GrayedFox / dd-ibs-test.sh
Created November 22, 2018 14:56
Output ideal input block size for use with dd
#!/bin/bash
# Since we're dealing with dd, abort if any errors occur
set -e
TEST_FILE=${1:-dd_ibs_testfile}
if [ -e "$TEST_FILE" ]; then TEST_FILE_EXISTS=$?; fi
TEST_FILE_SIZE=134217728
# Exit if file exists
@GrayedFox
GrayedFox / dd-obs-test.sh
Created November 22, 2018 14:54
Output ideal output block size for use with dd
#!/bin/bash
# Since we're dealing with dd, abort if any errors occur
set -e
TEST_FILE=${1:-dd_obs_testfile}
[ -e "$TEST_FILE" ]; TEST_FILE_EXISTS=$?
TEST_FILE_SIZE=134217728
# Header
@GrayedFox
GrayedFox / git-count
Last active February 5, 2024 03:40
Count how many unique commits are on your current branch
#!/usr/bin/env bash
BRANCH="main"
if [ $# -eq 1 ] ; then
BRANCH=$1
fi
# count how many commits on your branch are not on the target branch, defaults to main
git rev-list HEAD --count ^$BRANCH
@GrayedFox
GrayedFox / plus_ones_bad.md
Last active May 30, 2021 11:43
Why you shouldn't post "+1", "me too", or some form of "yup" in any GitHub thread

+1 Comments Are Evil

The reason is rather simple: there is a pretty well known and established convention inside GitHub threads to react to ideas, issues, and comments by indicating your support with a thumbs up or down.

If people who wish to show their support for something indicate this with a thumbs up reaction then:

  • we need only look at one place without scrolling up or down to see how much support the idea/issue/comment has
  • we reduce all the noise and pollution inside the thread so that we don't have to scroll past unhelpful "me too" comments which take up valuable screen space, especially if someone has actually posted something useful (like a workaround)
  • we can more easily create, open source, and share automated tools for issue/thread/PR analysis which help maintainers figure out what the hottest topics are without writing tons of exceptions for whatever version of your "yup" is
@GrayedFox
GrayedFox / filter-by-named-ranges-gas.js
Last active August 21, 2018 07:27
Filter a google spreadsheet by named ranges, but don't hide frozen rows or columns.
function onOpen() {
var menu = SpreadsheetApp.getUi().createMenu('Custom Filter');
menu
.addItem('Show All', 'showAll')
.addToUi();
}
function onEdit(e) {
var cellRef = e.range.getA1Notation();
@GrayedFox
GrayedFox / git-glean
Last active April 26, 2024 08:40
Remove local branches with a missing (gone) upstream
#!/usr/bin/env bash
# first we prune origin to ensure our local list of remote branches is up to date
git remote prune origin
GONE_BRANCHES=$(git branch -vv | grep 'origin/.*: gone]' | awk '{print $1}')
if [ -z "$GONE_BRANCHES" ]; then
echo "Could not find any local branches that have a gone remote"
exit 0
@GrayedFox
GrayedFox / goodMorning
Last active September 26, 2023 01:47
Daily tasks that should be run every morning. Colour codes output for readability; can also fetch latest changes and tries to automatically rebase active branches.
#!/usr/bin/env bash
isNumber() {
( printf "%f" $1 >/dev/null 2>&1 ) \
&& echo "true" \
|| echo "false"
}
log() {
GREEN='\033[0;32m'
@GrayedFox
GrayedFox / git-trim
Last active October 5, 2022 01:33
Delete local branches that have been merged into master (except master itself, with optional -f)
#!/usr/bin/env bash
BRANCH="main"
if [ $# -eq 1 ] ; then
BRANCH=$1
fi
MERGED_BRANCHES=$(git branch --merged $BRANCH | grep -v '^[ *]* '"$BRANCH"'$')