Thread View: alt.comp.software.thunderbird
17 messages
17 total messages
Started by "J. P. Gilliver"
Wed, 18 Jun 2025 11:43
random quote extractor?
Author: "J. P. Gilliver"
Date: Wed, 18 Jun 2025 11:43
Date: Wed, 18 Jun 2025 11:43
9 lines
401 bytes
401 bytes
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.) -- J. P. Gilliver. UMRA: 1960/<1985 MB++G()AL-IS-Ch++(p)Ar@T+H+Sh0!:`)DNAf
Re: random quote extractor?
Author: Chris
Date: Wed, 18 Jun 2025 12:51
Date: Wed, 18 Jun 2025 12:51
14 lines
572 bytes
572 bytes
J. P. Gilliver <G6JPG@255soft.uk> 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 like SQLite and then run this SQL statement: SELECT * FROM my_quotes ORDER BY RANDOM() LIMIT 1; Completely portable.
Re: random quote extractor?
Author: Chris Elvidge
Date: Wed, 18 Jun 2025 12:53
Date: Wed, 18 Jun 2025 12:53
13 lines
472 bytes
472 bytes
On 18/06/2025 at 11:43, J. P. Gilliver 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.) https://www.bgreco.net/fortune -- Chris Elvidge, England GRAMMAR IS NOT A TIME OF WASTE
Re: random quote extractor?
Author: "J. P. Gilliver"
Date: Wed, 18 Jun 2025 16:53
Date: Wed, 18 Jun 2025 16:53
26 lines
999 bytes
999 bytes
On 2025/6/18 13:51:49, Chris wrote: > J. P. Gilliver <G6JPG@255soft.uk> 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. -- J. P. Gilliver. UMRA: 1960/<1985 MB++G()AL-IS-Ch++(p)Ar@T+H+Sh0!:`)DNAf
Re: random quote extractor?
Author: "J. P. Gilliver"
Date: Wed, 18 Jun 2025 17:21
Date: Wed, 18 Jun 2025 17:21
32 lines
1113 bytes
1113 bytes
On 2025/6/18 12:53:46, Chris Elvidge wrote: > On 18/06/2025 at 11:43, J. P. Gilliver 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.) > > https://www.bgreco.net/fortune > Thanks for that. Looks a bit complicated for me. If I implemented it, and wanted to just get a random quote, would I have to invoke powershell with it as a parameter - something like "powershell <fortune>"? (And could I direct its output to a file, ideally with ">>" so it could _append_ to such a file)? I see the supplied fortune.txt has fortunes separated by "%" lines. Mine has "%%" lines. Could I just change -split "`n%`n" with -split "`n%%`n" in the two methods shown, or would it just be easier/safer to do a global change in my quotes file? -- J. P. Gilliver. UMRA: 1960/<1985 MB++G()AL-IS-Ch++(p)Ar@T+H+Sh0!:`)DNAf
Re: random quote extractor?
Author: Paul
Date: Wed, 18 Jun 2025 18:21
Date: Wed, 18 Jun 2025 18:21
47 lines
1770 bytes
1770 bytes
On Wed, 6/18/2025 6:43 AM, J. P. Gilliver 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.) One way of doing it, is to put all materials into just one file, compile, and now the EXE has all resources needed. #include <stdio.h> #include <stdlib.h> #include <string.h> #include <Windows.h> /* gcc -o randstmt.exe randstmt.c */ /* mingw32 installation... */ /* Some strings strng[0], strng[1], strng[2], plus an end marker as strng[3] */ /* Add statements and recompile */ /* To be triggered manually by the user. These are not really random numbers, but want to avoid linking in ugly DLLs */ int main() { /* The first chunk here, is your collection of thoughtful observations */ char *strng[] = { "To air is human.\n To dust, divine.\n", "When life gives you lemons\n open a used car lot\n", "A transcendental plan \n is better than no dental plan at all.\n", "End" }; int i = 0; int j = 0; __int64 now; QueryPerformanceCounter((LARGE_INTEGER *) &now); /* vaguely related to RDTSC ? */ printf("0x%I64X \n", now); /* Debug the range of the random numbers -- remove after testing */ while (strcmp(strng[i], "End") != 0) { /* This measures the number of statements in names[] */ i++ ; } /* statements mod i */ j = now % i ; printf("%d\n", j); /* Debug the range of the random numbers -- remove after testing */ printf( strng[ j ] ); /* Use printf punctuation, such as \n , for crude formatting */ exit(0); }
Re: random quote extractor?
Author: Chris
Date: Wed, 18 Jun 2025 19:30
Date: Wed, 18 Jun 2025 19:30
32 lines
1310 bytes
1310 bytes
J. P. Gilliver <G6JPG@255soft.uk> wrote: > On 2025/6/18 13:51:49, Chris wrote: >> J. P. Gilliver <G6JPG@255soft.uk> 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 … It's actually not. It may take a day or two understand the principles of an SQL database. After that it's not scary at all. >> 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. SQL is very, very common and SQLite exists for pretty much any platform. It's completely free - I found out this week that it is fact public domain software - and extremely lightweight.
Re: random quote extractor?
Author: MikeS
Date: Wed, 18 Jun 2025 21:23
Date: Wed, 18 Jun 2025 21:23
13 lines
704 bytes
704 bytes
On 18/06/2025 11:43, J. P. Gilliver 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.) If the old 16 bit program does all you want there is a good chance it will work in Windows 10 or 11 with a utility called otvdm https://mendelson.org/otvdm.html It is trivial to install and your program will then simply run. It is based on Wine but nothing like running a VM and I have used it for years without problems.
Re: random quote extractor?
Author: "J. P. Gilliver"
Date: Wed, 18 Jun 2025 23:35
Date: Wed, 18 Jun 2025 23:35
24 lines
1756 bytes
1756 bytes
T24gMjAyNS82LzE4IDIxOjIzOjUzLCBNaWtlUyB3cm90ZToNCj4gT24gMTgvMDYvMjAyNSAx MTo0MywgSi4gUC4gR2lsbGl2ZXIgd3JvdGU6DQo+PiBBbnlvbmUga25vdyBvZiBhIHV0aWxp dHkgdGhhdCB3aWxsIGV4dHJhY3QgYSBxdW90ZSwgYXQgcmFuZG9tLCBmcm9tIGEgDQo+PiBm aWxlIG9mIHF1b3RlcyAoc2VwYXJhdGVkIGJ5IGEgZ2l2ZW4gc3RyaW5nLCB3aGljaCBJIGNv dWxkIGNoYW5nZSANCj4+IGVhc2lseSBlbm91Z2ggLSBjdXJyZW50bHkgdXNpbmcgIiUlIiks IHRoYXQgd2lsbCB3b3JrIHVuZGVyIGEgNjQtYml0IA0KPj4gT1M/IFRoZSBvbmUgSSB1c2Vk IHRvIHVzZSBbVG9tUXVvdGVdIG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IHJpZGljdWxvdXNseSANCm9uLCB0 byBhZmZpcm0gdGhhdCBvdGhlciBwZW9wbGUncyBwbGVhc3VyZXMsIGV2ZW4gZ2hhc3RseSBv bmVzLCBhcmUgcGFydCANCm9mIHRoZSBncmVhdCBtb3VsZHkgcGF0Y2h3b3JrIGNsb3duLXRy b3VzZXIgb2YgdGhlIG5hdGlvbi4gLSBMaWJieSANClB1cnZlcywgcnQgMjAyMi8xMi8xNy0y Mw0K
Re: random quote extractor?
Author: Paul
Date: Wed, 18 Jun 2025 23:55
Date: Wed, 18 Jun 2025 23:55
103 lines
4250 bytes
4250 bytes
On Wed, 6/18/2025 11:53 AM, J. P. Gilliver wrote: > On 2025/6/18 13:51:49, Chris wrote: >> J. P. Gilliver <G6JPG@255soft.uk> 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
Re: random quote extractor?
Author: Herbert Kleebaue
Date: Thu, 19 Jun 2025 00:29
Date: Thu, 19 Jun 2025 00:29
121 lines
3404 bytes
3404 bytes
On 18.06.2025 12:43, J. P. Gilliver 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. The following batch will convert the "quotes.txt" input file to a batch file (q.bat). When you execute q.bat, a random quote is displayed. But to use batch control characters (like ^ & %) in the text, you have to escape them (^^ ^& %%). :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: @echo off echo @echo off>q.bat echo echo.>>q.bat echo goto :start>>q.bat echo :l0>>q.bat set /a n=1 for /f "tokens=*" %%i in (quotes.txt) do ( if "%%i"=="%%%%" ( echo echo.>>q.bat echo goto :eof>>q.bat call echo :l%%n%%>>q.bat set /a n=n+1) else ( echo echo %%i>>q.bat) ) echo echo.>>q.bat echo goto :eof>>q.bat echo :start>>q.bat echo set /a m=%%random%%>>q.bat echo set /a m=%%random%%%%%%%n%>>q.bat echo goto :l%%m%%>>q.bat :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: For the input file quotes.txt: Life isn't about getting and having, it's about giving and being. Kevin Kruse %% Whatever the mind of man can conceive and believe, it can achieve. Napoleon Hill %% Strive not to be a success, but rather to be of value. Albert Einstein %% Two roads diverged in a wood, and I-I took the one less traveled by, And that has made all the difference. Robert Frost %% I attribute my success to this: I never gave or took any excuse. Florence Nightingale %% You miss 100%% of the shots you don't take. Wayne Gretzky %% I've missed more than 9000 shots in my career. I've lost almost 300 games. 26 times I've been trusted to take the game winning shot and missed. I've failed over and over and over again in my life. And that is why I succeed. Michael Jordan :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: the following q.bat is generated: @echo off echo. goto :start :l0 echo Life isn't about getting and having, it's about giving and being. echo Kevin Kruse echo. goto :eof :l1 echo Whatever the mind of man can conceive and believe, it can achieve. echo Napoleon Hill echo. goto :eof :l2 echo Strive not to be a success, but rather to be of value. echo Albert Einstein echo. goto :eof :l3 echo Two roads diverged in a wood, and I-I took the one less traveled echo by, And that has made all the difference. echo Robert Frost echo. goto :eof :l4 echo I attribute my success to this: I never gave or took any excuse. echo Florence Nightingale echo. goto :eof :l5 echo You miss 100%% of the shots you don't take. echo Wayne Gretzky echo. goto :eof :l6 echo I've missed more than 9000 shots in my career. I've lost almost echo 300 games. 26 times I've been trusted to take the game winning shot echo and missed. I've failed over and over and over again in my life. echo And that is why I succeed. echo Michael Jordan echo. goto :eof :start set /a m=%random% set /a m=%random%%%7 goto :l%m%
Re: random quote extractor?
Author: Frank Miller
Date: Thu, 19 Jun 2025 00:30
Date: Thu, 19 Jun 2025 00:30
6 lines
346 bytes
346 bytes
J. P. Gilliver 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? Is this related to Mozilla Thunderbird (the topic of *this* newsgroup)? If not, please stop cross posting.
Re: random quote extractor?
Author: "J. P. Gilliver"
Date: Thu, 19 Jun 2025 09:00
Date: Thu, 19 Jun 2025 09:00
37 lines
2769 bytes
2769 bytes
T24gMjAyNS82LzE5IDc6NTU6MzgsIFJhbHBoIEZveCB3cm90ZToNCj4gT24gVGh1LCAxOSBK dW4gMjAyNSAwMDozMDo0OCArMDIwMCwgRnJhbmsgTWlsbGVyIHdyb3RlOg0KPj4gSi4gUC4g R2lsbGl2ZXIgd3JvdGU6DQo+Pg0KPj4+IEFueW9uZSBrbm93IG9mIGEgdXRpbGl0eSB0aGF0 IHdpbGwgZXh0cmFjdCBhIHF1b3RlLCBhdCByYW5kb20sIGZyb20gYQ0KPj4+IGZpbGUgb2Yg cXVvdGVzIChzZXBhcmF0ZWQgYnkgYSBnaXZlbiBzdHJpbmcsIHdoaWNoIEkg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CKytHKClBTC1J Uy1DaCsrKHApQXJAVCtIK1NoMCE6YClETkFmDQoADQoiSWYgZXZlbiBvbmUgcGVyc29uIiBh cmd1bWVudHMgYWxsb3cgdGhlIHBlcmZlY3QgdG8gYmVjb21lIHRoZSBlbmVteSBvZiANCnRo ZSBnb29kLCBhbmQgdGh1cyB0aGV5IHRlbmQgdG8gY2F1c2UgbW9yZSBoYXJtIHRoYW4gZ29v ZC4NCi0gSmltbXkgQWtpbnMgcXVvdGVkIGJ5IFNjb3R0IEFkYW1zLCAyMDE1LTUtNQ0K
Re: random quote extractor?
Author: Chris
Date: Thu, 19 Jun 2025 09:07
Date: Thu, 19 Jun 2025 09:07
106 lines
4337 bytes
4337 bytes
Paul <nospam@needed.invalid> wrote: > On Wed, 6/18/2025 11:53 AM, J. P. Gilliver wrote: >> On 2025/6/18 13:51:49, Chris wrote: >>> J. P. Gilliver <G6JPG@255soft.uk> 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 ***** If we're going into the details. For something simple like this a transaction isn't required so remove the BEGIN TRANSACTION and COMMIT lines. Every INSERT statement will be then committed automatically. However, I would use the .import pragma to insert directly from a CSV file instead. Much more practical with real data. https://www.sqlitetutorial.net/sqlite-import-csv/ The OP's source data may need reformatting, but this is a one-off that can be achieved easily enough in Notepad++ or similar. > 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. Well, yes. True randomness if effectively impossible on current technology. qbit machines might be able to achieve it. For the purposes of hobby exercises, tho, software randomness is fine.
Re: random quote extractor?
Author: Chris
Date: Thu, 19 Jun 2025 09:10
Date: Thu, 19 Jun 2025 09:10
37 lines
1353 bytes
1353 bytes
Paul <nospam@needed.invalid> wrote: > On Wed, 6/18/2025 6:43 AM, J. P. Gilliver 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.) > > One way of doing it, is to put all materials into just one file, > compile, and now the EXE has all resources needed. > > #include <stdio.h> > #include <stdlib.h> > #include <string.h> > #include <Windows.h> > > /* gcc -o randstmt.exe randstmt.c */ > /* mingw32 installation... */ > > /* Some strings strng[0], strng[1], strng[2], plus an end marker as strng[3] */ > /* Add statements and recompile */ > > /* To be triggered manually by the user. > These are not really random numbers, but want to avoid linking in ugly DLLs */ > > int main() { /* The first chunk here, is your collection of thoughtful observations */ > > char *strng[] = { > "To air is human.\n To dust, divine.\n", > "When life gives you lemons\n open a used car lot\n", > "A transcendental plan \n is better than no dental plan at all.\n", > "End" > }; Down side is you need recompile whenever you add new quotes.
Re: random quote extractor?
Author: Paul
Date: Thu, 19 Jun 2025 14:57
Date: Thu, 19 Jun 2025 14:57
12 lines
422 bytes
422 bytes
On Thu, 6/19/2025 5:10 AM, Chris wrote: > > Down side is you need recompile whenever you add new quotes. Large collection, no rush, as low odds of new item appearing (randomly). You could recompile your list once a month. It you were willing to keep state info, you could sort the lines randomly first, then serve like bog roll. That works better with the easily-accessible (pseudo) random number generators. Paul
Re: random quote extractor?
Author: Ralph Fox
Date: Thu, 19 Jun 2025 18:55
Date: Thu, 19 Jun 2025 18:55
33 lines
1033 bytes
1033 bytes
On Thu, 19 Jun 2025 00:30:48 +0200, Frank Miller wrote: > J. P. Gilliver 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? > > Is this related to Mozilla Thunderbird (the topic of *this* newsgroup)? Of course. The random quotes are to be used in the sig line of messages one sends from Thunderbird. One can even automate the whole process, so a random quote is automatically added without ongoing effort. 1. Configure Thunderbird in Account Settings to attach the sig from a text or HTML file. 2. Use a program such as Phranc's SigChanger [^1] to automatically update that text or HTML file without bothering you. [^1] Phranc's SigChanger <https://web.archive.org/web/20050305051404fw_/http://www.phranc.nl/index.html> -- Kind regards Ralph Fox 🦊️ “Fer from eȝe, fer from herte;” quoþ Hendyng.
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads