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

Keybase proof

I hereby claim:

  • I am grayedfox on github.
  • I am grayedfox (https://keybase.io/grayedfox) on keybase.
  • I have a public key whose fingerprint is 6847 1215 2CB4 7637 0582 3FBD CC33 73F2 7F9A 9688

To claim this, I am signing this object:

@GrayedFox
GrayedFox / foxy-ubuntu.sh
Last active September 25, 2023 07:10
Foxy Ubuntu
#!/usr/bin/env bash
source $HOME/.bashrc
MACHINE=$(uname -s)
cd $HOME
if [ "$MACHINE" == "Linux" ]; then
printf "Removing libreoffice, thunderbird, and webbrowser app..."
@GrayedFox
GrayedFox / RemoveHeaders.java
Last active June 2, 2018 15:58
removeCopyrightHeaders
/*
* Remove all instances of a commented copyright notice from all files inside of a project.
* Needs to be compiled first (javac).
* Will not overwrite hidden files, symbolic links, or attempt to write to directories that are not writable.
* Will only overwrite files where the copyright text is found (will not overwrite with no changes).
*/
import java.io.IOException;
import java.io.*;
import java.nio.file.Files;
@GrayedFox
GrayedFox / git-clone-latest
Last active August 13, 2018 16:52
Bash function to clone the latest tagged version of a repo
#!/usr/bin/env bash
LATEST_TAG="$(curl --silent https://api.github.com/repos/$1/$2/tags | grep -Po '"name": "\K.*?(?=")' | head -1)"
echo "Cloning $LATEST_TAG"
if [ "$3" = "-https" ]; then
git clone https://github.com/$1/$2.git --branch $LATEST_TAG
else
git clone git@github.com:$1/$2.git --branch $LATEST_TAG
@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 / 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-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 / 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 / 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 / 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