From 186030df6ef255592add8a58a1ed59dd066d433e Mon Sep 17 00:00:00 2001 From: "D. Ben Knoble" Date: Fri, 18 Oct 2024 21:55:26 -0400 Subject: [PATCH] find my blog posts across time Use this like Cory Doctorow's frequent re-review of posts in history: every day, run blog-posts-on | xargs -n1 open to see what I've written on this day in the past. This uses only libraries in Racket's base package, and can support other dates (for example, the find-repeats script in my blog [1] shows good dates to try). [1]: https://github.com/benknoble/benknoble.github.io/blob/master/find-repeats --- links/bin/blog-posts-on | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100755 links/bin/blog-posts-on diff --git a/links/bin/blog-posts-on b/links/bin/blog-posts-on new file mode 100755 index 0000000..627c33d --- /dev/null +++ b/links/bin/blog-posts-on @@ -0,0 +1,37 @@ +#! /usr/bin/env racket +#lang racket +; vim: ft=racket + +(require xml + xml/path + net/http-client + racket/date) + +(define now (current-date)) + +(define-values (month day) + (command-line + #:args ([month (~a (date-month now))] [day (~a (date-day now))]) + (unless (string->number month) + (error "month should be numeric: " month)) + (unless (string->number day) + (error "day should be numeric: " day)) + (values (~r (string->number month) #:min-width 2 #:pad-string "0") + (~r (string->number day) #:min-width 2 #:pad-string "0")))) + +(define-values (_status _headers response) + (http-sendrecv "benknoble.github.io" "/sitemap.xml" #:ssl? #t)) + +(define doc + (xml->xexpr (document-element (read-xml response)))) + +(define locations + (se-path*/list '(loc) doc)) + +(define posts + (filter-map + (λ (loc) + (regexp-match (pregexp (~a ".*" month "/" day ".*")) loc)) + locations)) + +(for-each (compose1 displayln first) posts)