XPost: alt.comp.software.thunderbird
On Wed, 6/18/2025 11:53 AM, J. P. Gilliver wrote:
On 2025/6/18 13:51:49, Chris wrote:
J. P. Gilliver <[email protected]> wrote:
Anyone know of a utility that will extract a quote, at random, from a
file of quotes (separated by a given string, which I could change easily >>> enough - currently using "%%"), that will work under a 64-bit OS? The
one I used to use [TomQuote] is I think 16 bit, and won't.
(And no, I can't use a VM, for legal reasons.)
I would put your list of quotes as individual entries in a simple database
That sounds like a lot of work …
like SQLite and then run this SQL statement:
SELECT * FROM my_quotes ORDER BY RANDOM() LIMIT 1;
… but that is a very elegant solution, and I appreciate your skill with the language involved. (I'll have a look at Chris Elvidge's solution first.)>
Completely portable.
Assuming you have a machine with an interpreter/compiler for whatever language that line is written in.
This is the current site.
https://sqlite.org/download.html
sqlite-tools-win-x64-3500100.zip (6.13 MiB)
A bundle of command-line tools for managing SQLite database files, including
(1) the command-line shell <=== sqlite3.exe or similar... That's what I would look for.
(2) sqldiff.exe
(3) sqlite3_analyzer.exe
(4) sqlite3_rsync.exe 64-bit
Mine is 3.39.4.0 2022-09-29 (3.39.4) This is a 32 bit version, suited to some situations.
https://web.archive.org/web/20221012234637/https://sqlite.org/download.html
sqlite-tools-win32-x86-3390400.zip (1.88 MiB)
A bundle of command-line tools for managing SQLite database files, including
command-line shell program <=== sqlite3.exe or similar...
sqldiff.exe program,
sqlite3_analyzer.exe program.
First, prepare the file that will create the database. I don't know
a thing about this topic, but I have done .dump on Firefox sqlite3 files before, so I knew where to go to find a copy/paste example :-) The
only thing I forgot on my first try, is I forgot the COMMIT line :-)
No guarantees what I've done is "right", it's just a pale imitation
of a file.
***** fortune.sql *****
PRAGMA foreign_keys=OFF;
BEGIN TRANSACTION;
CREATE TABLE fortunes ( id INTEGER PRIMARY KEY, fortune LONGVARCHAR );
INSERT INTO fortunes VALUES( 1,'I was working on the railroad, the live long day.');
INSERT INTO fortunes VALUES( 2,'Pack my jug with five dozen boxes.');
INSERT INTO fortunes VALUES( 3,'Mary had lamb chops, as white as snow.'); INSERT INTO fortunes VALUES( 4,'My hovercraft is full of spineless invertebrates');
COMMIT;
***** fortune.sql *****
echo .read fortune.sql | sqlite3 fortunes.sqlite3 # Loaded
sqlite3 fortunes.sqlite3 # Interactive
sqlite> SELECT * FROM fortunes ORDER BY RANDOM() LIMIT 1;
4|My hovercraft is full of spineless invertebrates
sqlite> .exit
Still work to do, you need to clean up some details
to make this fit for purpose. But at least I was able
to extract a line.
The first thing I notice, is I suspect it's using RAND() to
generate the numbers, and in my C code, I had to stop doing
that because I was tapping the same sequence each time. Not good.
Still some research to do, on a better seed and generator, as
even when I seeded my RAND() I wasn't happy with what I was
seeing from session to session.
It's not getting a text line that is tough, it's nailing
the randomness that is hard.
My CPU has a feature (Zen3) where it can generate 500 million bytes
of random numbers per second, using a metastability based generator
of some sort. This is a non-cryptographic source of random numbers.
Nobody on the OS sides would touch that with a barge pole, but
it neatly avoids seed and sequence issues. The solution is not
all that portable, as the generators in hardware vary from
none at all, to lousy-implementation, to so-so implementation
with post-whitener to make it minty fresh. Anything that produces
random numbers that quickly, can't be good :-)
Name: rdrand.bin # The file on my S: drive from some experiment.
Size: 1073741824 bytes (1024 MiB) # No idea what code I was using.
Anyway, randomness is the challenge. Not the storing them in
a table part.
Paul
--- SoupGate-Win32 v1.05
* Origin: fsxNet Usenet Gateway (21:1/5)