summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2026-05-31 14:38:03 +0300
committerPaul Buetow <paul@buetow.org>2026-05-31 14:38:03 +0300
commitc2d6b7528ff410ac37e64ce57b8dfa87a8060559 (patch)
tree38e10779cbdcbfc2e72870f8cdd0998e70497423
parenta9bff7565a76dc60d0585669d1fa50b29cce6253 (diff)
Update content for md
-rw-r--r--gemfeed/2026-06-01-gt-calculator.md90
-rw-r--r--index.md2
-rw-r--r--uptime-stats.md20
3 files changed, 93 insertions, 19 deletions
diff --git a/gemfeed/2026-06-01-gt-calculator.md b/gemfeed/2026-06-01-gt-calculator.md
index e913eaef..b679a4df 100644
--- a/gemfeed/2026-06-01-gt-calculator.md
+++ b/gemfeed/2026-06-01-gt-calculator.md
@@ -28,6 +28,7 @@ And no, this wasn't vibe-coded. I used a specific technique and a set of AI skil
* [⇢ ⇢ What it does](#what-it-does)
* [⇢ ⇢ Percentage calculations](#percentage-calculations)
* [⇢ ⇢ RPN arithmetic](#rpn-arithmetic)
+* [⇢ ⇢ ⇢ Modulo](#modulo)
* [⇢ ⇢ ⇢ Logarithms](#logarithms)
* [⇢ ⇢ ⇢ Hyper operators (n-ary)](#hyper-operators-n-ary)
* [⇢ ⇢ ⇢ Comparisons and booleans](#comparisons-and-booleans)
@@ -39,6 +40,7 @@ And no, this wasn't vibe-coded. I used a specific technique and a set of AI skil
* [⇢ ⇢ ⇢ Metric-aware arithmetic](#metric-aware-arithmetic)
* [⇢ ⇢ ⇢ Custom metrics](#custom-metrics)
* [⇢ ⇢ ⇢ SI vs IEC modes](#si-vs-iec-modes)
+* [⇢ ⇢ ⇢ Discovering metrics](#discovering-metrics)
* [⇢ ⇢ Stack manipulation](#stack-manipulation)
* [⇢ ⇢ Rational number mode](#rational-number-mode)
* [⇢ ⇢ The REPL](#the-repl)
@@ -98,6 +100,15 @@ Six basic operators: `+`, `-`, `*`, `/`, `^`, `%`. All work on the stack, poppin
The fast integer power operator `**` uses binary exponentiation (O(log n) instead of O(n)). So `2 100 **` does about 7 multiplications instead of 99. It only accepts integer exponents — use `^` for fractional powers.
+### Modulo
+
+`%` gives the remainder after division:
+
+```sh
+gt '17 5 %' # → 2
+gt '100 7 %' # → 2
+```
+
### Logarithms
Three unary operators for when you need them:
@@ -123,7 +134,13 @@ gt '2 5 10 [*]' # → 100 (product)
gt '1000 2 2 2 2 [/]' # → 62.5
```
-Full set: `[+]`, `[-]`, `[*]`, `[/]`, `[^]`, `[%]` for arithmetic, plus `[lg]`, `[log]`, `[ln]` for logarithms. The log hyper operators work differently from the arithmetic ones — they compute the sum of the log function applied to each value, not a left-associative reduction. The square-bracket syntax is inspired by Raku's hyper operators.
+Full set: `[+]`, `[-]`, `[*]`, `[/]`, `[^]`, `[%]` for arithmetic, plus `[lg]`, `[log]`, `[ln]` for logarithms. The log hyper operators work differently from the arithmetic ones — they compute the sum of the log function applied to each value, not a left-associative reduction. A quick entropy calculation:
+
+```sh
+gt '0.25 0.5 0.25 [lg]' # → -5 (information theory entropy bits)
+```
+
+The square-bracket syntax is inspired by Raku's hyper operators.
[https://raku.org](https://raku.org)
@@ -151,6 +168,13 @@ gt '72 68 gte 100 lte +' # → 2 (both checks pass, temp is in range)
gt '105 68 gte 100 lte +' # → 1 (out of range)
```
+Booleans also do plain arithmetic, which is occasionally useful:
+
+```sh
+gt 'true true +' # → 2 (1 + 1)
+gt 'false 5 +' # → 5 (0 + 5)
+```
+
## Variables and symbols
Store values with three assignment styles:
@@ -163,7 +187,16 @@ gt 'rate 100Mbps =' # standard (or rate = 100Mbps)
`vars` lists them, `clear` wipes all variables and constants, `:name d` deletes one. In REPL mode, variables persist to disk between sessions.
-Symbols (the `:x` syntax) are named placeholders on the stack. They're how you do explicit variable assignment and deletion without ambiguity. Bare identifiers that don't match any variable or constant also push as symbols.
+Symbols (the `:x` syntax) are named placeholders on the stack. The `:` prefix makes intent explicit: `:x` always pushes the symbol `x`, even if a variable named `x` already exists. This is how you delete a variable without ambiguity, and how you push a name onto the stack without resolving it.
+
+```sh
+> x 10 := # define x
+> x # pushes 10 (variable resolved)
+> :x # pushes :x (the symbol itself)
+> :x d # deletes the variable x
+```
+
+Bare identifiers that don't match any variable or constant also push as symbols.
## Built-in constants
@@ -178,6 +211,8 @@ gt 'sqrt2 sqrt3 *' # → 2.449 (√6)
Greek letter aliases work too: `π`, `τ`, `φ`, `√2`, `√3`, `√5`.
+There's also a `constants` command that lists all 36 in one shot. Edge cases are covered too — `inf`, `-inf`, and `nan` exist as constants if you ever need them.
+
## The metrics system
This is where `gt` earns its swiss army knife title. Every number carries a unit of measurement, and arithmetic understands those units.
@@ -242,16 +277,46 @@ gt '1GB 1024MB eq' # → false (SI: 1GB = 1000MB)
Define your own units:
```sh
-custom define reel 304.8 Distance # surveyor's reel
-custom define fortnight 1209600 Time
+custom define reel 304.8 Distance # surveyor's reel
+custom define fortnight 1209600 Time # 14 days
+custom define cup 240 Weight # cooking measure
```
-Then use them like built-ins: `5reel @m convert` → 1524.
+Then use them like built-ins:
+
+```sh
+> 5reel @m convert
+1524
+> 2fortnight @day convert
+28
+> 3cup @g convert
+720
+```
### SI vs IEC modes
Data size units have two modes. SI (default) uses powers of 1000. IEC uses powers of 1024. Switch with `metric decimal set` / `metric binary set`. The dedicated IEC units (KiB, MiB, GiB) are always unambiguous.
+### Discovering metrics
+
+You can explore what's available without leaving the REPL:
+
+```sh
+> metric list
+DataRate, DataSize, Distance, Speed, Time, Universal, Weight
+> metric DataRate
+Gbps, Kbps, Mbps, Tbps, bps
+```
+
+`metric compatible` checks whether two values can be combined before you try:
+
+```sh
+> 1km 5mi metric compatible
+km (Distance) and mi (Distance): true
+> 100Mbps 2hr metric compatible
+Mbps (DataRate) and hr (Time): false
+```
+
## Stack manipulation
Five operators for managing the RPN stack:
@@ -262,7 +327,7 @@ Five operators for managing the RPN stack:
- `show` / `showstack` / `print` — display the stack without modifying it
- `clear` — clear all variables and constants
-`dup` and `swap` come up a lot. Square a number: `7 dup *` → 49. Reverse operand order: `2 10 swap /` → 5 (instead of 0.2).
+`dup` and `swap` come up a lot. Square a number: `7 dup *` → 49. Reverse operand order: `2 10 swap /` → 5 (instead of 0.2). `pop` discards the top value if you pushed something by accident: `5 6 pop` → 5.
## Rational number mode
@@ -296,9 +361,16 @@ REPL-only. Has a known limitation with non-dyadic decimals and metric operations
Run `gt` with no arguments when attached to a terminal and you get the interactive session. Command history (1000 entries, persisted to `~/.gt_history`), tab completion, Emacs-style line editing, Ctrl+R reverse search.
-Variables save to disk between sessions. Session logging with `--log session.log`. Session state lives in `~/.local/state/gt/vars`.
+Variables save to disk between sessions. Session state lives in `~/.local/state/gt/vars`. For auditing or note-taking, session logging works like this:
-Built-in REPL commands: `help`, `clear`, `quit`/`exit`, `rpn`/`calc`, `rat`, `stack`. Tab-completes.
+```sh
+$ gt --log calc-session.log
+> 1Gbps 1hr *
+> @GB convert
+> quit
+```
+
+Built-in REPL commands: `help`, `clear`, `quit`/`exit`, `rpn`/`calc`, `rat`, `stack`. `stack` is a shorthand hint for viewing the RPN stack. Tab-completes.
Here's what a session looks like:
@@ -408,6 +480,8 @@ go install codeberg.org/snonux/gt/cmd/gt@latest
Or from the source directory: `mage install`.
+One quirk: there are no `-h` or `--help` flags. `gt version` gives you the version, and bare `gt` with no TTY prints usage. If you pass `-h`, `gt` tries to evaluate it as RPN and errors. It's intentional and keeps the surface area small.
+
## Wrapping up
The local LLM experiment worked. The code is clean enough, the tests pass, the docs are thorough, and I use the tool. The logo was generated by a local model too.
diff --git a/index.md b/index.md
index 0c77ad81..49ac9a3d 100644
--- a/index.md
+++ b/index.md
@@ -1,6 +1,6 @@
# Hello!
-> This site was generated at 2026-05-31T14:33:01+03:00 by `Gemtexter`
+> This site was generated at 2026-05-31T14:37:53+03:00 by `Gemtexter`
Welcome to the foo.zone!
diff --git a/uptime-stats.md b/uptime-stats.md
index ddb7accf..094e3f0b 100644
--- a/uptime-stats.md
+++ b/uptime-stats.md
@@ -1,6 +1,6 @@
# My machine uptime stats
-> This site was last updated at 2026-05-31T14:33:00+03:00
+> This site was last updated at 2026-05-31T14:37:53+03:00
The following stats were collected via `uptimed` on all of my personal computers over many years and the output was generated by `goprecords`, the global uptime records stats analyser of mine.
@@ -13,7 +13,7 @@ Also check out my blog post:
[Unveiling `guprecords.raku`: Uptime records with Raku (and also there is a version in Go now)](./gemfeed/2023-05-01-unveiling-guprecords:-uptime-records-with-raku.md)
-> Uptime stats were last updated Sun 31 May 14:33:01 EEST 2026
+> Uptime stats were last updated Sun 31 May 14:37:53 EEST 2026
## Top 20 Uptime's by Host
@@ -128,13 +128,13 @@ Boots is the total number of host boots over the entire lifespan.
| 10. | makemake | 81 | Linux 6.9.9-200.fc40.x86_64 |
| 11. | uranus | 59 | NetBSD 10.1 |
| 12. | pluto | 51 | Linux 3.2.0-4-amd64 |
-| 13. | *mega-m3-pro | 50 | Darwin 25.3.0 |
-| 14. | mega15289 | 50 | Darwin 23.4.0 |
-| 15. | *fishfinger | 50 | OpenBSD 7.8 |
+| 13. | *fishfinger | 50 | OpenBSD 7.8 |
+| 14. | *mega-m3-pro | 50 | Darwin 25.3.0 |
+| 15. | mega15289 | 50 | Darwin 23.4.0 |
| 16. | *blowfish | 50 | OpenBSD 7.8 |
| 17. | t450 | 46 | FreeBSD 14.2-RELEASE |
-| 18. | phobos | 40 | Linux 3.4.0-CM-g1dd7cdf |
-| 19. | mega8477 | 40 | Darwin 13.4.0 |
+| 18. | mega8477 | 40 | Darwin 13.4.0 |
+| 19. | phobos | 40 | Linux 3.4.0-CM-g1dd7cdf |
| 20. | *pi0 | 34 | Linux 6.1.31-v8.1.el9.altarch |
+-----+----------------+-------+-------------------------------+
```
@@ -190,14 +190,14 @@ Boots is the total number of host boots over the entire lifespan.
| 10. | *OpenBSD 7... | 110 |
| 11. | Darwin 13... | 40 |
| 12. | Darwin 24... | 27 |
-| 13. | Darwin 23... | 25 |
-| 14. | FreeBSD 5... | 25 |
+| 13. | FreeBSD 5... | 25 |
+| 14. | Darwin 23... | 25 |
| 15. | Linux 2... | 22 |
| 16. | Darwin 21... | 17 |
| 17. | Darwin 15... | 15 |
| 18. | Darwin 22... | 12 |
| 19. | Darwin 18... | 11 |
-| 20. | FreeBSD 7... | 10 |
+| 20. | FreeBSD 6... | 10 |
+-----+----------------+-------+
```