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 / 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"'$')
@GrayedFox
GrayedFox / post-build-script.sh
Last active May 19, 2022 06:59
AppCenter Post Build Script for running XCUI Tests
#!/bin/sh
# this script assumes you have added an API token via AppCenter and stored it
# as an environment variable in your build configuration settings
# see https://docs.microsoft.com/en-us/appcenter/test-cloud/frameworks/xcuitest/#build-for-testing
# for a better understanding of what's going on
SCHEME="schemeOfApplicationUnderTest"
APP="appleUserName/appName"
DEVICES="appCenterTestDevices"
@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 / patterns.js
Last active May 16, 2021 13:03
Common Coding Patterns
// PRIMITIVES (JavaScript -- 7)
// boolean null undefined number string symbol object
// FACTORY
// The Factory Pattern is a little dated (ES6 classes offer a pretty pain free way of defining classes and using default
// constructors with the 'new' keyword) however they do still see some use in modern web development and automation.
// Factories can be especially useful when designed to return objects/data structures common to certain test operations
// within an automation suite (i.e. mocking an object used to fill out all form fields with valid data).
function Car (options) {
@GrayedFox
GrayedFox / formulas.js
Last active May 16, 2021 12:50
Handy Formulas and Algorithms
// Calculate Triangle Possibility From Edges
// given a set of edges from 0 to N calculate if we can make at least one triangle from them
function triangleFromLengths(a) {
// the trick here is to sort the edges into ascending order
// given a = [10, 2, 5, 1, 8, 20], when sorted, we get [1, 2, 5, 8, 10, 20]
// ascending order guarantees that every value that suceedes another is either the same size or greater (A[0] <= A[1])
// this means that if the sum of any two edges preceeding a third is greater than that third (i.e. if 5 + 8 > 10)
// the triangle inequality theorem will hold true: https://www.wikihow.com/Determine-if-Three-Side-Lengths-Are-a-Triangle
// since: 5 + 8 > 10 && 8 + 10 > 5 && 5 + 10 > 8
@GrayedFox
GrayedFox / reviewBot.js
Last active July 2, 2019 12:33
Send personal review request messages via Slackbot channel (sample Gist for Zap integration)
// Zap Settings
// 1 use GitHub webhooks to send review request notifications to Zapier
// 2 apply text filter: action must exactly match "review_requested"
// 3 run some JavaScript (i.e. this script)
// 4 send a message to a channel (not a direct message), as a bot
// 5 use a custom value for the channel ID which takes the output channelId of this script
const reviewerName = inputData.reviewer.toLowerCase()
const requesterName = inputData.requester.toLowerCase()
@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