http://qs321.pair.com?node_id=844863

Why I Frequent the CB

[tye] gah, some kind of new-age meeting format. [Tanktalus] Tanktalus is trying to imagine a meeting room full of l +ong-haired people wearing braids, smoking marijuana, and listening to + Zamphyr... [RonW] That's the "old" "new age" [Tanktalus] Tanktalus can't keep up :)

Funny Story (and true!)

Take rectangular sheets of metal and form a strip by fastening the narrow ends to each other. Then bend the strip into a circle (diameter 30' or more) and fasten the ends to form a band. Now you have a tank. Make the tank deeper by stacking two more bands on it. Now fill said tank with liquid manure. Lots of liquid manure.

As it says on your cereal box, there will be some settling of contents. The layer of liquid on top will be mostly water, and not of much use in fertilizing.

*Bright idea* - remove one sheet from the top band to form a spout and pour off some of that liquid. Except sharp corners at the bottom of that spout form stress concentrations, and one of the sheets below tears like paper, and that tear continues into the sheet below it. The bands are only kept circular by fasteners, and now relieved of that restraint, the walls of the tank revert to nearly straight. The entire contents of the tank empties in a fairly rapid fashion.

Tree Structure Challenge

  1. call get_leaves on both objects
  2. remove duplicates
  3. for each leaf in list one
    1. get parent, grandparent
    2. push grandparent, parent, leaf onto delete list
  4. for each leaf in list two
    1. get parent, grand
    2. push onto add list

OO versus Procedures

One example of the difference is what is called data encapsulation. In an OO program, there (should be) no data outside of a context. In a procedure, I might have a variable called $user_name. Any code I have that can see that variable might also modify it. That can be okay, but it also can be a problem. It can make it hard to determine what part of my code changed something. Also, just because I called it $user_name, I could store ANY string in that variable, just for convenience sake. Heck, in Perl, I could reuse it to store a hash reference if I wanted. Why would I? No idea. But I could.

In an OO program, the user will have a name, but it will be an attribute, "name" of a class, "user". The ONLY way to modify and display the name will be to call the code in the user object to do it. If I want sometimes to display the full name, and sometimes the full name and title, and sometimes just the first name, I write the code to format that in the way I like once, and that functionality is now available to any other program that uses my user object. If I have users in my RPG, or in my music collection program, or in my website business, or whatever. Every time, I get every clever function that I have invented for displaying or using user names without having to copy code from one procedure to another, and without having to remember .. did I do that differently here than there? Will making them the same break something? I finally figure out how to handle names like Beyonce, Dr. Jose Juan Carlos Espinosa del Reyza III, and Seven of Nine. Now, every program knows how to deal with them and will do so consistently.

Okay, couldn't you do this with packages, or by being consistent in your programming? Much of it, you could. But it would not be enforced. At anytime, you could say "I'll do this just once because I'm in a hurry." Using OO, I am using the features of the language to enforce good programming practice. That makes it much easier to share what I've done with others.

XML to Hash

sub mapxml { my $xml = shift; my ($tag, $value, %xmlhash); my @lines = (split /\n/, $xml); chomp @lines; while (@lines) { my $line = shift @lines; ($tag,$value) = ($line =~ /<([\w:]+?\/?)>([^<]*)/); next if (! defined($tag) || (substr($tag,-1) eq '/')); if ($value =~ /[\w:-\\]+/) { $xmlhash{$tag} = $value; } else { my $contents = ""; while (1) { $line = shift (@lines); last if ($line eq '</' . $tag . '>'); $contents .= $line . "\n"; } $xmlhash{$tag} = mapxml($contents); } } return \%xmlhash; }

On the Subject of Off Topic

If Perlmonks decides to get more formal in its definition of off-topic, I'd suggest the following:

  1. Add "Off Topic" as a moderation selection, as an alternative to "Approve" or "Frontpage"
  2. Add "Off Topic" as consideration category, an alternative to keep/edit/reap/nada
  3. Allow users a selection to suppress nodes designated OT. This could be as simple as posting possible CSS language

Testing

use Test::Simple tests => 2; ok(1 == 1, 'Identity theorem'); ok( &ask eq 'yep', 'User response test'); sub ask { print "Are you a human?\n"; $answer = <STDIN>; chomp $answer; return($answer); }

Link to use as starting point for CSS/JS to color user names to reflect their age relative to me (based on the cb_author id):

CSS to display level

Code code for coding

use strict; use warnings; my $plaintext = 'We are discovered. Flee at once!'; my $key = 'CorrectBatteryHorseStaple'; print "Original message: $plaintext\n"; my $ciphertext = pack('u',cypher($plaintext,$key)); print " Encoded message: $ciphertext\n "; my $decoded = cypher(unpack('u',$ciphertext),$key); print " Decoded message: $decoded\n"; sub cypher { my $plain = shift; my $key = shift; my $i=0; my $j = length($key); return join '', map {$_^substr($key,$i++ % $j,1)} (split '',$plain); }

A favorite password algorithm

 $pwd = join '', sort grep { ! $uniq{$_}++ } split //, $string;

Stuff to Check Out

History

DatePointsPostsRankETA Next RankNext Rank
2010061500InitiateN/AN/A
20100910201NoviceN/AAcolyte
20101221503AcolyteN/ASexton
20110223908SextonN/ABeadle
2011041215013BeadleN/AScribe
2011080325025ScribeN/AMonk
2013020440037MonkN/APilgrim
2013093060048PilgrimN/AFriar
2014020390081FriarN/AHermit
201404281300113HermitN/AChaplain
201407211794154HermitN/AChaplain (1800)
201407231806154Chaplain20141030Deacon(2400)
201410042400203Deacon20141210Curate(3000)Saint
201412103023266Curate20150130Priest(4000)679
201503033620326Curate20150422Priest(4000)
201504074000358Priest20150709Vicar(5400)
201507205403530Vicar20151115Parson(7000)338
201512227000679Parson20160703Prior(9000)255
2017051710041907Prior20171123?Monsignor(12000)175