Posts Tagged ‘geekery’

Rate me, bitches!

You know at the bottom of those emails from your tech support people, where it asks you to take a survey and you might win something? Yeah, they use those ratings for something. I wrote a little script so I could cut and paste my most recent ratings and see my average.  We’re expected to stay above a 9.0. I’m just on the edge. I got rep bombed with some 1′s. :(

 $ ./rate.pl -n
Sean's Hack-O-Matic Rating Hack! HUZZAH!
#       Rating  Total   Avg
========================================
1:      10      10      10.00
2:      10      20      10.00
3:      10      30      10.00
4:      10      40      10.00
5:      9       49      9.80
6:      1       50      8.33
7:      10      60      8.57
8:      10      70      8.75
9:      9       79      8.78
10:     1       80      8.00
11:     9       89      8.09
12:     10      99      8.25
13:     10      109     8.38
14:     8       117     8.36
15:     10      127     8.47
16:     10      137     8.56
17:     10      147     8.65
18:     9       156     8.67
19:     9       165     8.68
20:     10      175     8.75
21:     10      185     8.81
22:     10      195     8.86
23:     5       200     8.70
24:     10      210     8.75
25:     8       218     8.72
26:     10      228     8.77
27:     10      238     8.81
28:     10      248     8.86
29:     10      258     8.90
30:     9       267     8.90
31:     8       275     8.87
32:     10      285     8.91
33:     10      295     8.94
34:     10      305     8.97
35:     10      315     9.00
36:     10      325     9.03
37:     10      335     9.05
38:     10      345     9.08
39:     10      355     9.10
40:     10      365     9.12
41:     4       369     9.00
42:     10      379     9.02
43:     10      389     9.05
44:     10      399     9.07
45:     5       404     8.98
46:     10      414     9.00
47:     10      424     9.02
48:     10      434     9.04
49:     6       440     8.98
50:     8       448     8.96
51:     10      458     8.98
Rating Average: 8.98

Here’s the code, just for those who are curious:

#!/usr/bin/perl

use Getopt::Std;
getopts('hn');

if ($opt_n) { $nolog = 1; }
if ($opt_h) { print "USAGE: $0 [-n]\n\t-n = no logging\n"; exit; }

# Eat it, Yoshi!
@ratings = `cat ./rate.txt`;
$history = "history.txt";
# Setup variables
$total = 0;
$rate_total = 0;

print "Sean's Hack-O-Matic Rating Hack! HUZZAH!\n";
print "#\tRating\tTotal\tAvg\n";
print "========================================\n";

foreach $line (@ratings)
{
        chomp $line;

        # If a blank line or a comment (#) skip the line
        if ($line eq "" || substr($line,0,1) eq "#") { $currentline++; next; }

        # DURTY DURTY
        ($spam, $ham) = split/Rating: /,$line;
        ($rating, $spam) = split/\]/,$ham;

        # NO NUMBER? NO CARE!
        if (!$rating) { next; }

        # If ticket had multiple ratings, let's not cheat ourselves. Conquer and divide... (and average!)
        if ($rating =~ ",") {

                @multirating = split/\,/,$rating;
                foreach $mr (@multirating) {
                        # For each rating, you need to increment your count to keep the average correct.
                        $total++;
                        # Add the new to the existing
                        $rate_total = $rate_total + $mr;
                        $current_average = sprintf("%.2f",$rate_total / $total);
                        print "$total:\t$mr\t$rate_total\t$current_average\n";
                }

        } else {
                # Incremement for the average.
                $total++;
                # Add the new to the existing
                $rate_total = $rate_total + $rating;
                $current_average = sprintf("%.2f",$rate_total / $total);
                print "$total:\t$rating\t$rate_total\t$current_average\n";
        }
}

# Average the totals, round to 2 decimal places
$avg = sprintf("%.2f",$rate_total / $total);

print "Rating Average: $avg\n";

# Log it for historical tracking.
if ($nolog) {
        print "Logging disabled\n";
} else {
        &HistoryLog("$avg");
}

sub HistoryLog
{
    my($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);

    open (LOGFILE, ">>$history");

    printf LOGFILE "%02d/%02d/%04d %02d:%02d:%02d => %s\n",
    $mon+1, $mday, $year+1900, $hour, $min, $sec, $_[0];

    close(LOGFILE);
}

Nerds at play, disregard.

Saving this for later.. read part of this, and it seems interesting, but I have no time for jibber jabber, and work is calling my name, so I’m using this as my bookmark.

It’s Orgasmatron 5.1: The Ultimate Asterisk Kitchen Sink

Asterisk + Google Voice + A whole bunch of other stuff. May be useful in my quest for global domination.

Edit: and while i’m here, I found this in a google search for a cheat command to update all the SERIAL numbers in my DNS zone files..

http://www.commandlinefu.com/

The command, by the way is:

sed -i ‘s/20[0-1][0-9]\{7\}/’`date +%Y%m%d%I`’/g’ *