PDA

View Full Version : F@H stats in your sig: not just for Linux anymore!


Pages : [1] 2

Christoph
01-28-05, 03:24 AM
Windows setup
Thanks to BeerCan for writing this section up.

Ok. Thanks to Christoph and his new perl script you can now update your signatures from a windows machine automatically.
There is one prerequisite. You need to download a win32 version of perl. You can find it here http://www.activestate.com/Products/Download/Download.plex?id=ActivePerl. I downloaded the msi version but your preference may vary. The AS Package doesn't provide any uninstall functionality, and ActiveState recommends it only if you can't use the MSI installer. Install using all of the defaults. It will create a directory c:\Perl and automatically install all necessary files there. It will also create your program groups and associate all perl extensions with perl.exe. The files we care about will end with the .pl extension. Next, we need a copy of Christoph's mksig (http://mksig.org/scripts/mksig.pl) script.

Create a directory on your c:\ drive called c:\mksig. Then, save the above linked file as c:\mksig\mksig.pl . Please make sure it has just the .pl extension and not the .pl.txt extension. If you renamed the file to mksig.pl and it still has the text icon, you need to disable hiding of known extenstions. If you do it right, the icon should turn from the notepad icon to an icon with a lizard on it. Next, execute mksig.pl. Either double click the icon or run it from a dos prompt. Both methods work. Answer all of the questions. It should create the following files in c:\mksig -- mksig.conf, sig, sig_gen.pl and sig.log. These are explaned later in this howto.

If all of those files are there, it installed correctly.
The next step is to make sure that any firewalls you're running don't block Perl.exe from connecting to the Internet. How this is accomplished will depend on your firewall, so check its documentation for more information. If you get an error like Please make sure that Perl can connect to the outside world. , you probably forgot to unblock Perl.exe.

If you want to keep your current forum sig, you should save it now, since mksig doesn't currently back up old sigs. Now when you run mksig.pl again it will update your sig :) Now we need to get it running as a task so it will update automatically.

Open the windows Scheduled Tasks manager. On windows XP it's start-->All Programs-->Accessories-->System Tools-->Scheduled Tasks on Win2K its Start-->Programs-->Accessories-->System Tools-->Scheduled Tasks.

Next click Add a Scheduled Task-->Next on the next screen you are going to hit Browse and browse to C:\mksig\mksig.pl and click open. Next you need to pick how often to run the task. I picked daily. Next, customize the start time to your liking and click next. On the next screen you need to enter the windows user that you would like to run the task under. This is what you use to login to windows and has nothing to do with your forum username. Make sure you enter a password or the task won't run properly. Click next. If you would like to run the task more often than daily, click on the open advanced properties checkbox and click finish. Now you can click the schedule tab and customize to your liking. It should be clear. Click ok and save and you are done.

Of course, if you want to change your sig you need to customize sig_gen.pl. That's covered in the last section of this howto.


Linux setup

Most distros today have Perl available, and installing it is usually a simple matter. For this script, you'll need Perl, LWP (which comes with the base Perl system), the Digest::MD5 module and the XML::Simple module if you're running Linux. If Digest::MD5 isn't installed on your system, just run the following command as root: perl -MCPAN -e "install Digest::MD5" or install from a distro-specific package. If you've never used CPAN before, you'll be asked a number of questions about your setup, and the overall setup can take several minutes. If you're running Gentoo, Debian or their offspring, you can install Digest-MD5 and XML-Simple or libdigest-md5-perl and libxml-simple-perl, respectively and avoid the hassle of CPAN. I don't know if similar packages are available for other distros.

Once you've got Digest::MD5 and XML::Simple installed, download mksig (http://mksig.org/scripts/mksig.pl). To get it ready to run, do the following commands as root:

mv mksig.txt mksig
chmod 755 mksig
mv mksig /usr/bin


The previous instructions recommended changing the ownership to root:root. With versions .62 and later, having mksig owned by either root or non-root will work, although installing as root and running as non-root will prevent automatic updates form working. Since you should *never ever* run day-to-day stuff like this as root, I recommend leaving the default ownership.

Now run mksig as a normal user. Tell it your username and password when asked and use y or n to indicate if you want automatic updates. (If you enable this, mksig will check for a newer version of itself each time it runs, and if possible will download, install and run it. This feature has been tested in both windows and Linux.) Now you're ready to use the default sig. Note that mksig won't change your sig the first time it's run. This is to give you a chance to backup the old one and edit your sig generator (see next section). All user-specific information is stored in ~/.mksig and is covered in the next section.

To get mksig to run at regular intervals, you have a couple options.
The simplest is a backgrounded while loop. Pick and update interval and run (while let 1 do; mksig >/dev/null; sleep 30m; done) & and your sig will silently be updated every half-hour. If you need it to stop updating, simply run pkill sleep and it'll stop.
A similar method is to the first is while loop in the foreground. Simply run while let 1 do; mksig >/dev/null; cat ~/.mksig/sig; sleep 30m; done and your sig will be updated every 30 minutes, and the vbcode will be displayed in the terminal window.
The third method is to use a cron job. cron jobs are executed at regular intervals and are quite simple to set up. You can find Gentoo's instructions on three popular cron implementations here (http://www.gentoo.org/doc/en/cron-guide.xml).


What the Files Do

There are four files: two config files and two logs. In mksig's directory, mksig.conf contains your username and password. sig_gen.pl is the Perl script (or any executable) whose output is submitted as your sig. Under Linux this file is called sig_gen because it's easier to type and Linux doesn't rely on filename extensions. sig contains the most recently submitted sig, and sig.log contains every sig mksig has submitted, along with a timestamp.


How to Get Your DC Stats in Your Sig

mksig determines what your sig will look by executing mksig.pl . Whatever it spits out will be your sig.
Below, I'll post a couple simple example sigs, two that demonstrate how to get stats from Stanford and Berkeley's pages, and the one I'm using now. If there's enough demand, I'll add code to get stats from other pages.
If you know Perl, you'll probably already have come up with some elaborate sig. Good for you. ;)
If you don't know Perl, however, feel free to use these examples as a starting point. While a Perl tutorial of decent length is beyond the scope of this howto, there are hundreds of Perl tutorials available via Google. Going over this one (http://incres.anu.edu.au/manuals/perl/start.html) should help you figure out most of what these scripts do. If it looks intimidating, just look at a page of the tutorial and figure out how the examples use its concepts. When you understand it, go on to the next page, etc.
If you'd like a sig_gen with easy setup, excellent explanation and a good default look, make sure to go through JerMe's excellent guide here (http://www.ocforums.com/showpost.php?p=3436436&postcount=241).
For something more basic, take a look at these scripts. In the first three, I've added links to the comments that explain what's happening on the next line. You're mostly on your own for the later ones.

Example 1:
#!/usr/bin/perl -w
print "Hello!\n";
print "I am a sig.\n";

output from example 1:
Hello!
I am a sig.



Example 2:

#!/usr/bin/perl -w
#http://www.perldoc.com/perl5.6/pod/func/localtime.html
@time = localtime;
$time[5] += 1900;
$time[4]++;
#http://www.perldoc.com/perl5.6/pod/perlfunc.html#Alphabetical-Listing-of-Perl-Functions
$time_str = sprintf("%02d/%02d/%04d at %02d:%02d.\n",$time[4],$time[3],$time[5],$time[2],$time[1]);

print "Christoph's automatic sig generator v.8\n";
print "This sig was generated on $time_str";


possible output from example 2:

Christoph's automatic sig generator v.8
This sig was generated on 01/26/2005 at 23:49.




Example 3 (default sig_gen):

#!/usr/bin/perl
use LWP::UserAgent;

#Get fortune from a website because windows isn't cool enough
#to have it installed natively.
#http://www.perldoc.com/perl5.6/lib/LWP/UserAgent.html
$ua= LWP::UserAgent->new();
$res=$ua->get("http://www.update.uu.se/user-cgi/bjorn/cookie.cgi?1+5");
$f_state=0;

$fortune="";

for $line (split /^/, $res->content) {
if ($line =~ m#<HR># && $f_state == 0) {
$f_state=1;
} elsif ($f_state==1) {
if ($line =~ m#</pre>#) {
$f_state=0;
} else {
$line =~ s/<[^>]*>//g;
$fortune .= $line;
}
}
}

@time = localtime;
$time[5] += 1900;
$time[4]++;
$time_str = sprintf("%02d/%02d/%04d at %02d:%02d.\n",$time[4],$time[3],$time[5],$time[2],$time[1]);

print "Christoph's automatic sig generator v.8\\n";
print "your fortune:[ font=monospace][ b]\\n";
print "$fortune";
print "\\n";
print "[/font][/b]This sig was generated on ";
print "$time_str";


possible output from example 3:

Christoph's automatic sig generator v.8
your fortune:
You are not Morg. You are not Eymorg.
-- Kara the Eymorg, "Spock's Brain," stardate 5432.3

This sig was generated on1/27/2005 at 0:1:59.


S@H stat example code
This will make a simple sig and demonstrate how to adapt it to your tastes. It's not pretty, but it's really more of a starting point than an end. A rewrite's on my todo list, but getting something that works is more important than getting something that's pretty and works.
Note that this has a lot of unnecessary code. Feel free to nuke all the code having to do with any pages you don't use stats from.


#!/usr/bin/perl

use XML::Simple;
use LWP::Simple;
use LWP::UserAgent;

$boinc_id=841;

#I don't know how to find out this email for any given user.
#I assume that you have to give Berkeley your email addy when you signed up.
$berk_email = "lmester\@access.k12.wv.us";

#This is where your seti client lives. If you're in windows, make sure
#to separate directories with "\\" instead of "\".
$seti_home = "/home/ideamagnate/OCFAQ/foldsig/seti/boincdir";
#$seti_home = "c:\\something\\something";

$wu = "$seti_home/slots/0/work_unit.sah";
$state = "$seti_home/slots/0/state.sah";
$c_state = "$seti_home/client_state.xml";

#0 means disable, 1 means enable
$use_boincstats = 1;
$use_localboinc = 1;
$use_classicstats = 0;
#Local classic client monitoring isn't implemented yet.
#I'll get to it. Bug me about it if not.
$use_localclassic = 0;

#windows-specific stuff
if ($^O =~ /win/i) {
#change "/" into "\" on windows machines
$wu =~ s/\//\\\\/g;
$state =~ s/\//\\\\/g;
$c_state =~ s/\//\\\\/g;
}

#read client's state into $boinc_progress
open BOINC_STATE, "$state";
while (<BOINC_STATE>) {
if (/<prog>[\d\.]*<\/prog>/) {
s/<prog>([\d\.]*)<\/prog>/$1/;
chomp;
$boinc_progress = $_;
}
}
close BOINC_STATE;

#get current wu's name from appropriate place
open BOINC_WU, "$wu";
while (<BOINC_WU>) {
s/<soft_link>\.\.\\\.\.\\projects\\setiathome\.berkeley\.edu\\//;
s/<\/soft_link>//;
chomp;
$wu_name = $_;
}
close BOINC_WU;

#parse and extract info from xml file
$cs_xml = XMLin($c_state);
$total_credit = $cs_xml->{project}->{host_total_credit};

###########################
#get BOINC stats from web##
###########################

if ($use_boincstats) {

#http://www.boincstats.com/stats/user_graph.php?pr=sah&id=841

$boinc_page = "http://www.boincstats.com/stats/user_graph.php?pr=sah&id=$boinc_id";
$local_boinc_cache = "boinc.html";

getstore($boinc_page, $local_boinc_cache);

if (! -e $local_boinc_cache) {
print "get the file, stupid\n";
exit;
}

#extract stats from boinc page
open BC, "$local_boinc_cache";
while(<BC>){

if (/Detailed statistics for<br>/) {
$_ =~ s/"([a-zA-Z][\w\s]*)/$1/;
$boinc_user = $1;

} elsif (/>User ID</) {
<BC>;
$boinc_id = <BC>;
chomp($boinc_id);
$boinc_id =~ s/\s*(\d*).*/$1/;

} elsif (/<td>Total Credit</) {
<BC>;
$boinc_total_credit = <BC>;
chomp($boinc_total_credit);
$boinc_total_credit =~ s/\s*([\d\.\,]*)<.*/$1/;

} elsif (/Number of hosts/) {
<BC>;
$boinc_hostcount = <BC>;
chomp($boinc_hostcount);
$boinc_hostcount =~ s/\s*([\d,]*).*/$1/;

} elsif (/World Position/) {
<BC>;
$boinc_overall_rank = <BC>;
chomp($boinc_overall_rank);
$boinc_overall_rank =~ s/\s*([\d,]*).*/$1/;

} elsif (/than % of all users/) {
$boinc_percentile = <BC>;
chomp($boinc_percentile);
$boinc_percentile =~ s/<td>(\d*.\d*)%.*/$1/;

} elsif (/Position in Team/) {
<BC>;
$boinc_team_rank = <BC>;
chomp($boinc_team_rank);
$boinc_team_rank =~ s/\s*([\d,]*).*/$1/;
}
}
close BC;
}


##########################
#get stats from Berkeley##
##########################

if ($use_classicstats) {

$berk_url = "http://setiathome2.ssl.berkeley.edu/fcgi-bin/fcgi";
$berk_url = "http://setiathome2.ssl.berkeley.edu/fcgi-bin/fcgi?email=";
$berk_url .= "$berk_email&cmd=user_xml";
$berk_url =~ s/@/%40/;

#http://setiathome2.ssl.berkeley.edu/fcgi-bin/fcgi?email=lmester%40access.k12.wv.us+&cmd=user_xml

$ua = LWP::UserAgent->new();
$berk_xml = $ua->get( "$berk_url");

#$berk_xml = $ua->get( "$berk_url",
# [ "cmd" => "user_xml",
# "email" => $berk_email]);

#extract info from Berkeley's not-quite XML
foreach $line (split /^/, $berk_xml->content) {

if ($line =~ /<name>/) {
for ($cl_name = $line) {
chomp;
s/<[^>]*>//g;
s/\s*//;
}
} elsif ($line =~ /numresults/) {
for ($cl_num_results = $line) {
chomp;
s/\s*<[a-z_]*>([^<]*).*/$1/;
}
} elsif ($line =~ /cputime/) {
for ($cl_user_time = $line) {
chomp;
s/\s*<[a-z_]*>([^<]*).*/$1/;
}
} elsif ($line =~ /resultsperday/) {
for ($cl_daily_results = $line) {
chomp;
s/\s*<[a-z_]*>([^<]*).*/$1/;
}
} elsif ($line =~ /<rank>/) {
for ($cl_rank = $line) {
chomp;
s/\s*<[a-z_]*>([^<]*).*/$1/;
}
}
}
}

#These are boring examples of how to print out stuff.
#Hopefully, you'll come up with something more interesting. ;)

#print "LOCAL BOINC INFO:\n";
#print "progress is $boinc_progress\n";
#print "total credits is $total_credit\n";
#print "wu name is $wu_name\n";

#if ($use_boincstats) {
# print "BOINC INFO:\n";
# print "username = $boinc_user\n";
# print "ID = $boinc_id\n";
# print "total credit = $boinc_total_credit\n";
# print "hosts = $boinc_hostcount\n";
# print "overall rank = $boinc_overall_rank\n";
# print "percentile = $boinc_percentile\n";
# print "team rank = $boinc_team_rank\n";
#}


#if ($use_classicstats) {
# print "CLASSIC INFO:\n";
# print "username is $cl_name\n";
# print "number of results is $cl_num_results\n";
# print "total cpu time donated is $cl_user_time\n";
# print "results per day is $cl_daily_results\n";
# print "overall rank is $cl_rank\n";
#}

#make a pretty progress bar

#length of progress bar
$prog_len = 25;

#starting and ending colors for progress bar
$prog_start = "ff0000";
$prog_end = "0000ff";

#colors for the percent indicator
$pct_begin = "ff0000";
$pct_end = "00ff00";

#You can't see me.
$invisible = "333333";

$filled_bars = sprintf("%.0f",($boinc_progress)*$prog_len);
$pct_prog = sprintf("%.0f",$boinc_progress*100);

$empty_bars = $prog_len - $filled_bars;
#print "$pct_prog% progress, $filled_bars chars, $empty_bars unfilled\n";


$prog_bar = "{";

for($i=0; $i < $filled_bars; $i++) {
$progress_char = "~";
$color=color_grad($prog_start,$prog_end,$prog_len, $i);
$prog_bar .= "\$progress_char\[/color\]";
}
$prog_bar .= "\";
$prog_bar .= "_" x $empty_bars;
$prog_bar .= "\[/color\]";
$prog_bar .= "}";

#now $prog_bar looks like "{****___}" but with color tags

$pct_len = length $pct_prog;
$spc_len = 4 - $pct_len;
$spc = "_" x $spc_len;
$prog_bar =~ s/$/\[color=#$invisible\]$spc\[\/color\]/;
#print "$prog_bar\n";

$pct_color = color_grad($pct_begin,$pct_end,100,$pct_prog);
$prog_bar =~ s/$/\[color=#$pct_color\]$pct_prog\%\[\/color\]/;

#progress bar is done!
#It should look like "{~~~~~~_____} 34%" but will COLOR.

$crunch_start = "ff00ff";
$crunch_end = "00ff00";

$crunch_str = color_string($crunch_start,$crunch_end,"Crunching for Overclockers.com!");

#99% means you're in the top 1%, so put that in $top_pct
$top_pct = sprintf("%.2f",100.0 - $boinc_percentile);
$rank = $boinc_overall_rank;
$boinc_total_credit =~ s/,//g;
$credits = sprintf("%.0f",$boinc_total_credit);


##################################
#This is where stuff is printed.##
##################################

print "$crunch_str\[\/b]\n";
print "ranked #$rank in the top $top_pct% with $credits credits\n";
print "current wu: $prog_bar completed\n";


#Given a starting color, an ending color, a total number of steps, the
#current step and an optional error, return the color that corresponds
#to that step in a gradient.
sub color_grad
{
$start_rgb = shift; #"ff00ff"
$end_rgb = shift; #"00ff00"
$last_step = shift; #"36"
$curr_step = shift; #"12"
#error is random variation, in decimal shades
$error = shift;
$periods = shift;
$fun = shift;

return color_grad_fun($start_rgb,$end_rgb,$curr_step/$last_step,$error,$periods,$fun);
}


sub color_grad_fun
{
my $start_rgb = shift; #"ff00ff"
my $end_rgb = shift; #"00ff00"
my $curr_step = shift; #floating pt number, modded between 0 and 1. inclusive

#OPTIONAL ARG: error is random variation, in decimal shades
my $error = shift;
$error = 0 if (! defined $error);

#OPTIONAL ARG: how many times to cycle through the above function
my $periods = shift;
$periods = 1 if (! defined $periods);

#OPTIONAL ARG: function with a period of 1 and a range 0-1 to determine color distribution
my $fun = shift;
#This function has the same behavior as the previous implementation.
$fun = sub {my $x = shift; return ((255*$x % 255)/255);} if (!defined $fun);

$error /= 255;

for $curr (0,1,2) {

$min = hex(substr($start_rgb,$curr*2,2)) / 255;
$max = hex(substr($end_rgb,$curr*2,2)) / 255;
$range = $max - $min;
$funval = &$fun($curr_step*$periods);

#print "max is $max, min is $min, range is $range, step is $curr_step,";
$color[$curr] = ($min + $range*$funval);

if ($error == 0) {
$my_error = 0;
} else {
$my_error = (rand 2*$error) - $error;
}

while (($color[$curr]+$my_error) < 0 || ($color[$curr]+$my_error) > 1) {
$my_error = ((rand 2*$error) - $error);
}
#print "using error of $my_error, max is $error\n";
#$norml = $color[$curr]*255;
#print "normal color is $norml, ";
$color[$curr] += $my_error;
$color[$curr] *= 255;
#$color[$curr] = sprintf("%.0f",)
#print "color is $color[$curr]\n";

}
return sprintf("%02x%02x%02x",$color[0],$color[1],$color[2]);
}

#Make a string shift from start_rgb to end_rgb, with an optional random error
sub color_string
{
$start_rgb = shift;
$end_rgb = shift;
$string = shift;
#optional args below
$error = shift;
$error = 0 if (! defined $error);

$periods = shift;
$periods = 1 if (! defined $periods);

$fun = shift;
$fun = sub {my $x = shift; return ((255*$x % 256)/255);} if (!defined $fun);

#ugly bug if this isn't declared my
my $color_str;
my $str_len = length $string;
my $prev_color = "gggggg";
my $prev_char = "?";
$i=0;

foreach $char (split //, $string) {

$fstr_color=color_grad($start_rgb,$end_rgb,$str_le n,$i++,$error,$periods,$fun);

#vb3 seems to treat individually colored spaces an non-printable
if ($char eq " ") {

#if this is the same char we just printed, we can use less bbcode
if ($prev_char eq " " && $color_str =~ /\[\/color\]$/) {
$color_str =~ s/.$/\.\.\[\/color\]/;


#we only need an invisible char if there's more than one in a row
} elsif ($prev_char eq " ") {
$color_str =~ s/.$/\[color=\#$invisible\]\.\.\[\/color\]/;

#else we've got a single space
} else {
#$color_str .= "\[color\=\#$invisible\].\[/color\]";
$color_str .= " ";
}

$fstr_color = $invisible;

} else {

#if this is the same color we just used, we can reuse tag
if ($prev_color eq $fstr_color) {
$color_str =~ s/(.)\[\/color\]$/$1$char\[\/color\]/;
} else {
$color_str .= "\[color\=\#$fstr_color\]$char\[/color\]";
}
}

$prev_char = $char;
$prev_color = $fstr_color;
}
#print "COLOR STRING: returning $color_str\n";
return $color_str;
}



Possible output from example s@h script:

Crunching for Overclockers.com!
ranked #1 in the top 0.11% with 495535 credits
current wu: {~~~~~~~~~~~~~~___________}__56% completed


F@H stat example code
This is something of a hack. While writing it, I downloaded the page so that each test run of the script wouldn't require re-downloading it again. While using the downloaded page, I accidentally wrote it so it depended on having a downloaded page. It isn't exactly good style, but it's all my brain will allow me to do at 1:22 in the morning.


#!/usr/bin/perl -w
use LWP::UserAgent;

#Stanford's stats
$stfd_username="PMSFishy";
$team_num=32;
$stfd_url="http://vspx27.stanford.edu/cgi-bin/main.py?qtype=userpage&username=$stfd_username&teamnum=$team_num";

$ua = LWP::UserAgent->new();
$page = $ua->get($stfd_url);
open STFD_PAGE,">stfd.html";
print STFD_PAGE $page->content;
close STFD_PAGE;


open STFD_PAGE, "stfd.html";
while (<STFD_PAGE>){

chop;

if (/updated/) {
s/.*updated://;
s/ //;
$stfd_last_update=$_;
}

if (/last work unit/) {
$_ = <STFD_PAGE>;
s/<[^>]*>//g;
s/[^\d]*//;
s/(\d\d:\d\d:\d\d)[^\d]*/$1/;
$stfd_last_wu=$_;
}

if (/Total score/) {
$_ = <STFD_PAGE>;
s/<[^>]*>//g;
s/[^\d]*//g;
$stfd_total_score=$_;
}

if (/Overall rank/) {
$_ = <STFD_PAGE>;
s/.*\d> //;
s/([\d]* of [\d]*)[^\d]*/$1/;
$stfd_overall_rank=$_;
}

if (/50 days/) {
$_ = <STFD_PAGE>;
s/.*\d> //;
/([\d]*)/;
$stfd_cpus_50days=$1;
}

if (/7 days/) {
$_ = <STFD_PAGE>;
s/.*\d> //;
/([\d]*)/;
$stfd_cpus_7days=$1;
}

if (/> WU/) {
$_ = <STFD_PAGE>;
$_ = <STFD_PAGE>;
s/[^\d]*//;
s/([\d]*)//;
$stfd_wu_total=$1;
}

}

print "date of last WU: $stfd_last_wu\n";
print "total score: $stfd_total_score\n";
print "overall rank: $stfd_overall_rank\n";
print "active cpus (50d): $stfd_cpus_50days\n";
print "active cpus (7d): $stfd_cpus_7days\n";
print "WU total: $stfd_wu_total\n";
print "stats last updated: $stfd_last_update\n";

possible output from F@H example code:

date of last WU: 2005-01-27 16:16:34
total score: 698940
overall rank: 166 of 419739
active cpus (50d): 28
active cpus (7d): 10
WU total: 16330
stats last updated: Fri Jan 28 00:29:16 PST 2005



This is what my current sig_gen looks like. I don't claim any great wisdom, but this is definitely not good code for a beginner to learn from. I release it into the public domain. Feel free to do with it whatever you like, although I appreciate giving credit where it's due.

Notes:
A little of the code specific to my computer. I run 3 instances of the F@H client on my SMP rig, which live in ~/f1 , ~/f2 and ~/f3 . Having similar names means that I can use 1 loop to do all the progress bar processing. The dirs where the F@H clients live is refered to by the line that reads open FH, "$home/f$n/unitinfo.txt" or die "error opening file: $!"; .
The load average is Linux-specific. To take it out, delete from open LOAD_AVG, ... to the next } .
The gradient functions look the easiest to rip off. Basically, the color_string takes a starting color, an ending color and a string and returns a string that evenly shifts from the beginning color to the ending one.
Since I wrote this, I have no idea how understandable it will be for others, and while I may have the time to help people out playing with it, be prepared to accept “no” or “later” for an answer.
In order to get this code to shop up semi-correctly, I had to put a space in all opening vbcode tags. When you see something like [ color=#333333], just delete the space.


#!/usr/bin/perl -w
use LWP::UserAgent;

#might be cool:
# * have the color of the "45%" change as they approach 100
# * Use. More. Colors.
# * use a funky character helix for the progress bar
# * find random quotes from the forums, maybe threads you've posted in
# * make everything invisible except for colored letters spelling out "FOLD!"
# * get gradient randomization working properly

#string to use for progress indicator
$progress_char="o";

#how many of the above char to use at 100%
$prog_len = 10;

#starting/ending color for progress indicator
$prog_start = "333333";
$prog_end = "ffd700";
#$prog_start = "ff00ff";
#$prog_end = "ffff00";

$fstr_start = "ff00ff";
$fstr_end = "ffff00";

$ldavg_begin = "00ff00";
$ldavg_end = "ff0000";

$pct_begin = "8f9aff";
$pct_end = "ff0000";

#how many times to cycle through the progress indicator gradient
$prog_cycles = 1;

#a place to hang your hat
$home = glob "~/";

#you can't see me
$invisible="333333";

@time = localtime;
$time[5] += 1900;
$time[4]++;

#get local info about current WUs

$stfd_cache = "stfd.html";
#$invisible_char = "\[color\=\#$invisible\].\[/color\]";

$min_pct = 100;

for $n (1, 2, 3) {
$f_name = "";
$f_prog = "";
open FH, "$home/f$n/unitinfo.txt" or die "error opening file: $!";
while(<FH>){
chomp;
$f_name .= $_;
}
close FH;
$f_prog = $f_name;

$f_name =~ s/.*Name://;
$f_name =~ s/Download.*//;
$f_name = color_string("ffff00","ff0000",$f_name,50);

for ($f_prog) {
s/.*Progress: //;
s/\%.*//;
$pct_prog = $_;
#$pct_prog = 100;
#this is a *recommended* way of rounding
$filled_bars = sprintf("%.0f",($pct_prog/100)*$prog_len);
$empty_bars = $prog_len - $filled_bars;
#print "$pct_prog% progress, $filled_bars chars, $empty_bars unfilled\n";

$f_prog = "{";

for($i=0; $i < $filled_bars; $i++) {
$color=color_grad($prog_start,$prog_end,$prog_len/$prog_cycles,$i);
$f_prog .= "\[color=#$color\]$progress_char\[/color\]";
}
$f_prog .= "[color=#$invisible]";
$f_prog .= "_" x $empty_bars;
$f_prog .= "";
$f_prog .= "}";

# now looks like "{****___}" but with color tags

$f_prog .= "$pct_prog%";

if ($pct_prog > 99) {
s/(\d\d\d%)/_[\/color]$1/;
} elsif ($pct_prog >9) {
s/(\d\d%)/[color=#$invisible]__[\/color]$1/;
} else {
s/(\d%)/[color=#$invisible]___[\/color]$1/;
}
#print "$f_prog\n";

$pct_color = color_grad($pct_begin,$pct_end,100,$pct_prog);
s/(\d*%)/\[color=#$pct_color\]$1\[\/color\]/;

$min_pct = $pct_prog if ($pct_prog < $min_pct);

}

$f_name[$n-1] = $f_name;
$f_prog[$n-1] = $f_prog;
}


#get stats from Intarw3b

$user="IdeaMagnate";
$team=32;

#only download stanford's page every hour ( = 60*60 seconds)
#(stat(file))[9] is the time since file was last modified, in seconds
if ((! -e $stfd_cache) || (time+(60*60) > (stat($stfd_cache))[9])) {

$ua = LWP::UserAgent->new();
$stfd_page = $ua->get("http://vspx27.stanford.edu/cgi-bin/main.py?qtype=userpage&teamnum=$team&username=$user");

if (! $stfd_page->is_success) {
die "Couldn't download Stanford's page.";
}

open STFD_CACHE, ">$stfd_cache";
print STFD_CACHE $stfd_page->content;
close STFD_CACHE;

$s_content = $stfd_page->content;

} else {

open STFD_CACHE, "$stfd_cache";
while(<STFD_CACHE>) {
$s_content .= $_;
}
close STFD_CACHE;

}

$pts = $s_content;
$wus = $s_content;
$cpu = $s_content;

for ($pts) {
s/[\n\r]//g;
s/.*Total score//g;
s/[^\d]*//;
s/4> (\d*).*/$1/;
}

for ($wus) {
s/[\n\r]//g;
s/.*WU</</g;
s/<[^>]*>//g;
s/\w*(\d\d\d\d).*/$1/;
s/ //g;
s/\t//g;
}

for ($cpu) {
s/[\n\r]//g;
s/.*Active processors//;
s/<[^>]*>//g;
s/[ \t]//g;
s/\([^\)]*\)//g;
s/(\d*).*/$1/g;
}

open LOAD_AVG, "uptime |";
$load_avg = <LOAD_AVG>;
close LOAD_AVG;

for ($load_avg) {
s/.*load average/\[u\]Load Avg\[\/u\]/;
s/,//g;
/(\d\d*\.\d\d*) *(\d\d*\.\d\d*) *(\d\d*\.\d\d*)/;
$c1 = color_grad($ldavg_begin,$ldavg_end,450,$1*100);
$c2 = color_grad($ldavg_begin,$ldavg_end,450,$2*100);
$c3 = color_grad($ldavg_begin,$ldavg_end,450,$3*100);
s/(\d\d*\.\d\d*) *(\d\d*\.\d\d*) *(\d\d*\.\d\d*)/\[color=#$c1\]$1\[\/color] [color=#$c2\]$2\[\/color] [color=#$c3\]$3\[\/color]/;
chomp;
}

$pts_len=7;
$wus_len=9;
$cpu_len=5;

$spcr1= "[color=#$invisible]" . "_" x 4 . "";
$spcr2= "" . "_" x 4 . "";
$spcr3= "" . "_" x 8 . "";


$pts_pad = $pts_len - (length $pts);
$wus_pad = $wus_len - (length $wus);
$cpu_pad = $cpu_len - (length $cpu);

$pts = "" . "_" x $pts_pad . "" . $pts . $spcr1;
$wus = "" . "_" x $wus_pad . "" . $wus . $spcr1;
$cpu = "" . "_" x $cpu_pad . "" . $cpu . $spcr1;

$folding_str = color_string($fstr_start,$fstr_end,"Folding for team 32!");

$time_str = sprintf("%02d/%02d/%04d at %02d:%02d.\n",$time[4],$time[3],$time[5],$time[2],$time[1]);

print "[b]Alt OS Lead Senior | del.icio.us | Heatware | FAQ 2.0 | Jellyfish\n";
print "[color=#CCCC00]Did someone go out of his way to help you? Show your appreciation here.\n\n";
print "$folding_str\n";
print "My stats:".$spcr3. "My current WUs:$spcr2$load_avg\n";
print "score:$pts". "$f_prog[0] :$f_name[0]\n";
print "WUs:$wus". "$f_prog[1] :$f_name[1]\n";
print "clients:$cpu". "$f_prog[2] :$f_name[2]\n";
# stat: 03030 {****** } 61% : p1139_p1133_L939_K12M_355K
print "This sig was generated on $time_str";

sub color_grad
{
$start_rgb = shift; #"ff00ff"
$end_rgb = shift; #"00ff00"
$last_step = shift; #"36"
$curr_step = shift; #"12"
#error is random variation, in decimal shades
$error = shift;

$error = 0 if (! defined $error);

$curr_step %= $last_step;

for $curr (0,1,2) {

$error[$curr] = (rand 2*$error) - $error;
$start[$curr] = hex(substr($start_rgb,$curr*2,2));
$end[$curr] = hex(substr($end_rgb,$curr*2,2));
$step[$curr] = ($end[$curr] - $start[$curr]) / $last_step;
$color[$curr] = $start[$curr] + $step[$curr]*$curr_step + $error[$curr];
#ensure that the color is within the possible range
while ((0 > $color[$curr]) || ($color[$curr] > 255)) {
$error[$curr] = (rand 2)*$error - $error;
$color[$curr] = $start[$curr]+ $step[$curr]*$curr_step + $error[$curr];
}
#print "start is $start[$curr], end is $end[$curr], step is $step[$curr], color is $color[$curr]\n";
}

return sprintf("%02x%02x%02x",$color[0],$color[1],$color[2]);
}


sub color_string
{
$start_rgb = shift;
$end_rgb = shift;
$string = shift;
$error = shift;
#print "COLOR STRING: passed $string\n";
$error = 0 if (! defined $error);

#ugly bug if this isn't declared my
my $color_string;
$str_len = length $string;
$i=0;

foreach $char (split //, $string) {
$fstr_color=color_grad($start_rgb,$end_rgb,$str_le n,$i++,$error);
#vb3 seems to treat individually colored spaces an non-printable
if ($char eq " ") {
$color_string .= "\[color\=\#$invisible\].\[/color\]";
} else {
$color_string .= "\[color\=\#$fstr_color\]$char\[/color\]";
}
}
#print "COLOR STRING: returning $color_string\n";
return $color_string;
}


License
All code in this post, including the linked mksig.pl script, is released into the public domain, meaning that you are free to do absolutely anything you like with it. I ask, but do not require, credit where it is due.
Enjoy!

SatanSkin
01-28-05, 04:06 AM
ygpm

mtb856
01-28-05, 06:04 AM
YGPM too ;)

Bon3thugz43v3r
01-28-05, 06:18 AM
I'm pretty sure I did everything correctly, but for some reason I can't get my stats to show up. :bang head

veryhumid
01-28-05, 07:11 AM
:drool: as soon as I get back from work I am going to try it out.

Christoph
01-28-05, 08:28 AM
This is going to be fun. :D
If you downloaded mksig.txt before this post, it will store its files in c:/Program Files/mksig instead of c:/mksig like I specified. The version up now is in sync with my instructions.

Christoph
01-28-05, 08:51 AM
Also, please download the version that's up now if you plan on using the default sig_gen. I've noticed that the old one will occasionally make excessively long sigs, and I don't want to get nasty PMs from people about it.
To upgrade, just download the current version (.54) and nuke your current sig_gen. Next time your run mksig, a new one will be put in place that ensures that sigs will be the proper length.
You can grab it here (http://gladstone.uoregon.edu/~cotto1/ochosting/mksig.txt), as always.

Sentential
01-28-05, 08:56 AM
:drool: as soon as I get back from work I am going to try it out.
Ditto on that thnx a ton!

BeerCan
01-28-05, 09:04 AM
If anyone needs help with the windows portion of this setup please feel free to PM me or IM me at shumph15@hotmail.com (msn).

Leviathan41
01-28-05, 09:19 AM
Very nice, I am going to link to this thread (and the previous Linux thread also) on the downloads section of the team page, they seem to have all the info, unless you have a website set up for these tools. Let me know.

Christoph
01-28-05, 09:40 AM
Go ahead. If I find the time to put up a separate page about this, I'll make sure to post a link in this thread.

To everyone, you're welcome. :D

Christoph
01-28-05, 12:16 PM
Alright, I'm smart.
If you're using the default sig_gen, please download again and nuke the old sig_gen. The fortune site I use, while very easy to parse, occasionally comes up with some fortunes that violate forum rules. I looked at several while writing the default sig_gen, but apparently I didn't look at the right ones. The sig_gen that the current version (.55) of mksig creates will filter out fortunes with certain unacceptable words. The version number is stored near the top of mksig.pl.
I'm pretty sure the changes will catch all the offensive fortunes that slip through, but I still *highly* recommend checking your sig.log to make sure nothing bad has slipped through. If it has, rerunning mksig.pl will take care of it.

Later today, I plan on adding some code to automatically check for updates so people won't have to worry about constantly re-downloading a new version of the script.

Note that if you're using your own sig_gen, you don't need any of these updates.

mtb856
01-28-05, 05:21 PM
When I try to use your sig script (the one at the bottom of your first post), I can't seem to get it to work...... I deleted the lines that you mentioned, but what I think is getting me is the directory to point to for the unitinfo.txt.

Instead of $home\F$n\unitinfo.txt .... what should I put in there if the directory is:

D:\Program Files\FAH\FAH1\unitinfo.txt

I'm not familiar with Perl, I've just used C++ so it's a little hard to figure out where to point to.

Here's the screen I get when I try to run mksig.pl
http://img.photobucket.com/albums/v168/mtb856/untitled1.jpg

Thanks

BeerCan
01-28-05, 05:28 PM
Line 35 of the mksig.pl script reads $sig_gen="$dir/sig_gen"; you need to add the .pl so it reads $sig_gen="$dir/sig_gen.pl"; That will fix your error dealing with the unrecognized command

mtb856
01-28-05, 05:31 PM
Okay, thanks :)

I'll give that a try

[edit]

Nope, didn't work.... well it did, it created a new sig_gen.pl, but I'm getting the same string of errors.

I'll dig around some more to see if there's something I should delete or change.

[double edit]

Well, I redownloaded and edited everything and it worked this time, so I'll go about editing the sig_gen now... thanks for your help. :)

mtb856
01-28-05, 05:52 PM
For this part specifically
for $n (1, 2, 3) {
$f_name = "";
$f_prog = "";
open FH, "$home/f$n/unitinfo.txt" or die "error opening file: $!";
while(<FH>){
chomp;
$f_name .= $_;


How would I go about directing it to D:\Program Files\FAH\FAH1\unitinfo.txt
?

It seems that I only get the errors when I download Christolf's script for his sig...... the little guy booby trapped it!!! :D

SatanSkin
01-28-05, 06:15 PM
Ok, beercan and I discovered that the last sig_gen and code example listed is cristoph's script for *nix. It errors because it is trying to do *nix related commands. What you need to do is just d/l the default 0.55 mksig.pl and copy and paste the first FAH stats code example into notepad and save it as sig_gen.pl. That will get your stats into your sig looking like mine. The second script listed under FAH stats, once again, is for *NIX only and needs to be ported to windows.

Christoph
01-28-05, 06:38 PM
How would I go about directing it to D:\Program Files\FAH\FAH1\unitinfo.txt
?




The simplest way is simply to change the $home/f$n stuff, as below. You have to use two slashes because Perl interperts one as an escape, and gives the character after it a special meaning. Also note that if you're not running 3 (or more) instances of the client, it will die. This part of the code is easy to chage for an arbitrary number of local clients (just change (1,2,3) to (1) or (1,2), etc) but the bottom part of the sig depends on there being three clients running. The script will still work since Perl doesn't complain when you use variables that haven't been defined, but the formatting will be broken.


for $n (1, 2, 3) {
$f_name = "";
$f_prog = "";
open FH, "D:\\Program Files\\FAH\\FAH$n\\unitinfo.txt" or die "error opening file: $!";
while(<FH>){
chomp;
$f_name .= $_;

In case you missed my edit in the first post, you'll also need to delete the stuff referring to $load_avg, since that's Linux-specific. The code you want to delete is all in one chunk:


open LOAD_AVG, "uptime |";
$load_avg = <LOAD_AVG>;
close LOAD_AVG;

for ($load_avg) {
s/.*load average/\[u\]Load Avg\[\/u\]/;
s/,//g;
chomp;
}


It seems that I only get the errors when I download Christolf's script for his sig...... the little guy booby trapped it!!! :D

BTW, I now have access to your checking accont. I'd like to thank your for the major hardware upgrade you just bought me. ;)

Christoph
01-28-05, 06:39 PM
Hmmm. I seem to have 10 clients running now. Cool. Thanks.

SatanSkin
01-28-05, 06:53 PM
Cristoph, I deleted the load_avg calls, changed the dir to mine and used the double \'s, and it is still giving me errors. It gives me: "building sig...error opening file: No such file or directory at C:\mksig\sig_gen.pl line 47.
Use of uninitialized value in string at C:\mksig\mksig.pl line 178.
OK
logging in...OK
submitting new sig...Use of uninitialized value in string at C:\mksig\mksig.pl line 228.
OK
logging out...OK"

Any ideas?

mtb856
01-28-05, 07:07 PM
BTW, I now have access to your checking accont. I'd like to thank your for the major hardware upgrade you just bought me.

ROFL :D I was wondering why I had all these bills from the 'egg. ;)

I think I'll just use the stock sig for a while until the kinks are worked out.... thanks for putting all this work in for the team :)

[edit]

I guess modifications aren't that hard.... I just cheated a little :D . In the print " \n"; area.... as long as it's within the quotes you can include bbcode and it will be formatted once it's loaded on the forums. My team rank and PPD I just added manually b/c it's not included on the stanford website.

Is there any easy way that you could load PPD and team rank information off of the http://folding.extremeoverclocking.com site or am I asking something that's rather difficult?

Christoph
01-28-05, 07:51 PM
ATM, I'm on my laptop away from my code while my main box memtests some new RAM, so I can't test any changes I make until the testing's done. (Please accept this as an excuse for my inexcusably low load averages. ;)) When I get back, I'll make sure to implement an automatic updater in addition to fixes for whatever needs it. I don't like rewarding you early adopters with constant manual updates.

SatanSkin
01-28-05, 07:53 PM
LOL. Sounds good. Thanks for your hard work and dedication!

mtb856
01-28-05, 09:16 PM
What??? No updates on the hour? :eek:


:D

I.M.O.G.
01-28-05, 11:25 PM
Updates would be better on the half hour, because then all the server stats (scores) are updated. ;)

Christoph - awesome.

SatanSkin
01-28-05, 11:38 PM
Hey how'd you get that nifty change?

mtb856
01-29-05, 09:13 AM
Instead of say- print " Total Points: $stdfu \n";

I did this- print "[ color=gold] Total Points: $stdfu [/color] \n";

The program itself doesn't recognize bbcode, but when it's loaded onto the ocforums, it's seen as bbcode and formatted. It's kind of a cheat since I don't know Perl :D

You can do the same thing with links...

Like at the bottom I have- print " [ url=folding website][ color=gold][ u]Folding for Team32[/u][/color][/url] \n";

and boom, you got color and a link :attn:

Just don't forget to put the tags in that order or you'll get a white line underlining Team32 instead of a colored one.

Christoph
01-29-05, 10:40 AM
mtb856, I have one problem with exoc; parsing their pages isn't harder than parsing anyone else's, but I've noticed that their pages occasionally change format. It might be purposeful and permanent, in which case I don't mind, but if they often change how the page looks it'll take more effort to reliably get stats from it and when it doesn't work your sig will be broken.
The ideal is that I have a page I can get stats from that never changes its format. I haven't been checking for long, but Statsman and Stanford seem to be stable enough.
I'm not saying no to exoc, but if you can find the stat you want from another site, I'd prefer it.

On other news, I've got a silly test version of the autoupdater working, so an implementation for mksig won't be far behind. I'm getting some hosting from PMSFishy, so life should get easier for all of you real soon. Once it's working, you'll have the option of telling mksig to update itself every time it runs.

SatanSkin
01-29-05, 02:27 PM
*Thread Hijack* what exactly is PPD and how do you find it?*end*

mtb856
01-29-05, 02:28 PM
It's your average points per day.... you can find it in your stats at http://folding.extemeoverclocking.com ..... it won't automatically add to your sig, so you'll have to do it manually.

SatanSkin
01-29-05, 02:37 PM
Well apparently I can't even find that site..... lol. And when I added the bbcode it started giving me errors now.

Also, print " [ url=folding website][ color=gold][ u]Folding for Team32[/u][/color][/url] \n"; pasted in and spaces taken out, and "folding website" replaced with the proper URL gives me an error. Says it's missing a right curly or square bracket. Eh? I Think I may have a very unefficient workaround though.

Christoph
01-29-05, 03:23 PM
mtb856: That's exactly what you're supposed to do. I'm glad you figured it out. It's obvious to me, but I'm a cis major and different concepts are obvious to people from different backgrounds.

Anyway, big freaking update time!

The new version is .6, since I've made some big changes.

I've got the autoupdater implemented for both the script itself and for the default sig_gen. The new version of mksig will look at the version that's currently online and itself (aka local version), and if the online version number is higher than the local version, it will download and run the online version. The version number is determined by the line in mksig that reads
#mksig version 0.6
This means that once this update is downloaded and installed, you won't have to manually download it again. It will do the check every time it's run, and if the online version isn't newer, it will simply update your sig as normal.
Also, this behavior is configurable and off by default. When v.6 or later is run, it will add an entry to your mksig.conf for automatic updating:
$auto_update = "n";
By default, it's "n", in which case mksig won't bother checking for updates. If you change it to "y", it will.
In short, after updating your config file, you won't have to do anything other than update your sig as normal, and mksig will always be at the latest version.

Also, it will now can automatically update default sig_gen files. If your sig_gen contains a line that reads
#This is the default sig_gen.
it will be overwritten with a new default sig_gen. If the line isn't there, it won't be touched. I chose a line that wasn't in the original default sig_gen on purpose


If you're using the default sig_gen: Delete the old one* and download the new mksig (http://gladstone.uoregon.edu/~cotto1/ochosting/mksig.txt).

For everyone:
Update as before. You can add the auto_update line to your mksig.conf manually or run mksig .6 or later and edit the file afterwards. Either works fine.

*There aren't any more known problems with the default sig_gen, but if any crop up, I want to be sure that they're patched as soon as an update is up.

dark_15
01-29-05, 03:35 PM
Cristoph... I noticed 1 minor error in the new version (after it kept erroring out on me) - variable is missing an extension:

SatanSkin
01-29-05, 03:39 PM
Also, You think you could help me out with pulling values from the page? Such as you getting your PPD and Rank, etc.? Trying to figure some of this out while giving cristoph a break so he can work on the mksig script.

mtb856
01-29-05, 03:46 PM
Okay, sorry I typed the link in wrong when I gave it to you...here's your stats page. On the stats, your "Points 24 Avg" is your PPD.

http://folding.extremeoverclocking.com/user_summary.php?s=&u=5313

To include that information in your sig do this:

1)open up sig_gen.pl in notepad and scroll to the bottom where all of the "print"s are.
2)type this in (or just copy and paste it into your sig_gen) to add your PPD to your sig.
print "[ color=gold]PPD: 73[/color] \n";

and this for your team rank

print "[ color=gold]Team Rank: 860 of 945[/color] \n";

Note that this won't be auto updated....I'm not sure how to do that, so I'm just going in every few days, looking up my PPD (it doesn't really change all that much) and Team Rank on EOC (extreme overclocking) and then manually entering it into sig_gen.pl.

Hope this helps a little :)

Christoph
01-29-05, 03:57 PM
O G M.
I think I've fixed that bug 150 different times, and I always seem to upload the file that doesn't have the fix in it.
The fix actually involves moving the line to before the check for windows, since the Linux version is easier to use if the file's called sig_gen. I've checked, and the right version is now up as .61. Time to test out that autoupdater!

SatanSkin: Does your name that mean your skin is satany smooth?
Also, I don't know what's wrong with what you're trying. The code below did the Right Thing for me. Please don't quote it. It's not pretty.
print "rl=http://example.com]]Folding for Team32[/url] \n";[/b]


edit: I'll get to the exoc stats tonight. For now, RL calls. Make sure to post if the autoupdater works. If you want to test it, edit mksig, lower the version and rerun it. When you open the file again, it should be back to how it was before you edited it, assuming you changed your mksig.conf.

mtb856
01-29-05, 04:03 PM
Okay, I checked and autoupdate worked correctly.... it got me from v. 5 to v. 6.1

The reason the link didn't work for him was b/c I typed in the EOC website incorrectly so the link didn't go anywhere :p

SatanSkin
01-29-05, 04:09 PM
First off, my name is actually taken from two seperate things that deal with my life.

Now for an update. I got the link working obviously (see sig). For changing the color of the text, I have to do it the long way of "print "[ color=gold]", print "blah text here", print "[/color] \n" all on seperate lines for each thing. For some reason, putting the tags and text all in one print command causes it not to show up in the sig at all. But for now I'm satisfied with it. It does it's job.

However, now I am trying to figure out how to grab values from a site. Such as a way to auto update the PPD from extremeoc (or stanford if they have it somewhere), etc. AT this point I know that i have to d/l the page and save it first. That's about it.

Christoph
01-29-05, 05:31 PM
The way I wrote that example is bad style, but I thought that I should put in something about F@H stats, since that's what this thread is about. ;)

Basically, putting stats in your sig involves 4 steps:
1) Download the page.
2) Parse the page so that only the numbers you want are stored in variables.
3) Do something with the variables, eg print or use them to make a progress bar.

For step 1, you can simply copy/paste code from the stat example.

Obviously, step 2 is the hardest, unless you feel like going nuts on step 3. There are a couple ways to do it. The first way is to store all the contents of the web page in each variable, then apply a series of regexes (ie regular expressions) to them to filter out the irrelevant 99.99% of the data. The second way is to parse through the file and only store certain lines in the variables.
The first way is more modular, ie it lets you add one chunk of code that will always filter stuff the right way and doesn't depend on anything other than having the page in a variable. The downside of this is that you're storing a copy of the page in each variable, so if you've got a 250k page and 10 vars, you're using 12.5MB of RAM, plus whatever Perl's overhead is. On today's machines, that doesn't matter much but you should be aware of it. You can see this technique in the script for my sig in the first post.
The other method makes for much easier regexes, since you usually just have to clear out some text and html tags. I use this in the example script. Note that in a couple cases, I used the exact same regexes to take out different stats.
If you want to do this yourself, you need to learn regexes first. They're discussed here (http://incres.anu.edu.au/manuals/perl/matching.html) and here (http://incres.anu.edu.au/manuals/perl/sandtr.html). If you can get through those two pages, you ought to be able to figure out what's going on.

People seem to have figured out step 3, at least for printing. If you want to use it to generate a maze, you're on your own. ;)

Christoph
01-29-05, 07:19 PM
The first post now has my current sig_gen, for the perverse and curious. Also, it should now be copy/pasteable thanks to the regex s/\[/[/g (or s/\[/[/g if you want the raw vbcode). What's it do? I don't actually know. I was just looking through the output from a random number generator, and happened to see it.

dark_15
01-29-05, 09:04 PM
Hey Cristoph,
That is some awesome work you have there. Excellent job and thanks for the help! I kinda like my sig now... and I'll probably change the colors soon...

PS - the sig_gen link at the top of the page needs a "-w" by the #!/usr/bin/perl...

Seven
01-29-05, 09:17 PM
Woah....real sweet.
Now if my wireless would quit dropping on me, I'd get this downloaded and I could have cool sigs like the rest of you...

7

Seven
01-29-05, 11:34 PM
Alright, the simple non-bargraph one is working for me...and it's looking good. However, the bargraphs keep on getting messed up somehow when executed. Let me know the fix for this.

Great work nonetheless!

7

mtb856
01-30-05, 12:06 AM
Finally got mine working to where I like how it looks..... it's a little unique now :D

Maybe some more work will be done to it later on.

Christoph
01-30-05, 01:00 AM
Cool. Looks like you got it mostly figured out. It looks like it even matches your avatar. I guess that means I have to make mine more complex.
*Grabs libaa Perl bindings, POV-Ray, perlmagick, fftw, metasploit, flex, bison and a plunger for good measure.
Heh. Heh.

I just hope that my near-non-existant fashion sense doesn't make someone puke.

GTFouts
01-30-05, 12:39 PM
Well, got the first one working great, even colored it up a bit and added my PC info, but I can not get the faded color one to work to save my life.

SatanSkin said it is *nix only and needs to be proted to windows, but I have no idea what that means. Would sure like to get it working in XP Pro. I have been torturing this poor script all morning, just keep getting string errors. Fix one and 3 more pop up. But hey, I tried my best... :)

dark_15
01-30-05, 12:53 PM
Well, got the first one working great, even colored it up a bit and added my PC info, but I can not get the faded color one to work to save my life.

SatanSkin said it is *nix only and needs to be proted to windows, but I have no idea what that means. Would sure like to get it working in XP Pro. I have been torturing this poor script all morning, just keep getting string errors. Fix one and 3 more pop up. But hey, I tried my best... :)

I got mine working under windows... it's a bit more manual... you will have to experiment with the spacing and stuff to get exactly how you want it.

here it is - rename it to sig_gen.pl to turn it into a perl script:

Christoph
01-30-05, 03:54 PM
One thing I've been meaning to mention is to be nice to the stat pages. There's no reason to reload a page more often than its stats are updated, and doing so only puts an extra load on the server. If you use a script like the stat example in the first post, only run sig_gen at most as often as Stanford's (or whomever's) page is updated. If you use one based off mine, it already will only download the page every two hours (without changes), so running it every 5 minutes won't hurt Stanford. ;)

Also, make sure to avoid dark blue unless you want your text to be impossible to read. You all seem to have figured that out (or luckily avoided it), but I just want to make sure the sigs stay readable, unless intentionally otherwise.

I.M.O.G.
01-30-05, 06:43 PM
Currently trying to get it to work. Followed Beercan's guide to a T, and no dice... Will update with any progress I make.

BTW, Perl is installed correctly, as I've worked a bit with perl before so I'm familiar with that. The appropriate files are being created also. The log simply cuts off after the "this sig was created on" statement...

Any pointers?

Heh, ignore the above until further notice. Might also want to ignore the below...

*IMOG dances naked as the town idiot*

I.M.O.G.
01-30-05, 07:07 PM
Okay, now that I have it working, do we have any volunteers to spice things up?

I'd like to pull some stats from EOC, as well as use some of the cool rainbow text, so if there are any volunteers who would like to assist (do this for me), it would be appreciated. :D

Wedo
01-30-05, 07:13 PM
my brain hurts....

Doh! answered my own question... I'll work on this too.

Christoph
01-30-05, 08:21 PM
Oh no! It looks like my gradient code is adding in random error now. How strange. ;)
I wonder if the code in the first post will be updated to reflect this strange development.

BTW, a rewrite of the first post is going to happen as soon as I find the time. It could be a couple days. :cry:

SatanSkin
01-30-05, 08:24 PM
I'm getting this error: "bulding sig....Name "main::curr_rgb" used only once: possible typo at C:\mksig\sig_gen.pl line 252." Any ideas what's up with that?

Christoph
01-30-05, 08:35 PM
That means that there's only one place where the variable $curr_rgb appears. Perl will give it a default value of 0, butwith the -w on the first line, it will also complain since it's possible that you also meant to do something with the variable somewhere else.

To get rid of that particular error, change the $curr_rgb = to return and it should go away.
I'm just now noticing that I haven't had the -w flag on to enable all warnings, and while my code works well, I get many complaints. I'll be working on that, where possible.

SatanSkin
01-30-05, 08:39 PM
Whoa! changing curr_rgb to "return" made it start bitching a LOT more!

Christoph
01-30-05, 08:44 PM
Whoa! changing curr_rgb to "return" made it start bitching a LOT more!

Did you change the "=" too? Anyway, the version that's posted now (or in 30 seconds) doesn't generate any of those nasty warnings. Also, warnings indicate that something *may* be wrong, not that it always is. While the script was quite noisy before I fixed it just now, the output was correct.

SatanSkin
01-30-05, 08:52 PM
I changed it from "curr_rgb =" to "curr_rgb = return" WOW! and trying to add a ; REALLY pissed it off!!!!! lol.

And where are you posting this one? The code excerpt on the front page still looked like your linux one.

Christoph
01-30-05, 08:55 PM
I changed it from "curr_rgb =" to "curr_rgb = return"

Oh. You were supposed to delete the first thing in bold and replace it with the second. The line should read return sprintf("%02x%02x%02x",<stuff>); now, for whatever's in your sprintf.

SatanSkin
01-30-05, 09:11 PM
AHHHH well that fixed it all up. Thanks. Also, where are the colors for the text located? I got it for the progress but not the text.

mtb856
01-30-05, 09:14 PM
Your sig's starting to look pretty good Satanskin, nice job on it....... Christoph, you definitely kicked it up a notch.... couldn't stay with us noobie programmers, huh? :D

SatanSkin
01-30-05, 09:37 PM
Thanks. mtb. yours too. I still have a little more tweaking i'm gonna do for now. like adding the "my current WUs:" and stuff. How do you get the spacing to work? mine's only seeing it as a single space. I even tried using \t for tab, but that didn't work either. Got the txt color working now. lol.

GTFouts
01-30-05, 10:04 PM
I know this is a silly question, but where can I find the HEX numbers for the colors? I would like to play with the gradient colors alot.

SatanSkin: The spacing is all right here:

$pts_len=7;
$wus_len=14;
$cpu_len=5;

$spcr1= "" . "_" x 4 . "";
$spcr2= "" . "_" x 8 . "";
$spcr3= "" . "_" x 1 . "";


$pts_pad = $pts_len - (length $pts);
$wus_pad = $wus_len - (length $wus);
$cpu_pad = $cpu_len - (length $cpu);


All you have to do is play with the numbers till you get it right. For some reason I had to make my $wus_len @ 14 when I would have bet the house it should have only been 9. Cant figure that one out.

dark_15
01-30-05, 10:15 PM
here's where I found mine:

http://www.december.com/html/spec/color.html

SatanSkin
01-30-05, 10:19 PM
http://webmonkey.wired.com/webmonkey/reference/color_codes/ has some. It's what i've been using for now. How'd you get the spacing working on yours so that "current % complete" is lined up right?

GTFouts
01-30-05, 10:23 PM
Here is what I had to do

$pts_len=7;
$wus_len=14;
$cpu_len=5;

$spcr1= "" . "_" x 4 . "";
$spcr2= "" . "_" x 8 . "";
$spcr3= "" . "_" x 1 . "";


$pts_pad = $pts_len - (length $pts);
$wus_pad = $wus_len - (length $wus);
$cpu_pad = $cpu_len - (length $cpu);

$pts = "" . "_" x $pts_pad . "" . $pts . $spcr1;
$wus = "" . "_" x $wus_pad . "" . $wus . $spcr1;
$cpu = "" . "_" x $cpu_pad . "" . $cpu;

$folding_str = color_string($fstr_start,$fstr_end,"Folding for team 32 in Loving memory of my Father!");

print "[ SIZE=1][ COLOR=Lime]ASUS P5AD2 Premium - Intel 3.6Ghz LGA775 @ 4.1 Ghz \n";
print "Antec True Power 550w - ASUS ATI EAX-800XT PCIe \n";
print "Corsair PC-5400 C4PRO DDR2-667 XMS2 (4x512) \n";
print "Plextor DVD+-RW PX-708A/SW - 2x WD Raptor 74GB 10,000 rpm SATA[/COLOR] \n";
print "[/SIZE] \n";

print "[ SIZE=2][ b]$folding_str\n";
print "[ u]My Stats[/u]:".$spcr2. "[ u]Current % Complete[/u]:".$spcr3. "[ u]Current Protien[/u]:\n";
print "Score:$pts". "$f_prog1[0] :$f_name1[0]\n";
print "WU's:$wus". "$f_prog2[0] :$f_name2[0]\n";
print "Clients:$cpu [/b][/SIZE] \n";
# stat: 03030 {****** } 61% : p1139_p1133_L939_K12M_355K


Hope that helps

SatanSkin
01-30-05, 10:23 PM
Yeah thanks. As soon as I posted that, I found it! lol.

GTFouts
01-30-05, 10:29 PM
Oh, and Thanks Dark_15 for posting your sig_gen. I was able to fix mine all up and now I understand what I was doing wrong before...appreciate it

Christoph
01-30-05, 10:33 PM
This thread is nuts, and I'm thrilled that it seems to have reached a critical mass where I can slack off as often as not, and questions will still either get answered or answer themselves.
As for spacing, I don't think I could even modify it and be confident of how it would turn out. Making it a little more modifiable is on the list of changes I'll make when I find the time. Given the of the size of my todo list, it should get done about 20 minutes before the sun turns cold. Bring a sweater.

Also, I posted a link to this thread in the Programming subforum, so we may find some Perl hackers here soon. I encourage them to post any cool tricks they come up with, or at least show their sigs so we can try to re-implement them. ;)

SatanSkin
01-30-05, 10:46 PM
Yeah this thread has turned out great. Can't wait for the perl hackers! wo0t! lol. I figured out the spacing that was needed. Not sure how you would be able to make it any more easily modifiable though.

GTFouts
01-30-05, 11:41 PM
Oh Man...I am WIDE OPEN now....Muahahahaha...Let the Rainbow BEGIN!!!

What would really be cool is if there was a way to get the colors to cycle in the Sig. Might be too much to ask, but still...would be very cool... :)

