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-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 / git-bottle
Last active March 6, 2024 16:34
Improved local patch management using named patch files, use carefully
#!/usr/bin/env bash
if [ $# -eq 1 ] ; then
NAME=$1
else
echo "Please pass exactly one argument, which is the name of the patch file"
exit 1
fi
git add .
@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 / show-hide-konsole
Last active October 31, 2023 00:25
A script to show and hide the konsole application, useful when bound to a custom keyboard shortcut.
#!/usr/bin/env bash
# if konsole is not open launch it
if [ -z "$(xdotool search --class konsole)" ]; then
konsole --tabs-from-file "/home/grayedfox/.config/konsole-tabs"
fi
# get current focused window and visible konsole window
CLASS="konsole"
KONSOLE_ID="$(xdotool search --class $CLASS | awk '{print $1}')"
@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 / 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 / extract-jpg
Last active April 22, 2023 03:02
Extract JPG image from binary data
#!/usr/bin/env python
# please ensure python means python3 on your system
# the file can be any binary file that contains a JPG image
# note that it's hungry and doesn't chunk the read so careful with large files
# usage: extract-jpg file_name
import sys
@GrayedFox
GrayedFox / grub.cfg
Created March 6, 2023 06:05 — forked from borysn/grub.cfg
multiboot iso usb
# multiboot iso grub config
set timeout=15
set default=0
# (U)EFI Graphic Protocol
insmod efi_gop
insmod efi_uga
insmod font
@GrayedFox
GrayedFox / arrayRemoveMethod.js
Last active January 9, 2023 11:58
Array.remove safe polyfill
// remove the first instance of an item inside an array (extends native array object)
if (!Array.prototype.remove) {
Array.prototype.remove = function remove (item) { // eslint-disable-line no-extend-native
if (!(this || Array.isArray(this))) {
throw new TypeError()
}
if (this.indexOf(item) !== -1) {
this.splice(this.indexOf(item), 1)
return this
@GrayedFox
GrayedFox / cpc
Created October 5, 2022 01:36
Copy contents of a file using xclip
#!/usr/bin/env bash
if [ $# -ne 1 ] ; then
echo "error: you must pass a single argument that is the file you wish to copy the contents of"
exit 1
fi
FILE=$1
xclip -selection clipboard < $FILE