From d4ee6684b7d6c8c8e5ff96f6998755c42465ec22 Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Sat, 18 May 2024 13:24:42 +0300 Subject: Update content for html --- gemfeed/atom.xml | 1122 +++++++++++++++++++++++++++--------------------------- 1 file changed, 561 insertions(+), 561 deletions(-) (limited to 'gemfeed/atom.xml') diff --git a/gemfeed/atom.xml b/gemfeed/atom.xml index 583d9b18..67fcc004 100644 --- a/gemfeed/atom.xml +++ b/gemfeed/atom.xml @@ -1,6 +1,6 @@ - 2024-05-12T14:48:38+03:00 + 2024-05-18T13:15:08+03:00 foo.zone feed To be in the .zone! @@ -232,12 +232,12 @@ Projects I currently don't have time for by Lorenzo Bettini http://www.lorenzobettini.it http://www.gnu.org/software/src-highlite --> -
Cluster :UK, :uk01 do
-  Customer.C1A1.segments.volumes.each do |volume|
-    puts volume.usage_stats
-    volume.move_off! if volume.over_subscribed?
-  end
-end
+
Cluster :UK, :uk01 do
+  Customer.C1A1.segments.volumes.each do |volume|
+    puts volume.usage_stats
+    volume.move_off! if volume.over_subscribed?
+  end
+end
 

I am abandoning this project because my workplace has stopped the annual pet project competition, and I have other more important projects to work on at the moment.
@@ -599,38 +599,38 @@ KISS high-availability with OpenBSD by Lorenzo Bettini http://www.lorenzobettini.it http://www.gnu.org/software/src-highlite --> -
#!/bin/ksh
-
-ZONES_DIR=/var/nsd/zones/master/
-DEFAULT_MASTER=fishfinger.buetow.org
-DEFAULT_STANDBY=blowfish.buetow.org
-
-determine_master_and_standby () {
-    local master=$DEFAULT_MASTER
-    local standby=$DEFAULT_STANDBY
-
-    .
-    .
-    .
-    
-    local -i health_ok=1
-    if ! ftp -4 -o - https://$master/index.txt | grep -q "Welcome to $master"; then
-        echo "https://$master/index.txt IPv4 health check failed"
-        health_ok=0
-    elif ! ftp -6 -o - https://$master/index.txt | grep -q "Welcome to $master"; then
-        echo "https://$master/index.txt IPv6 health check failed"
-        health_ok=0
-    fi
-    if [ $health_ok -eq 0 ]; then
-        local tmp=$master
-        master=$standby
-        standby=$tmp
-    fi
-
-    .
-    .
-    .
-}
+
#!/bin/ksh
+
+ZONES_DIR=/var/nsd/zones/master/
+DEFAULT_MASTER=fishfinger.buetow.org
+DEFAULT_STANDBY=blowfish.buetow.org
+
+determine_master_and_standby () {
+    local master=$DEFAULT_MASTER
+    local standby=$DEFAULT_STANDBY
+
+    .
+    .
+    .
+    
+    local -i health_ok=1
+    if ! ftp -4 -o - https://$master/index.txt | grep -q "Welcome to $master"; then
+        echo "https://$master/index.txt IPv4 health check failed"
+        health_ok=0
+    elif ! ftp -6 -o - https://$master/index.txt | grep -q "Welcome to $master"; then
+        echo "https://$master/index.txt IPv6 health check failed"
+        health_ok=0
+    fi
+    if [ $health_ok -eq 0 ]; then
+        local tmp=$master
+        master=$standby
+        standby=$tmp
+    fi
+
+    .
+    .
+    .
+}
 

The failover scripts looks for the ; Enable failover string in the DNS zone files and swaps the A and AAAA records of the DNS entries accordingly:
@@ -639,42 +639,42 @@ http://www.gnu.org/software/src-highlite --> by Lorenzo Bettini http://www.lorenzobettini.it http://www.gnu.org/software/src-highlite --> -
fishfinger$ grep failover /var/nsd/zones/master/foo.zone.zone
-        300 IN A 46.23.94.99 ; Enable failover
-        300 IN AAAA 2a03:6000:6f67:624::99 ; Enable failover
-www     300 IN A 46.23.94.99 ; Enable failover
-www     300 IN AAAA 2a03:6000:6f67:624::99 ; Enable failover
-standby  300 IN A 23.88.35.144 ; Enable failover
-standby  300 IN AAAA 2a01:4f8:c17:20f1::42 ; Enable failover
+
fishfinger$ grep failover /var/nsd/zones/master/foo.zone.zone
+        300 IN A 46.23.94.99 ; Enable failover
+        300 IN AAAA 2a03:6000:6f67:624::99 ; Enable failover
+www     300 IN A 46.23.94.99 ; Enable failover
+www     300 IN AAAA 2a03:6000:6f67:624::99 ; Enable failover
+standby  300 IN A 23.88.35.144 ; Enable failover
+standby  300 IN AAAA 2a01:4f8:c17:20f1::42 ; Enable failover
 

-
transform () {
-  sed -E '
-	/IN A .*; Enable failover/ {
-	    /^standby/! {
-	        s/^(.*) 300 IN A (.*) ; (.*)/\1 300 IN A '$(cat /var/nsd/run/master_a)' ; \3/;
-	    }
-	    /^standby/ {
-	        s/^(.*) 300 IN A (.*) ; (.*)/\1 300 IN A '$(cat /var/nsd/run/standby_a)' ; \3/;
-	    }
-	}
-	/IN AAAA .*; Enable failover/ {
-	    /^standby/! {
-	        s/^(.*) 300 IN AAAA (.*) ; (.*)/\1 300 IN AAAA '$(cat /var/nsd/run/master_aaaa)' ; \3/;
-	    }
-	    /^standby/ {
-	        s/^(.*) 300 IN AAAA (.*) ; (.*)/\1 300 IN AAAA '$(cat /var/nsd/run/standby_aaaa)' ; \3/;
-	    }
-	}
-	/ ; serial/ {
-	    s/^( +) ([0-9]+) .*; (.*)/\1 '$(date +%s)' ; \3/;
-	}
-  '
-}
+
transform () {
+  sed -E '
+	/IN A .*; Enable failover/ {
+	    /^standby/! {
+	        s/^(.*) 300 IN A (.*) ; (.*)/\1 300 IN A '$(cat /var/nsd/run/master_a)' ; \3/;
+	    }
+	    /^standby/ {
+	        s/^(.*) 300 IN A (.*) ; (.*)/\1 300 IN A '$(cat /var/nsd/run/standby_a)' ; \3/;
+	    }
+	}
+	/IN AAAA .*; Enable failover/ {
+	    /^standby/! {
+	        s/^(.*) 300 IN AAAA (.*) ; (.*)/\1 300 IN AAAA '$(cat /var/nsd/run/master_aaaa)' ; \3/;
+	    }
+	    /^standby/ {
+	        s/^(.*) 300 IN AAAA (.*) ; (.*)/\1 300 IN AAAA '$(cat /var/nsd/run/standby_aaaa)' ; \3/;
+	    }
+	}
+	/ ; serial/ {
+	    s/^( +) ([0-9]+) .*; (.*)/\1 '$(date +%s)' ; \3/;
+	}
+  '
+}
 