I.M.O.G.
01-30-05, 11:50 PM
Where is the progress and protein name coming from? I see mine is coming from stanford, but how where is your info coming from - they look much cooler?

SatanSkin
01-31-05, 01:13 AM
It gets the info from your unitinfo.txt in your folding dir.

Christoph
01-31-05, 02:23 AM
Minor update v.62: mksig will now fail gracefully if you don't have permission to update it. This mostly matters to Linux people who installed it as root and run it as a normal user, but it may apply to others. If it detects that it can't update itself, it will now spit out a warning and use the old version. The old behavior was a slow infinite loop. What fun.
The good news is that this bug won't mess up most people anyway. The better news is that you don't need to do anything to upgrade, if you've enabled automatic updates. :D

dark_15
01-31-05, 08:18 AM
Oh, and Thanks Dark_15 for posting your sig_gen. I was able to fix mine all up and now I understand what I was doing wrong before...appreciate it

Hey, no problem... I like all the pretty colors in everyone's sig... now we are like elite perl hackers... ;)

EDIT: I think I have found a way to edit the task scheduler to run the perl script every hour or so... let me experiment with a few batch files and I'll see what I can do with the results!

If you're feeling courageous yourself, take a look here (http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/schtasks.mspx) and see if this looks promising...

BC|Wulf
01-31-05, 12:39 PM
I got the sig generator working great, but one problem I have is the number of work units it is returning. As you can see by my sig it is grabbign way too many characters. It seems I don't have enough work units complete to make it work right, cause it works fine with someone elses username in there.

I.M.O.G.
01-31-05, 12:53 PM
Has the information in the first post of this thread been considered in generating the sig text? It may be something we should note if we are doing this:

http://forum.folding-community.org/viewtopic.php?t=6744

Helsyeah
01-31-05, 01:24 PM
I got the sig generator working great, but one problem I have is the number of work units it is returning. As you can see by my sig it is grabbign way too many characters. It seems I don't have enough work units complete to make it work right, cause it works fine with someone elses username in there.

I also had the same problem. First, let me say i am about as noobish with perl as you can be.. but heres what i did.

I change the following section in the sig_gen.bl from

for ($wus) {
s/[\n\r]//g;
s/.*WU</</g;
s/<[^>]*>//g;
s/\w*(\d\d\d\d).*/$1/;
s/ //g;
s/\t//g;
}

to:

for ($wus) {
s/[\n\r]//g;
s/.*WU</</g;
s/<[^>]*>//g;
s/\w*(\d\d).*/$2/;
s/ //g;
s/\t//g;
}

i havnt done enough digging to know how the above for loop pulls the WU's from the stanford stats page yet, so i cant explain what the correct approach would be. (gotta love shotgun programming :D)

dark_15
01-31-05, 01:39 PM
I got the sig generator working great, but one problem I have is the number of work units it is returning. As you can see by my sig it is grabbign way too many characters. It seems I don't have enough work units complete to make it work right, cause it works fine with someone elses username in there.

In your sig_gen.pl... look for this:

for ($wus) {
s/[\n\r]//g;
s/.*WU</</g;
s/<[^>]*>//g;
s/\w*(\d\d\d\d).*/$1/; - look at this line especially!!!!
}

If you have less than 10 WU's turned in, delete 3 \d's - leaving only 1 \d remaining.
If you have less than 100 WU's turned in, delete 2 \d's - leaving only 1 \d's remaining.
If you have less than 1000 WU's turned in, delete 2 \d's - leaving only 1 \d's remaining.

And also, I've got a task scheduler working... except it pops up every 5 minutes. I am trying to figure out how to run a task minimized...

Helsyeah
01-31-05, 01:49 PM
And also, I've got a task scheduler working... except it pops up every 5 minutes. I am trying to figure out how to run a task minimized...

Perhaps look into using firedaemon to run the updater as a service. The trial lets you run one service indefinatly and has the ability to hide any desktop interaction.

BC|Wulf
01-31-05, 02:46 PM
That wokred Helsyeah! Thanks! I somewhat follow the shotgun method of progaming. Most of the code looks like PHP style, except I got lost around that cache reading section. What does the /d do anyways?

JerMe
01-31-05, 05:57 PM
Christoph, your code took forever for me to dechiper! I'm no programmer, but I managed to pick apart your code. Now I remember why I'm in biochemistry ;) The link to the Perl site you gave was helpful, but I had trouble figuring out all the parse commands from that page alone, espcially since your technique is different than what they posted there.

I still don't understand a lot of it, but I managed to imitate your code and have Perl grab the stats off of both Standford (total points, WUs, active CPUs) and EOC (ppd, team rank). I want to add a small calculator that says how many positions in ranking I've moved up compared to 7 days ago.

Task manager is scheduled to update every 3 hours, 30 mins after the EOC checkpoints (as IMOG suggested), so 12:30am, 3:30am, 6:30am... etc...

Your sig is a great idea, and this is great code! I like automation :) Teach us more Christoph!

Edit: Just added p7d (points, last 7 days) from the EOC summary page.

Seven
01-31-05, 08:41 PM
Bah, I'm still helpless here.
I can't get this thing figured out, and it's KILLING me to do it so I have all the prettyful stats in my sig.

I get the same error regardless of what I do, so can somebody PLEASE tell me what I'm doing wrong?

I need a solid Windows version of folding for 1 core if that makes a difference. I just want the damn bargraphs.

If somebody has a bug-free version of their sig_gen.pl file, then post it up and I'll download it. Even Dark_15's version wasn't working for me...please help.

7

mtb856
01-31-05, 08:50 PM
Ygpm ;)

Helsyeah
01-31-05, 08:50 PM
here ya go, if you want just pm me and ill walk you through the stuff you need to assign to get just a single bar graph and any more customization i can figure out too...

mtb856
01-31-05, 08:50 PM
Well, I guess he's got another in case mine doesn't work... what he doesn't realize is when he loads the sig_gen, he starts folding for me :D




Just kidding ;)

Helsyeah
01-31-05, 08:51 PM
Ygpm ;)

bahh... meatball beats me to the punch.. i recall having this happen in the intel cpu forums..

Well, I guess he's got another in case mine doesn't work :D

lol, for sure :) oo.. gocha before the edit :D

mtb856
01-31-05, 08:52 PM
Yes, I'm very good at beating people in the Intel area...... got so I could beat batboy to a newbie 90% of the time :D

JerMe
01-31-05, 09:04 PM
Bah, I'm still helpless here.
I can't get this thing figured out, and it's KILLING me to do it so I have all the prettyful stats in my sig.

I get the same error regardless of what I do, so can somebody PLEASE tell me what I'm doing wrong?

I need a solid Windows version of folding for 1 core if that makes a difference. I just want the damn bargraphs.

If somebody has a bug-free version of their sig_gen.pl file, then post it up and I'll download it. Even Dark_15's version wasn't working for me...please help.

7

Still need help?

Christoph
01-31-05, 09:39 PM
You people have no idea how hard it is to keep away from this thread. Hopefully RL will be tame enough soon that I won't have to.

IMOG: That'd be exactly what I'd prefer to use, except that none of the links work. :cry: I've got no clue what kind of load the stats pages normally have, so I have no idea how much a five or ten clients autoloading the pages at regular intervals 24/7 will effect their servers.
All that I can recommend is that people be kind. To lead by example, I'm only having my stats updated every 6 hours. If you're using the version of my sig_gen that has the caching feature, the line that controls how long to wait between updates from Stanford reads something like
if ((! -e $stfd_cache) || (time+(6*60*60) > (stat($stfd_cache))[9])) {
BUGFIX: The line should read as follows, since we care about 6 hours ago, not 6 hours from now. ;) A way to read the line is "If the file doesn't exist or now minus 6 hours is sooner than the time the file was last updated..."
if ((! -e $stfd_cache) || (time-(6*60*60) > (stat($stfd_cache))[9])) {
where 6*60*60 is how long to wait between updates, in seconds. Looking for "60*60" is probably the easiest way to find it.
edit: It looks like the problem that the thread IMOG linked to refered to is was temporary. Of course, it doesn't mean that Stanford won't care if you update your stats every 5 minutes. ;)
If anyone cares to look into a lower-bandwidth way to get stats, I'd appreciate it. If not, it'll be on my to-do list.


