Skip to content

Instantly share code, notes, and snippets.

@ku
Created April 7, 2009 08:29
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save ku/91148 to your computer and use it in GitHub Desktop.
teiten hacks
#!/usr/bin/perl
use YAML;
my $tmpfile = 'teiten.tmp';
open F, '<', 'teiten.data';
my $data = join "", <F>;
my $params = {};
foreach my $pairs ( split /&/, $data ) {
my($n, $v) = split /=/, $pairs;
$params->{$n} = $v;
}
my @pixels = split /\%2C/, $params->{colors};
#my @pixels = (@pixels, @pixels,@pixels, @pixels);
open F, '>', $tmpfile;
print F 'colors=';
print F join '%2C', map {
my $r = hex substr($_, 0, 2);
my $g = hex substr($_, 2, 2);
my $b = hex substr($_, 4, 2);
if ( 0 ) {
$_;
} else {
my $avg = int(($r+$g+$b)/3);
sprintf('%02x%02x%02x',
$avg, # ($r),
$avg, # ($g),
$avg, # ($b),
);
}
} @pixels;
print F '&';
print F '&h=120&w=160';
print qx{curl -v --cookie teiten.cookie --data "\@$tmpfile" http://teiten.org/snapshot.php}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment