• Welcome to Overclockers Forums! Join us to reply in threads, receive reduced ads, and to customize your site experience!

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

Overclockers is supported by our readers. When you click a link to make a purchase, we may earn a commission. Learn More.
Christoph said:
*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:

Code:
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.
 
Last edited:
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.for.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. ;)
 
Last edited:
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.
 
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 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?
 
Last edited:
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.


Code:
####################################[b][/b]###########################################
#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))} );
###########################################[b][/b]####################################

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,$s[b][/b]tr_len,$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;
}


##########################################[b][/b]#####################################
#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
##########################################[b][/b]#####################################

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]);
}


#########################################[b][/b]######################################
#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
#########################################[b][/b]######################################
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.
 
Last edited:
cool, more code.. must have more code... *inhales code*

doh, the [co de] tag did the $str_le n thing again with the whitespace
 
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.)
 
Last edited:
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.
 
Last edited:
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 said:

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 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:

Code:
$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...
 
Last edited:
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
 
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.
 
The rules I based the checker on are here. Luckily, checking by hand is much easier than making a Perl script do it. I think you're at 8 points.
 
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.
 
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. ;)
 
Last edited:
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 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.
 
Last edited:
Back