BC|Wulf: Change the line to
s/\s*(\d*).*/$1/;
This is The Right Way (tm) since it grabs as many sequential digits as it can. Note that s/\s*(\d+).*/$1/; would be equally The Right Thing. Perl's like that. ;)
edit: This was brokenly using \w instead of \s.
The reason I didn't do it that way before was because I was only thinking about my own score and didn't expect to be posting my own sig_gen here. I would have done well to follow the ways of the old master who said "Though a program be but three lines long, someday it will have to be maintained."
Writing code and assuming that people won't either see or want to extend it is asking for a beatdown care of Murphy.
I'll definitely be doing an audit of my code to look for more junk like that. Now that I have a better idea of who/what it'll be used for, I should be able to make life simpler for you who want to use it.


JerMe: Thanks. I really appreciate you taking care of (some of?) the exoc stats. I'd have done them, but the consequences of putting this off are much smaller than those of putting RL off.
I hope figuring out my code both helps and doesn't scar you. ;) There's a whole book on Perl written specifically for bioinformatics people (two (http://www.oreilly.com/catalog/begperlbio/) actually (http://www.oreilly.com/catalog/mperlbio/)), so you may find a use for this elsewhere.

JerMe
01-31-05, 09:59 PM
Ok, here's my take on Christoph's script, hacked in every way possible and without a clue as to what I was doing. But hey, it got me the sig, right? ;)


#!/usr/bin/perl
use LWP::UserAgent;

#might be cool:
# * have the color of the "45%" change as they approach 100
# * Use. More. Colors.
# * use a funky character helix for the progress bar

#string to use for progress indicator
$progress_char="¤";

#how many of the above char to use at 100%
$prog_len = 10;

#starting/ending color for progress indicator
$prog_start = "333333";
$prog_end = "ffd700";
#$prog_start = "ff00ff";
#$prog_end = "ffff00";

$fstr_start = "ff00ff";
$fstr_end = "ffff00";

#how many times to cycle through the progress indicator gradient
$prog_cycles = 1;

#a place to hang your hat
$home = glob "~/";

#you can't see me
$invisible="333333";

@time = localtime;
$time[5] += 1900;
$time[4]++;

#################################
#get local info about current WUs
#################################

@f_name, @f_prog;
$f_name, $f_prog;
$stfd_cache = "stfd.html";
$eocsum_cache = "eocsum.html";
$invisible_char = "\.\[/color\]";

for $n (1, 2, 3) {
$f_name = "";
$f_prog = "";
open FH, "C:\\Program Files\\FAH\\unitinfo.txt" or die "error opening file: $!";
while(<FH>){
chomp;
$f_name .= $_;
}
close FH;
$f_prog = $f_name;

$f_name =~ s/.*Name://;
$f_name =~ s/Download.*//;
$f_name = color_string("ffff00","ff0000",$f_name);

for ($f_prog) {
s/.*Progress: //;
s/\%.*//;
$pct_prog = $_;
#$pct_prog = 100;
#this is a *recommended* way of rounding
$filled_bars = sprintf("%.0f",($pct_prog/100)*$prog_len);
$empty_bars = $prog_len - $filled_bars;
#print "$pct_prog% progress, $filled_bars chars, $empty_bars unfilled\n";

$f_prog = "{";

for($i=0; $i < $filled_bars; $i++) {
$color=color_grad($prog_start,$prog_end,$prog_len/$prog_cycles,$i);
$f_prog .= "\[color=#$color\]$progress_char\[/color\]";
}
$f_prog .= "[color=#$invisible]";
$f_prog .= "_" x $empty_bars;
$f_prog .= "";
$f_prog .= "}";

# now looks like "{****___}" but with color tags

$f_prog .= "$pct_prog%";
if ($pct_prog > 99) {
s/(\d\d\d%)/_[\/color]$1/;
} elsif ($pct_prog >9) {
s/(\d\d%)/[color=#$invisible]__[\/color]$1/;
} else {
s/(\d%)/[color=#$invisible]___[\/color]$1/;
}
#print "$f_prog\n";
}

$f_name[$n-1] = $f_name;
$f_prog[$n-1] = $f_prog;
}

########################
#get stats from Stanford
########################
$user="JerMe";
$team=32;
$s_content;

#only download stanford's page every 2 hours ( = 2*60*60 seconds)
#(stat(file))[9] is the time since file was last modified, in seconds
if ( (! -e $stfd_cache) || (time+(2*60*60) < (stat($stfd))[9])) {

$ua = LWP::UserAgent->new();
$stfd_page = $ua->get("http://vspx27.stanford.edu/cgi-bin/main.py?qtype=userpage&teamnum=$team&username=$user");

if (! $stfd_page->is_success) {
die "Couldn't download Stanford's page.";
}

open STFD_CACHE, ">$stfd_cache";
print STFD_CACHE $stfd_page->content;
close STFD_CACHE;

$s_content = $stfd_page->content;

} else {

open STFD_CACHE, "$stfd_cache";
while(<STFD_CACHE>) {
$s_content .= $_;
}
close STFD_CACHE;

}

$pts = $s_content;
$wus = $s_content;
$cpu = $s_content;

for ($pts) {
s/[\n\r]//g;
s/.*Total score//g;
s/[^\d]*//;
s/4> (\d*).*/$1/;
}

for ($wus) {
s/[\n\r]//g;
s/.*WU</</g;
s/<[^>]*>//g;
s/\w*(\d\d\d).*/$1/;
s/ //g;
s/\t//g;
}

for ($cpu) {
s/[\n\r]//g;
s/.*Active processors//;
s/<[^>]*>//g;
s/[ \t]//g;
s/\([^\)]*\)//g;
s/(\d*).*/$1/g;
}


################################################## #################
#
# get stats from EOC summary page, mooched off of Christoph's code
# now the problem is figuring out how to skip lines
#
################################################## ################



#only download EOC's page every 2 hours ( = 2*60*60 seconds)
#(stat(file))[9] is the time since file was last modified, in seconds
if ( (! -e $eocsum_cache) || (time+(2*60*60) < (stat($eocsum_cache))[9])) {

$eoc_id=5414;
$eocsum_content;

$ua = LWP::UserAgent->new();
$eocsum_page = $ua->get("http://folding.extremeoverclocking.com/user_summary.php?s=&u=$eoc_id");

if (! $eocsum_page->is_success) {
die "Couldn't download EOC's summary page.";
}

open EOCSUM_CACHE, ">$eocsum_cache";
print EOCSUM_CACHE $eocsum_page->content;
close EOCSUM_CACHE;

$eocsum_content = $eocsum_page->content;

} else {

open EOCSUM_CACHE, "$eocsum_cache";
while(<EOCSUM_CACHE>) {
$eocsum_content .= $_;
}
close EOCSUM_CACHE;
}

#rank in team 32
$rnk = $eocsum_content;
#points 24hr ave
$ppd = $eocsum_content;
#points last 24 hrs
$p24 = $eocsum_content;
#points last 7 days
$p7d = $eocsum_content;
#points this day
$p2d = $eocsum_content;
#points this week
$pwk = $eocsum_content;
#points total
#$pts = $eocsum_content;
#WUs total
#$wus = $eocsum_content;


#find WUs<div class='tblsub'>Total
#then find first numbers after that
for ($rnk) {
s/[\n\r]//g;
s/.*WUs.*Total//g;
s/\D*//;
s/(\d\d\d).*/$1/;
}

for ($ppd) {
s/[\n\r]//g;
s/.*WUs.*Total//g;
s/<td align='right'>...<\/td>//;
s/\D*//;
s/(\d\d\d).*/$1/;
}

for ($p7d) {
s/[\n\r]//g;
s/.*WUs.*Total//g;
s/<td align='right'>...<\/td>//;
s/<td align='right'>...<\/td>//;
s/<td align='right'>...<\/td>//;
s/\D*//;
s/(\d\d\d).*/$1/;
}




#################
#
# Spacer Code
#
#################

$pts_len=7;
$ppd_len=9;
$p7d_len=9;
$wus_len=9;
$cpu_len=5;
$rnk_len=5;

$spcr1= "[color=#$invisible]" . "_" x 4 . "";
$spcr2= "" . "_" x 4 . "";
$spcr3= "" . "_" x 8 . "";

$pts_pad = $pts_len - (length $pts);
$ppd_pad = $ppd_len - (length $ppd);
$p7d_pad = $p7d_len - (length $p7d);
$wus_pad = $wus_len - (length $wus);
$cpu_pad = $cpu_len - (length $cpu);
$rnk_pad = $rnk_len - (length $rnk);

$pts = "" . "_" x $pts_pad . "" . $pts . $spcr1;
$ppd = "" . "_" x $ppd_pad . "" . $ppd . $spcr1;
$p7d = "" . "_" x $p7d_pad . "" . $p7d . $spcr1;
$wus = "" . "_" x $wus_pad . "" . $wus . $spcr1;
$cpu = "" . "_" x $cpu_pad . "" . $cpu . $spcr1;
$rnk = "" . "_" x $rnk_pad . "" . $rnk . $spcr1;


#################################
# Print code
#
# everything here is shown in sig
#################################


$folding_str = color_string($fstr_start,$fstr_end,"Build! Borg! Recruit! Fold for team 32!");
$tagline_str = color_string($fstr_start,$fstr_end,"Christoph - Nice Code! We'll take it! (:0");

$time_str = sprintf("%02d/%02d/%04d at %02d:%02d.\n",$time[4],$time[3],$time[5],$time[2],$time[1]);
print "DFI LP-B, AXP2500+ @ 250x10=2500MHz, 2x256 Mushkin PC3500 lvl2\n";
print "Watercooled: White Water, Chevette Core, Mag 3\n\n";
print "$folding_str\n";
print "My stats:".$spcr3. "This Rig's Current WU:$spcr2$load_avg\n";
print "score:$pts". "$f_prog[0] :$f_name[0]\n";
print "ppd:$ppd". "\n";
print "p7d:$p7d". "\n";
print "WUs:$wus". "\n";
print "clients:$cpu". "\n";
print "OC rank:$rnk". "\n";
# stat: 03030 {****** } 61% : p1139_p1133_L939_K12M_355K
print "$tagline_str\n";

sub color_grad
{
$start_rgb = shift; #"ff00ff"
$end_rgb = shift; #"00ff00"
$last_step = shift; #"36"
$curr_step = shift; #"12"

$curr_step %= $last_step;

$r_start = hex(substr($start_rgb,0,2));
$g_start = hex(substr($start_rgb,2,2));
$b_start = hex(substr($start_rgb,4,2));

$r_end = hex(substr($end_rgb,0,2));
$g_end = hex(substr($end_rgb,2,2));
$b_end = hex(substr($end_rgb,4,2));

$r_step = ($r_end - $r_start)/$last_step;
$g_step = ($g_end - $g_start)/$last_step;
$b_step = ($b_end - $b_start)/$last_step;

$curr_rgb = sprintf("%02x%02x%02x",$r_start+$r_step*$curr_step,$g_start+$g_step*$cur r_step,$b_start+$b_step*$curr_step);
}


sub color_string
{
$start_rgb = shift;
$end_rgb = shift;
$string = shift;
#print "COLOR STRING: passed $string\n";

#ugly bug if this isn't declared my
my $color_string;
$str_len = length $string;
$i=0;

foreach $char (split //, $string) {
$fstr_color=color_grad($start_rgb,$end_rgb,$str_le n,$i++);
#vb3 seems to treat individually colored spaces an non-printable
if ($char eq " ") {
$color_string .= "\[color\=\#$invisible\].\[/color\]";
} else {
$color_string .= "\[color\=\#$fstr_color\]$char\[/color\]";
}
}
#print "COLOR STRING: returning $color_string\n";
return $color_string;
}


There's a lot of crap that could definitely be optimized, and much more that I left in, thinking that I'd use it sometime in the future. Bleh.

Seven, you'll obviously have to change my name to your name:


########################
#get stats from Stanford
########################
$user="JerMe";


Just change "JerMe" to whatever your folding name is. As for the EOC stats, you'll have to find your EOC user ID number. If you go to http://folding.extremeoverclocking.com/user_summary.php?s=&u=5414, the last number in the URL is the EOC ID. Mine is "5414". in the code, you'll have to change it:


if ( (! -e $eocsum_cache) || (time+(2*60*60) < (stat($eocsum_cache))[9])) {

$eoc_id=5414;
$eocsum_content;


so change "5414" to whatever your EOC ID is (check your stats on EOC and find out!)

Hopefully that should be all you'd need to change. Christoph made it easy for us to sift through the code, I just needed to know HOW to code...

@Christoph: Cool, those bioinformatics links are actually useful. I'm diggin' anything that I can apply from here, to working at the lab. I need to learn VB so that I can get scripts going for our robot (http://www.beckman.com/products/instrument/automatedsolutions/biomek/biomekfx_inst_dcr.asp).

Christoph
01-31-05, 10:19 PM
#!/usr/bin/perl
use LWP::UserAgent;

#might be cool:
# * have the color of the "45%" change as they approach 100
# * Use. More. Colors.
# * use a funky character helix for the progress bar

#string to use for progress indicator
$progress_char="¤";

#how many of the above char to use at 100%
$prog_len = 10;

#starting/ending color for progress indicator
$prog_start = "333333";
$prog_end = "ffd700";
#$prog_start = "ff00ff";
#$prog_end = "ffff00";

$fstr_start = "ff00ff";
$fstr_end = "ffff00";

#how many times to cycle through the progress indicator gradient
$prog_cycles = 1;

#a place to hang your hat
$home = glob "~/";

#you can't see me
$invisible="333333";

@time = localtime;
$time[5] += 1900;
$time[4]++;

#################################
#get local info about current WUs
#################################

@f_name, @f_prog;
$f_name, $f_prog;
$stfd_cache = "stfd.html";
$eocsum_cache = "eocsum.html";
$invisible_char = "\.\[/color\]";

for $n (1, 2, 3) {
$f_name = "";
$f_prog = "";
open FH, "C:\\Program Files\\FAH\\unitinfo.txt" or die "error opening file: $!";
while(<FH>){
chomp;
$f_name .= $_;
}
close FH;
$f_prog = $f_name;

$f_name =~ s/.*Name://;
$f_name =~ s/Download.*//;
$f_name = color_string("ffff00","ff0000",$f_name);

for ($f_prog) {
s/.*Progress: //;
s/\%.*//;
$pct_prog = $_;
#$pct_prog = 100;
#this is a *recommended* way of rounding
$filled_bars = sprintf("%.0f",($pct_prog/100)*$prog_len);
$empty_bars = $prog_len - $filled_bars;
#print "$pct_prog% progress, $filled_bars chars, $empty_bars unfilled\n";

$f_prog = "{";

for($i=0; $i < $filled_bars; $i++) {
$color=color_grad($prog_start,$prog_end,$prog_len/$prog_cycles,$i);
$f_prog .= "\[color=#$color\]$progress_char\[/color\]";
}
$f_prog .= "[color=#$invisible]";
$f_prog .= "_" x $empty_bars;
$f_prog .= "";
$f_prog .= "}";

# now looks like "{****___}" but with color tags

$f_prog .= "$pct_prog%";
if ($pct_prog > 99) {
s/(\d\d\d%)/_[\/color]$1/;
} elsif ($pct_prog >9) {
s/(\d\d%)/[color=#$invisible]__[\/color]$1/;
} else {
s/(\d%)/[color=#$invisible]___[\/color]$1/;
}
#print "$f_prog\n";
}

$f_name[$n-1] = $f_name;
$f_prog[$n-1] = $f_prog;
}

########################
#get stats from Stanford
########################
$user="JerMe";
$team=32;
$s_content;

#only download stanford's page every 2 hours ( = 2*60*60 seconds)
#(stat(file))[9] is the time since file was last modified, in seconds
if ( (! -e $stfd_cache) || (time-(2*60*60) > (stat($stfd))[9])) {

$ua = LWP::UserAgent->new();
$stfd_page = $ua->get("http://vspx27.stanford.edu/cgi-bin/main.py?qtype=userpage&teamnum=$team&username=$user");

if (! $stfd_page->is_success) {
die "Couldn't download Stanford's page.";
}

open STFD_CACHE, ">$stfd_cache";
print STFD_CACHE $stfd_page->content;
close STFD_CACHE;

$s_content = $stfd_page->content;

} else {

open STFD_CACHE, "$stfd_cache";
while(<STFD_CACHE>) {
$s_content .= $_;
}
close STFD_CACHE;

}

$pts = $s_content;
$wus = $s_content;
$cpu = $s_content;

for ($pts) {
s/[\n\r]//g;
s/.*Total score//g;
s/[^\d]*//;
s/4> (\d*).*/$1/;
}

for ($wus) {
s/[\n\r]//g;
s/.*WU</</g;
s/<[^>]*>//g;
s/\s*(\d+).*/$1/; #this line edited from what JerMe originally posted
s/ //g;
s/\t//g;
}

for ($cpu) {
s/[\n\r]//g;
s/.*Active processors//;
s/<[^>]*>//g;
s/[ \t]//g;
s/\([^\)]*\)//g;
s/(\d*).*/$1/g;
}


################################################## #################
#
# get stats from EOC summary page, mooched off of Christoph's code
# now the problem is figuring out how to skip lines
#
################################################## ################



#only download EOC's page every 2 hours ( = 2*60*60 seconds)
#(stat(file))[9] is the time since file was last modified, in seconds
if ( (! -e $eocsum_cache) || (time-(2*60*60) > (stat($eocsum_cache))[9])) {

$eoc_id=5414;
$eocsum_content;

$ua = LWP::UserAgent->new();
$eocsum_page = $ua->get("http://folding.extremeoverclocking.com/user_summary.php?s=&u=$eoc_id");

if (! $eocsum_page->is_success) {
die "Couldn't download EOC's summary page.";
}

open EOCSUM_CACHE, ">$eocsum_cache";
print EOCSUM_CACHE $eocsum_page->content;
close EOCSUM_CACHE;

$eocsum_content = $eocsum_page->content;

} else {

open EOCSUM_CACHE, "$eocsum_cache";
while(<EOCSUM_CACHE>) {
$eocsum_content .= $_;
}
close EOCSUM_CACHE;
}

#rank in team 32
$rnk = $eocsum_content;
#points 24hr ave
$ppd = $eocsum_content;
#points last 24 hrs
$p24 = $eocsum_content;
#points last 7 days
$p7d = $eocsum_content;
#points this day
$p2d = $eocsum_content;
#points this week
$pwk = $eocsum_content;
#points total
#$pts = $eocsum_content;
#WUs total
#$wus = $eocsum_content;


#find WUs<div class='tblsub'>Total
#then find first numbers after that
for ($rnk) {
s/[\n\r]//g;
s/.*WUs.*Total//g;
s/\D*//;
s/(\d\d\d).*/$1/;
}

for ($ppd) {
s/[\n\r]//g;
s/.*WUs.*Total//g;
s/<td align='right'>...<\/td>//;
s/\D*//;
s/(\d\d\d).*/$1/;
}

for ($p7d) {
s/[\n\r]//g;
s/.*WUs.*Total//g;
s/<td align='right'>...<\/td>//;
s/<td align='right'>...<\/td>//;
s/<td align='right'>...<\/td>//;
s/\D*//;
s/(\d\d\d).*/$1/;
}




#################
#
# Spacer Code
#
#################

$pts_len=7;
$ppd_len=9;
$p7d_len=9;
$wus_len=9;
$cpu_len=5;
$rnk_len=5;

$spcr1= "[color=#$invisible]" . "_" x 4 . "";
$spcr2= "" . "_" x 4 . "";
$spcr3= "" . "_" x 8 . "";

$pts_pad = $pts_len - (length $pts);
$ppd_pad = $ppd_len - (length $ppd);
$p7d_pad = $p7d_len - (length $p7d);
$wus_pad = $wus_len - (length $wus);
$cpu_pad = $cpu_len - (length $cpu);
$rnk_pad = $rnk_len - (length $rnk);

$pts = "" . "_" x $pts_pad . "" . $pts . $spcr1;
$ppd = "" . "_" x $ppd_pad . "" . $ppd . $spcr1;
$p7d = "" . "_" x $p7d_pad . "" . $p7d . $spcr1;
$wus = "" . "_" x $wus_pad . "" . $wus . $spcr1;
$cpu = "" . "_" x $cpu_pad . "" . $cpu . $spcr1;
$rnk = "" . "_" x $rnk_pad . "" . $rnk . $spcr1;


#################################
# Print code
#
# everything here is shown in sig
#################################


$folding_str = color_string($fstr_start,$fstr_end,"Build! Borg! Recruit! Fold for team 32!");
$tagline_str = color_string($fstr_start,$fstr_end,"Christoph - Nice Code! We'll take it! (:0");

$time_str = sprintf("%02d/%02d/%04d at %02d:%02d.\n",$time[4],$time[3],$time[5],$time[2],$time[1]);
print "DFI LP-B, AXP2500+ @ 250x10=2500MHz, 2x256 Mushkin PC3500 lvl2\n";
print "Watercooled: White Water, Chevette Core, Mag 3\n\n";
print "$folding_str\n";
print "My stats:".$spcr3. "This Rig's Current WU:$spcr2$load_avg\n";
print "score:$pts". "$f_prog[0] :$f_name[0]\n";
print "ppd:$ppd". "\n";
print "p7d:$p7d". "\n";
print "WUs:$wus". "\n";
print "clients:$cpu". "\n";
print "OC rank:$rnk". "\n";
# stat: 03030 {****** } 61% : p1139_p1133_L939_K12M_355K
print "$tagline_str\n";

sub color_grad
{
$start_rgb = shift; #"ff00ff"
$end_rgb = shift; #"00ff00"
$last_step = shift; #"36"
$curr_step = shift; #"12"

$curr_step %= $last_step;

$r_start = hex(substr($start_rgb,0,2));
$g_start = hex(substr($start_rgb,2,2));
$b_start = hex(substr($start_rgb,4,2));

$r_end = hex(substr($end_rgb,0,2));
$g_end = hex(substr($end_rgb,2,2));
$b_end = hex(substr($end_rgb,4,2));

$r_step = ($r_end - $r_start)/$last_step;
$g_step = ($g_end - $g_start)/$last_step;
$b_step = ($b_end - $b_start)/$last_step;

$curr_rgb = sprintf("%02x%02x%02x",$r_start+$r_step*$curr_step,$g_start+$g_step*$cur r_step,$b_start+$b_step*$curr_step);
}


sub color_string
{
$start_rgb = shift;
$end_rgb = shift;
$string = shift;
#print "COLOR STRING: passed $string\n";

#ugly bug if this isn't declared my
my $color_string;
$str_len = length $string;
$i=0;

foreach $char (split //, $string) {
$fstr_color=color_grad($start_rgb,$end_rgb,$str_le n,$i++);
#vb3 seems to treat individually colored spaces an non-printable
if ($char eq " ") {
$color_string .= "\[color\=\#$invisible\].\[/color\]";
} else {
$color_string .= "\[color\=\#$fstr_color\]$char\[/color\]";
}
}
#print "COLOR STRING: returning $color_string\n";
return $color_string;
}

There's a copy/paste friendly version.

Also, I was mixing up \s with \w. \w matches words, and \s matches spaces. I was thinking \w was for whitespace. \s was what I wanted. D'oh. I took the liberty of fixing it above.

Finally, I seem to have screwed up the cache time checking code. The above code has it correct. I could have sworn I had it working correctly beforehand.

I.M.O.G.
01-31-05, 10:38 PM
Mad props to all those who put work into this, especially christoph for spearheading this - I think it is safe to say we have once again been the first in creating something unique - overclockix, one-click, and autoupdating ascii sig stats. :D I think the response this has produced in this thread is a great indication of just how cool people think this is. :D

Special thanks to helsyeah for posting his version of the sig, as I ripped it off and was able to make it my own from there. (have no clue how the progress bar works still, but it looks awesome) :D

Also, thanks to jerme for posting his version, as I will soon be ripping it off to incorporate some EOC stats also. :D

I.M.O.G.
01-31-05, 11:04 PM
If there are any available good samaritans, I need help parseing EOC stats page I think - I'm getting this output from a direct copy and paste of Jerme's EOC and "print" code (I only changed the userid):
ppd:63</td> <td align='right'>1,246
p7d:63</td> <td align='right'>1,246
WUs:_____2778____
clients:___25
OC rank:63</td> <td align='right'>1,246

That should be an easy fix, but I am well short of a good understanding of all the code syntax.

For anyone who might find it useful, here is the code for my current sig:

this was all wrong *removed*

JerMe
01-31-05, 11:09 PM
Yeah I'm going through that as we speak. The quick and dirty way to fix it would be to remove a "\d" or two from

s/(\d\d\d).*/$1/;

I'm still not good with this RE stuff, so the \d\d\d was jerry-rigged to put out a 4 digit p7d result. Right now i have "2,978" points in 7 days, so I don't know if the comma is screwing the code up. Try chopping off the \d and see what happens to your sig (I'll be watching heheh)

Edit: Shouldn't s/(\d\d\d).*/$1/; be the same as s/(\d*).*/$1/;? It doesn't want to work for me. s/(\d\d\d).*/$1/; produces 2,978 where s/(\d*).*/$1/; just gives me a 2..

I.M.O.G.
01-31-05, 11:13 PM
Ya know, I think I've had it for tonight on that. :) I'll hit it again tomorow, code wears on me very quickly.

EDIT: I also cannot change the gradient color for the life of me, despite the fact that I changed all the color codes?

Christoph
01-31-05, 11:37 PM
If you want to grab as many sequential numbers and commas as possible, use ([\d,]*) in the first part of the regex and the number will be put into $1. You can use $1 in the second part of the regex or later in the code, as long as you don't have another regex that captures stuff with parens before you use $1.

I'll post a quick explanation of my progress bar code, and then I'm closing Mozilla and Thunderbird so I can get some work done. ;)


#right now, f_prog contains all of stfd's page
#any regexes that don't look like they apply to anything implicitly work on $f_prog, since that's
#what's in the for loop
for ($f_prog) {

#strip out extra stuff from html code
s/.*Progress: //;
s/\%.*//;

#pct_prog now has a number between 0 and 100
$pct_prog = $_;

#$pct_prog = 100; (in case you want to pretend you're done)

#This is a *recommended* way of rounding from "Programming Perl", 3rd ed, p. 732. I
#understand it, but I don't see why there isn't a more obvious way.

#this finds how many characters in the prog. bar we want to show
$filled_bars = sprintf("%.0f",($pct_prog/100)*$prog_len);

#this is how many we don't
$empty_bars = $prog_len - $filled_bars;

#now start building the progress bar
#first character...
$f_prog = "{";

#add $filled_bars chars to the progress bar, using that mysterious gradient thingy
#5 is to add a little random error so the chars aren't the exact same color. The version of
#color_grad with randomization is in the first post now, and will only do the random stuff if
#it's got a fifth arg.
# .= means append
for($i=0; $i < $filled_bars; $i++) {
$color=color_grad($prog_start,$prog_end,$prog_len/$prog_cycles,$i,5);
$f_prog .= "\$progress_char\[/color\]";
}

#now we want the spacers, so open an invisible color tag...
$f_prog .= "[color=#$invisible]";

#add $empty_bars underscores...
$f_prog .= "_" x $empty_bars;

#close the color tag...
$f_prog .= "";

#closing curly brace
$f_prog .= "}";

#now looks like "{****___}" but with color tags
#boo-yah


#add some invisible spacing to keep things even

#how many chars in the pct string (eg "92" has 2 chars)
$pct_len = length $pct_prog;
$spc_len = 4 - $pct_len;

#put that many underscores in $spc
$spc = "_" x $spc_len;
#add the stuff to the end of $f_prog
$f_prog =~ s/$/\[color=#$invisible\]$spc\[\/color\]/;


#print "$f_prog\n";

#Of course, we don't want an uncolored percentage. ;)
#get the color for whatever percent we're at from the gradient maker, without randomization
$pct_color = color_grad($pct_begin,$pct_end,100,$pct_prog);

#append the percentage, "%" and color tags
$f_prog =~ s/$/\[color=#$pct_color\]$pct_prog\%\[\/color\]/;

#Who knows. It's probably not important.
$min_pct = $pct_prog if ($pct_prog < $min_pct);

}

edit: code needed some cleaning, so I cleaned it. Comments are current with code. Hopefully, it's a little easier to read too.
edit2: Now they're current.

JerMe
01-31-05, 11:49 PM
If you want to grab as many sequential numbers and commas as possible, use ([\d,]*) in the first part of the regex and the number will be put into $1. You can use $1 in the second part of the regex or later in the code, as long as you don't have another regex that captures stuff with parens before you use $1.

Genius. Heh. Code's been changed to s/([\d,]*).*/$1/;, I shouldn't have any problems now or in the future.

Here's my PL, then I'm done for now:
(Edit: changed the EOC parsing code a tad bit)

Christoph
02-01-05, 08:36 AM
How strange. First some of my gradients start getting random error, and now I seem to be giving 110%. I don't even know how that's possible. ;)

mtb856
02-01-05, 09:46 AM
I don't know either, but 110% must mean it's working faster :D j/k

I tried out the EOC version of the sig, and it seems to work pretty well..... just meshed the parts I needed into my sig and changed it show both of my WU's..... nice job jerme :)

BTW, Christolph.... did you randomize the color change for your WU information? That looks pretty good.

enduro
02-01-05, 10:54 AM
Sig test:

Edit: Pimpin :D

How do you change the colors for the following area:
print "score:$pts". "$f_prog[0] :$f_name[0]\n";
print "ppd:$ppd". "\n";
print "p7d:$p7d". "\n";
print "WUs:$wus". "\n";
print "clients:$cpu". "\n";
print "OC rank:$rnk". "\n[/font]";
# stat: 03030 {****** } 61% : p1139_p1133_L939_K12M_355K
print "$tagline_str\n";

It looks like this in the sig:
score:__63267____{¤¤¤¤¤¤¤___}__66% :.p1140_RIBO_FSpeptide_EXT
ppd:______638____
p7d:____1,309____
WUs:______549____
clients:____7____
Team rank:__253____

I'm not big on the white. I don't know PERL but having a color string for those would be awesome. Just not sure how to do it.

BC|Wulf
02-01-05, 11:26 AM
For some reason my PPD and P7D are the same as my team rank! Any ideas?

JerMe
02-01-05, 11:45 AM
LOL 'cause I can't code (:0 Hopefully someone has read up on the REs and can optimize the parsing code, I think I know where a problem will pop up:


for ($ppd) {
s/[\n\r]//g;
s/.*WUs.*Total//g;
s/<td align='right'>...<\/td>//;
s/\D*//;
s/([\d,]*).*/$1/;

}

for ($p7d) {
s/[\n\r]//g;
s/.*WUs.*Total//g;
s/<td align='right'>...<\/td>//;
s/<td align='right'>...<\/td>//;
s/<td align='right'>...<\/td>//;
s/\D*//;
s/([\d,]*).*/$1/;
}

The ... in s/<td align='right'>...<\/td>//; allows for 3 chars... it might be better if it says s/<td align='right'>[/d,]*<\/td>//;, ... lemme try it out

Edit: Seems to be working. I'll update my pl in the previous post. I'm sure there's a cleaner method than above to parse the EOC local cache; if you know it, post it please!

Edit2: Christoph, can Perl parse through XML? The code is simpler, and the cache is only 0.9kb, versus 20kb for the HTML version.
http://folding.extremeoverclocking.com/xml/user_summary.php?s=&u=5414
Edit3: ActiveState's Perl already has XML::Parser / XML:Simple... now how do you use it...

I.M.O.G.
02-01-05, 12:47 PM
That was the same issue I had the last time I tried last night, will try again later today. Thanks JerMe, I'll get there eventually... I also dunno if its updating my rigs progress correctly... The colors won't change, and I haven't gotten anywhere... I've been encoding some video though so perhaps thats just been running constantly and I haven't made any progress on the WU.

JerMe
02-01-05, 12:51 PM
That was the same issue I had the last time I tried last night, will try again later today. Thanks JerMe, I'll get there eventually... I also dunno if its updating my rigs progress correctly... The colors won't change, and I haven't gotten anywhere... I've been encoding some video though so perhaps thats just been running constantly and I haven't made any progress on the WU.

Check your unitinfo.txt and FAHinfo in your FAHlog.txt in your FAH folder if you want to be sure that's the case (:

dang I'm hooked to this code heheh! NJ again Christoph

BC|Wulf
02-01-05, 01:04 PM
That worked JerMe...thanks! I even decided to pull the points from the EOC site, which worked, but could not pull the WUs from the EOC site. I was trying to avoid using Standford's site all together for the information. If I get time I will have to look into it more.

I.M.O.G.
02-01-05, 01:50 PM
Try to keep in mind the forum sig rules also while doing this... It's better to expand horizontally than vertically... Sigs get too long and they are just distracting - we want cool, not cumbersome. :D

BC|Wulf
02-01-05, 02:02 PM
Good point IMOG! Is the point system still in use for the sigs? If so I might have to check mine.

Glad I checked..I was 14 points I am now 9.75 points.

enduro
02-01-05, 04:13 PM
Ah ha. Figured it out. Normal BB code works but only in certain areas apparently........ green is definitely better than white :D

This is an awesome program. Props for designing it man.

Christoph
02-01-05, 04:49 PM
I'm just scratching an itch. Any semi-competent Perl programmer could hack something like this together. The hardest part was figuring out LWP, and that wasn't bad once I got over the initial hump.
It's nice not to be the only itchy one, though.

SatanSkin
02-01-05, 06:39 PM
Been hacking stuff together.....Should have a nice updated sig shortly.

FarkinBastage
02-01-05, 07:14 PM
Useless message to test signature

SatanSkin
02-01-05, 07:21 PM
MTB, what'd you use to get the rank off of EOC? I was using Jerme's but it grabs your ppd instead of rank. Any ideas? And also, where do you put in the code for the percent color fade?

MTB and BC, will you two post your sig_gen please?

Seven
02-01-05, 08:49 PM
UGH!
No errors, but no sig either.

Bah, Bah BAH!!!

7

mtb856
02-01-05, 10:01 PM
Sure thing bud :)

#starting/ending color for progress indicator
$prog_start = "fff400";
$prog_end = "ff2026";
#$prog_start = "fff400";
#$prog_end = "ff2026";

$fstr_start = "fff400";
$fstr_end = "ff2026";

prog_start is the beginning color for the progress indicator...

fstr_start is the beginning color for the "Folding for Team 32" statement.

SatanSkin
02-01-05, 10:18 PM
If that was for me mtb, i meant the whole thing.

I.M.O.G.
02-01-05, 10:19 PM
I have changed all of the values in the color code fields... Yet none of my gradient colors have changed from the initial color from the first time the sig was created... I can't understand it at all.

Attached:

SatanSkin
02-01-05, 10:41 PM
Try to find my nifty comments in your code IMOG. Hope this helps! Good luck.


#!/usr/bin/perl
use LWP::UserAgent;

#might be cool:
# * have the color of the "45%" change as they approach 100
# * Use. More. Colors.
# * use a funky character helix for the progress bar

#string to use for progress indicator
$progress_char="o";

#how many of the above char to use at 100%
$prog_len = 10;

#starting/ending color for progress indicator
$prog_start = "333333"; ###HEY IMOG, THESE CHANGE THE PROGRESS BAR COLOR!##
$prog_end = "FFC12E";
#$prog_start = "C1EAFF";
#$prog_end = "FFC12E";

$fstr_start = "C1EAFF";
$fstr_end = "FFC12E";

#how many times to cycle through the progress indicator gradient
$prog_cycles = 1;

#a place to hang your hat
$home = glob "~/";

#you can't see me
$invisible="333333";

@time = localtime;
$time[5] += 1900;
$time[4]++;


#get local info about current WUs

@f_name, @f_prog;
$f_name, $f_prog;
$stfd_cache = "stfd.html";
$invisible_char = "\.\[/color\]";

for $n (1, 1) {
$f_name = "";
$f_prog = "";
open FH, "c:/program files/fah/unitinfo.txt" or die "error opening file: $!";
while(<FH>){
chomp;
$f_name .= $_;
}
close FH;
$f_prog = $f_name;

$f_name =~ s/.*Name://;
$f_name =~ s/Download.*//;
$f_name = color_string("ffff00","ff0000",$f_name); ###I BELIEVE THIS##
####CHANGES COLOR OF PROTEIN NAME######
for ($f_prog) {
s/.*Progress: //;
s/\%.*//;
$pct_prog = $_;
#$pct_prog = 100;
#this is a *recommended* way of rounding
$filled_bars = sprintf("%.0f",($pct_prog/100)*$prog_len);
$empty_bars = $prog_len - $filled_bars;
#print "$pct_prog% progress, $filled_bars chars, $empty_bars unfilled\n";

$f_prog = "{";

for($i=0; $i < $filled_bars; $i++) {
$color=color_grad($prog_start,$prog_end,$prog_len/$prog_cycles,$i);
$f_prog .= "\$progress_char\[/color\]";
}
$f_prog .= "";
$f_prog .= "_" x $empty_bars;
$f_prog .= "";
$f_prog .= "}";

# now looks like "{****___}" but with color tags

$f_prog .= "$pct_prog%";
if ($pct_prog > 99) {
s/(\d\d\d%)/_[\/color]$1/;
} elsif ($pct_prog >9) {
s/(\d\d%)/__[\/color]$1/;
} else {
s/(\d%)/___[\/color]$1/;
}
#print "$f_prog\n";
}

$f_name[$n-1] = $f_name;
$f_prog[$n-1] = $f_prog;
}

#get stats from Intarw3b

$user="BorgIncarnate";
$team=32;

#only download stanford's page every hour ( = 60*60 seconds)
#(stat(file))[9] is the time since file was last modified, in seconds
if ((! -e $stfd_cache) || (time+(60*60) > (stat($stfd_cache))[9]))
{
$ua = LWP::UserAgent->new();
$stfd_page = $ua->get("http://vspx27.stanford.edu/cgi-bin/main.py?qtype=userpage&teamnum=$team&username=$user");

if (! $stfd_page->is_success) {
die "Couldn't download Stanford's page.";
}

open STFD_CACHE, ">$stfd_cache";
print STFD_CACHE $stfd_page->content;
close STFD_CACHE;

$s_content = $stfd_page->content;

} else {

open STFD_CACHE, "$stfd_cache";
while(<STFD_CACHE>) {
$s_content .= $_;
}
close STFD_CACHE;

}

$pts = $s_content;
$wus = $s_content;
$cpu = $s_content;

for ($pts) {
s/[\n\r]//g;
s/.*Total score//g;
s/[^\d]*//;
s/4> (\d*).*/$1/;
}

for ($wus) {
s/[\n\r]//g;
s/.*WU</</g;
s/<[^>]*>//g;
s/\w*(\d\d\d\d).*/$1/;
s/ //g;
s/\t//g;
}


for ($cpu) {
s/[\n\r]//g;
s/.*Active processors//;
s/<[^>]*>//g;
s/[ \t]//g;
s/\([^\)]*\)//g;
s/(\d*).*/$1/g;
}

################################################## #################
#
# get stats from EOC summary page, mooched off of Christoph's code
# now the problem is figuring out how to skip lines
#
################################################## ################



#only download EOC's page every 2 hours ( = 2*60*60 seconds)
#(stat(file))[9] is the time since file was last modified, in seconds
if ( (! -e $eocsum_cache) || (time+(2*60*60) < (stat($eocsum_cache))[9])) {

$eoc_id=87086;
$eocsum_content;

$ua = LWP::UserAgent->new();
$eocsum_page = $ua->get("http://folding.extremeoverclocking.com/user_summary.php?s=&u=$eoc_id");

if (! $eocsum_page->is_success) {
die "Couldn't download EOC's summary page.";
}

open EOCSUM_CACHE, ">$eocsum_cache";
print EOCSUM_CACHE $eocsum_page->content;
close EOCSUM_CACHE;

$eocsum_content = $eocsum_page->content;

} else {

open EOCSUM_CACHE, "$eocsum_cache";
while(<EOCSUM_CACHE>) {
$eocsum_content .= $_;
}
close EOCSUM_CACHE;
}

#rank in team 32
$rnk = $eocsum_content;
#points 24hr ave
$ppd = $eocsum_content;
#points last 24 hrs
$p24 = $eocsum_content;
#points last 7 days
$p7d = $eocsum_content;
#points this day
$p2d = $eocsum_content;
#points this week
$pwk = $eocsum_content;
#points total
#$pts = $eocsum_content;
#WUs total
#$wus = $eocsum_content;


#find WUs<div class='tblsub'>Total
#then find first numbers after that
for ($rnk) {
s/[\n\r]//g;
s/.*WUs.*Total//g;
s/\D*//;
s/([\d,]*).*/$1/;
}

for ($ppd) {
s/[\n\r]//g;
s/.*WUs.*Total//g;
s/<td align='right'>[\d,]*<\/td>//;
s/\D*//;
s/([\d,]*).*/$1/;

}

for ($p7d) {
s/[\n\r]//g;
s/.*WUs.*Total//g;
s/<td align='right'>[\d,]*<\/td>//;
s/<td align='right'>[\d,]*<\/td>//;
s/<td align='right'>[\d,]*<\/td>//;
s/\D*//;
s/([\d,]*).*/$1/;
}




#################
#
# Spacer Code
#
#################

$pts_len=7;
$wus_len=9;
$cpu_len=5;

$spcr1= "" . "_" x 4 . "";
$spcr2= "" . "_" x 8 . "";
$spcr3= "" . "_" x 1 . "";


$pts_pad = $pts_len - (length $pts);
$wus_pad = $wus_len - (length $wus);
$cpu_pad = $cpu_len - (length $cpu);

$pts = "" . "_" x $pts_pad . "" . $pts . $spcr1;
$wus = "" . "_" x $wus_pad . "" . $wus . $spcr1;
$cpu = "" . "_" x $cpu_pad . "" . $cpu;
#####YOU'RE ****ED ON THAT STUFF BELOW!######

print "[color=#0702D4]**********************The OC Forums Way (http://www.ocforums.com/showthread.php?t=241747&page=1&pp=50)\n";
print "[color=#0702D4]******************* ***We are a team.__________________My stats:" .$spcr2. "Current % Complete:".$spcr3."Current Protien:\n";
print "******[color=#333333]************* ***We are a community._____________Score:$pts"."$f_prog[0] :$f_name[0]\n";
print "******************* ***We are a fellowship_____________WUs:$wus"."$f_prog[1] :$f_name[1]\n";
print "******************* ***made strong by mutual respect___Clients:$cpu\n";
print "**********************[color=#5766E7]and shared dedication___________P7D:____$p7d\n";
print "**********************to the task of enriching________PPD:____$ppd\n";
print "****[color=#FFC12E]******************all who come here.\n";
print "**********************The OC Forums Thank You Thread (http://www.ocforums.com/showthread.php?t=345204)\n";


sub color_grad
{
$start_rgb = shift; #"C1EAFF"
$end_rgb = shift; #"FFC12E"
$last_step = shift; #"36"
$curr_step = shift; #"12"

$curr_step %= $last_step;

$r_start = hex(substr($start_rgb,0,2));
$g_start = hex(substr($start_rgb,2,2));
$b_start = hex(substr($start_rgb,4,2));

$r_end = hex(substr($end_rgb,0,2));
$g_end = hex(substr($end_rgb,2,2));
$b_end = hex(substr($end_rgb,4,2));

$r_step = ($r_end - $r_start)/$last_step;
$g_step = ($g_end - $g_start)/$last_step;
$b_step = ($b_end - $b_start)/$last_step;

$curr_rgb = sprintf("%02x%02x%02x",$r_start+$r_step*$curr_step,$g_start+$g_step*$cur r_step,$b_start+$b_step*$curr_step);
}


sub color_string
{
$start_rgb = shift;
$end_rgb = shift;
$string = shift;
#print "COLOR STRING: passed $string\n";

#ugly bug if this isn't declared my
my $color_string;
$str_len = length $string;
$i=0;

foreach $char (split //, $string) {
$fstr_color=color_grad($start_rgb,$end_rgb,$str_le n,$i++);
#vb3 seems to treat individually colored spaces an non-printable
if ($char eq " ") {
$color_string .= "\[color\=\#$invisible\].\[/color\]";
} else {
$color_string .= "\[color\=\#$fstr_color\]$char\[/color\]";
}
}
#print "COLOR STRING: returning $color_string\n";
return $color_string;
}

I.M.O.G.
02-01-05, 10:50 PM
Hey Satanskin, I swear I changed those values... Too many revisions, mixing them up I guess... Current sig version is v.18542894. Very slow progress here - I'll try to upgrade to v.2 here.

Thank you sir!

Christoph
02-01-05, 10:55 PM
IMOG: Was it the super-randomly colored protein names? I would have kept them, but they made me feel a little sick. You'll have to post a screenshot next time. I've been changing my sig more often than my underwear recently. It's important to note that this is not typical.

Also, I've got a couple of cool hacks planned as soon as I get the time, including an option to check the length of a sig according to the rules. I don't consider it my job to enforce the rules, but it'd be a nice feature to at least issuing a warning (but continue anyway) when a sig is too long.

SatanSkin
02-01-05, 10:55 PM
No worries. Glad I could be of help. However, your progress bar is now too dark to even see. I had the same problem at first.

I.M.O.G.
02-01-05, 11:13 PM
Progress bar is one thing... protein name is another...

Got it, maybe... kinda.

JerMe
02-01-05, 11:13 PM
This is fun (:0

I managed to sneak XML parsing into the code...it grabs all the stats from EOC's page, and the download is <1kb, versus 8kb for Stanford and 20kb for EOC's summary page, so it takes a (tiny) load off of those servers. That, and it doesn't have to mess with regular expressions that I totally suck at, so there shouldn't be any problems with grabbing the wrong stat.

These are the stats from EOC that can be included, both Team 32's and the user's stats...:


#Team Variables that can be used
$eocstats->{Rank};
$eocstats->{Users_Active};
$eocstats->{Users};
$eocstats->{Points_24hr_Avg};
$eocstats->{Points_Update};
$eocstats->{Points_Today};
$eocstats->{Points_Week};
$eocstats->{Points};
$eocstats->{WUs};

#User Variables that can be used
$rnk = $eocstats->{user}->{Team_Rank};
$r24 = $eocstats->{user}->{Change_Rank_24hr};
$r7d = $eocstats->{user}->{Change_Rank_7days};
$ppd = $eocstats->{user}->{Points_24hr_Avg};
$pud = $eocstats->{user}->{Points_Update};
$p2d = $eocstats->{user}->{Points_Today};
$pwk = $eocstats->{user}->{Points_Week};
$pts = $eocstats->{user}->{Points};
$wus = $eocstats->{user}->{WUs};


So that should make it easier to get your user stats, as well as Team32's stats, or another team's stats (i.e., oc.com's points today vs. [H's] points today).

Christoph's LWP::UserAgent is still downloading Stanford's and EOC's summary page, but now the only parses for "Active CPUs 7 days" (Stanford) and "Points 7 days" (EOC summary). These stats aren't included in EOC's XML feed. Since these 2 stats only require an update every 24 hours, the code checks every 24 hours. I still think my parser for $p7d is whacked, so please fix it.

Hopefully someone can find this useful. Hopefully it'll work for others ;)

Edit: LOL@Christophs's sig. Punky Brewster like. :)

Edit2: Christoph, is there any way you can make your LWP code into a subroutine, and have us users just enter "webpages to download" as input and it spits out a file to our mksig directory? I'm going to try to do it, but I'll most certainly fail.

Seven
02-01-05, 11:41 PM
*Test*

For some reason, IMOG's worked, but then didn't after I messed with it.
Ugh.

Hopefully this'll work.

EDIT: WOW. Awesome work!

7

I.M.O.G.
02-01-05, 11:43 PM
Gonna have to work on incorporate H and OCAU stats in sig soon. :)

On a related note, damn my rig has been too busy... This WU has progressed from 92% to 94% in over 24 hours. :eek:

SatanSkin
02-02-05, 12:23 AM
Great work jerme. Now i just need to find out how to implement those......

Christoph
02-02-05, 01:28 AM
Aaarrrggghhh. Must....kill.....homework....

I love what you've done with the XML stuff JerMe. It's so much cleaner and easier to understand. I just hope I get some sleep on the night I finally get time to get into this again. At least I won't be bored.

When you get a chance, I recommend copying in the new color gradient code. Or not. I've got another cool hack planned for it, so you may want to wait. ;) Whatever I end up doing, it'll be backwards-compatible with the current behavior since I won't want all my colorful strings to have the same wierdness.

JerMe
02-02-05, 01:37 AM
Lol I started using the XML because I couldn't figure out regexes for the life of me (: It's easier when some else writes the code and all you have to do is input stuff (drive a car with gas and brake, I don't have to reinvent the wheel)

Hey I just found out about LWP::Simple... it works like this:

use LWP::Simple;
getstore($url,$file);

and you can use it multiple times. Just add the error catching and that's it :) So I guess when we go to grab oc.au's and [H]'s stats we can just getstore() those two and then use XML::Simple to sift through the stuff. Easy!

I'll try your new color code in a second, lemme get oc.au's and [H]'s stats to download to the comp automatically. I gotta see learn your code is catching errors before so I can implement this like you did. I don't know if you know, but in a roundabout way you're teaching me how to code ;)

Edit: tried the new color code from the top of page 4 in this thread, and now it looks like:

Build!.Borg!.Recruit!.Fold.for.Team.32!
JerMe's Folding Stats:____This Rig's Current WU:_
Score:___________16888____{}__92% :.p1141_RIBO_FSpeptide_HEL
Pts (24hr avg):____373____
Pts (7days):_____2,614____
Work Units:________199____
Clients (7days):_____3____
Team 32 rank:______625 (+59 positions in 7 days)
Go to sleep. It's late. I'll tell you how we're doing against the other teams in the morning.
zzz... sleepy... while you sleep, your computer can fold... fold.. fold...

ayudame?

Christoph
02-02-05, 03:58 AM
Edit: w00r. Post #128. Let me reiterate that this thread is nuts.

Hmmm. I don't trust my brain to do more than memorize stuff right now, so here's a copy/paste friendly version of the color functions that color my current sig.
I do remember making some sort of change to the code around the time I posted the version with randomization support, but you'd think I'd update the first post if something were broken. I guess you'd be wrong. :-/
It's due for an update soon anyway.
My favorite feature is the range checking, which means I can set the error to something like 1024 and still get valid (although slightly chaotic) colors.

edit2: I actually remember what bug it was that caused that problem. I spent several minutes hunting it down. One of the subscripted variables shouldn't be subscripted. Change $step[$curr] to $step right before and during the while loop in color_grad, and it should be back to normal. If you're lazy (which is a good thing), you can just copy the code below anyway.

#Given a starting color, an ending color, a total number of steps, the
#current step and an optional error, return the color that corresponds
#to that step in a gradient.
sub color_grad
{
$start_rgb = shift; #"ff00ff"
$end_rgb = shift; #"00ff00"
$last_step = shift; #"36"
$curr_step = shift; #"12"
#error is random variation, in decimal shades
$error = shift;

$error = 0 if (! defined $error);

$curr_step %= $last_step;

for $curr (0,1,2) {

$error[$curr] = (rand 2*$error) - $error;
$start[$curr] = hex(substr($start_rgb,$curr*2,2));
$end[$curr] = hex(substr($end_rgb,$curr*2,2));
$step[$curr] = ($end[$curr] - $start[$curr]) / $last_step;
$color[$curr] = $start[$curr] + $step[$curr]*$curr_step + $error[$curr];

#ensure that the color is within the possible range
while ((0 > $color[$curr]) || ($color[$curr] > 255)) {
$error[$curr] = (rand 2)*$error - $error;
$color[$curr] = $start[$curr]+ $step[$curr]*$curr_step + $error[$curr];
}
#print "start is $start[$curr], end is $end[$curr], step is $step[$curr], color is $color[$curr]\n";
}

return sprintf("%02x%02x%02x",$color[0],$color[1],$color[2]);
}

#Make a string shift from start_rgb to end_rgb, with an optional random error
sub color_string
{
$start_rgb = shift;
$end_rgb = shift;
$string = shift;
$error = shift;
#print "COLOR STRING: passed $string\n";
$error = 0 if (! defined $error);

#ugly bug if this isn't declared my
my $color_string;
$str_len = length $string;
$i=0;

foreach $char (split //, $string) {
$fstr_color=color_grad($start_rgb,$end_rgb, $str_len,$i++,$error);
#vb3 seems to treat individually colored spaces an non-printable
if ($char eq " ") {
$color_string .= "\[color\=\#$invisible\].\[/color\]";
} else {
$color_string .= "\[color\=\#$fstr_color\]$char\[/color\]";
}
}
#print "COLOR STRING: returning $color_string\n";
return $color_string;
}

JerMe
02-02-05, 04:07 AM
i'm getting an unmatched curly, i think the code post ate some spaces

a whitespace popped up at $str_len
$char (split //, $string) {
$fstr_color=color_grad($start_rgb,$end_rgb,$str_le n,$i++,$error);

edit: ok, got it (:

Christoph
02-02-05, 04:17 AM
Wierd. The space only appeared when the thing was posted. It wasn't there either while I was posting or when I went back to edit. I added a syntactically compliant space, and that seems to have pleased the vb3 odds, er gods. ;)

Alright. I've found a nice minimal test case that exposed the bug, and will send a request for attention off to iNet as soon as my brian starts working. ;)

JerMe
02-02-05, 04:18 AM
do you sig my sig in post #129? i don't see it but it's in post #127.. now that's weird

ok here's tonight's sig_gen.pl with the XML stuff so far... I didn't add the error catching or time constraints when grabbing XML files for team24 or team33 yet...

Edit: Made location of unitinfo.txt as a variable, to be entered at top of sig_gen.pl along with username and EOC_ID number. Looks like this:

Build!.Borg!.Recruit!.Fold.for.the.points!.Fold.fo r.the.cure!.Fold.for.Team.32!
JerMe's Folding Stats:____This Rig's Current WU:_
Score:___________20262____{¤¤¤¤¤¤¤¤¤_}__88% :.p1134_RIBO_FSpeptide_EXT
Pts (24hr avg):____224____
Pts (7days):_____1,569____
Work Units:________208____
Clients (7days):_____4____
Team 32 rank:______579 (+21 in 7 days)
overclockers.au is outproducing us by 6600 points today! Join 32 and help us close in!
[H] is outproducing us by 7316 points today! Don't let them beat us! Join 32!

mtb856
02-02-05, 05:45 AM
If that was for me mtb, i meant the whole thing.

:eh?: but I did include the entire thing.... it was right below the code.......

Looks like you got IMOG's to work at any rate.

BTW, Jerme.... I downloaded your sig_gen and I got an error in line 285 when I tried to run it.

It was this area of the code, but I didn't see anything wrong with it.....

#########################
#XML::Simple
#
#where the XML sifting is
#########################

#Slurp in XML file
my $eocstats = XMLin('C:\\mksig\\eocxml.xml');
my $austats = XMLin('C:\\mksig\\au.xml');
my $hstats = XMLin('C:\\mksig\\h.xml');

JerMe
02-02-05, 12:13 PM
I think it's b/c it was looking for your unitinfo.txt in the wrong place, notice how it couldn't find the file, line 63? That's my C:\Program Files\FAH\unitinfo.txt location. Your location was in your D:\ drive, I recall? Anyhoo I made the location as a variable at the top of the file so hopefully that'll make it easier.

I.M.O.G.
02-02-05, 12:19 PM
JerMe, is your sig single? My sig would like to intertwine with your sig and make little sig babies... I love the OCAU and H stats in there. ;)

JerMe
02-02-05, 12:23 PM
lol i'm just posting my sig_gen.pl as an example, rape it all you want, it's Christoph we should be wanting more juicy code from :)

Christoph
02-02-05, 12:46 PM
And I'm wanting to make some more juicy...code. ;) My homework's finally cleared up (for the most part), so tonight should be the night. If anyone's got specific feature requests, please list them here and I'll see what I can't do. If the feature's already been mentioned, mentioning it again won't hurt, since I can't guarantee that I'll catch everything. (I will be looking, though.)

GTFouts
02-02-05, 05:01 PM
WOW, I go away for 3 days and BAM!!!, you guys go crazy!! I love it, I really do. :clap:

BTW, I like what JerMe did alot. Gives me a few Ideas for your major update Christoph. I like what he did at the beginning, i.e. enter your user name, EOC ID, FAH location...ect. SO I was thinking you could do that for all the things that people want.

Things like:
User ID
EOC ID
How many CPU's
Location of each FAH dir.
(and the important ones... :D )
enter the color number for the FAH line
enter the color number for the protien line
enter the number for the status bar
color for the %
color for the titles

Geez, I could go on and on BUT I think at least the first 3 color questions would make people very happy, the FAH, Status and protien names. How you would code it to accept different numbers of FAH directories is beyond me tho. I'm thinking if you make it too user freindly, then how is one to learn, but I've kinda gathered that you like lazy, soooo..... :eek:

Also, and maybe this is asking a bit much, but MANY MANY comment lines does help us non-educated programming hackers understand what you are doing in a certain area for, well, to put it bluntly, complete butchering of you most excellent code. (Yes, I am completely guilty of that one)

Another thing I was thinking was having the percentage change colors as ig gets bigger, like red at the beginning to green at the end or something like that.

One last thing, Great idea about the Sig point check routine. excellent idea!! :attn:

enduro
02-02-05, 05:05 PM
How would I go about reducing the size of the " Build, Borg, Recruit" section down to size=1? It's a little big for my tastes, but BB code won't work in those " " for some reason.

GTFouts
02-02-05, 05:31 PM
enduro, just before Built, right after the quote you put in [ SIZE=1] (without the space of course) and then make sure you put in [/SIZE] at the end before the end quote, that should do it. If it doesn't then use a seperate print statement before and after the things you want to size.

like this:

print "[ SIZE=1]"
the brog lines ect....
print "[/SIZE]"

I've done that before and it worked.

SatanSkin
02-02-05, 05:37 PM
enduro, I could never for the life of me get the size codes to work in the same statement. I had to use seperate statements as GT stated. Good luck.

mtb856
02-02-05, 07:20 PM
I think it's b/c it was looking for your unitinfo.txt in the wrong place, notice how it couldn't find the file, line 63? That's my C:\Program Files\FAH\unitinfo.txt location. Your location was in your D:\ drive, I recall? Anyhoo I made the location as a variable at the top of the file so hopefully that'll make it easier.

That's what I thought it might be too, but I still get the same error now...... one thing I did notice though is that it's not downloading the XML stats for AU or H, just the ocforums.... might that have something to do with it?

enduro
02-02-05, 07:23 PM
hmmmm. Well I tried adding the print statement outside of the entire statement. Inside the statement and then inside the quotes but it didn't work. Just got a load of errors.

JerMe
02-02-05, 07:27 PM
That's what I thought it might be too, but I still get the same error now...... one thing I did notice though is that it's not downloading the XML stats for AU or H, just the ocforums.... might that have something to do with it?

backup your current sig_gen.pl and try this one (the one I'm using right now), hopefully something is different now that'll make it work:

SatanSkin
02-02-05, 07:30 PM
did you put this:

print "";
print "**** yes, I'm cool!"
print "\n";

enduro
02-02-05, 07:35 PM
Yeah, I put them in there. it's actually showing the sig now that I remembered to put the ; in. But it doesn't look any smaller.

mtb856
02-02-05, 07:35 PM
Bingo..... you were right the entire time, I just looked at it wrong.... I had to make a few small changes, but it worked.

This what I had to do for my directory...... I was wondering why it said FAH\unitinfo.txt didn't exist.... I forgot I have two FAH folders to go through.

#---------=======Enter unitinfo.txt location========----------#
for $n (1, 2) {

$unitinfo_loc="D:\\Program Files\\FAH\\FAH$n\\unitinfo.txt";
}
#---------=======Enter unitinfo.txt location========----------#

Thanks for the help troubleshooting Jerme :)



[edit]

hmmm, no errors, but the sig isn't showing up......... :eh?:

Well, I figured it out again....... messed up on my EOC ID, still isn't showing up here yet, but maybe that's b/c I haven't made a new post yet.

JerMe
02-02-05, 07:42 PM
nj with the for loop (:

try deleting everything out of the c:\mksig directory except sig_gen.pl, mksig.pl, and mksig.conf, then try it again?

enduro
02-02-05, 07:46 PM
I give up for now. Onto a new quest. Since I'm a programming newbie; how do I add a color string like there is at the top of the sig with varying colors but at the bottom of the sig. below all of the data.....

JerMe
02-02-05, 07:50 PM
$folding_str = color_string($fstr_start,$fstr_end,"Build! Borg! Recruit! Fold for the points! Fold for the cure! Fold for Team 32!");

print "[ font=monospace][ size=1]$folding_str\n[/size][/font]";

Will print in size 1 all colorful,

Build! Borg! Recruit! Fold for the points! Fold for the cure! Fold for Team 32!

mtb856
02-02-05, 07:51 PM
Okay, should be working now..... this is just to test it.

BTW, how do you get rid of the random color for the "BUILD, BORG...." part if you just want it to color shift evenly?

I couldn't find how you were randomizing it.

Clean_Baldy
02-02-05, 08:14 PM
sig test..

umm.... i followed the instructions. That does NOT look like my folding stats...

I don't wanna read 4 pages to find out what I'm doing... *sigh*

EDIT: Looks like I kinda got it. Now, if only I could edit it to look the way I want it to...

mtb856
02-02-05, 08:16 PM
Welcome to the sig editing club, C_B :)

I'd try Jerme's sig_gen at the bottom of page 4, it's worked the best for me so far. Just copy his sig_gen over the one that you currently have and it should work with a little modification.

mtb856
02-02-05, 08:45 PM
Okay, here's the steps that I took to load it.......
1) Open up Jerme's sig_gen and copy everything in it.
2) Open up your sig_gen.pl and overwrite everything with it.
3) Change Jerme's username to yours, change his EOC# to yours, and change the directory for FAH to whatever it is on your computer (follow the double \\ scheme for going through directories, though).
4) Save and exit the sig_gen.pl
5) Double click mksig.pl to run it and load your new sig.

Clean_Baldy
02-02-05, 08:50 PM
Okay, here's the steps that I took to load it.......
1) Open up Jerme's sig_gen and copy everything in it.
2) Open up your sig_gen.pl and overwrite everything with it.
3) Change Jerme's username to yours, change his EOC# to yours, and change the directory for FAH to whatever it is on your computer (follow the double \\ scheme for going through directories, though).
4) Save and exit the sig_gen.pl
5) Double click mksig.pl to run it and load your new sig.

Thanks! now... I wish I knew how to edit it to look like I want.

Like this:

http://jeff.jonrosensystems.com/sig.JPG

or something like that. Since I am having my computer update every 3 hours, it will always be on track... so, I want to see what I always look for in my sig, so I don't have to go and check...

mtb856
02-02-05, 09:02 PM
You should be able to get that by doing this...

1) go into sig_gen and scroll down (it's near the bottom) until you see a lot of "prints"
print "$folding_str\n";
print "$user\'s Folding Stats:".$spcr3. "This Rig's Current WU:$spcr2\n";
print "Score:$pts". "$f_prog[0] :$f_name[0]\n";
print "--------------------- ".$spcr1. "$f_prog[1] :$f_name[1] \n \n";
print "Pts (24hr avg):$ppd". "$line1\n";
print "Pts (7days):$p7d". "$line2\n";
print "Work Units:$wus". "$line3\n";
print "Clients (7days):$cpu". "$line4\n";
print "Team 32 rank:$rnk ($r7d)". "\n";
print "$ocau_output". "\n";
print "$och_output". "\n ";

2) make a new line after the last one and paste this into it.


print "Points Today: $p2d";


and that will give you the points that you got so far today.... I don't think there's one for points last 24 hours though.

Clean_Baldy
02-02-05, 09:40 PM
^
that didn't work. Not sure why, but nothing new shows up with that code.

Also,

how do I get the numbers to align? they're all over, and un-neat! UNACCEPTABLE! lol
EDIT: I fixed it, by adding this code:

$spcr4= "" . "_" x 2 . "";

and then,

$pts = $spcr4 . "" . "_" x $pts_pad . "" . $pts . $spcr1;
$ppd = $spcr4 . "" . "_" x $ppd_pad . "" . $ppd . $spcr1;
$p7d = "" . "_" x $p7d_pad . "" . $p7d . $spcr1;
$wus = "" . "_" x $wus_pad . "" . $wus . $spcr1;
$cpu = $spcr4 . "" . "_" x $cpu_pad . "" . $cpu . $spcr1;
$rnk = "" . "_" x $rnk_pad . "" . $rnk . $spcr1;


probably the hard way, to manually make the spaces...
but, I don't know coding, but could follow it enough to do it that way :)

mtb856
02-02-05, 10:10 PM
that's what I've been doing..... just looking at the code and figuring out what it does. I've done C++, so that made it a little easier, but it still took a little while to get used to how Perl works...... nice job on the sig :)

JerMe
02-02-05, 11:41 PM
Ok, it's nighttime now, Mr. Coding Christoph, where art thou? :)

I think GTFouts has a lot of good ideas for your new nifty spiffy jiffy code. Here's my wish.. I guess since you have time now, you can parse through EOC and Stanford pages for the different stats available. Seems like everyone has different tastes for what they'd like included in their sig, and it'd be cool for them to just add the $variable name at the bottom, once they know it.

Definitely something to check the sig length, both tall and wide.

Could you add something to snag unitinfo.txt on other computers in the LAN? Perhaps variables at the top for number of folding instances, code to retrieve unitinfo.txt on LANs, and if there are multiple CPUs in the LAN it'd add progress curves in the sig (e.g., 4 CPUs running 1 F@H instance each around the house, 4 locations, it'd add 4 progress curves automatically.. or something to that effect?) Some people might like that.

For the XML, I was using XML::Simple, so there's definitely more stuff that you can do with the XML functions, I just don't know it... I'm sure you'll take that to the nth level..

Please please please rewrite the EOC parsing code, if you'd like you can write mod-friendly regexes that make it easy for us to grab the stats we need off of the EOC summary page (like points 7 days and points last 24 hours). When I wrote it, a lot of people were having trouble with it.

I know I added (hacked up) stuff to your code, so if you'd like to use any of it, use the idea of it, etc. feel free. If I can help in any way at all, just say the word. We're waiting for your next code! (:0

Seven
02-02-05, 11:53 PM
Woah. Some of you guys are...wow. Incredible what you guys have done.
Now if somebody could just condense the knowledge gained in this thread, I think we'd all be served...something like Wedo's One Click Guide?

Include user examples, etc.

7

/thanks JerMe for the stats man

Christoph
02-03-05, 12:28 AM
I'm around. I think I accidentally got a test version of my new gradient code hack working, so something that works in a sig_gen should be coming up shortly.

The only bad thing is that I wrote a really sexy line of code, but I then realized that I didn't actually need it. I'll post it here, just because I like it that much. What it does is assign the nth element in the second list to the nth element in the first list if the condition is true. It's a slick way to swap two variables without using a temporary third one. It'd take 5 or so lines of code in languages like C or java, and wouldn't be nearly as clear. If you know lisp or scheme, this will be very familiar to you. Most of you probably don't, though. ;)
($max,$min,$range) = ($min,$max,-$range) if ($range < 0);

Anyway, once the gradient hackery done, I'll got nuts with stats, length checking, throwing the seti guys a bone*, updating the first post of this thread and whatever else I find or can think of.

*This is mainly an excuse to link to something in the folding forum from the seti forum. I don't plan on defecting. ;)

Clean_Baldy
02-03-05, 01:11 AM
how do I add color to my score?

Can you post up your code to turn your WUs yellow like that?

JerMe
02-03-05, 01:27 AM
*This is mainly an excuse to link to something in the folding forum from the seti forum. I don't plan on defecting. ;)

LOL, though it is a way to nab Seti defectors for the fold ;) just joking heh, it'll be nice to have your code spread like jam over the OC Forums.

@C_B, to color your WUs and whatever else you'd like, it's a forum thing, so don't worry. The easiest way would be the same way we color stuff here in the forums, with the [c olor] tag (no space between the c & o of the word color.) So in the sig_gen, go to the area where the "Print Code" is, and put the following:

print "Work Units:[co lor=yellow]$wus". "[/color]\n";

that should do it. The same applies for the [si ze] and [fo nt] tags (again, no spaces, they should read as color, size, and font, between the [].) Don't forget to close your tags off like [/color] otherwise the sig will go haywire.

so, for example, if you wanted in your sig Orange Size 1 Courier New you'd code

print "[CO LOR=Orange][SI ZE=1][FO NT=Courier New]Orange Size 1 Courier New[/FONT][/SIZE][/COLOR]";

again without the spaces in the open tags.

Christoph
02-03-05, 02:20 AM
I'm in disbelief at how long that took. The important thing is that it works and it's backwards-compatible with the previous way of using it. Fortunately, I've only got one (basically non-interactive) class tomorrow, so I can pretend that sleep is for the weak. :D
It's now possible to define an abritrary function and number of periods for your colored strings. For instance, if you want a string to go in a cool wavy pattern, do this:
$folding_str = color_string($fstr_start,$fstr_end,"Build! Borg! Recruit! Fold for the points! Fold for the cure! Fold for Team 32!",0,4,sub {my $x = shift; abs(sin($pi*$x))});
and you'll end up with:
Build!.Borg!.Recruit!.Fold.for.the.points!.Fold.fo r.the.cure!.Fold.for.Team.32!

edit: The effect is also pretty cool if you use the default function but more periods:
Folding.for.team.32!

More changes to come soon. I'll post everything when I'm done for the night. It will be documented better too. ;)

Christoph
02-03-05, 03:07 AM
I'm quickly realizing that checking for compliance with the sig rules is going to be a little more than a 1-night project. I'm trying to figure out how to keep it as simple as possible (but no simpler), but I think I'll need to hack out a full-blown lexer for this, even if it's just a simple one.
For now, the rules checker is going on the back burner, but non-trivial enough enough that I'll eventually get it working.
Ironically, I think my code will have to do more work than the code vb3 uses to turn bbcode into html.

JerMe
02-03-05, 03:37 AM
That new color gradient looks nice.

I'm bored, just playing with ascii art. I don't know how the forum rules apply to ascii art in sigs, as I can imagine someone hacking the code to import an ascii-ized picture soon enough. I figure if the rules say you can have 13 lines of size=1 font, that'd be enough to put a picture in.

Edit: i'm afraid the sig rules (http://www.ocforums.com/showthread.php?t=58341) are going to have to be changed to clarify about ascii pictures. With all the color changing along with the number of ascii characters in ascii art, these sigs in mass can have a potentially hefty toll on the server. The ascii art below, along with the color gradient, runs at 18kb according to the sig.log generated . So imagine ~18kb per post for sigs, on top of the avatars and the posts themselves. It adds up.

I think for the forums sake, can you have the code check for sig kb size, and flag if it's over a certain threshold?

Christoph
02-03-05, 05:18 AM
I'm working on putting together a nice generic sig_gen based about half on what JerMe posted and half on other stuff, but it's not quite there yet. I've got a paper todo list so everything's in one place and *much* harder to lose.

Here's the modified color_string code. It's designed to work as a drop-in replacement for the previous code. It should also be well documented enough for general use, although the inner parts could use some more comments.


################################################## #############################
#color_string:
#This function returns its third argument (a string) with color tags, as
#specified by its other parameters.
#
#Usage: color_string($rgb_i, $rgb_f, $string, $err, $pds, $fun)
#$rgb_i : hex triplet (eg "ff00ff") indicating the color to start with
#$rgb_f : hex triplet indicating the color to stop with
#$string : the string to add color tags to
#
#All arguments below are optional, but you can't use one without using the ones
#before it. eg you need to specify $err and $pds in order to specify $fun.
#
#$err : 0-255 - add/subtract random fluctuations between 0 and $err to each
# color. The colors will always be valid, even if $err is large.
#$periods : how many times to cycle from $rgb_i to $rgb_f
#$fun : specify the function used to move between $rgb_i and $rgb_f
#
#Examples of valid usage:
#
#$pi = atan2(1,1)*4; #standard definition
#$str = color_string("ff00ff", "ffff00", "Like, wow.");
#$str = color_string("ff00ff", "ffff00", "Like, wow.", 15);
#$str = color_string("ff00ff", "ffff00", "Like, wow.", 15, 2);
#$str = color_string("ff00ff", "ffff00", "Like, wow.", 15, 2,
# sub {my $x = shift; return abs(sin($x*$pi))} );
################################################## #############################

sub color_string
{
$start_rgb = shift;
$end_rgb = shift;
$string = shift;
#optional args below
$error = shift;
$error = 0 if (! defined $error);

$periods = shift;
$periods = 1 if (! defined $periods);

$fun = shift;
$fun = sub {my $x = shift; return ((255*$x % 256)/255);} if (!defined $fun);

#ugly bug if this isn't declared my
my $color_str;
$str_len = length $string;
$i=0;

foreach $char (split //, $string) {
$fstr_color=color_grad($start_rgb,$end_rgb,$str_le n,$i++,$error,$periods,$fun);
#vb3 seems to treat individually colored spaces an non-printable
if ($char eq " ") {
$color_str .= "\[color\=\#$invisible\].\[/color\]";
} else {
$color_str .= "\[color\=\#$fstr_color\]$char\[/color\]";
}
}
#print "COLOR STRING: returning $color_str\n";
return $color_str;
}


################################################## #############################
#color_grad_fun:
#This function returns a single hex triplet based on the parameters passed to
#it.
#
#Usage: color_grad_fun($rgb_i, $rgb_f, $curr, $err, $pds, $fun)
#$rgb_i : hex triplet (eg "ff00ff") indicating the color to start with
#$rgb_f : hex triplet indicating the color to stop with
#$curr : a number between 0 and 1 indicating how far through the gradient
# the color is.
#
#All arguments below are optional, but you can't use one without using the ones
#before it. eg you need to specify $err and $pds in order to specify $fun.
#
#$err : 0-255 - add/subtract random fluctuations between 0 and $err to each
# eg you need to specify $err and $pds in order to specify $fun.
#
#$err : 0-255 - add/subtract random fluctuations between 0 and $err to each
# color. The colors will always be valid, even if $err is large.
#$periods : how many times to cycle from $rgb_i to $rgb_f
#$fun : specify the function used to move between $rgb_i and $rgb_f
# Default: 0
#$periods : how many times to cycle from $rgb_i to $rgb_f
# Default: 1
#$fun : specify the function used to move between $rgb_i and $rgb_f
# Default: constant increase
################################################## #############################

sub color_grad_fun
{
my $start_rgb = shift; #"ff00ff"
my $end_rgb = shift; #"00ff00"
my $curr_step = shift; #floating pt number between 0 and 1. inclusive

#OPTIONAL ARG: error is random variation, in decimal shades
my $error = shift;
$error = 0 if (! defined $error);

#OPTIONAL ARG: how many times to cycle through the above function
my $periods = shift;
$periods = 1 if (! defined $periods);

#OPTIONAL ARG: function with a period of 1 and a range 0-1 to determine color distribution
my $fun = shift;
#This function has the same behavior as the previous implementation.
$fun = sub {my $x = shift; return ((255*$x % 255)/255);} if (!defined $fun);

$error /= 255;

for $curr (0,1,2) {

$min = hex(substr($start_rgb,$curr*2,2)) / 255;
$max = hex(substr($end_rgb,$curr*2,2)) / 255;
$range = $max - $min;
$funval = &$fun($curr_step*$periods);

#print "max is $max, min is $min, range is $range, step is $curr_step,";
$color[$curr] = ($min + $range*$funval);

if ($error == 0) {
$my_error = 0;
} else {
$my_error = (rand 2*$error) - $error;
}

while (($color[$curr]+$my_error) < 0 || ($color[$curr]+$my_error) > 1) {
$my_error = ((rand 2*$error) - $error);
}
#at this point, $my
#print "using error of $my_error, max is $error\n";
#$norml = $color[$curr]*255;
#print "normal color is $norml, ";
$color[$curr] += $my_error;
$color[$curr] *= 255;
#$color[$curr] = sprintf("%.0f",)
#print "color is $color[$curr]\n";

}
return sprintf("%02x%02x%02x",$color[0],$color[1],$color[2]);
}


################################################## #############################
#color_grad:
#This function returns a single hex triplet based on the parameters passed to
#it. This function is just a wrapper for color_grad_fun. Either can be used.
#
#Usage: color_grad($rgb_i, $rgb_f, $step_f, $step_c, $err, $pds, $fun)
#$rgb_i : hex triplet (eg "ff00ff") indicating the color to start with
#$rgb_f : hex triplet indicating the color to stop with
#$step_f : how many total steps in the gradient (ie step_final)
#$step_c : the number of the current step; if this is half of step_f, the color
# returned will be halfway between rgb_i and rgb_f
#All arguments below are optional, but you can't use one without using the ones
#before it. eg you need to specify $err and $pds in order to specify $fun.
#
#$err : 0-255 - add/subtract random fluctuations between 0 and $err to each
# color. The colors will always be valid, even if $err is large.
#$periods : how many times to cycle from $rgb_i to $rgb_f
#$fun : specify the function used to move between $rgb_i and $rgb_f
################################################## #############################
sub color_grad
{
$start_rgb = shift; #"ff00ff"
$end_rgb = shift; #"00ff00"
$last_step = shift; #"36"
$curr_step = shift; #"12"
#error is random variation, in decimal shades
$error = shift;
$periods = shift;
$fun = shift;

return color_grad_fun($start_rgb,$end_rgb,$curr_step/$last_step,$error,$periods,$fun);
}

edit: The stupid code tag code keeps adding spaces. We hates it.

JerMe
02-03-05, 05:37 AM
cool, more code.. must have more code... *inhales code*

doh, the [co de] tag did the $str_le n thing again with the whitespace

Christoph
02-03-05, 05:41 AM
JerMe, I was actually thinking about that. It wouldn't have been an issue before because nobody would be patient enough to code 20K worth of bbcode, but now it takes very little effort. Also, the html seems to be about 20% larger than the bbcode, and the html in that sig of yours weighs in at about 23.6KB a pop (although it is unbelievably cool).
My thinking is that if iNet cared a whole lot about bandwidth, they wouldn't have switched to vb3, the pages of which are much more bloated than they were under vb2.
It could become a problem, though, since posting 5 times in a thread and forgetting to turn off your sig will mean an extra 100K to load. I can live with it, but it'll kill people stuck on dial up.

Fortunately, checking the size of the bbcode that mksig sends is almost trivial, as opposed to checking for things like size tags and smilies. The only problem I foresee is that people will be running this non-interactively (ie as a service whose output won't be seen). If mksig spits out warnings, they won't be seen except when it's run manually, and if it refuses to send a sig people won't know why.
In spite of that, I think I will have it spit out a warning at 15KB+ of bbcode and refuse to submit anything 25KB or bigger. I don't want to be at fault for making excessively slow page loads for 56kers.

At any rate, sleep may be for the weak, but I'm weak. Good night. (Or morning. Whatever.)

JerMe
02-03-05, 05:47 AM
that'd be a good idea. i'm playing with the sig right now since its early in the morning and traffic is minimal, but before i go to bed i'm reverting back my old sig_gen.pl to conserve the board's bandwidth (and yes also to save poor dial-uppers.) I don't think you'd be at fault for someone else's coding if they manage to create a sig too large.

i'm going through your new code now to see if the shoe fits

edit: at the closing curly of sub color_grad there is

} color. The colors will always be valid, even if $err is large.

which needs to be taken out. It compiles now, lemme play with it.

Edit: Ok, my current sig just barely complies with sig rules. It is viewable with at 800x600 resolution, is 13 lines of size=1, and the sig.log generated is 11.5kb, which makes it 13.8kb after ~20% markup, so it's half the size it used to be. This is a fricken awesome idea. I'm totally hooked.

BC|Wulf
02-03-05, 09:23 AM
I lvoe all the coding that is going on. I wish I had time to help out code it. I will help test it though! ;)

Christoph
02-03-05, 06:46 PM
I'm no programmer...


You lie!

JerMe
02-03-05, 06:50 PM
You lie!

