<commit_before>#!/usr/bin/env php
<?php

(@include_once __DIR__ . '/../vendor/autoload.php') or (print('ERROR: Installation incomplete, please see README' . PHP_EOL) and exit(1));

$loop = React\EventLoop\Factory::create();
$wolFactory = new Clue\Wol\Factory($loop);

$do = function ($mac, $address = Clue\Wol\Factory::DEFAULT_ADDRESS) use ($loop, $wolFactory) {
    $wolFactory->createSender($address)->then(function(Clue\Wol\Sender $wol) use($mac) {
        $wol->send($mac);
        echo 'Sending magic wake on lan (WOL) packet to ' . $mac . PHP_EOL;
    })->then(null, function (Exception $error) {
        echo 'Error: ' . $error->getMessage() . PHP_EOL;
        exit(1);
    });
};

$prompt = '> ';

if ($_SERVER['argc'] > 2) {
    $do($_SERVER['argv'][1], $_SERVER['argv'][2]);
} else if ($_SERVER['argc'] > 1) {
    $do($_SERVER['argv'][1]);
} else {
    echo 'No target MAC address given as argument, reading from STDIN: ' . PHP_EOL . $prompt;

    $loop->addReadStream(STDIN, function () use ($wol, $loop, $do, $prompt) {
        $line = fread(STDIN, 8192);
        if ($line === '') {
            // EOF: CRTL+D
            echo PHP_EOL;
            $loop->removeReadStream(STDIN);
        } else {
            $line = trim($line);
            if ($line === '') {
                // empty line<commit_msg>Use faster SocketSelectLoop<commit_after>#!/usr/bin/env php
<?php

(@include_once __DIR__ . '/../vendor/autoload.php') or (print('ERROR: Installation incomplete, please see README' . PHP_EOL) and exit(1));

$loop = new Socket\React\EventLoop\SocketSelectLoop();
$wolFactory = new Clue\Wol\Factory($loop);

$do = function ($mac, $address = Clue\Wol\Factory::DEFAULT_ADDRESS) use ($loop, $wolFactory) {
    $wolFactory->createSender($address)->then(function(Clue\Wol\Sender $wol) use($mac) {
        $wol->send($mac);
        echo 'Sending magic wake on lan (WOL) packet to ' . $mac . PHP_EOL;
    })->then(null, function (Exception $error) {
        echo 'Error: ' . $error->getMessage() . PHP_EOL;
        exit(1);
    });
};

$prompt = '> ';

if ($_SERVER['argc'] > 2) {
    $do($_SERVER['argv'][1], $_SERVER['argv'][2]);
} else if ($_SERVER['argc'] > 1) {
    $do($_SERVER['argv'][1]);
} else {
    echo 'No target MAC address given as argument, reading from STDIN: ' . PHP_EOL . $prompt;

    $loop->addReadStream(STDIN, function () use ($wol, $loop, $do, $prompt) {
        $line = fread(STDIN, 8192);
        if ($line === '') {
            // EOF: CRTL+D
            echo PHP_EOL;
            $loop->removeReadStream(STDIN);
        } else {
            $line = trim($line);
            if ($line === '') {
                // empty line
{'fraction_non_alphanumeric': 0.19375470278404816, 'fraction_numerical': 0.008276899924755455, 'mean_word_length': 2.804005722460658, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 23, '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': '5538763', 'n_tokens_mistral': 940, 'n_tokens_neox': 912, 'n_words': 206}