Skip to content

Instantly share code, notes, and snippets.


Alex Rutar alexrutar

View GitHub Profile
alexrutar /
Last active October 15, 2022 20:27
Get SSH Public Key Hash

To get the SHA256 hash of an existing public key, simply run

ssh-keygen -lvf path/to/

If you want the MD5 hash (or another supported format), run something like

ssh-keygen -lv -E MD5 -f path/to/

You can quickly visualize your current git tree structure with

git log --graph --oneline --all
alexrutar /
Last active February 11, 2022 17:52
Applying a command to each line of STDIN in fish

It's often useful to apply a command to each line of STDIN inside a pipeline. This is easy to do in fish:

ls | while read line; echo $line; end
alexrutar /
Last active February 11, 2022 17:52
Execute functions in parallel, and wait for them to finish.
# This is a short function demonstrating how to run a sequence of commands in parallel
# and wait for them to be completed before continuing
function test_sleep
set -l pid_list
for i in 1 4 2 5 3
# execute the command and put it in the background
fish --command "
sleep $i
echo \"Finished command $i!\"
" &
alexrutar /
Last active February 11, 2022 17:53
Validate HTML using the W3C API from the command line.

We can use httpie to make requests to the W3C validator. For example, to test the file index.html, run

https "" @index.html "Content-Type: text/html; charset=utf-8" --print 'b'

and any errors or warnings will be printed to STDOUT.

You can also get the error format in JSON by using the out=json syntax.

alexrutar /
Last active January 27, 2022 01:10
Get the largest files in a directory in human-readable format.

If you have a folder my/folder, you can run

du -h my/folder | sort -h | tail -n 10

to get a list of the 10 largest subfolders.


  • du -h: get the size of the elements in the folder in human-readable format
  • sort -h: sort human-readable (requires an updated version of sort)
  • tail -n 10: only take the last 10 elements