Skip to content

Instantly share code, notes, and snippets.

View jettero's full-sized avatar
🕸️
Hliðskjálf

Paul Miller jettero

🕸️
Hliðskjálf
View GitHub Profile
#!/bin/bash
# simple jq task: reduce list of objects with by workflow_id and job id
# into a object { workflow_id => [list of job ids] }
#
# .o(this seriously took like 2 whole hours ot figure out)
gh api repos/$owner_slash_repo/actions/runs?per_page=100 \
| jq '[ .workflow_runs | group_by(.workflow_id)[] | {(.[0].workflow_id|tostring): [ .[] | .id ]} ]
| reduce .[] as $item ({}; . * $item)'
In [8]: import re
...: import subprocess
...: def get_ext_info(dev):
...: try:
...: output = subprocess.check_output(['sudo', 'dumpe2fs', '-h', dev], stderr=subprocess.DEVNULL).decode()
...: except:
...: pass
...: data = dict()
...: for line in output.splitlines():
...: if m := re.match(r'^([^:]+):\s+(.+)$', line):
@jettero
jettero / black.vim
Created November 9, 2021 14:10
A function to invoke psf-black in vim without any plugins or their frankenstalled virtual environment mini-pseudo-python-distro-hidden-directory-thing
fun Blackify()
let l:bsave = winsaveview()
let l:tname = tempname()
exe 'keepjumps %!black --line-length 119 -q - 2>' . l:tname
if v:shell_error > 0
let l:lines = readfile(l:tname)
for l:line in l:lines
echo l:line
endfor
call delete(l:tname)
@jettero
jettero / gh-latest.sh
Last active June 17, 2021 16:57
every time I think to use 'gh', it needs an update... automate
#!/bin/bash
set -e
curl -s https://api.github.com/repos/cli/cli/releases/latest \
| grep "browser_download_url.*amd64.*deb" \
| cut -d : -f 2,3 \
| tr -d \" \
| wget -O ~/Downloads/gh-latest-linux-amd64.deb --progress=bar:force -T15 -t100 -i -
@jettero
jettero / .gitconfig
Last active February 17, 2021 16:55
# Personally I feel completely blind without my various logs. Especially
# `ftlog` for when I just can't figure out where I am in the tree.
#
# Every now and again, when people I'm helping with git that are feeling
# totally lost, I wish they had these commands. in reality, they totally do,
# `mylog` could probably just be `log --oneline`; but my format reveals details
# to help me figure out where I actually am. In particular, the commit id (%h)
# -- and/or reflog selector (%ar), the committer email (%ae), and the head and
# branch names (%d) where they occur in the tree. I suppose it helps an awful
# lot to know the human relatable timestamp too (%ar).
@jettero
jettero / reset-usb-hub
Last active September 30, 2020 22:09
Every now and again my xhci_hcd goes wonky and I can't get USB devices to pop up on it. I hate rebooting for usb problems, so I came up with this.
#!/usr/bin/env bash
# old http://billauer.co.il/blog/2013/02/usb-reset-ehci-uhci-linux/
# old http://enc.com.au/2014/02/14/resetting-usb-devices/
#
# http://www.linux.org/threads/resetting-the-usb-subsystem.6256/
# (page was dead, used google cache)
#
# XXX This definitely worked (2016-08-21), the trouble is finding the serial
# number and the bind/unbind kernel interfaces
@jettero
jettero / git-tls.sh
Created August 29, 2019 14:22
shell scirpt to list git tags along with their description and an annotation indicator ([t] for annotated/signed and [c] for unsigned/annotated)
#!/usr/bin/env bash
FMT=$'--pretty=format:{}%x1f%C(bold yellow) %h%C(bold blue) %ae%Creset: %s %C(bold black)%ar%Creset%n'
git tag -l | xargs -rn1 -I{} git log -1 "$FMT" {} | while read X
do commit="$(cut -d $'\x1f' -f1 <<< "$X")"
description="$(cut -d $'\x1f' -f2 <<< "$X")"
# use cat-file -t to add add [c] or [t]
#
# Wait, but why??
@jettero
jettero / ang
Created October 20, 2010 17:17
my angband savecheat shell (I am not hardcore)
#!/usr/bin/perl
use common::sense;
use IPC::System::Simple qw(systemx system);
use POSIX;
use Term::ReadLine;
use File::Basename;
use Data::Dump qw(dump);
use Date::Lima qw(beek_date);
use Digest::MD5 qw(md5_hex);
@jettero
jettero / Makefile
Created April 16, 2009 13:17
C blowfish demo
SHELL=/bin/bash
key=my key
go: clean
@ make --no-print-directory `git ls-files | sed 's/$$/.ubf/'`
@ for i in *.ubf; do x=`basename $$i .ubf`; ./my_diff.pl $$x $$i; done
words.bf: enc
./enc "$(key)" $(words) $@
@jettero
jettero / tf-graph-scene.css
Last active December 7, 2019 17:37
attempt to make tensorboard graph svg text redable when using a minimum-font-size in firefox
/* intended to be used with stylus (user-css add-on) or similar
** no copyright intended
**
** Basically the problem is that I use a minimum font size in firefox to ensure
** sites can't set fonts smaller than I can read. Zooming the sites is not an
** acceptable option because it also jacks up the layout. minimum font size
** works nearly everywhere except for single edge cases like tensorboard's SVG
** text ... and I can't think of a single other example at the moment.
**
** update: