Skip to content

Instantly share code, notes, and snippets.

View carlosmcevilly's full-sized avatar

Carlos McEvilly carlosmcevilly

View GitHub Profile
@carlosmcevilly
carlosmcevilly / gist:a265c23807b551ed53b9e9e31235d82b
Last active July 12, 2024 06:18
Some GitHub search operators
github search operators
date format is: 2023-01-01
repo
user:<username>
repo:<username>/<repository>
org:<organization>
@carlosmcevilly
carlosmcevilly / git-co-function.sh
Last active November 14, 2022 05:42
convenience bash function to git checkout whatever branch matches the passed-in substring
# git-co
# git checkout whatever branch matches the passed-in substring
#
# Argument:
# substring to match
#
# Example:
# git-co sparkles # checks out the branch whose name contains the substring "sparkles"
#
# Will abort with an informative message and no action in various error scenarios.
@carlosmcevilly
carlosmcevilly / random-color-function.sh
Last active December 12, 2021 18:20
generate a single random hex color string
function randomColor () {
# assuming 24-bit color
range_max=$((256 * 256 * 256))
printf "%06x\n" $(((((RANDOM*RANDOM)+(RANDOM*RANDOM))+RANDOM)%range_max))
}
# test
# $ for in in {0..99999}; do randomColor; done | sort | uniq | wc -l
# (should output a number roughly near 99700)
@carlosmcevilly
carlosmcevilly / apple-development-reference-links.md
Last active December 8, 2021 20:02
Device and software version reference links for development in Apple ecosystem
@carlosmcevilly
carlosmcevilly / bash-list.sh
Last active June 17, 2020 04:20
bash simple list
#!/bin/bash
export todo=()
for item in a b c; do
todo+=($item)
done
for item in "${todo[@]}"; do
echo got item [$item]
done
@carlosmcevilly
carlosmcevilly / dot_ssh_shortcuts
Created February 28, 2020 06:16
bash ssh and scp convenience functions for use on the command line
# change userid, remote ip address and name of keyfile as needed
# rasberry pi
pi-ssh () { ssh -l myuserid -i ~/.ssh/id_rasberrypi 192.168.3.141; }
pi-put () { scp -i ~/.ssh/id_rasberrypi $1 [email protected]:/home/myuserid/$2; }
pi-get () { scp -i ~/.ssh/id_rasberrypi [email protected]:/home/myuserid/$1 .; }
# beaglebone
bb-ssh () { ssh -l myuserid -i ~/.ssh/id_beaglebone 192.168.1.23; }
bb-put () { scp -i ~/.ssh/id_beaglebone $1 [email protected]:/home/myuserid/$2; }
jira() {
export jira_browse_url='https://jira.organization.domain/browse'
export ticket=$1
if [[ "$ticket" == '' ]]; then
# for tickets of the form "XYZ-1234"
export ticket=`git branch | grep '*' | perl -ne 's/.*\/(\w+\-\d+)/$1/; print;'`
fi
open "$jira_browse_url/$ticket"
}
@carlosmcevilly
carlosmcevilly / yt.sh
Created September 18, 2019 03:11
YouTube download helper alias
alias yt='unset PYTHONPATH; youtube-dl --recode-video mp4'
@carlosmcevilly
carlosmcevilly / is-ancestor-hash.sh
Created September 16, 2019 16:45
Check whether the current branch has <git hash> as an ancestor
#!/bin/bash
export hash=$1
if [[ "$hash" == '' ]]; then
echo usage: $0 '<git hash>'
exit -1
fi
if git merge-base --is-ancestor $hash HEAD 2> /dev/null; then
845a512599e7b6f16b2562f4b366dff160075981f8c59c4269f4cc771755a3273f618cd5ba90bbd0649e460c27cabbd62ed9fa8d639054ab8075261fa63e8b80