Skip to content

Instantly share code, notes, and snippets.

@atomicstack
atomicstack / tmux.vim
Last active March 21, 2024 00:55
a custom ~/.config/nvim/syntax/tmux.vim file which fixes colour definitions
" inspired by https://stackoverflow.com/a/69141482
" the existing highlight rules for tmux.vim create a bunch of highlight definitions similar to this:
" for i in range(0,255)
" hi tmuxColour$i ctermfg=$i
" ...but in neovim, this just resulted in plain white text. after looking at the output of :highlight
" in vim for a while, it seemed that other entries with guifg definitions were showing the right colour,
" and indeed, the fix was to instead specify RGB values for the guifg style.
@atomicstack
atomicstack / no-checklist-strikethrough.css
Created February 28, 2024 02:17
Obsidian CSS snippet: Disable strikethrough in marked checkboxes
.markdown-source-view.mod-cm6 .HyperMD-task-line[data-task]:not([data-task=" "]) {
text-decoration:none;
color: var(--text-normal);
}
.markdown-preview-view ul > li.task-list-item.is-checked {
text-decoration:none;
color:var(--text-normal);
}
@atomicstack
atomicstack / fetch_raspberry_pi_firmware.sh
Last active August 29, 2023 22:56
a one-liner to fetch the latest revisions of /boot/*.{elf,dat} in the RPi firmware repository (because it's a 14GB repo and cloning takes forever, and we're only interested in ~20MB of data). requires the command line utils wget and jq
wget --base=https://github.com/raspberrypi/firmware/raw/master/ -i <( wget -qO - https://github.com/raspberrypi/firmware/tree/master/boot | jq -r '.payload.tree.items[].path | select(test("(elf|dat)$"))' )
@atomicstack
atomicstack / extract-urls-from-youtube-search-results.js
Created August 26, 2022 20:37
a JS snippet that dumps a list of title+href for each selected YouTube search result
document.querySelectorAll('a[title*=$foo]').forEach(function(item, i) { console.log([item.title, item.href ]); })
@atomicstack
atomicstack / check-for-tmux-updates.zsh
Last active March 28, 2022 01:31
runs git pull in tmux.git and shows the most recent commit SHA; then queries homebrew to see which revision is installed locally
#!/bin/zsh
brew_tmux_path="$( brew info tmux | perl -naE '/[*]$/ and say($F[0])' )"
tmux_installed="${${brew_tmux_path//*HEAD-/}%_1}"
tmux_head=$(cd $HOME/git_tree/tmux && git pull &> /dev/null && git ls -1 | awk '{print $1}')
tmux_head_short=${tmux_head:0:7}
if [[ "$tmux_head_short" == "$tmux_installed" ]]; then
update_status="$(tput setaf 33)Already up to date.$(tput sgr0)"
else
@atomicstack
atomicstack / brew-active-path.zsh
Created March 27, 2022 07:25
zsh function to display the install path for a given brew package
function brew-active-path() {
brew info "$1" | perl -naE 'm/[*]$/ and say($F[0])'
}
lepton ~/bash_perl  zmodload zsh/sched
lepton ~/bash_perl  sched --help
lepton ~/bash_perl  sched
lepton ~/bash_perl  echo $zsh_scheduled_events
lepton ~/bash_perl  sched -o +10 echo hello world
lepton ~/bash_perl  echo $zsh_scheduled_events
1640831449:-o:echo hello world
lepton ~/bash_perl 
lepton ~/bash_perl  echo $zsh_scheduled_events
@atomicstack
atomicstack / brew-tmux-build-HEAD.sh
Created March 27, 2022 07:18
brew commands to build and upgrade tmux from its source repository
brew install --head tmux
brew upgrade --fetch-HEAD tmux
@atomicstack
atomicstack / dupe-remover.sh
Created March 5, 2022 22:25
removes files with duplicate SHA-256 hashes. tweaked enhancement of https://gist.github.com/atomicstack/2c5501f6210b6a303b626f447d50d487
find . -type f -print0 | xargs -0 sha256sum | pv -l -s $( find . -type f | wc -l ) | sponge | perl -naE 'my $hash = shift @F; $seen{$hash}++ or next; $ENV{UNLINK_FILES} and unlink "@F"; my $result = $! ? "failed" : ""; say qq{unlinked @F $result}'
@atomicstack
atomicstack / generate_ssh_key_2021.sh
Created March 22, 2021 09:18
ssh-key creation helper, 2021
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"