Scripting for Fun (6)

1 Name: Nameless : 2026/01/21 10:03

Using Elisp, calculate how many days it's been since world2ch.net went offline.

(defvar world2ch-offline-date "2026-01-18"
"Date that world2ch.net went offline.")

(defun today ()
"Return today's date as an ISO-8601 date string."
(format-time-string "%Y-%m-%d"))

(defun days-offline ()
"Print and return the number of days since world2ch.net went offline."
(interactive)
(let* ((math (format "<%s> - <%s> + 1"
(today)
world2ch-offline-date))
(answer (calc-eval math)))
(message answer)
answer))

(days-offline)

2 Name: Nameless : 2026/01/22 03:48

Using Elisp, determine the Chinese Zodiac sign for a given year.

(defvar cz-animals
'(rat
ox
tiger
rabbit
dragon
snake
horse
goat
monkey
rooster
dog
pig)
"These are the 12 animals of the Chinese Zodiac.")

(defun cz-animal (year)
"Return Chinese Zodiac animal for YEAR."
(let* ((offset (mod (- year 4) 12)))
(nth offset cz-animals)))

(defvar cz-elements
'(wood
fire
earth
metal
water)
"These are the 5 elements of the Chinese Zodiac.")

(defun cz-element (year)
"Return Chinese Zodiac element for YEAR."
(let* ((offset (/ (mod (- year 4) 10) 2)))
(nth offset cz-elements)))

(defun cz-sign (year)
"Return the Chinse Zodiac element and animal sign for the given YEAR."
(list (cz-element year) (cz-animal year)))

3 Name: Nameless : 2026/02/04 17:03

>>1
No programmer.So my question may sound really stupid.
But where in the script is the full url inlucing https and etc. so Emacs know how and where to connect?

4 Name: Nameless : 2026/02/04 19:47

>>3
There's no need to make any network requests.
It's just doing date math using the calc-eval function.
If you ran it today, it would do this.

(calc-eval "<2026-02-04> - <2026-01-18> + 1")

5 Name: Nameless : 2026/02/06 04:03

Using bash, fill the screen with rainbow-colored blocks.
This uses tput to do the lifting instead of manually blasting control codes out.
You've seen the elegance of elisp, now get ready for the ugliness of bash.

#!/bin/bash
#usage: rainbow.sh [fillrate]
#fillrate defaults to 2 (higher is faster)
#tries to be resize-aware but isn't great at it lol
#the resize can happen at exactly the wrong time, filling the whole screen with one color

check_key() {
read -t 0.03125 -N 1 -r -s
}

all_done() {
tput setab 0
tput clear
exit 0
}

emit_color() {
x=$(($RANDOM%width))
y=$(($RANDOM%height))
tput setab $(($RANDOM%8))
tput cup $y $x
echo -n " "
tput setab 0
}

trap 'all_done' SIGINT

check_key
while [ "$REPLY" = "" ]
do
width=`tput cols`
height=`tput lines`
for (( ii = 0 ; ii < ${1:-4} ; ii++ ))
do
emit_color
done
check_key
done
all_done

6 Name: Nameless : 2026/02/06 22:09

also yes, >>5 will absolutely spawn a ton of extremely short-lived processes nonstop lol
it is deeeeeeply inefficient and maybe I should rewrite it to blast out control codes manually
Name: E-Mail:
Leave these fields empty (spam trap):