Computers: October 2007 Archives
So in 2004 I predicted the Red Sox would win in 2006, using a mathematical formula. I was wrong. So I realized that my formula was off. Because the length of difference between last year won and the pivotal year of beating St. Louis crossed millennia, we had to add an extra year.
#!/usr/bin/perlThis formula correctly "predicts" the next championship of each team:
use warnings;
use strict;
# script to predict when the next Boston team championship
# will occur after either:
#
# * winning first championship in team history, against St. Louis
#
# OR
#
# * winning first championship since St. Louis existed as a team
my %boston_team = (
# team last year won, year beat St. Louis
Celtics => [1957, 1957],
Bruins => [1941, 1970],
Patriots => [2002, 2002],
'Red Sox' => [1918, 2004],
);
for my $team (sort { $boston_team{$a}[1] <=> $boston_team{$b}[1] } keys %boston_team) {
printf "%s: %d\n", $team,
predict_year(@{$boston_team{$team}});
}
sub predict_year {
my($last_won, $beat_stl) = @_;
my $base_year = $beat_stl + 2;
$base_year += int($beat_stl/1000) - int($last_won/1000); # adjust for difference
return $base_year;
}
__END__
Celtics: 1959I CALLED IT!!!!!</colbert>
Bruins: 1972
Patriots: 2004
Red Sox: 2007
So the question is: is there a way to detaint arbitary data in Perl without using hash keys or regexes or XS?
Something hit me. This: ./taint.plx -dakdjhasd and you get $name with dakdjhasd in it, untainted.
This is not the same thing, but what it does do is take some untrusted data that you normally might expect to be tainted, since it's just data on the command line, and makes it trusted. But this is not arbitrary data, and it is not tainted in the first place (and therefore not untainted). Interesting though. Then I thought:
Now, I know, this is still basically using hash keys, since the symbol table is a hash. But I don't care. Also, it wouldn't necessarily work with arbitrary data, given symbol table limitations.
Just something passing through my head.
Something hit me. This:
#!/usr/bin/perl -sTlExecute that like
use warnings;
use strict;
use Scalar::Util 'tainted';
no strict 'refs';
for my $name (keys %{'::'}) {
printf "%s:%d\n", $name, tainted($name)
if $name =~/^[a-z]\w+$/i
&& $$name;
}
This is not the same thing, but what it does do is take some untrusted data that you normally might expect to be tainted, since it's just data on the command line, and makes it trusted. But this is not arbitrary data, and it is not tainted in the first place (and therefore not untainted). Interesting though. Then I thought:
#!/usr/bin/perl -TlW00t. Data is untainted!
use warnings;
use strict;
use Scalar::Util 'tainted';
no strict 'refs';
my $foo = $ENV{HOME};
printf "%s:%d\n", $foo, tainted($foo);
${'::' . $foo} = 'la la la';
my $bar;
for my $name (keys %{'::'}) {
if ($name eq $foo) {
$bar = $name;
last;
}
}
printf "%s:%d\n", $bar, tainted($bar);
Now, I know, this is still basically using hash keys, since the symbol table is a hash. But I don't care. Also, it wouldn't necessarily work with arbitrary data, given symbol table limitations.
Just something passing through my head.
Back up your hard drive before upgrading.
You're welcome.
I back up my HD every night with SuperDuper!, and I make a special point to do it for any significant system upgrade, including a minor revision (like 10.4.9 -> 10.4.10). It it borks my system, I reinstall it from the backup.
It really works. Really.
You're welcome.
I back up my HD every night with SuperDuper!, and I make a special point to do it for any significant system upgrade, including a minor revision (like 10.4.9 -> 10.4.10). It it borks my system, I reinstall it from the backup.
It really works. Really.
The party last night was great. We had significantly less than the 157 people who signed up, but still a lot: about a third of that, I'd say. Plenty large. Amazon provided pizza and drinks (for which there was a lot of extra for people to take home!) and I had a great time meeting new people and meeting old friends for the first time in real life, and seeing old friends I hadn't seen in awhile.
Thanks again to Amazon and especially cjcollier for all the work he did to bring it all together.
Unfortunately I forgot to bring my camera. If you took pictures and you post them, please let me know!
Thanks again to Amazon and especially cjcollier for all the work he did to bring it all together.
Unfortunately I forgot to bring my camera. If you took pictures and you post them, please let me know!
I've posted my cover of "Still Alive" by Jonathan Coulton, from the video game Portal, on the Longest Concert Evar.
Don't forget to sign up for the Seattle Slashdot Party! Here's some of the details:
OK, we have a location: the 8th floor of the PacMed building on Beacon Hill. (Yes, that is Amazon HQ!).
The date is Saturday, October 20. Time is 6 p.m until whenever.
Because of security, please send me e-mail (pudge -at- slashdot -dot- org) with your name, and bring ID to the party confirming. If you don't, no huge deal, but you may need to spend a few minutes at the front desk while you fill out a paper and they print out a badge. Sorry about the minor hassle, but it'll be worth it!
Parking is free and available on the north side of the building (the graded area on the down-slope of Beacon Hill in the picture). If you give me your name beforehand and bring your ID, go to the west entrance. Otherwise, use the lower, north entrance. (If you have RSVP's and have your ID, but need a more accessible entrance, use the north entrance but skip the line and show your ID.)
If you want to network with people OR computers, feel free to bring the appropriate gear: resumes, business cards, laptops, etc. No WiFi provided (doesn't mean not allowed!).
Some food will probably be provided. Updates to follow on that. Alcohol will not be "provided."
Thanks very much to Amazon and their hospitality and generosity.
We will have some free t-shirts and things to give away.
See mullein's comment for bus information.
Thanks all, should be a great evening. See you Saturday.
OK, we have a location: the 8th floor of the PacMed building on Beacon Hill. (Yes, that is Amazon HQ!).
The date is Saturday, October 20. Time is 6 p.m until whenever.
Because of security, please send me e-mail (pudge -at- slashdot -dot- org) with your name, and bring ID to the party confirming. If you don't, no huge deal, but you may need to spend a few minutes at the front desk while you fill out a paper and they print out a badge. Sorry about the minor hassle, but it'll be worth it!
Parking is free and available on the north side of the building (the graded area on the down-slope of Beacon Hill in the picture). If you give me your name beforehand and bring your ID, go to the west entrance. Otherwise, use the lower, north entrance. (If you have RSVP's and have your ID, but need a more accessible entrance, use the north entrance but skip the line and show your ID.)
If you want to network with people OR computers, feel free to bring the appropriate gear: resumes, business cards, laptops, etc. No WiFi provided (doesn't mean not allowed!).
Some food will probably be provided. Updates to follow on that. Alcohol will not be "provided."
Thanks very much to Amazon and their hospitality and generosity.
We will have some free t-shirts and things to give away.
See mullein's comment for bus information.
Thanks all, should be a great evening. See you Saturday.
The location and time are set for the Slashdot Party in Seattle. Address is at the top of the page.
For more information, see the comment with details.
For more information, see the comment with details.