After the failover, the script reloads nsd and performs a sanity check to see if DNS still works. If not, a rollback will be performed:
@@ -683,48 +683,48 @@ http://www.gnu.org/software/src-highlite --> by Lorenzo Bettini http://www.lorenzobettini.it http://www.gnu.org/software/src-highlite --> -
#! Race condition !#
-   
-if [ -f $zone_file.bak ]; then
-    mv $zone_file.bak $zone_file
-fi
-
-cat $zone_file | transform > $zone_file.new.tmp 
-
-grep -v ' ; serial' $zone_file.new.tmp > $zone_file.new.noserial.tmp
-grep -v ' ; serial' $zone_file > $zone_file.old.noserial.tmp
-
-echo "Has zone $zone_file changed?"
-if diff -u $zone_file.old.noserial.tmp $zone_file.new.noserial.tmp; then
-    echo "The zone $zone_file hasn't changed"
-    rm $zone_file.*.tmp
-    return 0
-fi
-
-cp $zone_file $zone_file.bak
-mv $zone_file.new.tmp $zone_file
-rm $zone_file.*.tmp
-echo "Reloading nsd"
-nsd-control reload
-
-if ! zone_is_ok $zone; then
-    echo "Rolling back $zone_file changes"
-    cp $zone_file $zone_file.invalid
-    mv $zone_file.bak $zone_file
-    echo "Reloading nsd"
-    nsd-control reload
-    zone_is_ok $zone
-    return 3
-fi
-
-for cleanup in invalid bak; do
-    if [ -f $zone_file.$cleanup ]; then
-        rm $zone_file.$cleanup
-    fi
-done
-
-echo "Failover of zone $zone to $MASTER completed"
-return 1
+
#! Race condition !#
+   
+if [ -f $zone_file.bak ]; then
+    mv $zone_file.bak $zone_file
+fi
+
+cat $zone_file | transform > $zone_file.new.tmp 
+
+grep -v ' ; serial' $zone_file.new.tmp > $zone_file.new.noserial.tmp
+grep -v ' ; serial' $zone_file > $zone_file.old.noserial.tmp
+
+echo "Has zone $zone_file changed?"
+if diff -u $zone_file.old.noserial.tmp $zone_file.new.noserial.tmp; then
+    echo "The zone $zone_file hasn't changed"
+    rm $zone_file.*.tmp
+    return 0
+fi
+
+cp $zone_file $zone_file.bak
+mv $zone_file.new.tmp $zone_file
+rm $zone_file.*.tmp
+echo "Reloading nsd"
+nsd-control reload
+
+if ! zone_is_ok $zone; then
+    echo "Rolling back $zone_file changes"
+    cp $zone_file $zone_file.invalid
+    mv $zone_file.bak $zone_file
+    echo "Reloading nsd"
+    nsd-control reload
+    zone_is_ok $zone
+    return 3
+fi
+
+for cleanup in invalid bak; do
+    if [ -f $zone_file.$cleanup ]; then
+        rm $zone_file.$cleanup
+    fi
+done
+
+echo "Failover of zone $zone to $MASTER completed"
+return 1
 

A non-zero return code (here, 3 when a rollback and 1 when a DNS failover was performed) will cause CRON to send an E-Mail with the whole script output.
@@ -781,13 +781,13 @@ echo "Failover of zone $zone to $MASTER completed" by Lorenzo Bettini http://www.lorenzobettini.it http://www.gnu.org/software/src-highlite --> -
# Weekly auto-failover for Let's Encrypt automation
-local -i -r week_of_the_year=$(date +%U)
-if [ $(( week_of_the_year % 2 )) -eq 0 ]; then
-    local tmp=$master
-    master=$standby
-    standby=$tmp
-fi
+
# Weekly auto-failover for Let's Encrypt automation
+local -i -r week_of_the_year=$(date +%U)
+if [ $(( week_of_the_year % 2 )) -eq 0 ]; then
+    local tmp=$master
+    master=$standby
+    standby=$tmp
+fi
 

This way, a DNS failover is performed weekly so that the ACME automation can update the Let's Encrypt certificates (for master and standby) before they expire on each VM.
@@ -1133,8 +1133,8 @@ SSFISHKISSFISHKISSFISHKISSFISHKIS SFIS by Lorenzo Bettini http://www.lorenzobettini.it http://www.gnu.org/software/src-highlite --> -
$ doas installboot sd0 # Update the bootloader (not for every upgrade required)
-$ doas sysupgrade # Update all binaries (including Kernel)
+
$ doas installboot sd0 # Update the bootloader (not for every upgrade required)
+$ doas sysupgrade # Update all binaries (including Kernel)
 

sysupgrade downloaded and upgraded to the next release and rebooted the system. After the reboot, I run:
@@ -1143,9 +1143,9 @@ $ doas sysupgrade # Update all binaries (including Kern by Lorenzo Bettini http://www.lorenzobettini.it http://www.gnu.org/software/src-highlite --> -
$ doas sysmerge # Update system configuration files
-$ doas pkg_add -u # Update all packages
-$ doas reboot # Just in case, reboot one more time
+
$ doas sysmerge # Update system configuration files
+$ doas pkg_add -u # Update all packages
+$ doas reboot # Just in case, reboot one more time
 

