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

# Rudimentary Unique device counter
# <NAME> <<EMAIL>> - 2015-07-04
# Makes ALL THE ASSSUMPTIONS!
# Is generally naive.
# Many yaks were shaved.

use strict;
use warnings;
use 5.010;
use autodie;
use List::MoreUtils qw(uniq);
use File::Slurp;
use LWP::UserAgent;
 
my $ua = LWP::UserAgent->new;

# set iotransport ip in hosts
my $server_endpoint = "http://iotransport:1337/snapshot";

while ( 1 == 1 ) {
  my @lines = read_file( '/tmp/macs.txt' );
  unlink('/tmp/macs.txt');

  my @uniq = uniq @lines;

  my $unique = @uniq;


  # set custom HTTP request header fields
  my $req = HTTP::Request->new(POST => $server_endpoint);
  $req->header('content-type' => 'application/json');
   
  # add POST data to HTTP request body
  my $post_data = "{ \"device\":\"space3d\",\"count\":\"$unique\" }";
  $req->content($post_data);
   
  my $resp = $ua->request($req);
  if ( ! $resp->is_success) {
      say "HTTP POST error code: ".$resp->code;
      say "HTTP POST error message: ".$resp->message;
  }

  say "There are $unique unique devices";
  sleep 120;
}
<commit_msg>don't barf if macs.txt not yet generated<commit_after>#!/usr/bin/perl -w

# Rudimentary Unique device counter
# <NAME> <<EMAIL>> - 2015-07-04
# Makes ALL THE ASSSUMPTIONS!
# Is generally naive.
# Many yaks were shaved.

use strict;
use warnings;
use 5.010;
use autodie;
use List::MoreUtils qw(uniq);
use File::Slurp;
use LWP::UserAgent;
 
my $ua = LWP::UserAgent->new;

# set iotransport ip in hosts
my $server_endpoint = "http://iotransport:1337/snapshot";

while ( 1 == 1 ) {
  my @lines;
  if (-f "/tmp/macs.txt" ) {
    @lines = read_file( '/tmp/macs.txt' );
    unlink('/tmp/macs.txt');
  }

  if (@lines) {

    my @uniq = uniq @lines;

    my $unique = @uniq;


    # set custom HTTP request header fields
    my $req = HTTP::Request->new(POST => $server_endpoint);
    $req->header('content-type' => 'application/json');
     
    # add POST data to HTTP request body
    my $post_data = "{ \"device\":\"space3d\",\"count\":\"$unique\" }";
    $req->content($post_data);
     
    my $resp = $ua->request($req);
    if ( ! $resp->is_success) {
        say "HTTP POST error code: ".$resp->code;
        say "HTTP POST error message: ".$resp->message;
    }

    say "There are $unique unique devices";
  }
  sleep 120;
}

{'fraction_non_alphanumeric': 0.17303563761270932, 'fraction_numerical': 0.018892228424216402, 'mean_word_length': 3.2363636363636363, 'pattern_counts': {'":': 4, '<': 9, '<?xml version=': 0, '>': 29, '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': '7667548', 'n_tokens_mistral': 903, 'n_tokens_neox': 836, 'n_words': 230}