Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Comment on

( #3333=superdoc: print w/ replies, xml ) Need Help??
#!/usr/bin/perl -w #mstats Version 1.0 #7/29/2000 by ase (alevenson@uswest.net) # #Freely redistributable under the same terms as perl itself. # use strict; #Of course. use PerlMonksChat; #access perlmonks and get the page use HTML::TableExtract; #extract the HTML table use Date::Manip; #manipulate the Create times use GD::Graph::lines3d; #create the plots use Net::FTP; #Send them to a webserver #user configuration $Date::Manip::TZ='PST5PDT'; #timezone:see Date::Manip docs my $user = 'ase'; #monk Username (change) #ftp info my $ftpurl = 'CHANGETHIS.ftp'; #ftp url my $ftpuser = 'CHANGETHIS'; #user name my $ftppass = '*******'; #passwd (protect this script) #end of user configuration #users home node (shouldn't have to change) my $url = "http://www.perlmonks.org/index.pl?" . "node=Perl+Monks+User+Search&" . "usersearch=$user&orderby=createtime%20DESC"; my $p = new PerlMonksChat; #Create Chat Object $p->add_cookies(); #Get the login cookie my $c = $p->getpage($url); #get the users home node $c=~s/bgcolor=>/bgcolor="">/mg; #makes HTML::TableExtract happy my $te = new HTML::TableExtract(headers=>['Rep','Create Time'] ) ->parse($c); #Create the parser and get the table #process the table data into a hash my %data; for my $ts ($te->table_states) { #only one table should be returned for my $row ($ts->rows) { #the row contains [rep, create time] if ($row->[1]) { #if there's a create time my $key = UnixDate($row->[1],"%Q"); #makes key 'yyyymmdd' if(defined($row->[0])) { #if there's a Rep $data{$key}{REP}+=$row->[0]; #add it to the rep total f +or that day $data{$key}{NUM}++; #increment number of posts for that +day } } } } #create a list of lists for the plot objects my ($count,$rep); #running total number of writeups and reps my @data; #the data: munged for GD::graph::lines3d objects my $flag; #has $birth been set? my $birth; #earliest create time in the data for my $key (sort keys %data) { #loop through dates from earliest to + latest; if(!$flag) { #first item? (earliest) $birth=$key; #Set it $flag=1; #don't set it again. } $count+=$data{$key}{NUM}; #Add days writeups to total $rep+=$data{$key}{REP}; #add days rep to total push @{$data[0]}, #days since $birth sprintf("%d",Delta_Format(DateCalc($birth,$key),0 +,"%dt")); push @{$data[1]},$count/($data[0][-1]+1); #avg post/day to date push @{$data[2]},$rep/($data[0][-1]+1); #avg rep/day to date push @{$data[3]},sprintf("%.3f",$rep/$count); #avg rep/post to dat +e } #create some plot settings my %plot= (avg=>{ ylabel => 'Reputation/Writeup', title => 'Rep/Writeup', column => 3, }, post=>{ ylabel => 'Writeups/Day', title => 'Writeups/Day', column => 1, }, rep=>{ ylabel => 'Reputation/Day', title => 'Rep/Day', column => 2, }, ); #this does most of the work in actually making the plots for my $key (keys %plot) { $plot{$key}{GD} = new GD::Graph::lines3d(350,200); $plot{$key}{GD} ->set(x_label => 'Days since ' . UnixDate($birth,"%b %d, %Y +"), y_label => 'Avg ' . $plot{$key}{ylabel}, title => sprintf("%s %.3f)","Recent Avg. " . $plot{$key}{title} . "(currently",$data[$plot{$key}{col +umn}][-1]) ); $plot{$key}{PLOT} = $plot{$key}{GD} ->plot([$data[0],$data[$plot{$key}{column}]]) +; open(IMG,">$key.png") or die $!; binmode IMG; print IMG $plot{$key}{PLOT}->png; close IMG; } #Now send them to our webserver my $ftp = Net::FTP->new($ftpurl); $ftp->login($ftpuser,$ftppass); for my $file (keys %plot) { $ftp->binary; $ftp->put("$file.png"); } $ftp->quit; __END__

In reply to Personal Monk Stats plot creator by ase

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • Outside of code tags, you may need to use entities for some characters:
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others meditating upon the Monastery: (6)
    As of 2014-12-18 04:50 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      Is guessing a good strategy for surviving in the IT business?





      Results (41 votes), past polls