On Wed, 09 May 2007 22:34:17 +0200 Arthur de Jong <[EMAIL PROTECTED]> wrote:
> > 75- Kill a random process on your computer. > > 76- kill -9 `ps -A | awk '{print $1}' | rl --count=1` > > > > Lines #75-76 seem potentially harmful... > > I'm not very inclined to change this. I always thought it was a nice > example of how to use randomize lines (I like the example). Maybe I > will reword it slightly or include a warning with this specific > example... > > ...It also includes a rather fat warning already to be careful. Well I hope you'll consider the question. A few thoughts on humor... It's like the code equivalent of a "sick joke", e.g.: Kid: Mommy! Mommy! Daddy's on fire! Mom: Quick! Get the Marshmallows! I like some humor in computer texts. My favorite examples are Russ Walter's 'Secret Guide To Computers', Leo Brodie's 'Forth' books, or Michele Andreoli's 'muLinux' docs; all have concise information leavened with humor. A weak example is the "...for Dummies" books which pours gooey humor syrup over a hastily prepared dish, a cheap artificial sweetener. Larry Wall's 'perl' humor falls somewhere in the middle. Now the 'kill -9' example isn't in such bad taste as: # Play Linux Russian Roulette -- as root! # Silently background delete 10 random files. rm -f `locate --regex '.*' | rl --count=10` > /dev/null 2>&1 & ...which would be wrong to put in a man page. Does sick humor belong in a man page example? I'd say only if it's fantasy, (data), but not if it's functional, (code). To compare it to another kind of program, the black humor of 'Missile Command', 'Eliza', or even 'Grand Theft Auto' I'd accept as valid, (since those don't harm the material world), but the obstructive humor of the virus writer or cracker, though amusing to its author, is generally inappropriate. Summing up: if users can't run it, that's no example. > ...I like the idea of playing the last so many number of files though but I > don't like using the output of ls because many people alias ls to pass > it more options (e.g. -F) for highlighting purposes. Try '/bin/ls -c'? Further examples: # shuffle a deck of cards seq 52 | rl # garble a string S="hello world" echo $S | sed 's/\(.\)/\1\n/g' | rl | tr -d '\n' ; echo # mix the words in a sentence S="the quick brown fox jumps over the lazy dog." echo "$S" | sed 's/\( \)/\n/g' | rl | tr '\n' ' ' ; echo # roll Monopoly dice (2d6) (needs 'dc') dc -e "`seq 6 | rl -rc 2` + p" # do that 5000 times, (slow!), make a sorted table of results for f in `seq 5000`; do dc -e "`seq 6 | rl -rc 2` + p"; done | sort -g | uniq -c # same thing, only much faster seq 6 | rl -rc 10000 | while read a; do read b; echo $(($a + $b)); done | sort -g | uniq -c # print the words of a sentence in random colors S="the quick brown fox jumps over the lazy dog." seq 31 40 | rl -rc 100 | for f in $S ; do read c ; /bin/echo -ne "\033[$c\155$f " ; done ; echo HTH... -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]