Skip to content

Instantly share code, notes, and snippets.

Avatar
🎈

░░░░ ░░░░░░░ atomicstack

🎈
View GitHub Profile
@atomicstack
atomicstack / VolumeUp.scpt
Last active Aug 28, 2021
AppleScript one-liner to increase volume by 10%, for use with Stream Deck and OSA script plugin (Note: app restart required after any script update in the Stream Deck configurator, see https://github.com/gabrielperales/streamdeck-osascript/issues/2)
View VolumeUp.scpt
set volume output volume ((get output volume in (get volume settings)) + 10)
@atomicstack
atomicstack / prune-invalid-git-refs.sh
Created Jul 19, 2021
fixes annoying "error: refs/remotes/origin/${branch_name} does not point to a valid object!"
View prune-invalid-git-refs.sh
#!/bin/bash
git for-each-ref --format="%(refname)" | while read ref; do
git show-ref --quiet --verify $ref 2>/dev/null || git update-ref -d $ref
done
@atomicstack
atomicstack / ssh_config
Last active Jun 15, 2021
example Match stanza for ssh_config, which executes echo "hello world" before connecting to a (specific) host as a specific username. note: redirection to STDERR is necessary; using STDOUT will result in no output
View ssh_config
Match host $HOSTNAME exec "echo 'hello world' 1>&2"
User $USERNAME
View root_ps1.zsh
export PS1='%F{226}%m%f %F{33}%d%f %F{160}%#%f '
@atomicstack
atomicstack / cleanup_zsh_history_archive.sh
Created Jun 4, 2021
cleans up duplicate zsh_history files from $PWD (double check paths before use!)
View cleanup_zsh_history_archive.sh
ls | egrep --line-buffered 'zsh_history.*xz$' | xargs sha256sum | pv -l -s $( ls | egrep --line-buffered 'zsh_history.*xz$' | wc -l | xargs ) | /usr/local/bin/sponge | perl -naE '$seen{$F[0]}++ or next; unlink $F[1] and say qq{unlinked $F[1]}'
@atomicstack
atomicstack / backup_zsh_history.sh
Last active Jun 4, 2021
back up my zsh history (via crontab) (double check paths before use!)
View backup_zsh_history.sh
/bin/cat $HOME/.zsh_history | /usr/local/bin/xz > $HOME/.zsh_history.d/zsh_history.$(/usr/local/bin/gdate +%F-%T).xz
@atomicstack
atomicstack / ssh_warning.sh
Created Jun 2, 2021
a zsh thing to run at login time and check whether the user has an ssh-agent
View ssh_warning.sh
red=$(tput setaf 1)
reset=$(tput sgr0)
if [[ -n "${SSH_TTY}" || -n "${TTY}" ]]; then
if [[ $UID == 0 ]]; then
return
fi
if [[ -z "$SSH_AUTH_SOCK" || ! -S "$SSH_AUTH_SOCK" ]]; then
echo -e "${red}no ssh-agent found :(${reset}"
elif ssh-add -l | grep -q "no identities"; then
@atomicstack
atomicstack / .Xdefaults
Last active Jun 1, 2021
make XQuartz's xterm less fugly
View .Xdefaults
# xterm args:
# xterm -fg white -bg black -en utf8 -tn xterm-256color -fa inputmono:size=14 -fn inputmono:size=14 -geometry 90x30
# see also:
# https://web.archive.org/web/20100616023737/http://yarger.asu.edu/NMR/Xdefaults.html
# https://gist.github.com/tshanks/1145068/e04565f405098193f3fe79b123fa805d0102a5ab
# https://unix.stackexchange.com/questions/332316/configure-unreadable-tiny-small-huge-xterm-fonts
# man xterm
xterm*faceName:inputmono:style=Regular:size=14
@atomicstack
atomicstack / rpi_temperature-config.txt
Created May 31, 2021
a more sensible and less noisy fan config for raspberry pis with the poe hat.
View rpi_temperature-config.txt
dtoverlay=rpi-poe
dtparam=poe_fan_temp0=62000
dtparam=poe_fan_temp1=64000
dtparam=poe_fan_temp2=66000
dtparam=poe_fan_temp3=68000
@atomicstack
atomicstack / generate_ssh_key_2021.sh
Created Mar 22, 2021
ssh-key creation helper, 2021
View generate_ssh_key_2021.sh
key_name="${USER}_$(hostname -s)_$(date +%F)"; echo "creating $HOME/.ssh/${key_name}.pem..."; ssh-keygen -t ed25519 -f "$HOME/.ssh/${key_name}.pem" -C "$key_name"