Example: ./whatsnew-gist '2 hours ago' < gist-urls.txt
Use with moderation: Rate limits for unauthenticated IP addresses are very low (60 requests per hour as of 2016-06-20).
| https://api.github.com/gists/<gist 1 ID> | |
| https://api.github.com/gists/<gist 2 ID> | |
| https://api.github.com/gists/<…> |
| #! /bin/bash | |
| # NAME | |
| # whatsnew - return URLs of resources that changed since the specified | |
| # date | |
| # | |
| # SYNOPSIS | |
| # whatsnew date | |
| # | |
| # STANDARD INPUT | |
| # URLs to look for | |
| # | |
| # STANDARD OUTPUT | |
| # Changed resources | |
| set -e | |
| ref_date="$(date -u -Iseconds -d "$1")" | |
| # `read` tries to tokenize lines. But, since lines are URLs (should not contain | |
| # spacing) and we use the (non-standard) `-r` option (disables meaning of | |
| # backslashes), it does the job here. | |
| while IFS='' read -r url || [[ -n "${url}" ]]; do | |
| last_modified="$(curl -sI -- "${url}" | tr -d '\r' | sed -En 's/^Last-Modified: (.*)$/\1/Ip' | xargs -d '\n' -- date -u -Iseconds -d)" | |
| if [ "${last_modified}" '>' "${ref_date}" ]; then | |
| printf '%s\n' "${url}" | |
| fi | |
| done |
| #! /bin/sh | |
| ./whatsnew "$1" | sed 's|^https://api.github.com/gists/|https://gist.github.com/|' |