<commit_before>#!/usr/bin/perl -wT

use strict;
use File::Spec::Functions;
use File::Path;
use LWP::Simple;
use Data::Dumper;

$ENV{'PATH'} = '';
use vars qw($IMGURL $BASEDIR);

$IMGURL = 'http://homer.cnr.berkeley.edu/CoGe/GenomePNG.pl?';
# where to start the caching
$BASEDIR = "/opt/apache/CoGe/_cache_/";

while (! -e $BASEDIR){ mkdir($BASEDIR);  }
print "Content-type: image/png; mode=24bit\n\n";

my $basedir = [split(/[\\\/]/,$BASEDIR)];
my ($dir) = get_dir_array();

my $reldir = catfile(@$dir) . '.png';
my $basepath = catfile(@$basedir);


my $fn = catfile($basepath,@$dir) . '.png' ;
my $data;

if(!-e $fn){
   pop @$dir; # get rid of the file name
   mkpath($basepath . '/' . join("/",@$dir));
   LWP::Simple::getstore($IMGURL . $ENV{QUERY_STRING},$fn);
   chmod (0777, $fn);
#   print STDERR $IMGURL.$ENV{QUERY_STRING},"\n";
}


# DUMP THE IMAGE
{
local( *IMG,$/ ); 
my $mesg = "cant open $fn\nmake sure _cache_ dir is web writeable\n";
open( IMG,"<", $fn) or warn "cant open $mesg\n"; binmode IMG;
print <IMG>; close(IMG);
}

system 'chmod -R 777 /opt/apache/CoGe/_cache_/*';

##################################################
# Use %ENV to find where in directory structure
# we are and make an array of directory names  
##################################################
sub get_dir_array {
    my ($qstr) = $ENV{QUERY_STRING} =~ /(.*)/;
    $qstr =~ s/[\s-]//;
    my @dir = ();

    # parse the url;
    my %query_pairs = map { split('=', $_) } split(/&/,$qstr);<commit_msg>removed chmod<commit_after>#!/usr/bin/perl -wT

use strict;
use File::Spec::Functions;
use File::Path;
use LWP::Simple;
use Data::Dumper;

$ENV{'PATH'} = '';
use vars qw($IMGURL $BASEDIR);

$IMGURL = 'http://homer.cnr.berkeley.edu/CoGe/GenomePNG.pl?';
# where to start the caching
$BASEDIR = "/opt/apache/CoGe/_cache_/";

while (! -e $BASEDIR){ mkdir($BASEDIR);  }
print "Content-type: image/png; mode=24bit\n\n";

my $basedir = [split(/[\\\/]/,$BASEDIR)];
my ($dir) = get_dir_array();

my $reldir = catfile(@$dir) . '.png';
my $basepath = catfile(@$basedir);


my $fn = catfile($basepath,@$dir) . '.png' ;
my $data;

if(!-e $fn){
   pop @$dir; # get rid of the file name
   mkpath($basepath . '/' . join("/",@$dir));
   LWP::Simple::getstore($IMGURL . $ENV{QUERY_STRING},$fn);
#   chmod (0777, $fn);
#   print STDERR $IMGURL.$ENV{QUERY_STRING},"\n";
}


# DUMP THE IMAGE
{
local( *IMG,$/ ); 
my $mesg = "cant open $fn\nmake sure _cache_ dir is web writeable\n";
open( IMG,"<", $fn) or warn "cant open $mesg\n"; binmode IMG;
print <IMG>; close(IMG);
}

system 'chmod -R 777 /opt/apache/CoGe/_cache_/*';

##################################################
# Use %ENV to find where in directory structure
# we are and make an array of directory names  
##################################################
sub get_dir_array {
    my ($qstr) = $ENV{QUERY_STRING} =~ /(.*)/;
    $qstr =~ s/[\s-]//;
    my @dir = ();

    # parse the url;
    my %query_pairs = map { split('=', $_) } split(/&/,$qstr);
{'fraction_non_alphanumeric': 0.27132820341251257, 'fraction_numerical': 0.006022080963532954, 'mean_word_length': 4.050675675675675, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5644406', 'n_tokens_mistral': 1204, 'n_tokens_neox': 1182, 'n_words': 282}