KISS πŸ‡ΊπŸ‡¦

Stop the war!

Stop the war in Ukraine! Fuck putin!

More information is at: https://war.ukraine.ua/.

There is a fund to support the Ukrainian Army: https://savelife.in.ua/en/donate/, and there is a special bank account that accepts funds in multiple currencies: https://bank.gov.ua/en/about/support-the-armed-forces. I donated to them. Please donate if you can!

Killer putin

Killer putin. Source: politico.eu.

Arrested putin

"It hasn't happened yet, but it will happen sooner or later. Beautiful photo, isn't it?" Source: twitter.

Automate saving Glacier webcam pictures, update

| comments

I have previously posted a script to save Glacier webcam pictures. Since then I’ve made a few improvements and would like to describe them in this small post.

The script is here:

(save_glacier_image.sh) download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#!/usr/bin/env zsh

set -euo pipefail
IFS=$'\n\t'

URL="$1"

cd ~/Pictures/glacier

BASENAME="${URL:t:r}"
LATEST_FILE="$( ls $BASENAME*(.On[1]) )" || LATEST_FILE="${BASENAME}000"
PADDED_NEW_NUMBER="${(l:3::0:)$(( ${LATEST_FILE:${#BASENAME}:r} + 1 ))}"
EXTENSION="$( sed -E 's/.*\.([^?.]+)(\?[[:digit:]]+)?/\1/' <<<"$URL" )"

curl -Ss -o "${BASENAME}${PADDED_NEW_NUMBER}.${EXTENSION}" "$URL"
echo 'back'

And my changes are:

  • If there is no file with the given prefix in the directory yet, the script will start with number 001.

  • Unfortunately the thumbnails page has stopped updating and the main webcams page is more up-to-date. Most webcam image URLs there include a timestamp, e.g. https://www.nps.gov/webcams-glac/apvccam.jpg?1606399656222. The script used to treat jpg?1606399656222 as an extension; now it’s fixed and the script properly extracts the jpg extension.

  • The script used to echo done at the end as a signal of completion to the user. Tridactyl puts the output into the command line, so it becomes a command prompt: :done (but done is not a command). Due to this feature, it’s more convenient to echo back at the end so that Tridactyl will offer :back as the command and you can just press Enter to go back to the previous page! Neat.

Comments