LOL I'm not!!!! Okok, here's my secret. In college I wanted to jump ship from biochem to EE, so I took a java class at a local community college, so I know a little bit. But it's been a long time since, so reallly, all I did was read your code, read the Perl link you posted in the OP, and read a lil more online about ascii pictures. Then VOILA! So really, I'm no programmer. (:0

Edit: A BASIC first semester summer session java course at a community college.. READ: a little bit of java =X

Edit2: I just posted in the sig discussion thread (http://www.ocforums.com/showthread.php?p=3424777#post3424777) about the use of ascii art in sigs. My guess is that the mods will disallow the use of any pictures in sigs. I also moved to have the resolution rule increased from 800x600 to 1024x768. We'll see what happens.

In a nutshell, here's what I added:

$file_pic = 'C:\\mksig\\dnacolor.txt';
open(INFO, $file_pic);
@lines = <INFO>;
chop(@lines);
close(INFO);

so I learned about basic file handling, chop, and printing a simple array.

Must... have.. more.. code...

mtb856
02-03-05, 07:34 PM
ROFL, that's almost exactly my same story.... I was going into Mech. Engineering and I decided to switch over to EE. I took C++ in preparation for Java (which I found out later isn't required for EE at my college), but other than that I've had absolutely no programming experience.

Deja vu' :D

Christoph
02-03-05, 07:51 PM
Alright. I've got some size checking code working. It's really ugly and slow, but you can rest assured that it's not evil according to Knuth ("Premature optimization is the root of all evil.").
I'm going to try to get it working a little faster, and should have an update to mksig sometime later tonight. As it turns out, I didn't need to write out a full-blown lexer, although the code would definitely have been easier to understand.

JerMe, I'd appreciate it if you could email/PM me the bbcode for your sig. It'd be a great way to stress-test what my size checker, and if it runs fast on your sig it'll be fast on anything.

mtb856
02-03-05, 07:54 PM
I'm scared to update..... I don't know how big my sig is :D

Christoph
02-03-05, 08:03 PM
The rules I based the checker on are here (http://www.ocforums.com/showthread.php?t=58341). Luckily, checking by hand is much easier than making a Perl script do it. I think you're at 8 points.

Christoph
02-03-05, 08:52 PM
To clarify, what I'd like is the code that's sent to the forums, not what was added to your sig_gen. ie the stuff that if you put it in a post would reproduce your sig.

Also, I'll explicitly say when the length checking code is added, and it will be optional when it's there. It's not quite ready for prime time yet, although I did manage to get it to run in 1/7 the time of the original.

BatousaiRyu
02-03-05, 11:05 PM
any way to make the text in the output slightly larger then it is?

Christoph
02-03-05, 11:15 PM
Sure. Just change (or add) the size tags. Since you're at 10 lines, you can use size 2 and still be in compliance with the sig rules. Unfortunately*, you can't do anything more fine-grained than that.

*Or fortunately if you're writing a script to figure out rules compliance. ;)

Christoph
02-03-05, 11:57 PM
It's beta testing time!
I think that my length tester works correctly, but I want some beta testing done. To all interested members, please download this file (http://gladstone.uoregon.edu/~cotto1/ochosting/sig_check) and run it on your sig, which is stored in mksig's home along with your sig_gen, etc. To run it, just do sig_check sig and check by hand that it matches your sig. (Checking by hand only takes about 15 seconds once you know the rules.) If it doesn't, please add the argument "1" to the end to enable debugging output, run it and send me the output and your sig.

Also make sure to post something if your sig takes longer than a second to parse. The last few things I added seem to have made the code quite fast and no run has taken more than .2 seconds.

For each violation of the rules, it adds 100 points to your size, so you should be able to tell how many violations you have (if any) and how big your sig would be without them.

edit: Woah. You brought skip back from the dead. Cool trick.

edit2: I should also note that the script does no kind of checking how the sig will look at 800x600. Instead it assumes you have an infinitely wide monitor. I've got one. They're pretty cool.
Line length is browser-dependent and would be a huge pain to do, since the widths of characters vary between different characters and different fonts, and there aren't even any guarantees about which font will be used.

FizzledFiend
02-04-05, 06:45 AM
I am a bit confused as to what I need to do after I set the task to working daily

I.M.O.G.
02-04-05, 09:29 AM
Before you set the task, you should run mksig.pl and just make sure that your sig is being created successfully. If you have tested that, then you should go on to creating the task entry.

Once you have the task created, you need to right click on it and select properties. Then click on the schedule tab, then click on the advanced button - this will tell the task how often the task should repeat.

JerMe
02-04-05, 06:48 PM
It's beta testing time!
I think that my length tester works correctly, but I want some beta testing done.

Cool, I get drunk one night, come back the next day and find more code to play with. Bwuahaha~ I'll check it out, after the movies. Great job once again.

edit: Woah. You brought skip back from the dead. Cool trick.

Yeah, I was surprised by the turnout. Different color people responding, it was kinda cool (:0 Seems like they're giving the OK for ASCII sigs, but the 800x600 resolution might stay (blah).

edit2: I should also note that the script does no kind of checking how the sig will look at 800x600. Instead it assumes you have an infinitely wide monitor. I've got one. They're pretty cool.

I gotta get me one of these!

Clean_Baldy
02-04-05, 09:20 PM
I just realized that my computer isnt updating when it runs the program...

the numbers keep staying the same.

Any ideas?

FizzledFiend
02-04-05, 10:26 PM
test it how? I know less about codeing as i do women and god knows they are elusive to me.

JerMe
02-05-05, 02:43 AM
Ok, attached is the output from sig_check.pl v0.21. All lines are size=1 in the sig, which should correspond to 0.75 points each

JerMe
02-05-05, 02:44 AM
And here's the sig file

while ($line ne "") {
#size_open, /\[size=(\d*)\]/i
if ($line =~ /^\[size=(\d*)\]/i) {

$line =~ s/^\[size=(\d*)\]//i;
$size_tag = $1;
print "found a size tag on line $curr_line: $size_tag\n" if $debug;

#size 1 = .75 points
#size 2 = 1 point
#size 3 = 1.5 points

if ($size_tag == 1) {
$curr_size_tag = .75;
} elsif ($size_tag == 2) {
$curr_size_tag = 1;
} elsif ($size_tag == 3) {
$curr_size_tag = 1.5;
} else {
print "Warning: large size tag found on line $curr_line: $size_tag\n";
$curr_size_tag = 1.5;
$curr_size += 100;
}

$using_tag_size = 1;
$curr_size = max($curr_size_tag, $size_tag);
$size_state = $curr_size_tag;

the $curr_size_tag = 0.75, and the $size=tag = 1. sub max checks which one is bigger, is returning "1", and the print "line size is $curr_size\n" is outputting "1" rather than "0.75"... unless i'm trippin out and that line is not size=1?

JerMe
02-05-05, 02:52 AM
I just realized that my computer isnt updating when it runs the program...

the numbers keep staying the same.

Any ideas?

Can you post your sig_gen file? I'm not sure if your stats are pulling from EOC's html page or the xml page, but yeah it seems like you're sig is 50 WUs outdated. Good Lord, you have more points this week than I have TOTAL. :drool:

JerMe
02-05-05, 03:12 AM
test it how? I know less about codeing as i do women and god knows they are elusive to me.

i see a blank space below the quotes in your sig, so i'm assuming that's where you're trying to put your folding stats. is this correct?

to test in real-time, just navigate to c:\mksig and run mksig.pl. you can either do this from the command line in windows via start -> run -> cmd, through the actual run window and c:\mksig/mksig.pl, or just double click on the mksig.pl file in windows explorer. mksig.pl will then do it's dance, and you'll see the output onscreen. if it's going haywire, something's probably coded wrong in your sig_gen.pl file. if it seemed to go smoothly, go the ocforums.com and see if your sig printed out correctly.

if you say you know little about coding, you might have a hard time getting started editing sig_gen.pl with the information you'd like to show, in the format you'd like to show it. in this case, i'd sit around a bit and wait for christoph to post a nice, generic sig_gen.pl that everyone will love. then all you'd have to do is download that, follow the instructions for modifying it, then you'll be on your way with your super sig stats.

when you're confident your sig isn't going to mess up in the middle of the day, you can have task manager update your sig automatically.

christoph's has a new handy-dandy sig size checker in beta, called sig_check.pl. sig_check.pl will check the "sig" file in your c:\mksig directory to see if it complies with the forum signature rules. you'll have to download itinto your c:\mksig directory, run it through the command line (again, start -> run -> type "cmd" -> type "cd\mksig" -> type "sig_check.pl sig") and see what the final line says. you'll want the final thing to say, "your sig size seems to be 10", since the rules say we get 10 points for our sig size.

if the output line doesn't seem right to you, type "c:\mksig\sig_check.pl sig 1" so that it'll show you what it's thinking while it's thinking it. if you think it's buggy (its still beta), post a screenshot like i did, as well as the "sig" file (rename it to sig.txt and attach, or host it outside).

FizzledFiend
02-05-05, 07:07 AM
LOL where am i suppose to put this code?in my sig.log I have this
sig for 02/04/2005, 07:34 is:

sig for 02/04/2005, 15:00 is:

sig for 02/05/2005, 05:00 is:

sig for 02/05/2005, 08:06 is:

GTFouts
02-05-05, 09:58 AM
Thats just a log that shows when and what was submitted as your sig. Evidently your sig_gen.pl isnt working correctly. You can do 1 of 2 things here:

1. You can read thru this whole thread to see what you may be doing wrong.

2. You can attach your sig_gen.pl file so those of us here can take a look and see what it is doing wrong.

Some of us can help a little, some alot. Give us a try...:) (I'm only in the little catagory)

FizzledFiend
02-05-05, 10:07 AM
added .txt so i could upload it..obviously just drop that off...I never done anything to this so maybe here is where the problem is?
also is there something I am suppose to do in my usercp here on the board?

FizzledFiend
02-05-05, 10:09 AM
BTW GTFouts I like the way yours looks the best so far..I can actually read that one quite well.

Clean_Baldy
02-05-05, 10:47 AM
Can you post your sig_gen file? I'm not sure if your stats are pulling from EOC's html page or the xml page, but yeah it seems like you're sig is 50 WUs outdated. Good Lord, you have more points this week than I have TOTAL. :drool:

here is the link to my file:

http://jeff.jonrosensystems.com/sig_gen.pl

when i run it manually, it says "checking to see if sig should be updated:" and it says NO! :(

Hopefully that is a clue to what needs to be fixed :)

GTFouts
02-05-05, 11:17 AM
FizzledFiend what is your folding user name?

How many clients do you run?

What is the directories your FAH is installed in?

Christoph
02-05-05, 11:39 AM
here is the link to my file:

http://jeff.jonrosensystems.com/sig_gen.pl

when i run it manually, it says "checking to see if sig should be updated:" and it says NO! :(

Hopefully that is a clue to what needs to be fixed :)

That just means that it won't nuke your current sig_gen. It will always update your sig when it's run. That's what "building sig..." means. ;)

Christoph
02-05-05, 12:03 PM
Heh. When any of you need to post a sig_gen.pl and have non-homebrew hosting, make sure to rename it to sig_gen.txt so the server doesn't try to run it and send the results.

The sig checker has been fixed (now at v.22), although I ought to be shot for the way I named some of those variables. It should also be a little easier to read through now, if you're into that. Parsing code isn't usually pretty, but I want to take a shot at making it as clean as possible before adding it to mksig.
Also, please post if you've tested it and it works fine.

GTFouts
02-05-05, 01:06 PM
Hmmmm...I don't think I am running the sig check properly. What exctly am I looking for? It runs so fast that it just flickers the perl window.

Christoph
02-05-05, 01:23 PM
Download and run sig_check sig in the dir where mksig lives . It will output two lines that look something like this:
sig_checker v.22
Your sig takes up 66 B and seems to be of size 0.75.
but with a different numbers on the second line. To me it looks like it's all at size 1. Your size should be 7.75 if I'm guessing your size correctly. If it's not, run sig_check sig 1 and post your sig here.

Note that blank lines count at size 2 (1 point).

edit: The file is here (http://gladstone.uoregon.edu/~cotto1/ochosting/sig_check).

JerMe
02-05-05, 02:29 PM
added .txt so i could upload it..obviously just drop that off...I never done anything to this so maybe here is where the problem is?
also is there something I am suppose to do in my usercp here on the board?

When you go to the c:\mksig directory, the icon for your "sig_gen.pl" file looks like a gekko, right? i just tried your sig_gen.pl file (after chopping off the .txt of course) and it worked on this end.. what files are listed in your c:\mksig directory? if you're using that sig_gen.pl file, then you should have mksig.pl, mksig.conf, sig_gen.pl, sig.log, and sig.

i don't think you need to modify anything in your user profile here, just answer the questions correctly when you first run mksig.pl so that it can access the forums.

here is the link to my file:

http://jeff.jonrosensystems.com/sig_gen.pl

I can't see it ):0

@Christoph: w00t, sig_checker.pl works for me. It's reporting a size of 11773 bytes, and windows explorer reports 11.4kb.

GTFouts
02-05-05, 03:23 PM
OK...I dloaded the file, changed it to sig_check.pl, went into start>run, browsed to the mksig dir, selected sig_check.pl, got back to the run window, added sig to the end (C:\mksig\sig_check.pl sig) and ran it. the perl window flickers and thats it. Then I ran mksig.pl and it added the file "sig" to the mksig dir. I opened the sig file and its just the code that gets sent for my sig. So far it all makes complete sense to me except the 2 line output you are talking about. I can't find that anywhere, nor do I see it when anything runs. Am I just not looking in the right place? Where exactly are these 2 output lines outputted too? Thats what is confusing me...I can't find them anywhere or see them in any window.

Gautam
02-05-05, 03:29 PM
Very sweet

Awesome work! :thup:

JerMe
02-05-05, 03:30 PM
OK...I dloaded the file, changed it to sig_check.pl, went into start>run, browsed to the mksig dir, selected sig_check.pl, got back to the run window, added sig to the end (C:\mksig\sig_check.pl sig) and ran it. the perl window flickers and thats it. Then I ran mksig.pl and it added the file "sig" to the mksig dir. I opened the sig file and its just the code that gets sent for my sig. So far it all makes complete sense to me except the 2 line output you are talking about. I can't find that anywhere, nor do I see it when anything runs. Am I just not looking in the right place? Where exactly are these 2 output lines outputted too? Thats what is confusing me...I can't find them anywhere or see them in any window.

output is everything after you type the commands "sig_check.pl sig" or "sig_check.pl sig 1". if you don't see anything after you type the commands is what christoph would like to know, so he can tweak the code. hopefully everythign is a-ok and he won't need to change much after this.

GTFouts
02-05-05, 03:55 PM
See there..if you wouldn't have put that screen capture of you using the command prompt window I would have just gave up. My problem was I was running it from within windows using the Start>Run window, not the command prompt window....DOH!!! So of course I couldn't see anything cause windows shuts down the window as soon as the prg was finished...hence the flicker...fast prg for sure!

Mine outputs:

sig_checker v.22
Your sig takes up 3903 B and seems to be of size 9.

Looks like it works ok to me.

Christoph
02-05-05, 04:14 PM
Cool. I'll be adding the sig checker to mksig as soon as I'm done with the generic seti and folding sig_gen scripts, at which point I'll update the documentation in the first post. I'm shooting for having the first three done by Sun evening. I apologize to any newbies who see more than 200 posts worth of info to filter through, but the documentation will be done when I can get to it.

FizzledFiend
02-05-05, 05:29 PM
FizzledFiend what is your folding user name?

How many clients do you run?

What is the directories your FAH is installed in?

FizzeldFiend
C:\Program Files\FAH

GTFouts
02-05-05, 05:47 PM
FizzleFiend, give this a try. I take it you are only running 1 instance of FAH, so this is modified for just the FAH directory and not for the FAH\FAH1 and FAH\FAH2 directories. It might work, can't promise tho. It is close enough that you should be able to figure out the rest.

Dont forget to rename this as sig_gen.pl

FizzledFiend
02-06-05, 12:11 AM
okies now that i replaced my old one with your new one do i need to do anything in the user cp?

Christoph
02-06-05, 01:37 AM
You don't need to touch the user cp. Once you've given mksig your info (username/password/prefs) and got sig_gen so that it outputs some cool bbcode when you run it, just run mksig and it'll take care of the rest.

GTFouts
02-06-05, 07:00 AM
Christoph. I have a question about the "sub color_grad" section.
On these 2 lines:

$start_rgb = shift; #"ff00ff"
$end_rgb = shift; #"00ff00"

There are color numbers in there, yet if I enter different color numbers in the string declaration at the beginning, the "sub color_string" section will use those instead of what is in the "color_grad" section. (This is a good thing, and am glad it's that way.)
For example:

#starting/ending color for folding line
$fstr_start = "97ffff";
$fstr_end = "ff00ff";

these are used for this line

$folding_str = color_string($fstr_start,$fstr_end,"Folding for team 32 in Loving memory of my Father!");

My question is, what are the color numbers for in the "sub_grad" if it uses the string colors you entered in the variable instead?

Since I am assuming that the GRAD function is where it determines what the step colors will be, and the STRING function is where it puts together all the different colors of the letters, I am a bit confused as to why it doesn't use the colors defined in the GRAD lines. Just curious is all. Trying to understand it a little more so as to play with it some without totally destroying it.

FizzledFiend
02-06-05, 09:47 AM
why can't I get this to do properly seems I have done everything I should then ARGH..code is for a different mind...who is going to make an 1 click for this..input user names and passwords and your folding directories and blhamo it makes your cool sig?

Christoph
02-06-05, 09:54 AM
The stuff after the # is just comments with examples of possible valid parameters. IIRC, I put them in there earlier so wouldn't forget what the parameters were supposed to look like.

FizzledFiend: I've got the generic SETI@Home script all done, so a pretty (although not mind-boggling) fill-in-the-blanks F@H script is next on the agenda.

JerMe
02-06-05, 10:05 AM
Christoph, have you taken firewalls into account for your mksig.pl? If the firewall is blocking Perl.exe, mksig still goes through the motions of "logging in... logging out".

FizzledFiend, when you run mksig.pl, what does your screen say?

Edit: Try this sig_gen.pl for now (lob off the .txt at the end), it's my current one, but edited with your folding information. I looked up your Folding name and EOC_ID, so all you have to do is drop it into your c:\mksig directory and run mksig.pl. The font size is small, but if it works for you, then you can move on to bigger and better things. If it doesn't work, you can try wipe out the c:\mksig contents and download the newest mksig.pl that Christoph just posted (http://gladstone.uoregon.edu/~cotto1/ochosting/mksig.txt).

Edit2: oops fixed now

Christoph
02-06-05, 10:56 AM
Thanks for finding that. I've added a couple cases that will explicitly fail and exit when the script can't connect. I can't (or don't have the patience to) test them with a firewall, but they die correctly when I disconnect from my LAN. That can only mean...

update time
The current version is .63 and can automatically be upgraded with autoupdate enabled. As mentioned above, mksig will now fail and exit when it can't connect, instead of pretending that everything's alright.

Also, any crunchers in the vicinity will find a new script in the first post.

JerMe
02-06-05, 11:03 AM
I just updated to your newest mksig.pl, I could have sworn that "none needed" flashed before my eyes.. can you try a v0.62 autoupdate against a v0.63 and make sure I'm not trippin out?

edit: i speak good english in the morning, ugh. saw the new seti script on the OP. nice job once again, those seti guys should be bouncing around in their boinc-y chairs. :p help with regexes again?

here's the (relevant part of the) source for my eoc summary page that i'm grabbing some stats off of..

<th>Rank<div class='tblsub'>Team</div></th>

<th>Points<div class='tblsub'>24hr Avg</div></th>

<th>Points<div class='tblsub'>Last 24hr</div></th>

<th>Points<div class='tblsub'>Last 7days</div></th>

<th>Points<div class='tblsub'>Today</div></th>

<th>Points<div class='tblsub'>Week</div></th>

<th>Points<div class='tblsub'>Total</div></th>

<th>WUs<div class='tblsub'>Total</div></th>

</tr><tr bgcolor='#FFFFFF'>

<td align='right'>601</td>

<td align='right'>374</td>

<td align='right'>0</td>

<td align='right'>2,619</td>

<td align='right'>0</td>

<td align='right'>0</td>

<td align='right' bgcolor='#EFEFEF'>18,693</td>

<td align='right' bgcolor='#EFEFEF'>203</td>

and here's what I'm using to parse it

for ($p7d) {
s/[\n\r]//g;
s/.*WUs.*Total//g;
s/<td align='right'>[\d,]*<\/td>//;
s/<td align='right'>[\d,]*<\/td>//;
s/<td align='right'>[\d,]*<\/td>//;
s/\D*//;
s/([\d,]*).*/$1/;
}

I suck at regexes. I'm looking for the 4th stat, "2,619", which is points in the last 7 days. Can you shorten out that code to look for the same thing?

Edit.. I think I got it now... I'm arraying all the variables from the 4 different tables...

FizzledFiend
02-06-05, 12:14 PM
this is a test, and only a test. if this actually works I will be impressed :)

ok douwnloaded the new stuff. grabbed your file and removed the [1].txt part of it

still looks like I am skipping a step..I get no pop-up telling me anything..should I be doing something in dos?

FizzledFiend
02-06-05, 12:24 PM
Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.

C:\Documents and Settings\Fox Roshak>cd C:\mksig

C:\mksig>sig-gen.pl
'sig-gen.pl' is not recognized as an internal or external command,
operable program or batch file.

C:\mksig>mksig.pl
Checking for updates...failed
Could not get update from server: Unknown error
This session will modify FizzledFiend's sig.
checking if your sig_gen should be updated...no
building sig...Couldn't download Stanford's page. at C:\mksig\sig_gen.pl line 13
3.
Use of uninitialized value in concatenation (.) or string at C:\mksig\mksig.pl l
ine 245.
Use of uninitialized value in string at C:\mksig\mksig.pl line 250.
OK
Use of uninitialized value in split at C:\mksig\mksig.pl line 513.
Use of uninitialized value in length at C:\mksig\mksig.pl line 257.
checking sig length (will enforce rules)...OK
logging in...failed
failed to retrieve login page.
Please make sure that Perl can connect to the outside world.

C:\mksig>

Christoph
02-06-05, 03:06 PM
Two things: First, sig_gen.pl is spelled with an underscore, not a dash. Second, Make sure that any firewalls you're running aren't blocking Perl.exe.

FizzledFiend
02-06-05, 04:39 PM
Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.

C:\Documents and Settings\Fox Roshak>cd c:\mksig

C:\mksig>sig_gen.pl
Couldn't download Stanford's page. at C:\mksig\sig_gen.pl line 133.

C:\mksig>


no firewalls, no AVS, no nothing running...however I am behind a router does peral run on a special port?..shouldn't mater as I am in the DMZ in moy routers setings

JerMe
02-06-05, 04:42 PM
Sorry I know the reason, try this one, i snipped off code some of the XML code =X but you're doing the right thing, just run mksig.pl again like you did before.

GTFouts
02-06-05, 06:11 PM
After doing the cut and paste thing with the new code on the first page, I ran into an error on this line in the "sub color_string" function. It has 2 extra spaces again in the $str_len string. Just letting ya know Christoph so you can fix it and we won't have pages of people wondering why it doesnt work.

$fstr_color=color_grad($start_rgb,$end_rgb,$str_le n,$i++,$error);

GTFouts
02-06-05, 06:16 PM
FizzledFiend, you almost had the right command there. Make it say this:

C:\mksig\mksig.pl

instead of

C:\mksig\mksig

You don't run the sig_gen file, the mksig file will run the sig_gen file as a subroutine. You may already know this, I just havent spotted it yet is all...:attn:

JigPu
02-06-05, 09:26 PM
Christoph, you've got two bugs in the code in your first post. First off, the SETI sig generator is missing the entire color_string subroutine, causing errors while making the sig. Second, on copying the color_string routine from the Folding example, you seem to have a space that causes some more errors (see red code below)

foreach $char (split //, $string) {
$fstr_color=color_grad($start_rgb,$end_rgb,$str_le n,$i++,$error);
#vb3 seems to treat individually colored spaces an non-printable
if ($char eq " ") {

I'm messing around with it as much as I can for knowing zero perl, and hopefully will be able to help you with some of the BOINC stuff :)

JigPu

JigPu
02-07-05, 01:11 AM
Another error for the BOINC client: When finding $boinc_overall_rank, your parser breaks for me. I believe it has to do with boincstats grouping it's digits with commas (for me, boincstats shows 1,777) since it only seems to capture the first digit.

JigPu

Christoph
02-07-05, 02:18 AM
Heh. You'd think I'd do some testing before running the scripts. At any rate, the seti script now includes the previously omitted subroutine (it was there, just not in the code block), should work when $boinc_overall_rank has a comma in it, and should have no further split up variable names. Just so I don't look like a complete idiot, it's a bug in vb3 that causes the spacing, and I have to add some funky tags to get around it.
This time, I tested the code by copy/pasting into a script, and it works as expected. Sorry for the inconvenience.

Brad84cnc
02-07-05, 03:08 AM
thanks and keep up the good work

JerMe
02-07-05, 06:09 AM
Christoph you're going to be proud of me, I finally (sorta) understand what you were doing with the regexes and parsing the html pages. :attn:

Anyways I threw everything but the dates/times from the EOC summary page into arrays that can be manipulated in every way possible (e.g., points in the last 24 hours, versus points today, versus points 24 hour average). The timescale could be in hours, days, weeks, or months. The stats can be outputted to a file to generate graphs like EOC, but for personal use. Maybe even little ascii graphs or something, I dunno.

$eoc_copy = $eocsum_content;

#parsing through the EOC HTML page
#via pacman technique
#chomp through the lines,
#then save what you want into array

for ($eoc_copy) {
#get general stats
s/[\n\r]//g;
s/\#.{6}//g;
s/.*WUs.*Total//;

for ($i=0; $i<8; $i++)
{
s/[\d,]*//;
s/\D*//;
m/([\d,]*)/;
@stats_gen[$i] = $1;
}

#get last 7 months stats
@stats_l7m=([],[]);
s/.*Months Production//;

for ($i=0; $i<8; $i++)
{
s/[\d,]*//;
s/\d\d\.\d\d.//;
s/\D*//;
m/([\d,]*)/;
$stats_l7m[$i][$i] = $1;
s/[\d,]*//;
s/\D*//;
m/([\d,]*)/;
$stats_l7m[$i][$i+1] = $1;
s/[\d,]*//;
}

#get last 7 weeks production
@stats_l7w=([],[]);
s/.*Weeks Production//;

for ($i=0; $i<8; $i++)
{
s/[\d,]*//;
s/\d\d\.\d\d.\d\d//;
s/\D*//;
m/([\d,]*)/;
$stats_l7w[$i][$i] = $1;
s/[\d,]*//;
s/\D*//;
m/([\d,]*)/;
$stats_l7w[$i][$i+1] = $1;
s/[\d,]*//;
}

#get last 7 days production
@stats_l7w=([],[]);
s/.*Days Production//;

for ($i=0; $i<8; $i++)
{
s/[\d,]*//;
s/\d\d\.\d\d.\d\d//;
s/\D*//;
m/([\d,]*)/;
$stats_l7d[$i][$i] = $1;
s/[\d,]*//;
s/\D*//;
m/([\d,]*)/;
$stats_l7d[$i][$i+1] = $1;
s/[\d,]*//;
}

#get last 24 hour production
@stats_l1w=([],[]);
s/.*Hours Production//;

for ($i=0; $i<8; $i++)
{
s/[\d,]*//;
s/\d\d\.\d\d,.\d*.m//;
s/\D*//;
m/([\d,]*)/;
$stats_l1d[$i][$i] = $1;
s/[\d,]*//;

s/\D*//;
m/([\d,]*)/;
$stats_l1d[$i][$i+1] = $1;
s/[\d,]*//;
}

}

I don't know if $stats_xxx[$col][$row] = $1; is proper notation, but it seemed to work. :beer: Anyways I know you're a busy guy with the SETI sig and the WW4 stats, I did this to increase the available statistics that can be inserted into our sigs to maybe take some flak off of you so that you can code the harder stuff (like LWP and all the fancier Perl happenings.)

FizzledFiend
02-07-05, 06:36 AM
Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.

C:\Documents and Settings\Fox Roshak>cd c:\mksig

C:\mksig>sig_gen.pl
Couldn't download Stanford's page. at C:\mksig\sig_gen.pl line 134.

C:\mksig>mksig
'mksig' is not recognized as an internal or external command,
operable program or batch file.

C:\mksig>mksig.pl
Checking for updates...failed
Could not get update from server: Unknown error
This session will modify FizzledFiend's sig.
checking if your sig_gen should be updated...no
building sig...Couldn't download Stanford's page. at C:\mksig\sig_gen.pl line 13
4.
Use of uninitialized value in concatenation (.) or string at C:\mksig\mksig.pl l
ine 245.
Use of uninitialized value in string at C:\mksig\mksig.pl line 250.
OK
Use of uninitialized value in split at C:\mksig\mksig.pl line 513.
Use of uninitialized value in length at C:\mksig\mksig.pl line 257.
checking sig length (will enforce rules)...OK
logging in...failed
failed to retrieve login page.
Please make sure that Perl can connect to the outside world.

C:\mksig>

JerMe
02-07-05, 06:52 AM
It doesn't seem like perl.exe is talking to the net. Perl uses broswer port 80. Maybe there's an anti-trojan blocking perl scripts? Here's a small script just to download a small xml file called "oc.xml" to your local drive.

#!/usr/bin/perl
use LWP::Simple;
use XML::Simple;

#Team 32 stats URL
$url_oc = "http://folding.extremeoverclocking.com/xml/team_summary.php?t=32";

#xml files that will be saved locally
$file_oc = "oc.xml";

#get pages off net and store them locally
getstore($url_oc,$file_oc);

Christoph
02-07-05, 11:54 AM
JerMe, did you ever see if mksig properly updated itself? It worked as expected for a dummy account on my computer.

Christoph
02-07-05, 06:18 PM
Announcement time!
JerMe is now taking over the generic folding stats sig_gen. This will give me more time to work on mksig, the SETI sig and PMSFishy's WW4 project, and ought to result in higher quality and/or faster responses to bugs and stuff.

New Version!
The latest version is now .64. If you like running mksig without a mksig.conf file, mksig will no longer nuke your non-default sig_gen.

TollhouseFrank
02-07-05, 06:56 PM
been working with perlscript for the first time.... it reminds me a lot of a combo of C++ (shudders in horror at the memory) and a bit of HTML.... its not too bad.

FizzledFiend
02-07-05, 08:04 PM
I guess i will wait till somebody has all the bugs worked out and a one click failsafe installer.

JerMe
02-07-05, 08:08 PM
Sorry I can't figure out what's going on with your system, FizzledFiend. Have you tried the getxml.pl file i posted earlier? That should dump a file called "oc.xml" onto your local drive. Just run getxml.pl from the command line.

I'm furiously working on the generic sig_gen.pl, so hang on.

JerMe
02-07-05, 09:58 PM
Ok, rough draft time. I guess this would be an "alpha". Or a beta? Christoph is going to have to christen the version numbers, if you leave it up to me it'll be like v3.141592652 ;)

Anyways, for now I'm posting what is available to display in your sig. Tons of stats that can be included, think I counted 24 core statistics, and 48 lesser stats, for a total of 72 different stats available. So you can mix and match as you like. Here are the variables so far:

################################################## #######################
# Possible Stats to Include in Your Signature
#
# These are the list of statisthat can be listed in
# your sig. Just add the variable name in the
# "Actual Signature" section at the bottom of this code.
# You technically should "turn off" the variables you're not going to use,
# since you're probably not going to display 50 different stats
# in your sig. No need to have the computer make stuff it
# doesn't need.
# Just add or delete the "#" pound sign in front of where the
# variable is defined (do a search).
#
# Here are the variables that can be used:
#
#
# **From Stanford's Site:
#
# $c07 = Active processors (within 7 days)
# $c50 = Active processors (within 50 days)
# = Date of last work unit
#
# **From EOC's XML Page (assuming team 32 member):
#
# $rnk = Rank in Team 32
# $r24 = Change in rank in the past 24 hours
# $r7d = Change in rank in the past 7 days, as a string
# $ppd = Points 24 hour average, or "points per day"
# $pud = Points update
# $p2d = Points today, since midnight
# $pwk = Points this week, since sunday
# $pts = Total points so far in project
# $wus = Work Units complete so far in project
#
# $rnk_oc = Rank of your team vs. other teams
# $uac_OC = Users active within team
# $usr_oc = Total users within team, active and inactive
# $ppd_oc = Points per day for team
# $pud_oc = Points update for team
# $p2d_oc = Points today for team
# $pwk_oc = Points this week, for team
# $pts_oc = Total points for team
# $wus_oc = Total WUs complete by team
#
# $p2d_au = Points today for overclockers.au (OCAU)
# $p2d_ho = Points today for [H]ardOCP ([H])
#
# **From EOC's User Summary Page (assuming team 32 member):
#
# $stats_gen[0] = Rank in team 32 (same as $rnk)
# $stats_gen[1] = Points 24hr avg (same as $ppd)
# $stats_gen[2] = Points last 24 hrs
# $stats_gen[3] = Points last 7 days
# $stats_gen[4] = Points today (same as $p2d)
# $stats_gen[5] = Points Week (same as $pwk)
# $stats_gen[6] = Points Total (same as $pts)
# $stats_gen[7] = WUs Total (same as $wus)
#
#
# EOC: LAST 7 MONTHS, LAST 7 WEEKS, LAST 7 DAYS, LAST 24 HOURS
# The following stats are more involved, so before you use them,
# you better brush up on how to print strings in perl, what an
# array does, how to access variables in a multidimensional
# array, and how to use the "spacer code" section to fix spacing
# so your sig looks aligned. This is set up just like a matrix
# (graph table), where the first entry is [0][0], the last is
# [7][1]. That makes an 8x2 matrix, or 16 entries per table.
#
#
# **Stats from "Last 7 Months Production"
# $stats_l7m[0][0] = This month's points so far (same as $p0m)
# $stats_l7m[0][1] = This month's WUs completed so far
# $stats_l7m[1][0] = Points total 1 month ago
# $stats_l7m[1][1] = WUs total 1 month ago
# $stats_l7m[2][0] = Points total from 2 months ago
# ... and so on, up to [7][0] for the points and [7][1] for the WUs.
#
# **Stats from "Last 7 Weeks Production"
# $stats_l7w[0][0] = Points this week so far
# $stats_l7w[6][1] = WUs completed from 6 weeks ago
# ... and so on, up to [7][0] for the points and [7][1] for the WUs.
#
# **Stats from "Last 7 Days Production"
# $stats_l7d[0][0] = points from the last 7th days
# $stats_l7d[0][1] = WUs from the last 7th days
# ... and so on, up to [7][0] for the points and [7][1] for the WUs.
#
# **Stats from "Last 24 Hours Production"
# $stats_l1d[0][0] = points since last checkpoint
# $stats_l1d[0][1] = WUs since last checkpoint
# ... and so on, up to [7][0] for the points and [7][1] for the WUs.
#
# $f_prog[0] = progress curve of 1st WU
# $f_prog[1] = progress curve of 2nd WU (if running 2 instances)
# $f_prog[2] = progress curve of 3rd WU (if running 3 instances)
# $f_name[0] = name of 1st WU
# $f_name[1] = name of 2nd WU (if running 2 instances)
# $f_name[2] = name of 2nd WU (if running 3 instances)
#
# $ocau_str = line stating how we're doing against OCAU. put on bottom.
# $ocho_str = line stating how we're doing against [H]. put on bottom.
################################################## #######################


The generic sig_gen.pl will only contain 3-5 statistics, have more color, and will conform to the signature rules of <=10 lines@ size2, <800 pixels wide. Anyone want to chime in on what else it should include?

gustav
02-07-05, 10:18 PM
First let me say this: Thanks Christoph for putting in the time to make this. It is much appreciated.

Second: I've wasted enough time getting my sig the way it is as you see it now and I can't figure out how to do this. Can someone help me (if possible) to remove this from my sig (so that there is say 3-4 invisible spaces between the last number in the total score and the first number of the percent done of the "p1141_RIBO_FSpeptide_HEL" work unit and also that there is 3-4 invisible spaces between the last number of WUs and the first number in the percent done of the "p1140_RIBO_FSpeptide_EXT":
{oooooo____} (the o's are different colors, the underscores are invisible)
{__________} (the underscores are all invisible)

The reason why I need help is because I'm not sure what I need to remove. As you can see in my attached sig_gen file, I had to "cheat" but using forum code to put in spaces where I needed them as I have not and probably cannot learn this perl code. If possible, could someone explain to me how to remove the above mentioned text and replace it with spaces? Or if someone has the time edit it and send it to gustav88 AT gmail DOT com?

Third: Thanks for fetching all those possible variables JerMe...could be usefull in the future...would be nice to put in a combo of those! :drool:

JerMe
02-07-05, 10:30 PM
I think you're asking how to delete the progress curve, but keep the % complete?

gustav
02-07-05, 10:46 PM
I think you're asking how to delete the progress curve, but keep the % complete?

Not sure what that means? I want to get rid of the text that seperates the stats from the current work units. Whatever that junk in the { } is I want to delete and just leave a blank space 3-4 spaces wide inbetween the stats and the current work units, but I don't know how.

JerMe
02-07-05, 11:16 PM
the {**********} is the "progress curve". It' supposed to be a graphical representation of the completed WU, kinda like how EMIII does it. Anyways, to turn if off:


for ($f_prog) {
s/.*Progress: //;
s/\%.*//;
$pct_prog = $_;
#$pct_prog = 100;
#this is a *recommended* way of rounding
$filled_bars = sprintf("%.0f",($pct_prog/100)*$prog_len);
$empty_bars = $prog_len - $filled_bars;
#print "$pct_prog% progress, $filled_bars chars, $empty_bars unfilled\n";

$f_prog = "{";

for($i=0; $i < $filled_bars; $i++) {
$color=color_grad($prog_start,$prog_end,$prog_len/$prog_cycles,$i);
$f_prog .= "\$progress_char\[/color\]";
}
$f_prog .= "[color=#$invisible]";
$f_prog .= "_" x $empty_bars;
$f_prog .= "";
$f_prog .= "}";

# now looks like "{****___}" but with color tags

$f_prog .= "$pct_prog%";
if ($pct_prog > 99) {
s/(\d\d\d%)/[color=#$invisible]_[\/color]$1/;
} elsif ($pct_prog >9) {
s/(\d\d%)/[color=#$invisible]__[\/color]$1/;
} else {
s/(\d%)/[color=#$invisible]___[\/color]$1/;
}
#print "$f_prog\n";
}

Has to be replaced with this:

$f_prog =~ s/.*([\d]*\%).*//;

All of Christoph's hard work, down the tube :D Backup your sig_gen before you do anything else.

BTW, where you have all those

[color=#$invisible]_________________________[/color ]

there are variables to adjust it called $spcr1 and $spcr2. Take a look at $spcr1:

$spcr1= "[color=#$invisible]" . "_" x 25 . "[/color ]";

it just puts 25 underscores between the color tags. So to lessen the number of underscores, you'd just adjust that 25 to something smaller, and put $spcr1 whereever you'd like it to be.

In Christoph's Linux 3 Instance sig, he has $spcr1, $spcr2, and $spcr3.

gustav
02-07-05, 11:29 PM
OHhhhhhhhhhhhhhhhhhhhhh! So its supposed to be like a progress bar? LOL! I get it now. Very cool! Nvm I'm keeping it! Thanks, I'm dumb! LOL! :clap:

JerMe
02-08-05, 02:45 AM
"Generic", Windows-Friendly sig_gen.pl (beta)
Big thanks to Christoph for creating the mksig and sig_gen. Without it, we'd all have static sigs. ;)


Christoph's a busy guy with all the different projects he has going, so he asked me to create a generic sig_gen.pl for those who would like to have stats in their sig with minimal effort. This version is just like his sig_gen in the first post of this thread, with some minor tweeks to help you get running. Download it here. (http://www.geocities.com/jerme@sbcglobal.net/sig_gen.pl) Don't know what this is? Check out the first page in this thread. (http://www.ocforums.com/showthread.php?t=361456)

If you want a version of this sig_gen.pl with the documentation inside removed, get it here. (http://www.geocities.com/jerme@sbcglobal.net/lite/sig_gen.pl) A GUI (http://www.ocforums.com/showthread.php?t=370627) for this sig_gen is in development, which should allow you to change values for the sig_gen from a window, rather than editing the script by hand.

Despite the length of this post, all you really have to do is change 3 things to get your sig up and running.

It looks like this:


Build!.Borg!.Recruit!.Folding.for.Team.32! (http://www.ocforums.com/forumdisplay.php?f=21)
My Folding Stats:____Currently Monitored WUs:
score:______20862____{§¤´²¨ª___________}_36%: p1134_RIBO_FSpeptide_EXT
Pts Per Day:__310____{§¤_______________}_10%: OneIsTheLoneliestNumber
Pts 7 Days:_2,169____{§¤´²¨ª‰•_________}_50%: UnitTwoWhereAreYou
Clients:________4____{§¤´²¨ª‰•*»§¤´____}_75%: ThreeisMe_MeToo_MeToo
Work Units:___209____{§¤´²¨ª‰•*»§¤´²¨ª‰}_99%: Impossible_AMD_Quad_Power
Team 32 Rank:_575 (+26.in.7.days)____



What's different about this sig_gen?
Add your name, EOC id#, and the path of each FAH folder for each progress bar you want to show. If you put one path, the sig will only show one progress bar. If you want to show more than one, just keep adding paths, and the code will add more progress bars to the sig. Up to five progress bars can be displayed.
List of 70+ FAH statistics available.
Can change to different FAH statistics easily.
Automatically formats spacing between the stats, columns and headers. Can also "easily" change the colors of the stat description and stats.
Can enter different characters for your progress bar.
Can display how Team 32 is doing against OCAU and [H].
As the WU gets closer to 100% completion, the color of the % value changes (Christoph's code).
A boatload of documentation and support


This is what it looks like on the inside:

#!/usr/bin/perl
use LWP::UserAgent;
use LWP::Simple;
use XML::Simple;


################################################## ###############################
# USER NAME, EOC #ID, FAH FOLDER LOCATION(S) #
# modify the variables $user, $eod_id, and unitinfo_loc below this section #
# to your own folding name, EOC ID, and the folder(s) containing your FAH #
# nstance(s). #
# #
# #
# USER NAME #
# User Name is your folding name, case sensitive. #
# #
# EOC_ID #
# If you don't know EOC_ID, go to the EOC website at #
# http://folding.extremeoverclocking.com, look up your folding #
# name, navigate to user summary, and then look at the last #
# few digits in the URL. If you look up "IdeaMagnate", you'll see #
# "http://folding.extremeoverclocking.com/user_summary.php?s=&u=4937", #
# so 4937 is the EOC_ID. #
# #
# FAH_PATH - YOUR FOLDER(S) CONTAINING UNITINFO.TXT #
# unitinfo.txt is the textfile containing the name of the WU and percent #
# completion of that WU thus far. It resides in your FAH folder. #
# #
# If you are using Wedo's One-Click, the default folder is #
# "c:/Program Files/FAH". If you are using a P4 with HT or Dual CPU, the #
# default folder is "c:/Program Files/FAH1", "c:/Program Files/FAH2". #
# #
# The FAH paths are stored in a variable called @fah_path. #
# #
# To add a folder, just add it's full path in "quotes", followed by a comma. #





# You don't add a comma to the last file path entered. When you're done, #
# put the ");" to end it. Syntax: #
# #
# If you have a single WU machine it will look like this: #
# #
# @fah_path = ( #
# "C:\\Program Files\\FAH"); #single instance path #
# #
# If you have a P4 with HT, or a Dual CPU machine it will look like this: #
# #
# @fah_path = ( #
# "C:\\Program Files\\FAH\\FAH1", #multi instance path 1 #
# "C:\\Program Files\\FAH\\FAH2"); #multi instance path 2 #
# #
# A networked path, when typed in Windows, looks like "\\LANcomputer\\FAH". #
# In Perl, you need a forwardslash "/" before the first backslash "\", #
# so that would look like this: #
# #
# "/\\LANcomputer/\\FAH" #
# #
# Just add all the paths you wish, up to five. Two paths are entered by #
# default. #
# #
# #
# (FYI: If you're not familiar with Perl or coding, any line of code that #
# starts with a "#", like this section, is considered a "comment" and is not #
# processed by the computer. So if you see any code, but has a "#" in the #
# beginning, that means it is "commented out", and will not be run.) #
# #
# Enter your folding information below. #
# #
################################################## ###############################

$user="JerMe";
$eoc_id=5414;
@fah_path = (
"C:\\Program Files\\FAH\\FAH1", #multi instance path 1
"C:\\Program Files\\FAH\\FAH2"); #multi instance path 2


$adv_stats="n"; #change to "y" if you want advanced stats


################################################## ###############################
# Possible FAH Statistics to Include in Your Signature #
# #
# Should you feel the need to include FAH stats other than the default, #
# an extensive list of alternative stats (70+) are made available to you. #
# #
# For a HOWTO on how to do this, go online at #
# http://www.ocforums.com/showpost.php?p=3436436&postcount=241. #
# #
# Here are the $variables that can be used: #
# #
# #
# **From Stanford's Site: #
# #
# $c07 = Active processors (within 7 days) #
# $c50 = Active processors (within 50 days) #
# = Date of last work unit #
# #
# **From EOC's XML Page (assuming team 32 member): #
# #
# $rnk = Rank in Team 32 #
# $r24 = Change in rank in the past 24 hours #
# $r7d = Change in rank in the past 7 days, as a string, #
# "(+7 in 7 days)" #
# $ppd = Points 24 hour average, or "points per day" #
# $pud = Points update #
# $p2d = Points today, since midnight #
# $pwk = Points this week, since sunday #
# $pts = Total points so far in project #
# $wus = Work Units complete so far in project #
# #
# $rnk_oc = Rank of your team vs. other teams #
# $uac_OC = Users active within team #
# $usr_oc = Total users within team, active and inactive #
# $ppd_oc = Points per day for team #
# $pud_oc = Points update for team #
# $p2d_oc = Points today for team #
# $pwk_oc = Points this week, for team #
# $pts_oc = Total points for team #
# $wus_oc = Total WUs complete by team #
# #
# $p2d_au = Points today for overclockers.au (OCAU) #
# $p2d_ho = Points today for [H]ardOCP ([H]) #
# #
# **From EOC's User Summary Page (assuming team 32 member): #
# #
# $stats_gen[0] = Rank in team 32 (same as $rnk) #
# $stats_gen[1] = Points 24hr avg (same as $ppd) #
# $stats_gen[2] = Points last 24 hrs #
# $stats_gen[3] = Points last 7 days #
# $stats_gen[4] = Points today (same as $p2d) #
# $stats_gen[5] = Points Week (same as $pwk) #
# $stats_gen[6] = Points Total (same as $pts) #
# $stats_gen[7] = WUs Total (same as $wus) #
# #
# #
# ADV_STATS: LAST 7 MONTHS, LAST 7 WEEKS, LAST 7 DAYS, LAST 24 HOURS #
# The following stats are more involved, so before you use them, #
# you better brush up on how to print strings in perl, what an #
# array does, how to access variables in a multidimensional #
# array. This is set up just like a matrix where the first entry is #
# [0][0], the last is [7][1]. That makes an 8x2 matrix, or 16 entries #
# per table. These stats are OFF BY DEFAULT, so to gain access to them, #
# you need to change #
# #
# $adv_stats="n"; #
# to #
# $adv_stats="y"; #
# #
# located up where you entered your name, eoc id#, and fah path. #
# #
# #
# **Stats from "Last 7 Months Production" #
# $stats_l7m[0][0] = This month's points so far (same as $p0m) #
# $stats_l7m[0][1] = This month's WUs completed so far #
# $stats_l7m[1][0] = Points total 1 month ago #
# $stats_l7m[1][1] = WUs total 1 month ago #
# $stats_l7m[2][0] = Points total from 2 months ago #
# ... and so on, up to [7][0] for the points and [7][1] for the WUs. #
# #
# **Stats from "Last 7 Weeks Production" #
# $stats_l7w[0][0] = Points this week so far #
# $stats_l7w[6][1] = WUs completed from 6 weeks ago #
# ... and so on, up to [7][0] for the points and [7][1] for the WUs. #
# #
# **Stats from "Last 7 Days Production" #
# $stats_l7d[0][0] = points from the last 7th day #
# $stats_l7d[0][1] = WUs from the last 7th days #
# ... and so on, up to [7][0] for the points and [7][1] for the WUs. #
# #
# **Stats from "Last 24 Hours Production" #
# $stats_l1d[0][0] = points since last checkpoint #
# $stats_l1d[0][1] = WUs since last checkpoint #
# ... and so on, up to [7][0] for the points and [7][1] for the WUs. #
# #
# #
# The following are variables that display the status of the WUs you are #
# monitoring locally or on your LAN. They show the progress bar #
# and the WU name being folded. #
# #
# $prog_bar[0] = progress bar of 1st WU #
# $prog_bar[1] = progress bar of 2nd WU (if running 2 instances) #
# $prog_bar[2] = progress bar of 3rd WU (if running 3 instances) #
# $wu_name[0] = name of 1st WU #
# $wu_name[1] = name of 2nd WU (if running 2 instances) #
# $wu_name[2] = name of 2nd WU (if running 3 instances) #
# #
# $progress1 = progress bar and name of FAH instance #1 (FAH1) #
# $progress2 = progress bar and name of FAH instance #2 (FAH2) #
# $progress3 = progress bar and name of FAH instance #3 (FAH3) #
# $progress4 = progress bar and name of FAH instance #4 (FAH4) #
# $progress5 = progress bar and name of FAH instance #5 (FAH5) #
# #
# #
# The variables below show how well we're doing against the #1 and #2 #
# folding teams, overclockers.au and [H]ardOCP. #
# #
# $ocau_str = line stating how we're doing against OCAU. put on bottom. #
# $ocho_str = line stating how we're doing against [H]. put on bottom. #
# #
################################################## ###############################



#-----------------------------------------------------------
# Folding String
# this is the "Build! Borg! Recruit! Fold for Team 32!" at
# top of the signature. Change it to whatever you'd like.
# You can change the beginning and ending (hex) colors, too.
# See http://www.december.com/html/spec/colorhex.html for a
# list of colors.
#-----------------------------------------------------------

$folding_str = "Build! Borg! Recruit! Folding for Team 32!";

#enter colors for the folding string
$fstr_start = "00BFFF"; #original was ff00ff
$fstr_end = "00ff00"; #original was ffff00


#---------------------------------------------------------------------------
# ProgressBar Section
#
# Here, you can modify the characters in the progress bar, the colors of the
# progress bar, the gradient colors of the WU name.
#---------------------------------------------------------------------------

#enter string to use for progress indicator bar
$progress_char="§¤´²¨ª‰•*»";

#enter total char length of the progress indicator bar
#make value bigger/smaller to widen/shrink progress bar
$bar_len = 17; #original was 10

#enter colors for progress indicator bar
$bar_start = "333399"; #original was 333333
$bar_end = "00BFFF"; #original was ffd700

#enter colors for the percent indicator
$pct_begin = "1E90FF"; #original was ff0000
$pct_end = "00ff00"; #original was 00ff00

#enter colors for the WU name
$wu_start = "00ff00"; #original was ffff00
$wu_end = "0066FF"; #original was ff0000

#you can't see me, invisible bkgd color for the forums
$invisible="333333"; #invisible is 333333


#---------------------------------
# get local info about current WUs
#---------------------------------

#legacy $n counter, useful for older code hiccups
#$n refers to FAH folder location, useful for smp
#for ($n=1; $n < $num_instances+1; $n++) {
#
# if ($num_instances > 1) {
# $unit_info = "$fah_folder$n\\unitinfo.txt";
# } else {
# $unit_info = "$fah_folder\\unitinfo.txt";
# }


foreach $unit_info (@fah_path) {

$unit_info .= "\\unitinfo.txt";

open FH, "$unit_info" or die "Could not find unitinfo.txt at $unit_info $!";
while(<FH>){
chomp;
$unitinfo_copy .= $_;
}
close FH;

$wu_name = $unitinfo_copy;
$wu_name =~ s/.*Name:\s(.*)Do.*/$1/;
$wu_name = color_string($wu_start, $wu_end, $wu_name);

#check to see if progrss bar is bigger than chars defined
# if it is, just loop the existing chars
$my_len = length($progress_char);
if ($bar_len > $my_len ) {

$char_diff = $bar_len - $my_len;
$char_mult = sprintf("%.0f",($char_diff/$my_len));
$progress_char .= substr($progress_char,0,$my_len)x$char_mult;
}
@chr = split(//,$progress_char);

for ($prog_bar) {
$prog_bar = $unitinfo_copy;
s/.*Progress:\s(\d*)%.*/$1/;

$pct_prog = $_;
#$pct_prog = 100;
#this is a *recommended* way of rounding

$filled_bars = sprintf("%.0f",($pct_prog/100)*$bar_len);
$empty_bars = $bar_len - $filled_bars;

#print "$pct_prog% progress, $filled_bars chars, $empty_bars unfilled\n";

$prog_bar = "{";

for($i=0; $i < $filled_bars; $i++) {
$color=color_grad($bar_start,$bar_end,$bar_len,$i) ;
$prog_bar .= "".$chr[$i]."";
}

$prog_bar .= "";
$prog_bar .= "_" x $empty_bars;
$prog_bar .= "";
$prog_bar .= "}";

# now looks like "{****___}" but with color tags

$pct_color = color_grad($pct_begin,$pct_end,100,$pct_prog);
$prog_bar =~ s/$/\$pct_prog\%\[\/color\]/;

#$prog_bar .= "$pct_prog%";
if ($pct_prog > 99) {
s/(\d\d\d%)/[\/color]$1/;
} elsif ($pct_prog >9) {
s/(\d\d%)/_[\/color]$1/;
} else {
s/(\d%)/[color=#$invisible]__[\/color]$1/;
}

} #end for(@prog_bar)

#to turn off progress bar... comment for(@prog_bar){} and uncomment below
#$prog_bar =~ s/.*([\d]*\%).*//;

#push it baby
push(@wu_name,$wu_name);
push(@prog_bar,$prog_bar);

} #end foreach


#------------------------
# get stats from Stanford
#------------------------
@time = localtime;
$time[5] += 1900;
$time[4]++;

$team=32;
$stfd_cache = "stfd.html";

#only download stanford's page every 3 hours ( = 60*60*3 seconds)
#(stat($file))[9] is the time since file was last modified, in seconds

if ( (! -e $stfd_cache) || (time - (stat($stfd_cache))[9] > (60*60*3)) ) {

$ua = LWP::UserAgent->new();
$stfd_page = $ua->get(
"http://vspx27.stanford.edu/cgi-bin/main.py?qtype=userpage&teamnum=$team&username=$user");

if (! $stfd_page->is_success) {
die "Couldn't download Stanford's page.";
}

open STFD_CACHE, ">$stfd_cache";
print STFD_CACHE $stfd_page->content;
close STFD_CACHE;

$s_content = $stfd_page->content;

} else {

open STFD_CACHE, "$stfd_cache";
while(<STFD_CACHE>) {
$s_content .= $_;
}
close STFD_CACHE;

}

$c07 = $s_content;

for ($c07) {
s/[\n\r]//g; #chop new lines and return chars
s/\#.{6}//g; #chop all colors like #000fff (kills digits)
s/=(\d*)//g; #chop all numbers like size=3
s/.*7 days//; #chop before & including "7 days"
s/\D*//; #chop all non-digits
s/(\d*).*/$1/; #store stat in variable, kill rest
}

check_stat($c07);

$c50 = $s_content;

for ($c50) {
s/[\n\r]//g;
s/\#.{6}//g;
s/=(\d*)//g;
s/.*50 days//;
s/\D*//;
s/(\d*).*/$1/;
}

check_stat($c50);

#-------------------------------------------------
# get stats from EOC summary page
# everything else will come out of the XML file
#-------------------------------------------------

#download EOC's summary page every 2 hours ( = 60*60*2 seconds)

$eocsum_cache = "eocsum.html";

if ( (! -e $eocsum_cache) || (time - (stat($eocsum_cache))[9] > (60*60*2)) ) {

$ua = LWP::UserAgent->new();
$eocsum_page = $ua->get("http://folding.extremeoverclocking.com/user_summary.php?s=&u=$eoc_id");

if (! $eocsum_page->is_success) {
die "Couldn't download EOC's summary page.";
}

open EOCSUM_CACHE, ">$eocsum_cache";
print EOCSUM_CACHE $eocsum_page->content;
close EOCSUM_CACHE;

$eocsum_content = $eocsum_page->content;

} else {

open EOCSUM_CACHE, "$eocsum_cache";
while(<EOCSUM_CACHE>) {
$eocsum_content .= $_;
}
close EOCSUM_CACHE;
}

$eoc_copy = $eocsum_content;

#parsing through the EOC HTML page via pacman technique
#chomp through the lines, then save what you want into array

for ($eoc_copy) {
#get general stats
#print "===General Stats===\n";
s/[\n\r]//g;
s/\#.{6}//g; #chop those annoying arse colors
s/.*WUs.*Total//;

for ($i=0; $i<8; $i++)
{
s/[\d,]*//;
s/\D*//;
m/([\d,]*)/;
$stats_gen[$i] = $1;
#print "$1\n";
check_stat($1);
}

#if you want adv_stats, comp will parse for the rest of stats
if ($adv_stats eq "y" || $adv_stats eq "yes")
{

#get last 7 months stats
#print "===L7M Stats===\n";
@stats_l7m=([],[]);
s/.*Months Production//;

for ($i=0; $i<8; $i++)
{
s/[\d,]*//;
s/\d\d\.\d\d.//;
s/\D*//;

m/([\d,]*)/;
check_stat($1);
$stats_l7m[$i][0] = $1;
s/[\d,]*//;
s/\D*//;
m/([\d,]*)/;
check_stat($1);
$stats_l7m[$i][1] = $1;
s/[\d,]*//;
#print "$stats_l7m[$i][0],$stats_l7m[$i][1]\n";
}

#get last 7 weeks production
#print "===L7W Stats===\n";
@stats_l7w=([],[]);
s/.*Weeks Production//;

for ($i=0; $i<8; $i++)
{
s/[\d,]*//;
s/\d\d\.\d\d.\d\d//;
s/\D*//;
m/([\d,]*)/;
check_stat($1);
$stats_l7w[$i][0] = $1;
s/[\d,]*//;
s/\D*//;
m/([\d,]*)/;
check_stat($1);
$stats_l7w[$i][1] = $1;
s/[\d,]*//;
#print "$stats_l7w[$i][0],$stats_l7w[$i][1]\n";
}

#get last 7 days production

#print "===L7D Stats===\n";





@stats_l7d=([],[]);
s/.*Days Production//;

for ($i=0; $i<8; $i++)
{
s/[\d,]*//;
s/\d\d\.\d\d.\d\d//;
s/\D*//;
m/([\d,]*)/;
check_stat($1);
$stats_l7d[$i][0] = $1;
s/[\d,]*//;

s/\D*//;
m/([\d,]*)/;

check_stat($1);
$stats_l7d[$i][1] = $1;
s/[\d,]*//;
#print "$stats_l7d[$i][0],$stats_l7d[$i][1]\n";
}

#get last 24 hour production
#print "===L1D Stats===\n";
@stats_l1d=([],[]);
s/.*Hours Production//;

for ($i=0; $i<8; $i++)
{
s/[\d,]*//;
s/\d\d\.\d\d,.\d*.m//;
s/\D*//;
m/([\d,]*)/;
check_stat($1);
$stats_l1d[$i][0] = $1;
s/[\d,]*//;
s/\D*//;
m/([\d,]*)/;
check_stat($1);
$stats_l1d[$i][1] = $1;
s/[\d,]*//;
#print "$stats_l1d[$i][0],$stats_l1d[$i][1]\n";
}

} #end if for $adv_stats
}


#----------------------------------
# grab other webpages and save them
# need to add error correcting
#----------------------------------

#my stats, aussie stats, [h] stats URLs
$url_oc = "http://folding.extremeoverclocking.com/xml/user_summary.php?s=&u=$eoc_id";
$url_au = "http://folding.extremeoverclocking.com/xml/team_summary.php?t=24";
$url_ho = "http://folding.extremeoverclocking.com/xml/team_summary.php?t=33";

#xml files that will be saved locally
$file_oc = "oc.xml";
$file_au = "au.xml";
$file_ho = "ho.xml";

#get pages off net and store them locally
getstore($url_oc,$file_oc) if (time-(stat($file_oc))[9] > 60*60*2 );
getstore($url_au,$file_au) if (time-(stat($file_au))[9] > 60*60*2 );
getstore($url_ho,$file_ho) if (time-(stat($file_ho))[9] > 60*60*2 );

#Slurp in XML file
my $ocstats = XMLin($file_oc);
my $austats = XMLin($file_au);
my $hstats = XMLin($file_ho);

#Team Variables that can be used
$rnk_oc = $ocstats->{Rank};
$uac_OC = $ocstats->{Users_Active};
$usr_oc = $ocstats->{Users};
$ppd_oc = $ocstats->{Points_24hr_Avg};
$pud_oc = $ocstats->{Points_Update};
$p2d_oc = $ocstats->{Points_Today};
$pwk_oc = $ocstats->{Points_Week};
$pts_oc = #$ocstats->{Points};
$wus_oc = $ocstats->{WUs};

#User Variables that can be used
$rnk = $ocstats->{user}->{Team_Rank};
$r24 = $ocstats->{user}->{Change_Rank_24hr};
$r7d = $ocstats->{user}->{Change_Rank_7days};
$ppd = $ocstats->{user}->{Points_24hr_Avg};
$pud = $ocstats->{user}->{Points_Update};
$p2d = $ocstats->{user}->{Points_Today};
$pwk = $ocstats->{user}->{Points_Week};
$pts = $ocstats->{user}->{Points};
$wus = $ocstats->{user}->{WUs};

#mod rank stat to statement
if ($r7d > 0) {
$r7d = "(+".$r7d." in 7 days)";
}
elsif ($r7d == 0) {
$r7d = "";
}
else {
$r7d = "$r7d in 7 days)";
}

#compare h and au stats to our stats
$p2d_au = $austats->{Points_Today};
$p2d_ho = $hstats->{Points_Today};

#where we stand versus each team
$p2d_ocau = $p2d_oc - $p2d_au;
$p2d_ocho = $p2d_oc - $p2d_ho;

#make a statement about ocau and point difference
if ($p2d_ocau == 0) {
$ocau_str = 'Go to sleep. It\'s late.';
}
elsif ($p2d_ocau > 0) {
$ocau_str = "We\'re outproducing OCAU by [color=green]"
.$p2d_ocau." powah points today! w00t!";
}
else {
$p2d_ocau = $p2d_ocau*-1;
$ocau_str = "OCAU is outproducing us by "
.$p2d_ocau." points today! ):0";
}

#make a statement about [H] and point difference
if ($p2d_ocho == 0) {
$ocho_str = 'while you sleep, your computer can fold...';
}
elsif ($p2d_ocho > 0) {
$ocho_str = "We\'re outproducing [H] by "
.$p2d_ocho." powah points today! w00t!";
}
else {
$p2d_ocho = $p2d_ocho*-1;
$ocho_str = "[H] is outproducing us by "
.$p2d_ocho." points today! ):0";
}



###################################
# Actual Signature #
# #
# everything here is shown in sig #
###################################

#enter column width
$left_length = 17;

#enter num spaces between columns
$num_col_spaces = 4;

#$folding_str on top now

$folding_str = color_string($fstr_start,$fstr_end,$folding_str,0, 1);
$folding_str = "".
$folding_str." (http://www.ocforums.com/forumdisplay.php?f=21)";

#enter header titles in string below
$hdr_left = "My Folding Stats:";
$hdr_right = "Currently Monitored WUs:";

#enter stats
#auto_spacer("statistic",$statistic) to use default forum colors
#autospacer("statistic",$statistic,"description_color","statistic_color") for colors
#see online HOWTO online documentation or sub auto_spacer() for details

$col_left1 = auto_spacer("score",$pts,"FFFAF0","00BFFF");
$col_left2 = auto_spacer("Pts Per Day",$ppd,"FFFAF0","00BFFF");
$col_left3 = auto_spacer("Pts 7 Days",$stats_gen[3],"FFFAF0","00BFFF");
$col_left4 = auto_spacer("Clients",$c07,"FFFAF0","00BFFF");
$col_left5 = auto_spacer("Work Units",$wus,"FFFAF0","00BFFF");
$col_left6 = auto_spacer("Team 32 Rank",$rnk,"FFFAF0","00BFFF").
" ".color_string("1e90ff","eeee00",$r7d);


#array to scalar to check size
$num_instances = @fah_path;





# $progress1 looks like {**** } 44%: p1134_RIBO_FSpeptide_EXT

$progress1 = "$prog_bar[0]: $wu_name[0]";
$progress2 = "$prog_bar[1]: $wu_name[1]";
$progress2 = "" if ($num_instances==1);
$progress3 = "$prog_bar[2]: $wu_name[2]";
$progress3 = "" if ($num_instances<=2);
$progress4 = "$prog_bar[3]: $wu_name[3]";
$progress4 = "" if ($num_instances<=3);
$progress5 = "$prog_bar[4]: $wu_name[4]";
$progress5 = "" if ($num_instances<=4);

$spcr_col= "" . "_" x $num_col_spaces. "";
$spcr_hdr= ""."_" x
($left_length - ((length ($hdr_left))-7-23) + $num_col_spaces) . "";

$time_str = sprintf("%02d/%02d/%04d %02d:%02d",
$time[4],$time[3],$time[5],$time[2],$time[1]);

$tagline = ""."Auto Generated ".$time_str.
". ".
"AutoSig ©2005 Christoph et al (http://www.ocforums.com/showthread.php?t=361456). " .
"Want a sig too? ".
"Let Me help (http://www.ocforums.com/showpost.php?p=3436436&postcount=241). (:0";

#shortcut to make print layout easier to read
$fmt_o = "";
$fmt_c = "";

#$wu_start = "00ff00"; #original was ffff00
#$wu_end = "0066FF"; #original was ff0000

# Layout of signature in forums
#______Left_Column_______________________Right_Col umn_____

print "$fmt_o$folding_str". "\n";
print "$hdr_left" .$spcr_hdr. "$hdr_right\n";
print "$col_left1" .$spcr_col. "$progress1\n";
print "$col_left2" .$spcr_col. "$progress2\n";
print "$col_left3" .$spcr_col. "$progress3\n";
print "$col_left4" .$spcr_col. "$progress4\n";
print "$col_left5" .$spcr_col. "$progress5\n";
print "$col_left6" .$spcr_col. "\n";
#print "$ocau_str". "\n";
#print "$ocho_str". "\n";
print "".$tagline."$fmt_c";

# stat: 03030 {****** } 61% : p1139_p1133_L939_K12M_355K

# end "Actual Signature" Section





################################################## #############################
#color_string:
#This function returns its third argument (a string) with color tags, as
#specified by its other parameters.
#
#Usage: color_string($rgb_i, $rgb_f, $string, $err, $pds, $fun)
#$rgb_i : hex triplet (eg "ff00ff") indicating the color to start with
#$rgb_f : hex triplet indicating the color to stop with
#$string : the string to add color tags to
#
#All arguments below are optional, but you can't use one without using the ones
#before it. eg you need to specify $err and $pds in order to specify $fun.
#
#$err : 0-255 - add/subtract random fluctuations between 0 and $err to each
# color. The colors will always be valid, even if $err is large.
#$periods : how many times to cycle from $rgb_i to $rgb_f
#$fun : specify the function used to move between $rgb_i and $rgb_f
#
#Examples of valid usage:
#
#$pi = atan2(1,1)*4; #standard definition
#$str = color_string("ff00ff", "ffff00", "Like, wow.");
#$str = color_string("ff00ff", "ffff00", "Like, wow.", 15);
#$str = color_string("ff00ff", "ffff00", "Like, wow.", 15, 2);
#$str = color_string("ff00ff", "ffff00", "Like, wow.", 15, 2,
# sub {my $x = shift; return abs(sin($x*$pi))} );
################################################## #############################

sub color_string
{
$start_rgb = shift;
$end_rgb = shift;
$string = shift;
#optional args below
$error = shift;
$error = 0 if (! defined $error);

$periods = shift;
$periods = 1 if (! defined $periods);

$fun = shift;
$fun = sub {my $x = shift; return ((255*$x % 256)/255);} if (!defined $fun);

#ugly bug if this isn't declared my
my $color_str;
$str_len = length $string;
$i=0;

foreach $char (split //, $string) {
$fstr_color=color_grad($start_rgb,$end_rgb,$str_le n,$i++,$error,$periods,$fun);
#vb3 seems to treat individually colored spaces an non-printable
if ($char eq " ") {
$color_str .= "\.\";
} else {
$color_str .= "\$char\";
}
}
#print "COLOR STRING: returning $color_str\n";
return $color_str;
}


################################################## #############################
#color_grad_fun:
#This function returns a single hex triplet based on the parameters passed to
#it.
#
#Usage: color_grad_fun($rgb_i, $rgb_f, $curr, $err, $pds, $fun)
#$rgb_i : hex triplet (eg "ff00ff") indicating the color to start with
#$rgb_f : hex triplet indicating the color to stop with
#$curr : a number between 0 and 1 indicating how far through the gradient
# the color is.
#
#All arguments below are optional, but you can't use one without using the ones
#before it. eg you need to specify $err and $pds in order to specify $fun.
#
#$err : 0-255 - add/subtract random fluctuations between 0 and $err to each
# eg you need to specify $err and $pds in order to specify $fun.
#
#$err : 0-255 - add/subtract random fluctuations between 0 and $err to each
# color. The colors will always be valid, even if $err is large.
#$periods : how many times to cycle from $rgb_i to $rgb_f
#$fun : specify the function used to move between $rgb_i and $rgb_f
################################################## #############################
sub color_grad_fun

{
my $start_rgb = shift; #"ff00ff"
my $end_rgb = shift; #"00ff00"
my $curr_step = shift; #floating pt number between 0 and 1. inclusive

#OPTIONAL ARG: error is random variation, in decimal shades
my $error = shift;
$error = 0 if (! defined $error);

#OPTIONAL ARG: how many times to cycle through the above function
my $periods = shift;
$periods = 1 if (! defined $periods);

#OPTIONAL ARG: function with a period of 1 and a range 0-1 to determine color
#distribution
my $fun = shift;
#This function has the same behavior as the previous implementation.
$fun = sub {my $x = shift; return ((255*$x % 255)/255);} if (!defined $fun);

$error /= 255;

for $curr (0,1,2) {

$min = hex(substr($start_rgb,$curr*2,2)) / 255;
$max = hex(substr($end_rgb,$curr*2,2)) / 255;
$range = $max - $min;
$funval = &$fun($curr_step*$periods);

#print "max is $max, min is $min, range is $range, step is $curr_step,";
$color[$curr] = ($min + $range*$funval);

if ($error == 0) {
$my_error = 0;
} else {
$my_error = (rand 2*$error) - $error;
}

while (($color[$curr]+$my_error) < 0 || ($color[$curr]+$my_error) > 1) {
$my_error = ((rand 2*$error) - $error);
}
#at this point, $my
#print "using error of $my_error, max is $error\n";
#$norml = $color[$curr]*255;
#print "normal color is $norml, ";
$color[$curr] += $my_error;
$color[$curr] *= 255;
#$color[$curr] = sprintf("%.0f",)
#print "color is $color[$curr]\n";

}
return sprintf("%02x%02x%02x",$color[0],$color[1],$color[2]);
}


################################################## #############################
#color_grad:
#This function returns a single hex triplet based on the parameters passed to
#it. This function is just a wrapper for color_grad_fun. Either can be sued.
#
#Usage: color_grad($rgb_i, $rgb_f, $step_f, $step_c, $err, $pds, $fun)
#$rgb_i : hex triplet (eg "ff00ff") indicating the color to start with
#$rgb_f : hex triplet indicating the color to stop with
#$step_f : how many total steps in the gradient (ie step_final)
#$step_c : the number of the current step; if this is half of step_f, the color
# returned will be halfway between rgb_i and rgb_f
#All arguments below are optional, but you can't use one without using the ones
#before it. eg you need to specify $err and $pds in order to specify $fun.
#
#$err : 0-255 - add/subtract random fluctuations between 0 and $err to each
# color. The colors will always be valid, even if $err is large.
#$periods : how many times to cycle from $rgb_i to $rgb_f
#$fun : specify the function used to move between $rgb_i and $rgb_f
################################################## #############################



sub color_grad

{
$start_rgb = shift; #"ff00ff"
$end_rgb = shift; #"00ff00"
$last_step = shift; #"36"
$curr_step = shift; #"12"
#error is random variation, in decimal shades
$error = shift;
$periods = shift;
$fun = shift;

return color_grad_fun($start_rgb, $end_rgb, $curr_step/$last_step, $error, $periods,$fun);
}



################################################## ################################
# check_stat
#
# Function checks if stats are numbers and not a long string, meant for checking
# if HTML source changes. Returns same number if is number, otherwise dies.
################################################## ################################
sub check_stat
{
$number_var = shift;

$number_var =~ s/,//g; #kill commas

die "malformed html detected" unless $number_var =~ /^\d[\d]*$/;
return $number_var;

} #end sub check_stat

################################################## ################################
# sub auto_spacer
#
# formats left column according to a user defined column width (length). Optional
# to input hex colors for description and statistic. Returns string with
# description,invisible spacing, and stat.
#
# usage:
#
# auto_spacer(stat_description, stat_variable);
#
# optional usage, with colors:
#
# auto_spacer(stat_description, stat_variable,
# stat_description_color, stat_variable_color);
#
# example:
# auto_spacer("rank",$rnk)
#
# output in sig:
# rank:__________________597 (invisible color tags omitted)
#
# example, with color:
# auto_spacer("rank",$rnk,"000000","CCCCCC")
#
# output in sig:
# rank:__________________597 (color tags omitted)
#
################################################## ################################
sub auto_spacer
{
$tot_length = $left_length; #width of column, in length of chars
$desc = shift; #description of stat
$stat = shift; #stat to be used
$desc_color = shift; #optional, color of description
$stat_color = shift; #optional, color of stat

$desc .= ":"; #gotta add this here so char count is right

#find how many invisible spaces needed
$num_inv = $tot_length-(length $desc)-(length $stat);
$inv_spcr = ""."_" x $num_inv ."";

if (! defined $desc_color) {
$d1 = "";
$d2 = "";
} else {
$d1 = "";
$d2 = "";
}
if (! defined $stat_color) {
$s1 = "";
$s2 = "";
} else {
$s1 = "";
$s2 = "";
}
$whole_str = $d1.$desc.$d2.$inv_spcr.$s1.$stat.$s2;

return $whole_str;

} #end sub auto_spacer


Download this sig_gen.pl (http://www.geocities.com/jerme@sbcglobal.net/sig_gen.pl) to your c:\mksig directory, open it with notepad, and edit three variables near the top:

$user="JerMe";
$eoc_id=5414;
@fah_path = (
"C:\\Program Files\\FAH\\FAH1", #multi instance path 1
"C:\\Program Files\\FAH\\FAH2"); #multi instance path 2


$user is the name you are folding under, according to Stanford. It is CaSe SeNSiTiVe, yo. "JerMe" is different from "jerme".

$eoc_id is the number that extremeoverclocking.com (or "EOC", another good F@H tracking website) identifies your Standford folding name as. If you don't know EOC_ID, go to their website at http://folding.extremeoverclocking.com, look up your folding name, navigate to user summary, and then look at the last few digits in the URL. If you look up "JerMe", then click on the name, you'll see "http://folding.extremeoverclocking.com/user_summary.php?s=&u=5414" in the address bar, so 5414 in the last part of the URL is the EOC_ID.

@fah_path is the full directory path to each of your FAH folders. Note that a double backslash "\\" has to be used.

If you have 1 instance of FAH running, edit @fah_path to read

@fah_path = (
"C:\\Program Files\\FAH");


If you have 2 instances of FAH running (such as a P4 with HT or Dual CPUs), then edit @fah_path to read

@fah_path = (
"C:\\Program Files\\FAH\\FAH1",
"C:\\Program Files\\FAH\\FAH2");

If you want to monitor 1 instance on your local computer, and one instance on a networked computer (that is always on, that you can always access, otherwise the script will die and you won't get a sig), type it's network path to the FAH folder, with a forwardslash "/" before the "\\" (don't forget to set the permissions on the LAN computer, and set your firewall accordingly). For a network path ""\\LanComputerName\\FAH"":

@fah_path = (
"C:\\Program Files\\FAH\\",
"/\\LanComputerName/\\FAH");

So in general, it needs to be @fah_path=("path1","path2"); with a comma between each "path", and ending with a ");" to close it off. You can add up to five paths, with the sig_gen adding/deleting the instances as you go.


Again, If you haven't done so already, read the first post of this thread. Synopsis:

Install ActiveState's ActivePerl (http://www.activestate.com/Products/Download/Download.plex?id=ActivePerl) with it's default settings.
Download mksig.txt (http://gladstone.uoregon.edu/~cotto1/ochosting/mksig.txt) into a directory called c:\mksig. Rename it to mksig.pl.
Download sig_gen.pl. Open with notepad, and edit the 3 lines as described above.
Run sig_gen.pl via commandline (start > run > cmd > cd\mksig > sig_gen.pl). The window should look something like this (http://img.photobucket.com/albums/v280/jerme/siggencmdline.gif). If you see something with errors, then don't run mksig.pl.
Run mksig.pl either by double clicking its icon in either windows explorer, or via commandline (preferred, as the window wont disappear on you if there's an error) and follow the onscreen instructions on username, updates, etc. It will save your information to a file called mksig.conf. Run mksig.pl again to upload your new signature to the forums.
CHECK YOUR SIG AT THE FORUMS. My biggest concern is to have the code go haywire, and thus everyone's sig go haywire all at once, creating a forum full of gigantic sigs that, even as they're killed one-by-one by our forum mods, respawn with every task scheduler update. The code is written in such a way to prevent this, but make sure your sig is putting out the right information before you start your automatic updates.


Changing Colors, Adding Your Own Stats

First, changing colors of the gradients for "Build! Borg! Recruit! Folding for Team 32!" (called the "folding string), progress bar characters, the WU name, the % indicator. Then how to change the stats color.

Find this in the code:

$folding_str = "Build! Borg! Recruit! Folding for Team 32!";

#enter colors for the folding string
$fstr_start = "00BFFF"; #original was ff00ff
$fstr_end = "00ff00"; #original was ffff00

The stuff in yellow is the hexidecimal color. $fstr_start is the color you want to start the gradient with. $fstr_end is the color you want the gradient to end with. You'll get this:

Build!.Borg!.Recruit!.Folding.for.Team.32!

The other colors are located a few lines further down:

#enter colors for progress indicator bar
$bar_start = "333399"; #original was 333333
$bar_end = "00BFFF"; #original was ffd700

#enter colors for the percent indicator

$pct_begin = "1E90FF"; #original was ff0000
$pct_end = "00ff00"; #original was 00ff00

#enter colors for the WU name
$wu_start = "00ff00"; #original was ffff00
$wu_end = "0066FF"; #original was ff0000

This lets you color most of sig, except the stats and their descriptions. To color stats and their description, read on.

There are a ton of different stats to choose from. Once you understand the code somewhat, you can get to mixing and matching your own stats within your signature.

To do that, you'll need to find this section:

$col_left1 = auto_spacer("score",$pts,"FFFAF0","00BFFF");
$col_left2 = auto_spacer("Pts Per Day",$ppd,"FFFAF0","00BFFF");
$col_left3 = auto_spacer("Pts 7 Days",$stats_gen[3],"FFFAF0","00BFFF");
$col_left4 = auto_spacer("Clients",$c07,"FFFAF0","00BFFF");
$col_left5 = auto_spacer("Work Units",$wus,"FFFAF0","00BFFF");
$col_left6 = auto_spacer("Team 32 Rank",$rnk,"FFFAF0","00BFFF").
" ".color_string("1e90ff","eeee00",$r7d);

The highlighted line produces the following as the 4th stat in the sig:

Clients:________4

Let's say that you want to change that to "Pts This Week". Let's also say that you want to change the color of "Pts This Week" from it's current whitish color to yellow (hex code FFFF00), and want to change the color of the stat from it's current blueish color to a greenish color (hex code 00FF00). You would replace that line with the following:

$col_left4 = auto_spacer("Pts This Week",$pwk,"FFFF00","00FF00");

and your sig would replace the line to look like this:

Build!.Borg!.Recruit!.Folding.for.Team.32! (http://www.ocforums.com/forumdisplay.php?f=21)
My Folding Stats:____Currently Monitored WUs:
score:______20862____{§¤´²¨ª___________}[color=#13b5a9]_34%: p1134_RIBO_FSpeptide_EXT
Pts Per Day:__310____{§¤_______________}_10%: OneIsTheLoneliestNumber
Pts 7 Days:_2,169____{§¤´²¨ª‰•_________}_50%: UnitTwoWhereAreYou
Pts This Week:__0____{§¤´²¨ª‰•*»§¤´____}_75%: ThreeisMe_MeToo_MeToo
Work Units:___209____{§¤´²¨ª‰•*»§¤´²¨ª‰}_99%: Impossible_AMD_Quad_Power
Team 32 Rank:_575 (+26.in.7.days)____


If you'd rather have "Pts This Week" and the stat colored with the forum default colors, you can omit the colors when calling auto_spacer():

auto_spacer("Pts This Week",$pwk)

Changing Spacing Between Stat Descprition & Statistic, and Changing Spacing Between Stats & Progressbar(s)

If you notice in the example sig above, there isn't that much space between "Pts This Week" and "0". If you find that you need more space between the stat description and the stat (a.k.a, need to widen the column), you'll need to find $left_length = 17; and increase "17" to meet your spacing needs. The "Currently Monitored WUs" and progress bars will move over as well. Here, I've increased it to 21 chars with $left_length = 21:

Build!.Borg!.Recruit!.Folding.for.Team.32! (http://www.ocforums.com/forumdisplay.php?f=21)
My Folding Stats:________Currently Monitored WUs:
score:[color=#333333]__________20862____{§¤´²¨ª___________}_34%: p1134_RIBO_FSpeptide_EXT
Pts Per Day:______310____{§¤_______________}_10%: OneIsTheLoneliestNumber
Pts 7 Days:_____2,169____{§¤´²¨ª‰•_________}_50%: UnitTwoWhereAreYou
Pts This Week:______0____{§¤´²¨ª‰•*»§¤´____}_75%: ThreeisMe_MeToo_MeToo
Work Units:_______209____{§¤´²¨ª‰•*»§¤´²¨ª‰}_99%: Impossible_AMD_Quad_Power
Team 32 Rank:_____575 (+26.in.7.days)____

If you want to adjust how much space there is between the stats and the progressbar, you'll need to find $num_col_spaces = 4; and change it to your preference.


Variables That Can Be Added to the Sig

Here's the list of variables that can be added:

################################################## ###############################
# Possible FAH Statistics to Include in Your Signature #
# #
# Should you feel the need to include FAH stats other than the default, #
# an extensive list of alternative stats (70+) are made available to you. #
# #
# For a HOWTO on how to do this, go online at #
# http://www.ocforums.com/showpost.php?p=3436436&postcount=241. #
# #
# Here are the $variables that can be used: #
# #
# #
# **From Stanford's Site: #
# #
# $c07 = Active processors (within 7 days) #
# $c50 = Active processors (within 50 days) #
# = Date of last work unit #
# #
# **From EOC's XML Page (assuming team 32 member): #
# #
# $rnk = Rank in Team 32 #
# $r24 = Change in rank in the past 24 hours #
# $r7d = Change in rank in the past 7 days, as a string, #
# "(+7 in 7 days)" #
# $ppd = Points 24 hour average, or "points per day" #
# $pud = Points update #
# $p2d = Points today, since midnight #
# $pwk = Points this week, since sunday #
# $pts = Total points so far in project #
# $wus = Work Units complete so far in project #
# #
# $rnk_oc = Rank of your team vs. other teams #
# $uac_OC = Users active within team #
# $usr_oc = Total users within team, active and inactive #
# $ppd_oc = Points per day for team #
# $pud_oc = Points update for team #
# $p2d_oc = Points today for team #
# $pwk_oc = Points this week, for team #
# $pts_oc = Total points for team #
# $wus_oc = Total WUs complete by team #
# #
# $p2d_au = Points today for overclockers.au (OCAU) #
# $p2d_ho = Points today for [H]ardOCP ([H]) #
# #
# **From EOC's User Summary Page (assuming team 32 member): #
# #
# $stats_gen[0] = Rank in team 32 (same as $rnk) #
# $stats_gen[1] = Points 24hr avg (same as $ppd) #
# $stats_gen[2] = Points last 24 hrs #
# $stats_gen[3] = Points last 7 days #
# $stats_gen[4] = Points today (same as $p2d) #
# $stats_gen[5] = Points Week (same as $pwk) #
# $stats_gen[6] = Points Total (same as $pts) #
# $stats_gen[7] = WUs Total (same as $wus) #
# #
# #
# ADV_STATS: LAST 7 MONTHS, LAST 7 WEEKS, LAST 7 DAYS, LAST 24 HOURS #
# The following stats are more involved, so before you use them, #
# you better brush up on how to print strings in perl, what an #
# array does, how to access variables in a multidimensional #
# array. This is set up just like a matrix where the first entry is #
# [0][0], the last is [7][1]. That makes an 8x2 matrix, or 16 entries #
# per table. These stats are OFF BY DEFAULT, so to gain access to them, #
# you need to change #
# #
# $adv_stats="n"; #
# to #
# $adv_stats="y"; #
# #
# located up where you entered your name, eoc id#, and fah path. #
# #
# #
# **Stats from "Last 7 Months Production" #
# $stats_l7m[0][0] = This month's points so far (same as $p0m) #
# $stats_l7m[0][1] = This month's WUs completed so far #
# $stats_l7m[1][0] = Points total 1 month ago #
# $stats_l7m[1][1] = WUs total 1 month ago #
# $stats_l7m[2][0] = Points total from 2 months ago #
# ... and so on, up to [7][0] for the points and [7][1] for the WUs. #
# #
# **Stats from "Last 7 Weeks Production" #
# $stats_l7w[0][0] = Points this week so far #
# $stats_l7w[6][1] = WUs completed from 6 weeks ago #
# ... and so on, up to [7][0] for the points and [7][1] for the WUs. #
# #
# **Stats from "Last 7 Days Production" #
# $stats_l7d[0][0] = points from the last 7th day #
# $stats_l7d[0][1] = WUs from the last 7th days #
# ... and so on, up to [7][0] for the points and [7][1] for the WUs. #
# #
# **Stats from "Last 24 Hours Production" #
# $stats_l1d[0][0] = points since last checkpoint #
# $stats_l1d[0][1] = WUs since last checkpoint #
# ... and so on, up to [7][0] for the points and [7][1] for the WUs. #
# #
# #
# The following are variables that display the status of the WUs you are #
# monitoring locally or on your LAN. They show the progress bar #
# and the WU name being folded. #
# #
# $prog_bar[0] = progress bar of 1st WU #
# $prog_bar[1] = progress bar of 2nd WU (if running 2 instances) #
# $prog_bar[2] = progress bar of 3rd WU (if running 3 instances) #
# $wu_name[0] = name of 1st WU #
# $wu_name[1] = name of 2nd WU (if running 2 instances) #
# $wu_name[2] = name of 2nd WU (if running 3 instances) #
# #
# $progress1 = progress bar and name of FAH instance #1 (FAH1) #
# $progress2 = progress bar and name of FAH instance #2 (FAH2) #
# $progress3 = progress bar and name of FAH instance #3 (FAH3) #
# $progress4 = progress bar and name of FAH instance #4 (FAH4) #
# $progress5 = progress bar and name of FAH instance #5 (FAH5) #
# #
# #

# The variables below show how well we're doing against the #1 and #2 #
# folding teams, overclockers.au and [H]ardOCP. #
# #
# $ocau_str = line stating how we're doing against OCAU. put on bottom. #
# $ocho_str = line stating how we're doing against [H]. put on bottom. #
# #
################################################## ###############################


Changing Characters For The Progress Bar

You can enter any number of characters for your progress bar, as well as adjust the length of the progress bar. Look for the following in the code:

#enter string to use for progress indicator bar
$progress_char="§¤´²¨ª‰•*»";

#enter total char length of the progress indicator bar
#make value bigger/smaller to widen/shrink progress bar
$bar_len = 17; #original was 10

For $progress_char, just enter anything you want, doesn't matter how short or how long. $bar_len is the length of the progress bar, in number of characters. If you enter only 1 or 2 characters for $progress_char and $bar_len is 17, then the code loops the chars.


Modifying the Signature Layout

To modify the layout of the sig, you'll need to understand how Perl puts out text. If you understand this already, skip this quick tutorial.

The folllowing code

print "Hello world!\n";
print "I'm a new line!";

puts out:

Hello world!
I'm a new line!


Mind the "\n", that means "new line", which is the same thing as hitting enter on your keyboard so that it goes to a.. new line. If omitted, the previous code would read, Hello world!I'm a new line!

You'll need to know about concatenating (joining) strings (words), too. The following puts out exactly the same thing as above:

print "Hello" . " world!\n";
print "I'm a new line!";

To join two things within quotes " ", like "Hello" and " world!", you need to use the period "." character.

Why do you need to know all this? This is why. Here's the code that prints the layout for the sig:

print "$fmt_o$folding_str". "\n";
print "$hdr_left" .$spcr_hdr. "$hdr_right\n";
print "$col_left1" .$spcr_col. "$progress1\n";
print "$col_left2" .$spcr_col. "$progress2\n";
print "$col_left3" .$spcr_col. "$progress3\n";
print "$col_left4" .$spcr_col. "$progress4\n";
print "$col_left5" .$spcr_col. "$progress5\n";
print "$col_left6" .$spcr_col. "\n";
#print "$ocau_str". "\n";
#print "$ocho_str". "\n";
print "$tagline"."$fmt_c";


By correlation, you might be able to figure out what it's saying. Notice that every print line ends with "\n" to go to a new line. Notice the use of concatenation in order to make the code a little more "readable". Instead of actual words, $variables were used in their place to make it easier to code. $col_left represents all the stats and description, on the left side of the sig. There are 6 of them. $spcr_col represents the number of blank spaces between the end of the stats and the beginning of the progress bar. $progress represents the progress bar and WU name for each FAH path that you entered. (The code is set up such that if you dont' have 5 instances, it won't show any extra progress bars.)

Also notice how there is a "#" in front of print "$ocau_str". When a "#" is added to the beginning of a line of code, it is ignored by the computer. A "#" means "comment", and is typically used to.. add personal comments to the code, or remove lines of code from being processed without actually processing them. If you take out the "#" for those lines, it'll print out a string that says how we're doing against our bitter rivals, OCAU and [H]. (It'll also violate signature rules, since we're only allowed 10 lines at size=2. If you decide to modify this sig, please mind that rule, as well as the that limits our sigs to a width of a *cough* 800x600 *cough* resolution screen. So if you uncomment those lines, make sure you figure out what lines you want to delete, thus keeping 10 lines total.)

Hence you can type in more stuff if you'd like. You can delete the various "print" lines at will, if the number of stats doesn't suit your taste. You can reformat the signature and use the stats $variables that are listed.


Modifying Older sig_gen.pl Versions Containing Spacer Code

If your sig_gen.pl looks like below, then you know what i'm talking about.

You'll need to know 2 parts. The first makes the invisible spaces:

#num of blank spaces before each stat
$pts_len=16;
$ppd_len=7;
$p7d_len=10;
$c07_len=6;
$rnk_len=9;

$pts_pad = $pts_len - (length $pts);
$ppd_pad = $ppd_len - (length $ppd);
$p7d_pad = $p7d_len - (length $stats_gen[3]);
$c07_pad = $c07_len - (length $c07);
$rnk_pad = $rnk_len - (length $rnk);

#spcr1 is num blank spaces after stat
#spcr2 is num blank spaces num space btwn 1st and 2nd column header
#adjust to widen/shrink column size
$spcr1= "" . "_" x 4 . "[/color ]";
$spcr2= "[color=#$invisible]" . "_" x 9 . "[/color ]";

$pts = "[color=#$invisible]" . "_" x $pts_pad . "[/color ]" . $pts . $spcr1;
$ppd = "[color=#$invisible]" . "_" x $ppd_pad . "[/color ]" . $ppd . $spcr1;
$p7d = "[color=#$invisible]" . "_" x $p7d_pad . "[/color ]" . $stats_gen[3] . $spcr1;
$c07 = "[color=#$invisible]" . "_" x $c07_pad . "[/color ]" . $c07 . $spcr1;
$rnk = "[color=#$invisible]" . "_" x $rnk_pad . "[/color ]" . $rnk;

and the second determines the print layout:

$f_prnm = "$f_prog[1]: $f_name[1]";
#if 2nd instance doesn't exist don't add to stats
#isn't the best way to check this
$f_prnm = "" if ($f_name[0] == $f_name[1]);

$folding_str = color_string($fstr_start,$fstr_end,
"Build! Borg! Recruit! Folding for Team 32!",0,2);
#$folding_str = "Build! Borg! Recruit! Fold for Team 32!";
$time_str = sprintf("%02d/%02d/%04d %02d:%02d",$time[4],$time[3],$time[5],$time[2],$time[1]);

#enter header titles in string below
#adjust $spcr3 number above to get the alignment right
$hdr_1 = "[.u]My Folding Stats[/u ]";
$hdr_2 = "[.u]This Rig's Current WU[/u ]:";

#shortcut to make print layout easier to read
$fmt_o = "[.size=2][.font=monospace]";
$fmt_c = "[/font ][/size ]";

# _1st column_ _2nd column_

print "$fmt_o$folding_str". "\n";
print "$hdr_1:$spcr2". "$hdr_2\n";
print "Score:$pts". "$f_prog[0]: $f_name[0]\n";
print "Pts (24hr avg):$ppd". "$f_prnm\n";
print "Pts (7days):$p7d". "\n";
print "Clients (7days):$c07". "\n";
print "Team 32 rank:$rnk ($r7d)". "\n";
print "$ocau_str". "\n";
print "$ocho_str". "$fmt_c\n";
print "[.size=1]Stats as of ".$time_str." . Developed by Christoph. Fold for Team 32![/size ]\n";

# stat: 03030 {****** } 61% : p1139_p1133_L939_K12M_355K

Both work together to output this:

[color=#ff00ff]Build!.Borg!.Recruit!.Folding.for.Team.32!
My Folding Stats:_________This Rig's Current WU:
Score:___________19293____{¤_________}__12%: p1141_RIBO_FSpeptide_HEL
Pts (24hr avg):____377____
Pts (7days):_____2,641____
Clients (7days):_____3____

Team 32 rank:______591 (+37 in 7 days)
We're outproducing OCAU by 10201 powah points today! w00t!
We're outproducing [H] by 9482 powah points today! w00t!
Stats as of 02/07/2005 21:53 PST. Developed by Christoph. Fold for Team 32!



Pretty much anything with a $ in front of it is a variable that can be replaced with any other variable listed at the beginning of sig_gen.pl. The trouble is getting the sig to align correctly. That's where the spacer code comes in.


Let's follow how the sig calculates "Score":

Score:[color=#333333\]___________[/color\]19293[color=#333333 \]____[/color\]

The variables involved in making the above line are

$pts_len=16;
$pts_pad = $pts_len - (length $pts);
$spcr1= "[color=#$invisible]" . "_" x 4 . "[/color ]";
$pts = "[color=#$invisible]" . "_" x $pts_pad . "[/color ]" . $pts . $spcr1;

The first really long ___________ is determined by $pts_pad, but is really controlled by $pts_len. You're telling the code that you want 16 characters between the end of the stat description (in the above sig's case, "score:") and the end of the last digit of the stat (in the above case, "19293"). So if you want to adjust how much space is between score: and 19293, just change $pts_len .

The variable $spcr1 determines how many spaces after the stat. Right now it's set up for 4 spaces, just change the 4 to something else if you want to widen/shrink the gap between the left column of stats and the right column of stats.

Finally, $pts puts it all together - spaces in the beginning, the actual score, and spaces at the end.

The variable $spcr2 determines the spaces between the column headers My Folding Stats and This Rig's Current WU:. Right now it's set for 9, but can be adjusted to fit your needs.

So, if you want to add more stats, you'll have mimic what we just went over above with your own naming convention - basically a copy/paste routine. Use the variables listed in sig_gen and adjust your spacers accordingly.


Final Words


I'm no programmer, so trust me when I say that you can figure this out. Once you understand the code, modify the sig_gen to your own personal layouts and tastes. If not, post in this thread, or shoot me a PM. Good luck, and happy siggin'! :beer:




Edit 2/11/05: New version in the works, that doesn't require all this spacer number changing stuff. Sneak Preview here (http://www.ocforums.com/showpost.php?p=3445286&postcount=258). Also, once everything is ironed out, I'll have different formats/colors available to choose from. I'll try to add in any new code that Christoph throws our way.

Edit 2/12/05: Yet again, an updated version. Changelog:

*$n issue with multiple FAH instances "fixed", just add paths of all the instances at the top, including networked locations if you'd like. The more paths you add, the more progress bars it'll show, up to five.
*Can now color the stat and description easily.
*Can make your own progress bar with different characters in it.
*Christoph's percentage color code now included.
*Made it a little bit easier to find where to change the colors for the different signature elements.

Edit 2/13/05: Removed old attached sig_gen.pl. Rewrote the HOWTO to reflect this newest (final-ish) version. Decided to keep the HOWTO on the spacer code, if anyone with older code wanted to know how to use it.

Edit 2/25/05: Created a GUI to change items such as user name, eoc id, fah paths, variables, etc. See post #285 (http://www.ocforums.com/showpost.php?p=3484971&postcount=285). Also fixed a small bug displaying negative rank changes.

Edit 2/26/05: Modified the sig_gen to use $folding_str ONCE, to make the GUI work properly (there were 4 nearly identical instances of $folding_str, which made it a pain to parse.) GUI updated to v0.02. Now includes option to edit the folding string text, edit the spacing size between the stat and label, and edit the colors of each the stat and its label.


-Jer

JigPu
02-08-05, 03:28 AM
Christoph, I've been messing around with the BOINC version and getting it to work with RPC calls (so that you can have data for multiple clients in the sig). I don't have much, but I consider it a miracle that I even managed to learn how to mess with sockets and XML by my 2nd day in the language (yea for Google!! :D)

There are a few bugs I haven't managed to work out yet, but hopefully they're easy to fix or I'm just ignorant of the right way to coerce Perl to do my bidding ;)


Here's the code for the getting the XML via RPC. @remote_hosts is an array of hostnames (@remote_hosts = ("Goddess", "CRACKERJACK", "Nacho") on my computer), and @remote_ports is the corresponding array of ports for each host (@remote_ports = (31416, 31416, 31416) for me again). To output the "non-canned" vars (since I commented out the canned ones for now) you use something like print "$rpc[0]->{host_info}->{ip_addr}", which accesses the data at the specified point in the XML tree.
if ($boinc_remoteaccess) { #Get BOINC data from remote RPC calls

for($i=0; $i<@remote_hosts; $i++) {

# Set server and port number for socket
################
my $name = $remote_hosts[$i];
#or die "Missing server name\n";
my $port = $remote_ports[$i];
#or die "Missing port number\n";


# Create socket
################
my $socket = IO::Socket::INET->new('PeerAddr' => $name, 'PeerPort' => $port, 'Proto' => 'tcp');
#or die "Can't create socket ($!)\n";


if ($socket) { #ONLY do the following if socket creation sucessful
# Send "<get_state/>", recieve first 100K of reply
################
print $socket "<get_state/>\n";
$socket->recv($reply,102400);
#print "$reply";


# Close the socket
################
close $socket
or die "Can't close socket ($!)\n";


# Remove trailing charachter from string (to make XML compliant)
################
$reply = substr($reply, 0, -1, );


# Push the XML reply onto the array of replys for "non-canned" vars
################
$xml = new XML::Simple;
push(@rpc, $xml->XMLin($reply));

# Parse the XML reply for a few "canned" vars
# !!! BUGGY -- COMMENTED OUT !!!
################
#$rpc_xml = XMLin($reply);
#print "$rpc_xml->{host_info}->{domain_name} / ";
#push(@domain_name, $rpc_xml->{host_info}->{domain_name});

#print "$rpc_xml->{host_info}->{p_model}";
#push(@p_model, $rpc_xml->{host_info}->{p_model});

#print "$rpc_xml->{project}->{host_total_credit} /";
#push(@host_total_credit, $rpc_xml->{project}->{host_total_credit});

#print "$rpc_xml->{project}->{host_expavg_credit} / ";
#push(@host_expavg_credit, $rpc_xml->{project}->{host_expavg_credit});

#print "$rpc_xml->{result}->{active_task}->{result_name} / ";
#push(@result_name, $rpc_xml->{result}->{active_task}->{result_name});

#print "$rpc_xml->{result}->{active_task}->{fraction_done} / ";
#push(@fraction_done, $rpc_xml->{result}->{active_task}->{fraction_done});

#print "$rpc_xml->{result}->{active_task}->{current_cpu_time} \n";
#push(@current_cpu_time, $rpc_xml->{result}->{active_task}->{current_cpu_time});

}
}
}

JigPu

Christoph
02-08-05, 03:43 AM
JigPu, I'd love to see what you've got. After I was done with ww4, I was planning on looking into remote monitoring for both f@h and s@h. If there's already something like xml-rpc in place, getting a script going should be only a small to mid-sized project. There's even an article on DeveloperWorks (http://www-106.ibm.com/developerworks/webservices/library/ws-xpc1/) on it.
Heh. That was fast. Try letting me finish posting next time. ;) I'll be playing with it sometime tomorrow, if you haven't had a chance to get it going by then.

It's funny. I thought this project would slow down once people could get progress bars for local boxes and a couple stats working. The more, the merrier!

JigPu
02-09-05, 02:40 AM
OK, I've got an updated BOINC script. The code is mostly the same as what Christoph has in his first post, but I've rearranged some things and renamed some variables (while learning the basics of Perl). It's mostly the same, but there might be a few little quirks if you try to port over some parts directly.

The RPC should be fully functional in this version. It now correctly gets the XML (the last version didn't work because XML::Simple slightly changed the XML structure by default) and saves some values to "default" variables. I don't find the defaults of much use though since when doing a foreach loop, accessing the appropriate array positions is difficult. Manually accessing the XML data (as I do when building my sig) looks a lot more cluttered, but it's also a lot easier to work with.

My code could also probably stand to be hacked away at, since I doubt it's the most beautiful Perl for the job.... Feel free to improve on anything y'all see wrong with it :)


#!/usr/bin/perl

use XML::Simple;
use LWP::Simple;
use LWP::UserAgent;
use IO::Socket;
use Data::Dumper;

@time = localtime;
$time[5] += 1900;
$time[4]++;
#http://www.perldoc.com/perl5.6/pod/...-Perl-Functions
$time_str = sprintf("%02d/%02d/%04d at %02d:%02d.\n",$time[4],$time[3],$time[5],$time[2],$time[1]);


# Projects To Provide Data For
# 0 means disable, 1 means enable
################
$get_boinc = 1;
$boinc_fileaccess = 0; #Using remoteaccess can get the same data, so why run both?
$boinc_webaccess = 1;
$boinc_remoteaccess = 1;

$get_classic = 0;
$classic_fileaccess = 0; #Not implemented yet!
$classic_webaccess = 0;



# BOINC Setup
# If you're in windows, make sure to separate directories with "\\" instead of "\".
################
$boinc_home = "c:\\program files\\boinc";
@remote_hosts = ("Goddess", "CRACKERJACK", "Nacho");
@remote_ports = (31416, 31416, 31416);
$seti_id = 15576;



# Classic Setup
################
$classic_home = "c:\\program files\\seti\@home";
$classic_email = "somebody/@adomain.com";



if ($get_boinc) { #Get BOINC data

if ($boinc_fileaccess) { #Get BOINC data from the local instalation

# SETI Client File Locations
################
$wu = "$boinc_home/slots/0/work_unit.sah";
$state = "$boinc_home/slots/0/state.sah";
$c_state = "$boinc_home/client_state.xml";

#windows-specific stuff
if ($^O =~ /win/i) {
#change "/" into "\" on windows machines
$wu =~ s/\//\\\\/g;
$state =~ s/\//\\\\/g;
$c_state =~ s/\//\\\\/g;
}


################################################
# Get data from the local BOINC instalation ##
################################################

#read client's state into $seti_progress
open BOINC_STATE, "$state";
while (<BOINC_STATE>) {
if (/<prog>[\d\.]*<\/prog>/) {
s/<prog>([\d\.]*)<\/prog>/$1/;
chomp;
$seti_progress = $_;
}
}
close BOINC_STATE;


open BOINC_WU, "$wu";
while (<BOINC_WU>) {
s/<soft_link>\.\.\\\.\.\\projects\\setiathome\.berkeley\.edu\\//;
s/<\/soft_link>//;
chomp;
$wu_name = $_;
}
close BOINC_WU;


$cs_xml = XMLin($c_state);
$seti_credit_total = $cs_xml->{project}->{user_total_credit};
$seti_credit_recent = $cs_xml->{project}->{user_expavg_credit};

}



if ($boinc_webaccess) { #Get BOINC data from http://www.boincstats.com

################################
# Get BOINC stats from web ##
################################

#http://www.boincstats.com/stats/use...p?pr=sah&id=841

$boinc_page = "http://www.boincstats.com/stats/user_graph.php?pr=sah&id=$seti_id";
$local_boinc_cache = "boinc.html";

getstore($boinc_page, $local_boinc_cache);

if (! -e $local_boinc_cache) {
print "get the file, stupid\n";
exit;
}

#extract stats from boinc page
open BC, "$local_boinc_cache";
while(<BC>){

if (/Detailed statistics for<br>/) {
$_ =~ s/"([a-zA-Z][\w\s]*)/$1/;
$seti_user = $1;

} elsif (/<td>Total Credit</) {
<BC>;
$seti_total_credit = <BC>;
chomp($seti_total_credit);
$seti_total_credit =~ s/\s*([\d\.\,]*)<.*/$1/;

} elsif (/Number of hosts/) {
<BC>;
$seti_hostcount = <BC>;
chomp($seti_hostcount);
$seti_hostcount =~ s/\s*(\d*).*/$1/;

} elsif (/World Position/) {
<BC>;
$seti_overall_rank = <BC>;
chomp($seti_overall_rank);
$seti_overall_rank =~ s/\s*([\d,]*).*/$1/;

} elsif (/Recent Average Credit/) {
<BC>;
$seti_rac = <BC>;
chomp($seti_rac);
$seti_rac =~ s/\s*(\d*).*/$1/;

} elsif (/than % of all users/) {
$seti_percentile = <BC>;
chomp($seti_percentile);
$seti_percentile =~ s/<td>(\d*.\d*)%.*/$1/;

} elsif (/Position in Team/) {
<BC>;
$seti_team_rank = <BC>;
chomp($seti_team_rank);
$seti_team_rank =~ s/\s*(\d*).*/$1/;
}
}
close BC;
}



if ($boinc_remoteaccess) { #Get BOINC data from remote RPC calls

#Cycle through all hosts declared in the array at top
################
for($i=0; $i<@remote_hosts; $i++) {

# Set server and port number for socket
################
my $name = $remote_hosts[$i] or die "Missing server name\n";
my $port = $remote_ports[$i] or die "Missing port number\n";


# Create socket
################
my $socket = IO::Socket::INET->new('PeerAddr' => $name, 'PeerPort' => $port, 'Proto' => 'tcp');


if ($socket) { #ONLY do the following if socket creation sucessful
# Get first 100K of state data
################
print $socket "<get_state/>\n";
$socket->recv($reply,102400);
#print "$reply";

close $socket or die "Can't close socket ($!)\n";


# Remove trailing charachter from string (to make XML compliant)
################
$reply = substr($reply, 0, -1, );


# Push the XML reply onto the array of replys
################
$xml = new XML::Simple keyattr => [];
push(@rpc, $xml->XMLin($reply));

}

}

}

}



if ($get_classic) { #Get Classic Data

if ($classic_fileaccess) {

#NOT YET IMPLMENTED!!

}


if ($classic_webaccess) {

################################
# Get stats from Berkeley ##
################################

$berk_url = "http://setiathome2.ssl.berkeley.edu/fcgi-bin/fcgi";
$berk_url = "http://setiathome2.ssl.berkeley.edu/fcgi-bin/fcgi?email=";
$berk_url .= "$classic_email&cmd=user_xml";
$berk_url =~ s/@/%40/;

#http://setiathome2.ssl.berkeley.edu...s+&cmd=user_xml

$ua = LWP::UserAgent->new();
$berk_xml = $ua->get( "$berk_url");

#$berk_xml = $ua->get( "$berk_url",
# [ "cmd" => "user_xml",
# "email" => $classic_email]);

#extract info from Berkeley's not-quite XML
foreach $line (split /^/, $berk_xml->content) {

if ($line =~ /<name>/) {
for ($cl_name = $line) {
chomp;
s/<[^>]*>//g;
s/\s*//;
}
} elsif ($line =~ /numresults/) {
for ($cl_num_results = $line) {
chomp;
s/\s*<[a-z_]*>([^<]*).*/$1/;
}
} elsif ($line =~ /cputime/) {
for ($cl_user_time = $line) {
chomp;
s/\s*<[a-z_]*>([^<]*).*/$1/;
}
} elsif ($line =~ /resultsperday/) {
for ($cl_daily_results = $line) {
chomp;
s/\s*<[a-z_]*>([^<]*).*/$1/;
}
} elsif ($line =~ /<rank>/) {
for ($cl_rank = $line) {
chomp;
s/\s*<[a-z_]*>([^<]*).*/$1/;
}
}
}
}
}



# Set up some initial vars into arrays
# Not extremely useful for "foreach" loops, as you will have to use
# the @index array to sucessfully substitute in array values.
#
# $xxxxx[i] = $xxxxx for the ith host successfully contacted
# $xxxxx[i][0] = The first of (possibly several) values for $xxxxx
# Only applies to XML elements that would have multiple values
# (ie: result_name, project_name, etc)
################

$host_num = 0;
foreach $host (@rpc) {

$index[$host_num] = $host_num; #Index is NOTHING more than a cheap way of allowing foreach loops to work. By doing a foreach $i ($index), it's possible to loop through and access host subscripts individually.

$domain_name[$host_num] = $host->{host_info}->{domain_name};
$ip_addr[$host_num] = $host->{host_info}->{ip_addr};
$p_ncpus[$host_num] = $host->{host_info}->{p_ncpus};
$p_model[$host_num] = $host->{host_info}->{p_model};

if (ref($host->{project}) eq 'ARRAY') { #If signed up for multiple projects...
$i = 0;
foreach $project (@{$host->{project}}) { #Store each project into it's own array
$project_name[$host_num][$i] = $project->{project_name};
$total_credit[$host_num][$i] = $project->{user_total_credit};
$recent_credit[$host_num][$i] = $project->{user_expavg_credit};

$i = $i + 1;
}
}
else { #Get only the single project's data
$project_name[$host_num][0] = $project->{project_name};
$total_credit[$host_num][0] = $project->{user_total_credit};
$recent_credit[$host_num][0] = $project->{user_expavg_credit};
}


if (ref($host->{result}) eq 'ARRAY') { #If more than one result is on the system...
$i = 0;
foreach $result (@{$host->{result}}) { #Extract the results....
$active = $result->{active_task}->{result_name};
if ($active ne "") { #Looking only for the "active" one.
$result_name[$host_num][$i] = $result->{active_task}->{result_name};
$fraction_done[$host_num][$i] = $result->{active_task}->{fraction_done};
$cpu_time[$host_num][$i] = $result->{active_task}->{current_cpu_time};
}

$i = $i + 1;
}
}
else { #Extract the only result (which should be active...)
$result_name[$host_num][0] = $host->{result}->{active_task}->{result_name};
$fraction_done[$host_num][0] = $host->{result}->{active_task}->{fraction_done};
$cpu_time[$host_num][0] = $host->{result}->{active_task}->{current_cpu_time};
}

$host_num = $host_num + 1;

}







#These are boring examples of how to print out stuff.
#Hopefully, you'll come up with something more interesting. ;)

#print "LOCAL BOINC INFO:\n";
#print "progress is $seti_progress\n";
#print "total credits is $seti_credit\n";
#print "wu name is $wu_name\n";

#if ($boinc_webaccess) {
# print "BOINC INFO:\n";
# print "username = $boinc_user\n";
# print "ID = $boinc_id\n";
# print "total credit = $boinc_total_credit\n";
# print "hosts = $boinc_hostcount\n";
# print "overall rank = $boinc_overall_rank\n";
# print "percentile = $boinc_percentile\n";
# print "team rank = $boinc_team_rank\n";
#}

#if ($classic_webaccess) {
# print "CLASSIC INFO:\n";
# print "username is $cl_name\n";
# print "number of results is $cl_num_results\n";
# print "total cpu time donated is $cl_user_time\n";
# print "results per day is $cl_daily_results\n";
# print "overall rank is $cl_rank\n";
#}

#You can't see me.
$invisible = "333333";

$crunch_start = "ff00ff";
$crunch_end = "00ff00";

$crunch_str = color_string($crunch_start,$crunch_end,"Crunching for Overclockers.com!");

#99% means you're in the top 1%, so put that in $top_pct
$top_pct = sprintf("%.2f",100.0 - $seti_percentile);
$rank = $seti_overall_rank;
$boinc_total_credit =~ s/,//g;
$credits = sprintf("%.0f",$seti_total_credit);


##################################
#This is where stuff is printed.##
##################################

print "\$crunch_str\[\/b\]\n";
print "\[size=1\]Team Rank: \[b\]$seti_team_rank" . "th\[\/b]\________________\[\/color\]\[b\]$seti_total_credit\[\/b] Total SETI@Home Credit\n";
print "World Rank: \[b\]$seti_overall_rank" . "th\[\/b\]\[color=#$invisible\]___________________\[\/color\]\[b\]$seti_rac\[\/b\] Recent Average Credit\n";
print "\n";
print "Current Work As Of $time_str \[\/size\]";

foreach $host (@rpc) { #Go through all this code for every host that we managed to connect to via RPC

if (ref($rpc[0]->{result}) eq 'ARRAY') { #If there is more than one result, choose the active one...

foreach $result (@{$host->{result}}) {
$active = $result->{active_task}->{result_name};
if ($active ne "") {

#Create progress bar
################
$progress = progbar($result->{active_task}->{fraction_done});


#Get name of the project the WU is for
# note: this requires making a new XML object for this
# specific RPC so that we can "fold" the tree and find
# the title from what data we are given
###############
$p_url = $result->{active_task}->{project_master_url};
$temp_xml = XMLin($reply, keyattr => [ 'master_url' ]);
$project = $temp_xml->{project}->{$p_url}->{project_name};


#Color the project depending on if it's a SETI@Home WU or not...
###############
if ($project eq "SETI@Home") { #If a SETI@Home WU....
$project = "\[color=PaleTurquoise\]" . $project . "\[\/color\]";
}
else { #If not a SETI@Home WU (LHC, CPDN, Predictor, etc)...
$project = "\[color=RoyalBlue\]" . $project . "\[\/color\]";
}


#Make IP address into XXX.XXX.XXX form
################
$domain = $host->{host_info}->{domain_name};


#Make IP address into XXX.XXX.XXX form
# note: only commented out because I use the
# domain name in my sig
################
#$ip = $host->{host_info}->{ip_addr};
#$ip =~ /(\d+)\.(\d+)\.(\d+)\.(\d+)/;
#$ip = sprintf("%03d.%03d.%03d.%03d",$1,$2,$3,$4);


#Colorize / Trim CPU data
# note: aparently some chips have the actual CPU info
# stored in the p_vendor space instead of the p_model
# space. This if statement sees which is longer, and
# sets CPU to that (this assumes the CPU info will
# take more room)
################
if ($host->{host_info}->{p_model} =~ /AMD/i | $host->{host_info}->{p_vendor} =~ /AMD/i) {
$cpu = "\[color=Lime\]";
}
elsif ($host->{host_info}->{p_model} =~ /Intel/i | $host->{host_info}->{p_vendor} =~ /Intel/i) {
$cpu = "\[color=DeepSkyBlue\]";
}
else {
$cpu = "\[color=White\]";
}

if ( length(trimwhitespace(stripcpu($host->{host_info}->{p_model}))) > length(trimwhitespace(stripcpu($host->{host_info}->{p_vendor}))) ) {
$cpu = $cpu . trimwhitespace(stripcpu($host->{host_info}->{p_model}));
}else {
$cpu = $cpu . trimwhitespace(stripcpu($host->{host_info}->{p_vendor}));
}
$cpu = sprintf("%15s",$cpu);

$cpu = $cpu . "\[\/color\]";


#Now, print off the bits and pieces in one fell swoop
################
print "\[FONT=Courier New\] $progress $project $domain ($cpu) \[/FONT\] \n";
}
}

} else { #If there is only one result, it should be the active one...

#Create progress bar
################
$progress = progbar($host->{result}->{active_task}->{fraction_done});


#Get name of the project the WU is for
# note: this requires making a new XML object for this
# specific RPC so that we can "fold" the tree and find
# the title from what data we are given
###############
$p_url = $host->{result}->{active_task}->{project_master_url};
$temp_xml = XMLin($reply, keyattr => [ 'master_url' ]);
$project = $temp_xml->{project}->{$p_url}->{project_name};


#Color the project depending on if it's a SETI@Home WU or not...
###############
if ($project eq "SETI@Home") { #If a SETI@Home WU....
$project = "\[color=PaleTurquoise\]" . $project . "\[\/color\]";
}
else { #If not a SETI@Home WU (LHC, CPDN, Predictor, etc)...
$project = "\[color=RoyalBlue\]" . $project . "\[\/color\]";
}


#Make IP address into XXX.XXX.XXX form
################
$domain = $host->{host_info}->{domain_name};


#Make IP address into XXX.XXX.XXX form
# note: only commented out because I use the
# domain name in my sig
################
#$ip = $host->{host_info}->{ip_addr};
#$ip =~ /(\d+)\.(\d+)\.(\d+)\.(\d+)/;
#$ip = sprintf("%03d.%03d.%03d.%03d",$1,$2,$3,$4);


#Colorize / Trim CPU data
# note: aparently some chips have the actual CPU info
# stored in the p_vendor space instead of the p_model
# space. This if statement sees which is longer, and
# sets CPU to that (this assumes the CPU info will
# take more room)
################
if ($host->{host_info}->{p_model} =~ /AMD/i | $host->{host_info}->{p_vendor} =~ /AMD/i) {
$cpu = "\[color=Lime\]";
}
elsif ($host->{host_info}->{p_model} =~ /Intel/i | $host->{host_info}->{p_vendor} =~ /Intel/i) {
$cpu = "\[color=DeepSkyBlue\]";
}
else {
$cpu = "\[color=White\]";
}

if ( length(trimwhitespace(stripcpu($host->{host_info}->{p_model}))) > length(trimwhitespace(stripcpu($host->{host_info}->{p_vendor}))) ) {
$cpu = $cpu . trimwhitespace(stripcpu($host->{host_info}->{p_model}));
}else {
$cpu = $cpu . trimwhitespace(stripcpu($host->{host_info}->{p_vendor}));
}
$cpu = sprintf("%15s",$cpu);

$cpu = $cpu . "\[\/color\]";


#Now, print off the bits and pieces in one fell swoop
################
print "\[FONT=Courier New\] $progress $project $domain ($cpu) \[/FONT\] \n";
}

}




#Given a starting color, an ending color, a total number of steps, the
#current step and an optional error, return the color that corresponds
#to that step in a gradient.
sub color_grad
{
$start_rgb = shift; #"ff00ff"
$end_rgb = shift; #"00ff00"
$last_step = shift; #"36"
$curr_step = shift; #"12"
#error is random variation, in decimal shades
$error = shift;
$periods = shift;
$fun = shift;

return color_grad_fun($start_rgb,$end_rgb,$curr_step/$last_step,$error,$periods,$fun);
}


sub color_grad_fun
{
my $start_rgb = shift; #"ff00ff"
my $end_rgb = shift; #"00ff00"
my $curr_step = shift; #floating pt number, modded between 0 and 1. inclusive

#OPTIONAL ARG: error is random variation, in decimal shades
my $error = shift;
$error = 0 if (! defined $error);

#OPTIONAL ARG: how many times to cycle through the above function
my $periods = shift;
$periods = 1 if (! defined $periods);

#OPTIONAL ARG: function with a period of 1 and a range 0-1 to determine color distribution
my $fun = shift;
#This function has the same behavior as the previous implementation.
$fun = sub {my $x = shift; return ((255*$x % 255)/255);} if (!defined $fun);

$error /= 255;

for $curr (0,1,2) {

$min = hex(substr($start_rgb,$curr*2,2)) / 255;
$max = hex(substr($end_rgb,$curr*2,2)) / 255;
$range = $max - $min;
$funval = &$fun($curr_step*$periods);

#print "max is $max, min is $min, range is $range, step is $curr_step,";
$color[$curr] = ($min + $range*$funval);

if ($error == 0) {
$my_error = 0;
} else {
$my_error = (rand 2*$error) - $error;
}

while (($color[$curr]+$my_error) < 0 || ($color[$curr]+$my_error) > 1) {
$my_error = ((rand 2*$error) - $error);
}
#print "using error of $my_error, max is $error\n";
#$norml = $color[$curr]*255;
#print "normal color is $norml, ";
$color[$curr] += $my_error;
$color[$curr] *= 255;
#$color[$curr] = sprintf("%.0f",)
#print "color is $color[$curr]\n";

}
return sprintf("%02x%02x%02x",$color[0],$color[1],$color[2]);
}

sub color_string
{
$start_rgb = shift;
$end_rgb = shift;
$string = shift;
$error = shift;
#print "COLOR STRING: passed $string\n";
$error = 0 if (! defined $error);

#ugly bug if this isn't declared my
my $color_string;
$str_len = length $string;
$i=0;

foreach $char (split //, $string) {
$fstr_color=color_grad($start_rgb,$end_rgb,$str_le n,$i++,$error);
#vb3 seems to treat individually colored spaces an non-printable
if ($char eq " ") {
$color_string .= "\[color\=\#$invisible\].\[/color\]";
} else {
$color_string .= "\[color\=\#$fstr_color\]$char\[/color\]";
}
}
#print "COLOR STRING: returning $color_string\n";
return $color_string;
}

# Remove whitespace from the start and end of the string
sub trimwhitespace($)
{
my $string = shift;
$string =~ s/^\s+//;
$string =~ s/\s+$//;
return $string;
}

sub stripcpu($) {
my $string = shift;
$string =~ s/Intel//ig;
$string =~ s/AMD//ig;
$string =~ s/\(R\)//ig;
$string =~ s/\(tm\)//ig;
$string =~ s/CPU//ig;
return $string;
}


sub progbar($) {
#make a pretty progress bar
my $seti_progress = shift;

#length of progress bar
$prog_len = 15;

#starting and ending colors for progress bar
$prog_start = "ff0000";
$prog_end = "0000ff";

#colors for the percent indicator
$pct_begin = "ff0000";
$pct_end = "00ff00";

#You can't see me.
#$invisible = "333333";

$filled_bars = sprintf("%.0f",($seti_progress)*$prog_len);
$pct_prog = sprintf("%.0f",$seti_progress*100);

$empty_bars = $prog_len - $filled_bars;
#print "$pct_prog% progress, $filled_bars chars, $empty_bars unfilled\n";


$prog_bar = "{";

for($i=0; $i < $filled_bars; $i++) {
$progress_char = ">";
$color=color_grad($prog_start,$prog_end,$prog_len, $i);
$prog_bar .= "\[color=#$color\]$progress_char\[/color\]";
}
$prog_bar .= "\[color=#$invisible\]";
$prog_bar .= "_" x $empty_bars;
$prog_bar .= "\[/color\]";
$prog_bar .= "}";

#now $prog_bar looks like "{****___}" but with color tags

$pct_len = length $pct_prog;
$spc_len = 4 - $pct_len;
$spc = "_" x $spc_len;
$prog_bar =~ s/$/\[color=#$invisible\]$spc\[\/color\]/;
#print "$prog_bar\n";

$pct_color = color_grad($pct_begin,$pct_end,100,$pct_prog);
$prog_bar =~ s/$/\[color=#$pct_color\]$pct_prog\%\[\/color\]/;

#progress bar is done!
#It should look like "{~~~~~~_____} 34%" but will COLOR.

return $prog_bar;
}

This produces an output similar to the following:
[color=#ff00ff]Crunching.for.Overclockers.com!
Team Rank: [b]29th________________81,952.95 Total SETI Credit
World Rank: 1,770th___________________517 Recent Average Credit

Current Work As Of 02/09/2005 at 00:53.
{>>>>>>>>>>_____}__65% goddess (Athlon XP 1800+)
{>>>>>>>________}__43% Crackerjack (mobile Athlon XP 1500+)
{>>>>>>>>>>>>>__}__86% Nacho (Mobile Pentium 4 2.80GHz)
{>>>>>>>>_______}__54% Nacho (Mobile Pentium 4 2.80GHz)

JigPu

JerMe
02-09-05, 10:55 PM
That's some hot stuff, JigPu =) I like what you've done with the code. Can I borrow? It'd help me learn about this stuff :D

When I have time, I think I'm going try to combine everything you and Christoph have done into a few versions of the sig (colors and layouts) and have people just nab the version they like. We'll see though 'cause it looks like this thread is slowing down.

gustav
02-10-05, 12:07 AM
That's some hot stuff, JigPu =) I like what you've done with the code. Can I borrow? It'd help me learn about this stuff :D

When I have time, I think I'm going try to combine everything you and Christoph have done into a few versions of the sig (colors and layouts) and have people just nab the version they like. We'll see though 'cause it looks like this thread is slowing down.

This sounds awesome! I'll have to try out the one you posted this weekend when I have time to mess around with it. Thanks for all your work!

JigPu
02-10-05, 01:24 AM
That's some hot stuff, JigPu =) I like what you've done with the code. Can I borrow? It'd help me learn about this stuff :D

When I have time, I think I'm going try to combine everything you and Christoph have done into a few versions of the sig (colors and layouts) and have people just nab the version they like. We'll see though 'cause it looks like this thread is slowing down.
Sure :) It's out there for anybody to tweak or improve on. Just PM me if you need any clarifications on how to do stuff with it.

JigPu

hrdwrjnkie
02-10-05, 01:45 AM
absolutely awesome tool, Christoph

Christoph
02-10-05, 02:34 AM
Thanks.
Just a note: If you want a colorful link, you have to use color_string on the string first, then add the url tags. I've checked, and colored links do work.

Also, update time!
There was a minor update with .65 that I forgot to mention. It just made the output from sig length checking more verbose, for those of you who care. It took a while to hack out that sig length checker code, and I like to at least see that it's doing something. ;)
The newest version is .66. The only changes are that the new version looks for updates on my fileserver (mksig.no-ip.org) and mksig now identifies itself as "mksig (your OS here) v.66 via LWP". This will give me an idea of how popular the project is but will have no impact on anyone otherwise. If you don't like this, just take ($^O) out of the line with "agent" or disable automatic updates.
As always, the update will be done automatically if you've enabled it and vice versa.

gustav
02-10-05, 07:38 PM
Ok I'm using Jerme's modified script posted a few posts up. I put in my info and followed the instructions best I could (I'm new to coding, barely understand it - just enough to get a grasp). We've PMed back and forth but we cant figure out why the stats for my second console won't show up. We got 2 of them to show up (at first I could only get one progress bar to show up) but now it shows 2 progress bars of the same console. Maybe someone can help me fix this? I'll post the file.