Skip to content

Commit

Permalink
find my blog posts across time
Browse files Browse the repository at this point in the history
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
  • Loading branch information
benknoble committed Oct 19, 2024
1 parent 9c17e48 commit 186030d
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions links/bin/blog-posts-on
Original file line number Diff line number Diff line change
@@ -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)

0 comments on commit 186030d

Please sign in to comment.