Skip to content

Instantly share code, notes, and snippets.

@thcipriani
Last active May 7, 2021 18:38
Show Gist options
  • Save thcipriani/9ed54c9d87ff5919f96596b678c855cc to your computer and use it in GitHub Desktop.
Save thcipriani/9ed54c9d87ff5919f96596b678c855cc to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
#
# Word of the Day!
#
# Get m-w.com's top word lookup of however long...
#
# USAGE:
#
# (/^ヮ^)/*:・゚✧ date -Is
# 2021-01-06T16:38:27-07:00
# (/^ヮ^)/*:・゚✧ ./word-of-the-day.sh
# WotD: "insurrection"
#
# Copyright Tyler Cipriani <tyler@tylercipriani.com> 2020
# License: GPLv3
set -euo pipefail
WORD=
WOTD="${XDG_CACHE_HOME:-"$HOME"}/.wotd"
MW_POPULAR_JSON="https://www.merriam-webster.com/lapi/v1/mwol-mp/get-lookups-data-homepage"
OLD=1
if [[ -f "$WOTD" ]]; then
CTIME=$(stat -c '%X' "$WOTD")
NOW=$(date +%s)
ONE_HOUR=3600
OLD=$(( (NOW - CTIME) > ONE_HOUR ))
fi
if (( OLD == 1 )); then
WORD=$(curl -s "$MW_POPULAR_JSON" | jq -r '.data.words[0]')
printf 'WotD: "%s"\n' "$WORD" > "$WOTD"
fi
cat "$WOTD"
@thcipriani
Copy link
Author

~
(/^ヮ^)/*:・゚✧ date --utc -Is
2021-01-13T23:46:57+00:00
~
(/^ヮ^)/*:・゚✧ word-of-the-day.sh 
WotD:"impeach"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment