Created
October 3, 2019 05:11
-
-
Save marked/f0c39aa1220f42fda76fb4c8ec844a23 to your computer and use it in GitHub Desktop.
Tabulates for each character what codes it's been a part of before
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl | |
use warnings; | |
use strict; | |
use autodie; | |
my $interesting_RE = "Fetched http://picosong.s3.amazonaws.com/"; | |
my %char_range = map { $_ => 1 } (32..126); | |
my %char_stats = map { $_ => 0 } keys(%char_range); | |
my %stat_code_bitmask = ( 200 => 2, 403 => 1 ); | |
while (my $line = <>) { | |
chomp $line; | |
if ($line =~ "$interesting_RE") { | |
my @fields = split / /, $line; | |
my ($url, $http_code) = ($fields[5], $fields[6]); | |
chop $url; | |
$url = (split /\?/, $url)[0]; | |
my @chars = split //, $url; | |
foreach my $ch (@chars) { | |
if ( ! defined $stat_code_bitmask{$http_code} ) { print "New Code: $http_code\n"; last; } | |
if ( defined($char_stats{ord($ch)}) && $char_range{ord($ch)} && defined $stat_code_bitmask{$http_code}) { | |
$char_stats{ord($ch)} = $stat_code_bitmask{$http_code} | $char_stats{ord($ch)}; | |
} | |
} | |
} | |
} | |
print "------------------------------------------------------------------------------------------------------\n"; | |
print "both "; print_row(3); | |
print " 200 "; print_row(2); | |
print " 403 "; print_row(1); | |
print "none "; print_row(0); | |
print "------------------------------------------------------------------------------------------------------\n"; | |
sub print_row{ | |
my $level = pop @_; | |
foreach my $c (sort { $a <=> $b } (keys(%char_range))) { | |
if (defined $char_stats{$c} && $char_stats{$c} == $level) { | |
print chr($c); | |
#{ print "_" } if ($c == 32); #TODO | |
} else { | |
print " "; | |
} | |
} | |
print "\n"; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# cat qwarc*log | ./char_stats.pl | |
New Code: 503 | |
------------------------------------------------------------------------------------------------------ | |
both % -./0123456789: ABCDEFGHIJKLMNOPQRSTUVWXYZ _ abcdefghijklmnopqrstuvwxyz | |
200 | |
403 ! &'() , @ | |
none "#$ *+ ;<=>? [\]^ ` {|}~ | |
------------------------------------------------------------------------------------------------------ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment