Quote from thing

Linux gives you random 'witticisms' when you log in. I can't remember the proper name for the bit that does it. I just had....

Here is a simple experiment that will teach you an important electrical lesson: On a cool, dry day, scuff your feet along a carpet, then reach your hand into a friend's mouth and touch one of his dental fillings. Did you notice how your friend twitched violently and cried out in pain? This teaches us that electricity can be a very powerful force, but we must never use it to hurt others unless we need to learn an important electrical lesson.

It also teaches us how an electrical circuit works. When you scuffed your feet, you picked up batches of "electrons", which are very small objects that carpet manufacturers weave into carpets so they will attract dirt. The electrons travel through your bloodstream and collect in your finger, where they form a spark that leaps to your friend's filling, then travels down to his feet and back into the carpet, thus completing the circuit.

Amazing Electronic Fact: If you scuffed your feet long enough without touching anything, you would build up so many electrons that your finger would explode! But this is nothing to worry about unless you have carpeting. -- Dave Barry, "What is Electricity?"

Reply to
Genome
Loading thread data ...

Genome wrote: On a cool, dry day, scuff your feet along a carpet, then reach

Not as loud as you cried out when he bit off your fingertip.

Reply to
kell

IIRC, the program that generates those is called fortune.

--
James T. White
Reply to
James T. White

It might be fortune, if that is being run when he logs in. IIRC, though, another commonly-used one, at login, was/is motd (i.e. message of the day). I think they both just have simple text files, containing all of the messages. (Fun to mess with, if you're logged in as root on a large multi-user system. ;-) )

- Tom Gootee

Reply to
tomg

motd gives you one single message. Fortune chooses one, pseudo-randomly. To make this thread vaguely relevant to electronics, and because I think it's interesting. I'm going to tell you how it (the original version) chooses one.

It uses stat() or fstat() to work out the total size of the text file in bytes. Then it reads each multi-line message, one at a time. For each message, it decides what fraction it represents of the remaining file size. Then it chooses a random boolean value having that fraction as a probability of truth, and if true, emits the message and terminates.

Thus even though the messages all vary in size, and it doesn't know how many messages are present in advance, there's an equal chance of choosing each one.

Well, I didn't say I expected *you* to be interested as well :-).

Reply to
Clifford Heath

Aren't the probabilities proportional to the messages sizes? Say there are 4 messages of sizes s1, s2, s3 and s4.

p(1) = s1 / (s1+s2+s3+s4) p(2) = (s2+s3+s4) / (s1+s2+s3+s4) * s2 / (s2+s3+s4) p(3) = (s2+s3+s4) / (s1+s2+s3+s4) * (s3+s4) / (s2+s3+s4) * s3 / (s3+s4) e.t.c. i.e. p(1) = s1 / (s1+s2+s3+s4) p(2) = s2 / (s1+s2+s3+s4) p(3) = s3 / (s1+s2+s3+s4) p(4) = s4 / (s1+s2+s3+s4)

Reply to
Andrew Holme

I thought it was relevant to electronics, it's even got the word 'electronics' in it. I thought it was funny as well, tickled my funny bone anyway. Especially the bit about zapping a tooth filling.

If you have some of those mercury amalgam fillings try chewing aluminium foil. Well, actually, don't because it hurts.....

Ermmmm.... need to know how to power an oral RFID tag.

There, totally on topic.

DNA

Reply to
Genome

Yes, but do it that way and rounding errors mean the probabilities won't add up to 1 exactly. Better to compute the probability that we should emit *this* message, regardless of what's gone before. That way if you get to the last one, the probability is 1 exactly, and the message *will* get emitted.

Didn't mean to criticize the OT-ness of the original post, but the followup.

Reply to
Clifford Heath

You already have the answer - stick a piece of Al foil on it, and use the potential between it and fillings...

--
Regards,

Adrian Jansen           adrianjansen at internode dot on dot net
Design Engineer         J & K Micro Systems
Microcomputer solutions for industrial control
Note reply address is invalid, convert address above to machine form.
Reply to
Adrian Jansen

Obviously not because you have no ! marks in your analysis.

DNA

Reply to
Genome

You can get much bigger reaction if he/she kneels on the ground as you are pleasured in the driver's seat. Those anti-static straps hanging from the rear bumper are a sure sign of a regular contributor.

Reply to
J.A. Legris

Who is going to let somebody stick their finger in his mouth in the first place? ;-)

BTW, it's called "fortune". On my system (Slack 10 or so), there's a bunch of files on /usr/share/games/fortunes:

$ ls /usr/share/games/fortunes fortunes fortunes2 limerick-o startrek zippy fortunes-o fortunes2-o limerick-o.dat startrek.dat zippy.dat fortunes-o.dat fortunes2-o.dat linuxcookie unamerican-o fortunes.dat fortunes2.dat linuxcookie.dat unamerican-o.dat

the ones with the '-o' are "off-color", or maybe it means "offensive". :-)

They're all just text files - the -o ones have been rot13'd.

Cheers! Rich

Reply to
Rich Grise

...

from man fortune: ... The user may specify alternative sayings. You can specify a specific file, a directory which contains one or more files, or the special word all which says to use all the standard databases. Any of these may be preceded by a percentage, which is a number N between 0 and 100 inclu- sive, followed by a %. If it is, there will be a N percent probability that an adage will be picked from that file or directory. If the per- centages do not sum to 100, and there are specifications without percent- ages, the remaining percent will apply to those files and/or directories, in which case the probability of selecting from one of them will be based on their relative sizes.

As an example, given two databases funny and not-funny, with funny twice as big, saying

fortune funny not-funny

will get you fortunes out of funny two-thirds of the time. The command

fortune 90% funny 10% not-funny

will pick out 90% of its fortunes from funny (the ``10% not-funny'' is unnecessary, since 10% is all that's left). The -e option says to con- sider all files equal; thus

fortune -e

is equivalent to

fortune 50% funny 50% not-funny

-------------------------------------------- It doesn't seem to care about the sizes of individual messages.

Cheers! Rich

Reply to
Rich Grise

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.