Restful #03

(&rest rest)

Emacs, the longest

Reading the article Timeline of free and open-source software in Wikipedia, I noticed something: Emacs was the first thing that showed up.

The original one (spelled “EMACS”) was written in 1976, and later released in 1984 as GNU Emacs. The article named it the “longest continuously-developed GNU project”. You knew that it’d been around for a while. But did you know that it was that long of a while?

At some point in 2026, it’ll be a 50-year-old project.

Ordinal dates in Elisp and Bash

There’s something called an ordinal date.
It’s a simple thing: the year followed by how many days have passed.

So 2042-04-02 is 2042-092 (31 + 28 + 31 + 2 = 92)

In Elisp, you can get that ordinal number with:

(format-time-string "%j" (date-to-time "2042-04-02")) => "092"

and in Bash with just:

date +%j -d 2042-04-02  #⇒ 092

Now, I know what you’re wondering: which are the 42nd, 142nd, 242nd, and 342nd days of a non-leap year?

Glad that you’re wondering that, because I was just about to calculate them.

In Emacs Lisp

Using dash:

(--map (format-time-string
        "%b %d" (date-to-time
                 (format "2042-%s42" it)))
       (-iota 4))
=> '("Feb 11" "May 22" "Aug 30" "Dec 08")
;;    42nd     142nd    242nd    342nd

And a dashless version:

(with-output-to-string
  (dotimes (i 4)
    (princ (format-time-string
            "\n%b %d" (date-to-time
                       (format "2042-%s42" i))))))
=> "
Feb 11
May 22
Aug 30
Dec 08"

In Bash

With seq and sed:

seq 0 3 | sed 's/./2041-12-31 &42 days/' | date +"%b %d" -f -

or just printf:

printf '2041-12-31 %s42 days\n' {0..3} | date +"%b %d" -f -
Feb 11
May 22
Aug 30
Dec 08

Colors and effects in the terminal

While writing Ecos, I came up with a couple of cool functions to test colors and effects in the terminal.

I thought others might like it, so here they are.

#!/usr/bin/env bash

# Save as showcase.sh
# Then:
#   chmod +x showcase.sh
#   ./showcase.sh effects-1
#   ./showcase.sh effects-2
#   ./showcase.sh rgb

showcase-effects-1()
{ : <<_
Show most common text effects as applied to 4-bit colors.

These are text effects (bold, italic, underline, etc.) that your terminal is
more likely to support.
_
  : '{0..5} {7..9} 21 53'
  : "Effects $_ applied to:\nregular and intense, foreground and background\n"
  printf "\e[1;34m$_\e[0m\n"
  for c in {0..7}
    do for i in 0 6 1 7
       do for e in {0..5} {7..9} 21 53
          do printf "\e[%s;%s%smFOO\e[0m " \
                    "$e" "$((3+i))" "$c"
          done; echo
       done; echo
    done ;}

showcase-effects-2()
{ : <<_
Show "all" text effects as applied to 4-bit colors.

These are pretty much all possible text effects, so that you can find out if
there're any others that your terminal supports.
_
  : '{0..29} {50..65} {73..75}'
  : "Effects $_ applied to: regular and intense, foreground and background\n"
  printf "\e[1;34m$_\e[0m\n"
  for c in {0..7}
    do for i in 0 6 1 7
       do for e in {0..29} {50..65} {73..75}
          do printf "\e[%s;%s%smo\e[0m " \
                    "$e" "$((3+i))" "$c"
          done; echo
       done; echo
    done ;}

showcase-rgb()
{ : <<_
Show many RGB colors. Scroll up and down. Quit with q.
_
  _showcase-rgb | \less -x4 -R ;}

_showcase-rgb()
while read -r rgb
do for foo in {0..255}
   do printf '\e[38;2;%sm%03d\e[0m\n' \
             "${rgb/FOO/$foo}" "$foo"
   done | paste -{,}{,}{,}{,}
done <<RGBs
255;000;FOO
FOO;255;000
000;FOO;255
FOO;000;000
255;FOO;000
255;255;FOO
000;FOO;000
000;255;FOO
FOO;255;255
000;000;FOO
FOO;000;255
255;FOO;255
RGBs

showcase-"${1:?Usage: ./showcase.sh (effects-1 | effects-2 | rgb)}"

Enjoy your colorful terminal!

📆 2026-W02-3📆 2026-01-07