That's it! Took me around 5 minutes in total! No issues, only these few comands, only 5 minutes! It just works! No problems, no conflicts, no tons (actually none) config file merge conflicts.
@@ -1289,24 +1289,24 @@ jgs^^^^^^^`^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ by Lorenzo Bettini http://www.lorenzobettini.it http://www.gnu.org/software/src-highlite --> -
#!/usr/bin/env bash
+
#!/usr/bin/env bash
 
-log () {
-    local -r level="$1"; shift
-    local -r message="$1"; shift
-    local -i pid="$$"
+log () {
+    local -r level="$1"; shift
+    local -r message="$1"; shift
+    local -i pid="$$"
 
-    local -r callee=${FUNCNAME[1]}
-    local -r stamp=$(date +%Y%m%d-%H%M%S)
+    local -r callee=${FUNCNAME[1]}
+    local -r stamp=$(date +%Y%m%d-%H%M%S)
 
-    echo "$level|$stamp|$pid|$callee|$message" >&2
-}
+    echo "$level|$stamp|$pid|$callee|$message" >&2
+}
 
-at_home_friday_evening () {
-    log INFO 'One Peperoni Pizza, please'
-}
+at_home_friday_evening () {
+    log INFO 'One Peperoni Pizza, please'
+}
 
-at_home_friday_evening
+at_home_friday_evening
 

The output is as follows:
@@ -1315,8 +1315,8 @@ at_home_friday_evening by Lorenzo Bettini http://www.lorenzobettini.it http://www.gnu.org/software/src-highlite --> -
./logexample.sh
-INFO|20231210-082732|123002|at_home_friday_evening|One Peperoni Pizza, please
+
./logexample.sh
+INFO|20231210-082732|123002|at_home_friday_evening|One Peperoni Pizza, please
 

:(){ :|:& };:


@@ -1350,18 +1350,18 @@ INFO|20231210- -
#!/usr/bin/env bash
+
#!/usr/bin/env bash
 
-outer() {
-  inner() {
-    echo 'Intel inside!'
-  }
-  inner
-}
+outer() {
+  inner() {
+    echo 'Intel inside!'
+  }
+  inner
+}
 
-inner
-outer
-inner
+inner
+outer
+inner
 

And let's execute it:
@@ -1379,26 +1379,26 @@ Intel inside! by Lorenzo Bettini http://www.lorenzobettini.it http://www.gnu.org/software/src-highlite --> -
#!/usr/bin/env bash
+
#!/usr/bin/env bash
 
-outer1() {
-  inner() {
-    echo 'Intel inside!'
-  }
-  inner
-}
+outer1() {
+  inner() {
+    echo 'Intel inside!'
+  }
+  inner
+}
 
-outer2() {
-  inner() {
-    echo 'Wintel inside!'
-  }
-  inner
-}
+outer2() {
+  inner() {
+    echo 'Wintel inside!'
+  }
+  inner
+}
 
-outer1
-inner
-outer2
-inner
+outer1
+inner
+outer2
+inner
 

And let's run it:
@@ -1419,14 +1419,14 @@ Wintel inside! by Lorenzo Bettini http://www.lorenzobettini.it http://www.gnu.org/software/src-highlite --> -
#!/usr/bin/env bash
+
#!/usr/bin/env bash
 
-some_expensive_operations() {
-  echo "Doing expensive operations with '$1' from pid $$"
-}
+some_expensive_operations() {
+  echo "Doing expensive operations with '$1' from pid $$"
+}
 
-for i in {0..9}; do echo $i; done \
-  | xargs -P10 -I{} bash -c 'some_expensive_operations "{}"'
+for i in {0..9}; do echo $i; done \
+  | xargs -P10 -I{} bash -c 'some_expensive_operations "{}"'
 

We try here to run ten parallel processes; each of them should run the some_expensive_operations function with a different argument. The arguments are provided to xargs through STDIN one per line. When executed, we get this:
@@ -1451,15 +1451,15 @@ bash: line 1: some_expensive_operations: command not found by Lorenzo Bettini http://www.lorenzobettini.it http://www.gnu.org/software/src-highlite --> -
#!/usr/bin/env bash
+
#!/usr/bin/env bash
 
-some_expensive_operations() {
-  echo "Doing expensive operations with '$1' from pid $$"
-}
-export -f some_expensive_operations
+some_expensive_operations() {
+  echo "Doing expensive operations with '$1' from pid $$"
+}
+export -f some_expensive_operations
 
-for i in {0..9}; do echo $i; done \
-  | xargs -P10 -I{} bash -c 'some_expensive_operations "{}"'
+for i in {0..9}; do echo $i; done \
+  | xargs -P10 -I{} bash -c 'some_expensive_operations "{}"'
 

When we run this now, we get:
@@ -1484,19 +1484,19 @@ Doing expensive operations with '9' from pid 132840 by Lorenzo Bettini http://www.lorenzobettini.it http://www.gnu.org/software/src-highlite --> -
#!/usr/bin/env bash
+
#!/usr/bin/env bash
 
-some_other_function() {
-  echo "$1"
-}
+some_other_function() {
+  echo "$1"
+}
 
-some_expensive_operations() {
-  some_other_function "Doing expensive operations with '$1' from pid $$"
-}
-export -f some_expensive_operations
+some_expensive_operations() {
+  some_other_function "Doing expensive operations with '$1' from pid $$"
+}
+export -f some_expensive_operations
 
-for i in {0..9}; do echo $i; done \
-  | xargs -P10 -I{} bash -c 'some_expensive_operations "{}"'
+for i in {0..9}; do echo $i; done \
+  | xargs -P10 -I{} bash -c 'some_expensive_operations "{}"'
 

... because some_other_function isn't exported! You will also need to add an export -f some_other_function!
@@ -1509,22 +1509,22 @@ http://www.gnu.org/software/src-highlite --> by Lorenzo Bettini http://www.lorenzobettini.it http://www.gnu.org/software/src-highlite --> -
#!/usr/bin/env bash
+
#!/usr/bin/env bash
 
-foo() {
-  local foo=bar # Declare local/dynamic variable
-  bar
-  echo "$foo"
-}
+foo() {
+  local foo=bar # Declare local/dynamic variable
+  bar
+  echo "$foo"
+}
 
-bar() {
-  echo "$foo"
-  foo=baz
-}
+bar() {
+  echo "$foo"
+  foo=baz
+}
 
-foo=foo # Declare global variable
-foo # Call function foo
-echo "$foo"
+foo=foo # Declare global variable
+foo # Call function foo
+echo "$foo"
 

Let's pause a minute. What do you think the output would be?
@@ -1549,34 +1549,34 @@ foo by Lorenzo Bettini http://www.lorenzobettini.it http://www.gnu.org/software/src-highlite --> -
#!/usr/bin/env bash
+
#!/usr/bin/env bash
 
-declare -r foo=foo
-declare -r bar=bar
+declare -r foo=foo
+declare -r bar=bar
 
-if [ "$foo" = foo ]; then
-  if [ "$bar" = bar ]; then
-    echo ok1
-  fi
-fi
+if [ "$foo" = foo ]; then
+  if [ "$bar" = bar ]; then
+    echo ok1
+  fi
+fi
 
-if [ "$foo" = foo ] && [ "$bar" == bar ]; then
-  echo ok2a
-fi
+if [ "$foo" = foo ] && [ "$bar" == bar ]; then
+  echo ok2a
+fi
 
-[ "$foo" = foo ] && [ "$bar" == bar ] && echo ok2b
+[ "$foo" = foo ] && [ "$bar" == bar ] && echo ok2b
 
-if [[ "$foo" = foo && "$bar" == bar ]]; then
-  echo ok3a
-fi
+if [[ "$foo" = foo && "$bar" == bar ]]; then
+  echo ok3a
+fi
 
- [[ "$foo" = foo && "$bar" == bar ]] && echo ok3b
+ [[ "$foo" = foo && "$bar" == bar ]] && echo ok3b
 
-if test "$foo" = foo && test "$bar" = bar; then
-  echo ok4a
-fi
+if test "$foo" = foo && test "$bar" = bar; then
+  echo ok4a
+fi
 
-test "$foo" = foo && test "$bar" = bar && echo ok4b
+test "$foo" = foo && test "$bar" = bar && echo ok4b
 

The output we get is:
@@ -1600,18 +1600,18 @@ ok4b by Lorenzo Bettini http://www.lorenzobettini.it http://www.gnu.org/software/src-highlite --> -
#!/usr/bin/env bash
+
#!/usr/bin/env bash
 
-# Single line comment
+# Single line comment
 
-# These are two single line
-# comments one after another
+# These are two single line
+# comments one after another
 
-: <<COMMENT
-This is another way a
-multi line comment
-could be written!
-COMMENT
+: <<COMMENT
+This is another way a
+multi line comment
+could be written!
+COMMENT
 

I will not demonstrate the execution of this script, as it won't print anything! It's obviously not the most pretty way of commenting on your code, but it could sometimes be handy!
@@ -1624,11 +1624,11 @@ COMMENT by Lorenzo Bettini http://www.lorenzobettini.it http://www.gnu.org/software/src-highlite --> -
#!/usr/bin/env bash
+
#!/usr/bin/env bash
 
-echo foo
-echo echo baz >> $0
-echo bar
+echo foo
+echo echo baz >> $0
+echo bar
 

When it is run, it will do:
@@ -1977,42 +1977,42 @@ photoalbum makemake by Lorenzo Bettini http://www.lorenzobettini.it http://www.gnu.org/software/src-highlite --> -
% photoalbum makemake
-You may now customize ./photoalbumrc and run make
-
-% cat Makefile
-all:
-	photoalbum generate photoalbumrc
-clean:
-	photoalbum clean photoalbumrc
-
-% cat photoalbumrc
-# The title of the photoalbum
-TITLE='A simple Photoalbum'
-
-# Thumbnail height geometry
-THUMBHEIGHT=300
-# Normal geometry height (when viewing photo). Uncomment, to keep original size.
-HEIGHT=1200
-# Max previews per page.
-MAXPREVIEWS=40
-# Randomly shuffle all previews.
-# SHUFFLE=yes
-
-# Diverse directories, need to be full paths, not relative!
-INCOMING_DIR=$(pwd)/incoming
-DIST_DIR=$(pwd)/dist
-TEMPLATE_DIR=/usr/share/photoalbum/templates/default
-#TEMPLATE_DIR=/usr/share/photoalbum/templates/minimal
-
-# Includes a .tar of the incoming dir in the dist, can be yes or no
-TARBALL_INCLUDE=yes
-TARBALL_SUFFIX=.tar
-TAR_OPTS='-c'
-
-# Some debugging options
-#set -e
-#set -x
+
% photoalbum makemake
+You may now customize ./photoalbumrc and run make
+
+% cat Makefile
+all:
+	photoalbum generate photoalbumrc
+clean:
+	photoalbum clean photoalbumrc
+
+% cat photoalbumrc
+# The title of the photoalbum
+TITLE='A simple Photoalbum'
+
+# Thumbnail height geometry
+THUMBHEIGHT=300
+# Normal geometry height (when viewing photo). Uncomment, to keep original size.
+HEIGHT=1200
+# Max previews per page.
+MAXPREVIEWS=40
+# Randomly shuffle all previews.
+# SHUFFLE=yes
+
+# Diverse directories, need to be full paths, not relative!
+INCOMING_DIR=$(pwd)/incoming
+DIST_DIR=$(pwd)/dist
+TEMPLATE_DIR=/usr/share/photoalbum/templates/default
+#TEMPLATE_DIR=/usr/share/photoalbum/templates/minimal
+
+# Includes a .tar of the incoming dir in the dist, can be yes or no
+TARBALL_INCLUDE=yes
+TARBALL_SUFFIX=.tar
+TAR_OPTS='-c'
+
+# Some debugging options
+#set -e
+#set -x
 

In the case for irregular.ninja, I changed the defaults to the following:
@@ -2021,38 +2021,38 @@ clean: by Lorenzo Bettini http://www.lorenzobettini.it http://www.gnu.org/software/src-highlite --> -
--- photoalbumrc        2023-10-29 21:42:00.894202045 +0200
-+++ photoalbumrc.new 2023-06-04 10:40:08.030994440 +0300
-@@ -1,23 +1,24 @@
- # The title of the photoalbum
--TITLE='A simple Photoalbum'
-+TITLE='Irregular.Ninja'
-
- # Thumbnail height geometry
--THUMBHEIGHT=300
-+THUMBHEIGHT=400
- # Normal geometry height (when viewing photo). Uncomment, to keep original size.
--HEIGHT=1200
-+HEIGHT=1800
- # Max previews per page.
- MAXPREVIEWS=40
--# Randomly shuffle all previews.
--# SHUFFLE=yes
-+# Randomly shuffle
-+SHUFFLE=yes
-
- # Diverse directories, need to be full paths, not relative!
--INCOMING_DIR=$(pwd)/incoming
-+INCOMING_DIR=~/Nextcloud/Photos/irregular.ninja
- DIST_DIR=$(pwd)/dist
- TEMPLATE_DIR=/usr/share/photoalbum/templates/default
- #TEMPLATE_DIR=/usr/share/photoalbum/templates/minimal
-
- # Includes a .tar of the incoming dir in the dist, can be yes or no
--TARBALL_INCLUDE=yes
-+TARBALL_INCLUDE=no
- TARBALL_SUFFIX=.tar
- TAR_OPTS='-c'
+
--- photoalbumrc        2023-10-29 21:42:00.894202045 +0200
++++ photoalbumrc.new 2023-06-04 10:40:08.030994440 +0300
+@@ -1,23 +1,24 @@
+ # The title of the photoalbum
+-TITLE='A simple Photoalbum'
++TITLE='Irregular.Ninja'
+
+ # Thumbnail height geometry
+-THUMBHEIGHT=300
++THUMBHEIGHT=400
+ # Normal geometry height (when viewing photo). Uncomment, to keep original size.
+-HEIGHT=1200
++HEIGHT=1800
+ # Max previews per page.
+ MAXPREVIEWS=40
+-# Randomly shuffle all previews.
+-# SHUFFLE=yes
++# Randomly shuffle
++SHUFFLE=yes
+
+ # Diverse directories, need to be full paths, not relative!
+-INCOMING_DIR=$(pwd)/incoming
++INCOMING_DIR=~/Nextcloud/Photos/irregular.ninja
+ DIST_DIR=$(pwd)/dist
+ TEMPLATE_DIR=/usr/share/photoalbum/templates/default
+ #TEMPLATE_DIR=/usr/share/photoalbum/templates/minimal
+
+ # Includes a .tar of the incoming dir in the dist, can be yes or no
+-TARBALL_INCLUDE=yes
++TARBALL_INCLUDE=no
+ TARBALL_SUFFIX=.tar
+ TAR_OPTS='-c'
 

So I changed the album title, adjusted some image and thumbnail dimensions, and I want all images to be randomly shuffled every time the album is generated! I also have all my photos in my Nextcloud Photo directory and don't want to copy them to the local incoming directory. Also, a tarball containing the whole album as a download isn't provided.
@@ -2208,7 +2208,7 @@ blurs html index.html photos thumbs by Lorenzo Bettini http://www.lorenzobettini.it http://www.gnu.org/software/src-highlite --> -
% dtail --servers serverlist.txt --grep INFO --files "/var/log/dserver/*.log"
+
% dtail --servers serverlist.txt --grep INFO --files "/var/log/dserver/*.log"
 

Hint: you can also provide a comma separated server list, e.g.: servers server1.example.org,server2.example.org:PORT,...
@@ -2221,7 +2221,7 @@ http://www.gnu.org/software/src-highlite --> by Lorenzo Bettini http://www.lorenzobettini.it http://www.gnu.org/software/src-highlite --> -
% dtail --servers serverlist.txt --grep INFO "/var/log/dserver/*.log"
+
% dtail --servers serverlist.txt --grep INFO "/var/log/dserver/*.log"
 

Aggregating logs


@@ -2234,10 +2234,10 @@ http://www.gnu.org/software/src-highlite --> by Lorenzo Bettini http://www.lorenzobettini.it http://www.gnu.org/software/src-highlite --> -
% dtail --servers serverlist.txt \
-    --files '/var/log/dserver/*.log' \
-    --query 'from STATS select sum($goroutines),sum($cgocalls),
-             last($time),max(lifetimeConnections)'
+
% dtail --servers serverlist.txt \
+    --files '/var/log/dserver/*.log' \
+    --query 'from STATS select sum($goroutines),sum($cgocalls),
+             last($time),max(lifetimeConnections)'
 

Beware: For map-reduce queries to work, you have to ensure that DTail supports your log format. Check out the documentaiton of the DTail query language and the DTail log formats on the DTail homepage for more information.
@@ -2250,10 +2250,10 @@ http://www.gnu.org/software/src-highlite --> by Lorenzo Bettini http://www.lorenzobettini.it http://www.gnu.org/software/src-highlite --> -
% dtail --servers serverlist.txt \
-    --files '/var/log/dserver/*.log' \
-    'from STATS select sum($goroutines),sum($cgocalls),
-     last($time),max(lifetimeConnections)'
+
% dtail --servers serverlist.txt \
+    --files '/var/log/dserver/*.log' \
+    'from STATS select sum($goroutines),sum($cgocalls),
+     last($time),max(lifetimeConnections)'
 

Here is another example:
@@ -2262,10 +2262,10 @@ http://www.gnu.org/software/src-highlite --> by Lorenzo Bettini http://www.lorenzobettini.it http://www.gnu.org/software/src-highlite --> -
% dtail --servers serverlist.txt \
-    --files '/var/log/dserver/*.log' \
-    --query 'from STATS select $hostname,max($goroutines),max($cgocalls),$loadavg,
-             lifetimeConnections group by $hostname order by max($cgocalls)'
+
% dtail --servers serverlist.txt \
+    --files '/var/log/dserver/*.log' \
+    --query 'from STATS select $hostname,max($goroutines),max($cgocalls),$loadavg,
+             lifetimeConnections group by $hostname order by max($cgocalls)'
 

Tail map-reduce example 2
@@ -2276,9 +2276,9 @@ http://www.gnu.org/software/src-highlite --> by Lorenzo Bettini http://www.lorenzobettini.it http://www.gnu.org/software/src-highlite --> -
% dtail --servers serverlist.txt \
-    --files '/var/log/dserver/*.log' \
-    --query 'from STATS select ... outfile append result.csv'
+
% dtail --servers serverlist.txt \
+    --files '/var/log/dserver/*.log' \
+    --query 'from STATS select ... outfile append result.csv'
 

How to use dcat


@@ -2291,7 +2291,7 @@ http://www.gnu.org/software/src-highlite --> by Lorenzo Bettini http://www.lorenzobettini.it http://www.gnu.org/software/src-highlite --> -
% dcat --servers serverlist.txt --files /etc/hostname
+
% dcat --servers serverlist.txt --files /etc/hostname
 

Cat example
@@ -2302,7 +2302,7 @@ http://www.gnu.org/software/src-highlite --> by Lorenzo Bettini http://www.lorenzobettini.it http://www.gnu.org/software/src-highlite --> -
% dcat --servers serverlist.txt /etc/hostname
+
% dcat --servers serverlist.txt /etc/hostname
 

How to use dgrep


@@ -2313,9 +2313,9 @@ http://www.gnu.org/software/src-highlite --> by Lorenzo Bettini http://www.lorenzobettini.it http://www.gnu.org/software/src-highlite --> -
% dgrep --servers server1.example.org:2223 \
-    --files /etc/passwd \
-    --regex nologin
+
% dgrep --servers server1.example.org:2223 \
+    --files /etc/passwd \
+    --regex nologin
 

Generally, dgrep is also a very useful way to search historic application logs for certain content.
@@ -2332,10 +2332,10 @@ http://www.gnu.org/software/src-highlite --> by Lorenzo Bettini http://www.lorenzobettini.it http://www.gnu.org/software/src-highlite --> -
% dmap --servers serverlist.txt \
-    --files '/var/log/dserver/*.log' \
-    --query 'from STATS select $hostname,max($goroutines),max($cgocalls),$loadavg,
-             lifetimeConnections group by $hostname order by max($cgocalls)'
+
% dmap --servers serverlist.txt \
+    --files '/var/log/dserver/*.log' \
+    --query 'from STATS select $hostname,max($goroutines),max($cgocalls),$loadavg,
+             lifetimeConnections group by $hostname order by max($cgocalls)'
 

Remember: For that to work, you have to make sure that DTail supports your log format. You can either use the ones already defined in internal/mapr/logformat or add an extension to support a custom log format. The example here works out of the box though, as DTail understands its own log format already.
@@ -2358,9 +2358,9 @@ http://www.gnu.org/software/src-highlite --> by Lorenzo Bettini http://www.lorenzobettini.it http://www.gnu.org/software/src-highlite --> -
% dmap --files /var/log/dserver/dserver.log
-    --query 'from STATS select $hostname,max($goroutines),max($cgocalls),$loadavg,
-              lifetimeConnections group by $hostname order by max($cgocalls)'
+
% dmap --files /var/log/dserver/dserver.log
+    --query 'from STATS select $hostname,max($goroutines),max($cgocalls),$loadavg,
+              lifetimeConnections group by $hostname order by max($cgocalls)'
 

As a shorthand version the following command can be used:
@@ -2369,9 +2369,9 @@ http://www.gnu.org/software/src-highlite --> by Lorenzo Bettini http://www.lorenzobettini.it http://www.gnu.org/software/src-highlite --> -
% dmap 'from STATS select $hostname,max($goroutines),max($cgocalls),$loadavg,
-        lifetimeConnections group by $hostname order by max($cgocalls)' \
-        /var/log/dsever/dserver.log
+
% dmap 'from STATS select $hostname,max($goroutines),max($cgocalls),$loadavg,
+        lifetimeConnections group by $hostname order by max($cgocalls)' \
+        /var/log/dsever/dserver.log
 

You can also use a file input pipe as follows:
@@ -2380,9 +2380,9 @@ http://www.gnu.org/software/src-highlite --> by Lorenzo Bettini http://www.lorenzobettini.it http://www.gnu.org/software/src-highlite --> -
% cat /var/log/dserver/dserver.log | \
-    dmap 'from STATS select $hostname,max($goroutines),max($cgocalls),$loadavg,
-          lifetimeConnections group by $hostname order by max($cgocalls)'
+
% cat /var/log/dserver/dserver.log | \
+    dmap 'from STATS select $hostname,max($goroutines),max($cgocalls),$loadavg,
+          lifetimeConnections group by $hostname order by max($cgocalls)'
 

Aggregating CSV files


@@ -2393,16 +2393,16 @@ http://www.gnu.org/software/src-highlite --> by Lorenzo Bettini http://www.lorenzobettini.it http://www.gnu.org/software/src-highlite --> -
% cat example.csv
-name,lastname,age,profession
-Michael,Jordan,40,Basketball player
-Michael,Jackson,100,Singer
-Albert,Einstein,200,Physician
-% dmap --query 'select lastname,name where age > 40 logformat csv outfile result.csv' example.csv
-% cat result.csv
-lastname,name
-Jackson,Michael
-Einstein,Albert
+
% cat example.csv
+name,lastname,age,profession
+Michael,Jordan,40,Basketball player
+Michael,Jackson,100,Singer
+Albert,Einstein,200,Physician
+% dmap --query 'select lastname,name where age > 40 logformat csv outfile result.csv' example.csv
+% cat result.csv
+lastname,name
+Jackson,Michael
+Einstein,Albert
 

DMap can also be used to query and aggregate CSV files from remote servers.
@@ -2415,44 +2415,44 @@ Einstein,Albert by Lorenzo Bettini http://www.lorenzobettini.it http://www.gnu.org/software/src-highlite --> -
% dtail /var/log/dserver/dserver.log
+
% dtail /var/log/dserver/dserver.log
 

-
% dtail --logLevel trace /var/log/dserver/dserver.log
+
% dtail --logLevel trace /var/log/dserver/dserver.log
 

-
% dcat /etc/passwd
+
% dcat /etc/passwd
 

-
% dcat --plain /etc/passwd > /etc/test
-# Should show no differences.
-diff /etc/test /etc/passwd 
+
% dcat --plain /etc/passwd > /etc/test
+# Should show no differences.
+diff /etc/test /etc/passwd 
 

-
% dgrep --regex ERROR --files /var/log/dserver/dsever.log
+
% dgrep --regex ERROR --files /var/log/dserver/dsever.log
 

-
% dgrep --before 10 --after 10 --max 10 --grep ERROR /var/log/dserver/dsever.log
+
% dgrep --before 10 --after 10 --max 10 --grep ERROR /var/log/dserver/dsever.log
 

Use --help for more available options. Or go to the DTail page for more information! Hope you find DTail useful!
@@ -2609,9 +2609,9 @@ DC on fire: by Lorenzo Bettini http://www.lorenzobettini.it http://www.gnu.org/software/src-highlite --> -
if [ -n "$foo" ]; then
-  echo "$foo"
-fi
+
if [ -n "$foo" ]; then
+  echo "$foo"
+fi
 

Please run source-highlight --lang-list for a list of all supported languages.
@@ -2640,7 +2640,7 @@ http://www.gnu.org/software/src-highlite --> by Lorenzo Bettini http://www.lorenzobettini.it http://www.gnu.org/software/src-highlite --> -
declare -xr MASTODON_URI='https://fosstodon.org/@snonux'
+
declare -xr MASTODON_URI='https://fosstodon.org/@snonux'
 

and add the following into your index.gmi:
@@ -2655,7 +2655,7 @@ http://www.gnu.org/software/src-highlite --> by Lorenzo Bettini http://www.lorenzobettini.it http://www.gnu.org/software/src-highlite --> -
<a href='https://fosstodon.org/@snonux' rel='me'>Me at Mastodon</a>
+
<a href='https://fosstodon.org/@snonux' rel='me'>Me at Mastodon</a>
 

More


@@ -3104,11 +3104,11 @@ Have a nice day! by Lorenzo Bettini http://www.lorenzobettini.it http://www.gnu.org/software/src-highlite --> -
git clone https://codeberg.org/snonux/gogios.git
-cd gogios
-go build -o gogios cmd/gogios/main.go
-doas cp gogios /usr/local/bin/gogios
-doas chmod 755 /usr/local/bin/gogios
+
git clone https://codeberg.org/snonux/gogios.git
+cd gogios
+go build -o gogios cmd/gogios/main.go
+doas cp gogios /usr/local/bin/gogios
+doas chmod 755 /usr/local/bin/gogios
 

You can use cross-compilation if you want to compile Gogios for OpenBSD on a Linux system without installing the Go compiler on OpenBSD. Follow these steps:
@@ -3117,9 +3117,9 @@ doas chmod 755 /usr/local/bin/gogios by Lorenzo Bettini http://www.lorenzobettini.it http://www.gnu.org/software/src-highlite --> -
export GOOS=openbsd
-export GOARCH=amd64
-go build -o gogios cmd/gogios/main.go
+
export GOOS=openbsd
+export GOARCH=amd64
+go build -o gogios cmd/gogios/main.go
 

On your OpenBSD system, copy the binary to /usr/local/bin/gogios and set the correct permissions as described in the previous section. All steps described here you could automate with your configuration management system of choice. I use Rexify, the friendly configuration management system, to automate the installation, but that is out of the scope of this document.
@@ -3134,11 +3134,11 @@ go build -o gogios cmd/gogios/main.go by Lorenzo Bettini http://www.lorenzobettini.it http://www.gnu.org/software/src-highlite --> -
doas adduser -group _gogios -batch _gogios
-doas usermod -d /var/run/gogios _gogios
-doas mkdir -p /var/run/gogios
-doas chown _gogios:_gogios /var/run/gogios
-doas chmod 750 /var/run/gogios
+
doas adduser -group _gogios -batch _gogios
+doas usermod -d /var/run/gogios _gogios
+doas mkdir -p /var/run/gogios
+doas chown _gogios:_gogios /var/run/gogios
+doas chmod 750 /var/run/gogios
 

Please note that creating a user and group might differ depending on your operating system. For other operating systems, consult their documentation for creating system users and groups.
@@ -3151,8 +3151,8 @@ doas chmod 750 /var/run/gogios by Lorenzo Bettini http://www.lorenzobettini.it http://www.gnu.org/software/src-highlite --> -
doas pkg_add monitoring-plugins
-doas pkg_add nrpe # If you want to execute checks remotely via NRPE.
+
doas pkg_add monitoring-plugins
+doas pkg_add nrpe # If you want to execute checks remotely via NRPE.
 

Once the installation is complete, you can find the monitoring plugins in the /usr/local/libexec/nagios directory, which then can be configured to be used in gogios.json.
@@ -3179,41 +3179,41 @@ echo 'This is a test email from OpenBSD.' | mail -s 'Test Email' by Lorenzo Bettini http://www.lorenzobettini.it http://www.gnu.org/software/src-highlite --> -
{
-  "EmailTo": "paul@dev.buetow.org",
-  "EmailFrom": "gogios@buetow.org",
-  "CheckTimeoutS": 10,
-  "CheckConcurrency": 2,
-  "StateDir": "/var/run/gogios",
-  "Checks": {
-    "Check ICMP4 www.foo.zone": {
-      "Plugin": "/usr/local/libexec/nagios/check_ping",
-      "Args": [ "-H", "www.foo.zone", "-4", "-w", "50,10%", "-c", "100,15%" ],
-      "Retries": 3,
-      "RetryInterval": 10
-    },
-    "Check ICMP6 www.foo.zone": {
-      "Plugin": "/usr/local/libexec/nagios/check_ping",
-      "Args": [ "-H", "www.foo.zone", "-6", "-w", "50,10%", "-c", "100,15%" ],
-      "Retries": 3,
-      "RetryInterval": 10
-    },
-    "www.foo.zone HTTP IPv4": {
-      "Plugin": "/usr/local/libexec/nagios/check_http",
-      "Args": ["www.foo.zone", "-4"],
-      "DependsOn": ["Check ICMP4 www.foo.zone"]
-    },
-    "www.foo.zone HTTP IPv6": {
-      "Plugin": "/usr/local/libexec/nagios/check_http",
-      "Args": ["www.foo.zone", "-6"],
-      "DependsOn": ["Check ICMP6 www.foo.zone"]
-    }
-    "Check NRPE Disk Usage foo.zone": {
-      "Plugin": "/usr/local/libexec/nagios/check_nrpe",
-      "Args": ["-H", "foo.zone", "-c", "check_disk", "-p", "5666", "-4"]
-    }
-  }
-}
+
{
+  "EmailTo": "paul@dev.buetow.org",
+  "EmailFrom": "gogios@buetow.org",
+  "CheckTimeoutS": 10,
+  "CheckConcurrency": 2,
+  "StateDir": "/var/run/gogios",
+  "Checks": {
+    "Check ICMP4 www.foo.zone": {
+      "Plugin": "/usr/local/libexec/nagios/check_ping",
+      "Args": [ "-H", "www.foo.zone", "-4", "-w", "50,10%", "-c", "100,15%" ],
+      "Retries": 3,
+      "RetryInterval": 10
+    },
+    "Check ICMP6 www.foo.zone": {
+      "Plugin": "/usr/local/libexec/nagios/check_ping",
+      "Args": [ "-H", "www.foo.zone", "-6", "-w", "50,10%", "-c", "100,15%" ],
+      "Retries": 3,
+      "RetryInterval": 10
+    },
+    "www.foo.zone HTTP IPv4": {
+      "Plugin": "/usr/local/libexec/nagios/check_http",
+      "Args": ["www.foo.zone", "-4"],
+      "DependsOn": ["Check ICMP4 www.foo.zone"]
+    },
+    "www.foo.zone HTTP IPv6": {
+      "Plugin": "/usr/local/libexec/nagios/check_http",
+      "Args": ["www.foo.zone", "-6"],
+      "DependsOn": ["Check ICMP6 www.foo.zone"]
+    }
+    "Check NRPE Disk Usage foo.zone": {
+      "Plugin": "/usr/local/libexec/nagios/check_nrpe",
+      "Args": ["-H", "foo.zone", "-c", "check_disk", "-p", "5666", "-4"]
+    }
+  }
+}
 

    @@ -3242,7 +3242,7 @@ http://www.gnu.org/software/src-highlite --> by Lorenzo Bettini http://www.lorenzobettini.it http://www.gnu.org/software/src-highlite --> -
    doas -u _gogios /usr/local/bin/gogios -cfg /etc/gogios.json
    +
    doas -u _gogios /usr/local/bin/gogios -cfg /etc/gogios.json
     

    To run Gogios via CRON on OpenBSD as the gogios user and check all services once per minute, follow these steps:
    @@ -3467,7 +3467,7 @@ http://www.gnu.org/software/src-highlite --> by Lorenzo Bettini http://www.lorenzobettini.it http://www.gnu.org/software/src-highlite --> -
    $ raku guprecords.raku --stats=dir=$HOME/git/uprecords/stats --all
    +
    $ raku guprecords.raku --stats=dir=$HOME/git/uprecords/stats --all
     

    This command will generate a comprehensive uptime report from the collected statistics, making it easy to review and enjoy the data.
    @@ -3624,19 +3624,19 @@ no1 in 455 days, 18:52:44 | at Sun Jul 21 07:37:51 2024 by Lorenzo Bettini http://www.lorenzobettini.it http://www.gnu.org/software/src-highlite --> -
    package ds
    +
    package ds
     
    -import (
    -	"golang.org/x/exp/constraints"
    -)
    +import (
    +	"golang.org/x/exp/constraints"
    +)
     
    -type Integer interface {
    -	constraints.Integer
    -}
    +type Integer interface {
    +	constraints.Integer
    +}
     
    -type Number interface {
    -	constraints.Integer | constraints.Float
    -}
    +type Number interface {
    +	constraints.Integer | constraints.Float
    +}
     
     

    @@ -3648,19 +3648,19 @@ http://www.gnu.org/software/src-highlite --> by Lorenzo Bettini http://www.lorenzobettini.it http://www.gnu.org/software/src-highlite --> -
    package ds
    +
    package ds
     
    -import (
    -	"fmt"
    -	"math/rand"
    -	"strings"
    -)
    +import (
    +	"fmt"
    +	"math/rand"
    +	"strings"
    +)
     
    -type ArrayList[V Number] []V
    +type ArrayList[V Number] []V
     
    -func NewArrayList[V Number](l int) ArrayList[V] {
    -	return make(ArrayList[V], l)
    -}
    +func NewArrayList[V Number](l int) ArrayList[V] {
    +	return make(ArrayList[V], l)
    +}
     

    As you can see, the code uses Go generics, which I refactored recently. Besides the default constructor (which only returns an empty ArrayList with a given capacity), there are also a bunch of special constructors. NewRandomArrayList is returning an ArrayList with random numbers, NewAscendingArrayList and NewDescendingArrayList are returning ArrayLists in either ascending or descending order. They all will be used later on for testing and benchmarking the algorithms.
    @@ -3669,35 +3669,35 @@ http://www.gnu.org/software/src-highlite --> by Lorenzo Bettini http://www.lorenzobettini.it http://www.gnu.org/software/src-highlite --> -
    func NewRandomArrayList[V Number](l, max int) ArrayList[V] {
    -	a := make(ArrayList[V], l)
    -	for i := 0; i < l; i++ {
    -		if max > 0 {
    -			a[i] = V(rand.Intn(max))
    -			continue
    -		}
    -		a[i] = V(rand.Int())
    -	}
    -	return a
    -}
    -
    -func NewAscendingArrayList[V Number](l int) ArrayList[V] {
    -	a := make(ArrayList[V], l)
    -	for i := 0; i < l; i++ {
    -		a[i] = V(i)
    -	}
    -	return a
    -}
    -
    -func NewDescendingArrayList[V Number](l int) ArrayList[V] {
    -	a := make(ArrayList[V], l)
    -	j := l - 1
    -	for i := 0; i < l; i++ {
    -		a[i] = V(j)
    -		j--
    -	}
    -	return a
    -}
    +
    func NewRandomArrayList[V Number](l, max int) ArrayList[V] {
    +	a := make(ArrayList[V], l)
    +	for i := 0; i < l; i++ {
    +		if max > 0 {
    +			a[i] = V(rand.Intn(max))
    +			continue
    +		}
    +		a[i] = V(rand.Int())
    +	}
    +	return a
    +}
    +
    +func NewAscendingArrayList[V Number](l int) ArrayList[V] {
    +	a := make(ArrayList[V], l)
    +	for i := 0; i < l; i++ {
    +		a[i] = V(i)
    +	}
    +	return a
    +}
    +
    +func NewDescendingArrayList[V Number](l int) ArrayList[V] {
    +	a := make(ArrayList[V], l)
    +	j := l - 1
    +	for i := 0; i < l; i++ {
    +		a[i] = V(j)
    +		j--
    +	}
    +	return a
    +}
     

    Helper methods


    @@ -3708,25 +3708,25 @@ http://www.gnu.org/software/src-highlite --> by Lorenzo Bettini http://www.lorenzobettini.it http://www.gnu.org/software/src-highlite --> -
    func (a ArrayList[V]) FirstN(n int) string {
    -	var sb strings.Builder
    -	j := n
    +
    func (a ArrayList[V]) FirstN(n int) string {
    +	var sb strings.Builder
    +	j := n
     
    -	l := len(a)
    -	if j > l {
    -		j = l
    -	}
    +	l := len(a)
    +	if j > l {
    +		j = l
    +	}
     
    -	for i := 0; i < j; i++ {
    -		fmt.Fprintf(&sb, "%v ", a[i])
    -	}
    +	for i := 0; i < j; i++ {
    +		fmt.Fprintf(&sb, "%v ", a[i])
    +	}
     
    -	if j < l {
    -		fmt.Fprintf(&sb, "... ")
    -	}
    +	if j < l {
    +		fmt.Fprintf(&sb, "... ")
    +	}
     
    -	return sb.String()
    -}
    +	return sb.String()
    +}
     

    The Sorted method checks whether the ArrayList is sorted. This will be used by the unit tests later on:
    @@ -3735,14 +3735,14 @@ http://www.gnu.org/software/src-highlite --> by Lorenzo Bettini http://www.lorenzobettini.it http://www.gnu.org/software/src-highlite --> -
    func (a ArrayList[V]) Sorted() bool {
    -	for i := len(a) - 1; i > 0; i-- {
    -		if a[i] < a[i-1] {
    -			return false
    -		}
    -	}
    -	return true
    -}
    +
    func (a ArrayList[V]) Sorted() bool {
    +	for i := len(a) - 1; i > 0; i-- {
    +		if a[i] < a[i-1] {
    +			return false
    +		}
    +	}
    +	return true
    +}
     

    And the last utility method used is Swap, which allows swapping the values of two indices in the ArrayList:
    @@ -3751,11 +3751,11 @@ http://www.gnu.org/software/src-highlite --> by Lorenzo Bettini http://www.lorenzobettini.it http://www.gnu.org/software/src-highlite --> -
    func (a ArrayList[V]) Swap(i, j int) {
    -	aux := a[i]
    -	a[i] = a[j]
    -	a[j] = aux
    -}
    +
    func (a ArrayList[V]) Swap(i, j int) {
    +	aux := a[i]
    +	a[i] = a[j]
    +	a[j] = aux
    +}
     
     

    @@ -3768,40 +3768,40 @@ http://www.gnu.org/software/src-highlite --> by Lorenzo Bettini http://www.lorenzobettini.it http://www.gnu.org/software/src-highlite --> -
    package sort
    +
    package sort
     
    -import (
    -	"codeberg.org/snonux/algorithms/ds"
    -	"sync"
    -	"time"
    -)
    +import (
    +	"codeberg.org/snonux/algorithms/ds"
    +	"sync"
    +	"time"
    +)
     
    -func Sleep[V ds.Integer](a ds.ArrayList[V]) ds.ArrayList[V] {
    -	sorted := ds.NewArrayList[V](len(a))
    +func Sleep[V ds.Integer](a ds.ArrayList[V]) ds.ArrayList[V] {
    +	sorted := ds.NewArrayList[V](len(a))
     
    -	numCh := make(chan V)
    -	var wg sync.WaitGroup
    -	wg.Add(len(a))
    +	numCh := make(chan V)
    +	var wg sync.WaitGroup
    +	wg.Add(len(a))
     
    -	go func() {
    -		wg.Wait()
    -		close(numCh)
    -	}()
    +	go func() {
    +		wg.Wait()
    +		close(numCh)
    +	}()
     
    -	for _, num := range a {
    -		go func(num V) {
    -			defer wg.Done()
    -			time.Sleep(time.Duration(num) * time.Second)
    -			numCh <- num
    -		}(num)
    -	}
    +	for _, num := range a {
    +		go func(num V) {
    +			defer wg.Done()
    +			time.Sleep(time.Duration(num) * time.Second)
    +			numCh <- num
    +		}(num)
    +	}
     
    -	for num := range numCh {
    -		sorted = append(sorted, num)
    -	}
    +	for num := range numCh {
    +		sorted = append(sorted, num)
    +	}
     
    -	return sorted
    -}
    +	return sorted
    +}
     

    This Go code implements the sleep sort algorithm using generics and goroutines. The main function Sleep[V ds.Integer](a ds.ArrayList[V]) ds.ArrayList[V] takes a generic ArrayList as input and returns a sorted ArrayList. The code creates a separate goroutine for each element in the input array, sleeps for a duration proportional to the element's value, and then sends the element to a channel. Another goroutine waits for all the sleeping goroutines to finish and then closes the channel. The sorted result ArrayList is constructed by appending the elements received from the channel in the order they arrive. The sync.WaitGroup is used to synchronize goroutines and ensure that all of them have completed before closing the channel.
    @@ -3814,22 +3814,22 @@ http://www.gnu.org/software/src-highlite --> by Lorenzo Bettini http://www.lorenzobettini.it http://www.gnu.org/software/src-highlite --> -
    package sort
    +
    package sort
     
    -import (
    -	"fmt"
    -	"testing"
    +import (
    +	"fmt"
    +	"testing"
     
    -	"codeberg.org/snonux/algorithms/ds"
    -)
    +	"codeberg.org/snonux/algorithms/ds"
    +)
     
    -func TestSleepSort(t *testing.T) {
    -	a := ds.NewRandomArrayList[int](10, 10)
    -	a = Sleep(a)
    -	if !a.Sorted() {
    -		t.Errorf("Array not sorted: %v", a)
    -	}
    -}
    +func TestSleepSort(t *testing.T) {
    +	a := ds.NewRandomArrayList[int](10, 10)
    +	a = Sleep(a)
    +	if !a.Sorted() {
    +		t.Errorf("Array not sorted: %v", a)
    +	}
    +}
     

    As you can see, it takes 9s here for the algorithm to finish (which is the highest value in the ArrayList):
    @@ -3838,11 +3838,11 @@ http://www.gnu.org/software/src-highlite --> by Lorenzo Bettini http://www.lorenzobettini.it http://www.gnu.org/software/src-highlite --> -
    ❯ go test ./sort -v -run SleepSort
    -=== RUN   TestSleepSort
    ---- PASS: TestSleepSort (9.00s)
    -PASS
    -ok      codeberg.org/snonux/algorithms/sort     9.002s
    +
    ❯ go test ./sort -v -run SleepSort
    +=== RUN   TestSleepSort
    +--- PASS: TestSleepSort (9.00s)
    +PASS
    +ok      codeberg.org/snonux/algorithms/sort     9.002s
     

    I won't write any benchmark for sleep sort; that will be done for the algorithms to come in this series :-).
    @@ -4123,8 +4123,8 @@ Blablabla... by Lorenzo Bettini http://www.lorenzobettini.it http://www.gnu.org/software/src-highlite --> -
    declare -xr PRE_GENERATE_HOOK=./pre_generate_hook.sh
    -declare -xr POST_PUBLISH_HOOK=./post_publish_hook.sh
    +
    declare -xr PRE_GENERATE_HOOK=./pre_generate_hook.sh
    +declare -xr POST_PUBLISH_HOOK=./post_publish_hook.sh
     

    Use of safer Bash options


    @@ -4141,10 +4141,10 @@ http://www.gnu.org/software/src-highlite --> by Lorenzo Bettini http://www.lorenzobettini.it http://www.gnu.org/software/src-highlite --> -
    % cat gemfeed/2023-02-26-title-here.gmi
    -# Title here
    +
    % cat gemfeed/2023-02-26-title-here.gmi
    +# Title here
     
    -The remaining content of the Gemtext file...
    +The remaining content of the Gemtext file...
     

    Gemtexter will add a line starting with > Published at ... now. Any subsequent Atom feed generation will then use that date.
    @@ -4153,12 +4153,12 @@ The remaining content of the Gemtext file... by Lorenzo Bettini http://www.lorenzobettini.it http://www.gnu.org/software/src-highlite --> -
    % cat gemfeed/2023-02-26-title-here.gmi
    -# Title here
    +
    % cat gemfeed/2023-02-26-title-here.gmi
    +# Title here
     
    -> Published at 2023-02-26T21:43:51+01:00
    +> Published at 2023-02-26T21:43:51+01:00
     
    -The remaining content of the Gemtext file...
    +The remaining content of the Gemtext file...
     

    XMLLint support


    @@ -5326,23 +5326,23 @@ jgs (________\ \ by Lorenzo Bettini http://www.lorenzobettini.it http://www.gnu.org/software/src-highlite --> -
    check_dependencies () {
    -    # At least, Bash 5 is required
    -    local -i required_version=5
    -    IFS=. read -ra version <<< "$BASH_VERSION"
    -    if [ "${version[0]}" -lt $required_version ]; then
    -        log ERROR "ERROR, \"bash\" must be at least at major version $required_version!"
    -        exit 2
    -    fi
    -
    -    # These must be the GNU versions of the commands
    -    for tool in $DATE $SED $GREP; do
    -        if ! $tool --version | grep -q GNU; then
    -            log ERROR "ERROR, \"$tool\" command is not the GNU version, please install!"
    -            exit 2
    -        fi
    -    done
    -}
    +
    check_dependencies () {
    +    # At least, Bash 5 is required
    +    local -i required_version=5
    +    IFS=. read -ra version <<< "$BASH_VERSION"
    +    if [ "${version[0]}" -lt $required_version ]; then
    +        log ERROR "ERROR, \"bash\" must be at least at major version $required_version!"
    +        exit 2
    +    fi
    +
    +    # These must be the GNU versions of the commands
    +    for tool in $DATE $SED $GREP; do
    +        if ! $tool --version | grep -q GNU; then
    +            log ERROR "ERROR, \"$tool\" command is not the GNU version, please install!"
    +            exit 2
    +        fi
    +    done
    +}
     

    Especially macOS users didn't read the README carefully enough to install GNU Grep, GNU Sed and GNU Date before using Gemtexter.
    @@ -5363,7 +5363,7 @@ http://www.gnu.org/software/src-highlite --> by Lorenzo Bettini http://www.lorenzobettini.it http://www.gnu.org/software/src-highlite --> -
    ./gemtexter --generate '.*hello.*'
    +
    ./gemtexter --generate '.*hello.*'
     

    Revamped git support


    -- cgit v1.2.3