<commit_before><?php
namespace Stark\Core;

class System {
    const OS_TYPE_MAC_OS = 'Darwin';
    const OS_TYPE_LINUX  = 'Linux';

    public static function runInBackground() {
        $pid = pcntl_fork();
        if ($pid == -1) die("Unable to fork\r\n");
        elseif ($pid) exit;
        
        posix_setsid();
        usleep(100000);
        
        $pid = pcntl_fork();
        if ($pid == -1) die("Unable to fork\r\n");
        elseif ($pid) exit;           
    }

    public static function getStatus($pid) {
        $file = "/proc/{$pid}/status";

        if (file_exists($file) === false) {
            return false;
        }

        $data = array();
        $lines = file($file);
        foreach ($lines as $line) {
            $line = trim($line);
            list($name, $value) = explode(':', $line);
            $data[trim($name)] = trim($value);
        }

        return $data;
    }

    public static function getProcNumber() {
        return shell_exec("nproc");
    }

    public static function setAffinity($pid, $mask = '1-32') {
        return shell_exec("taskset -cp {$mask} {$pid}");
    }

    public static function setProcTitle($pid, $title) {
        //TODO
    }

    public static function getLocalIp($device = '') {
        $osType = ucfirst(strtolower(php_uname('s')));

        if (!$device) {
            // Linux and other OS use eth0 as default device
            $device = 'eth0';

            if ($osType == self::OS_TYPE_MAC_OS) {
                $device = 'en0';
            }
        }

        $checkDeviceCommand = "(ifconfig {$device} >> /dev/null 2>&1 || (echo false && exit 1))";
        $awkCommand = 'awk \'/inet / {ipstr = $0;gsub("addr:", "", ipstr);split(ipstr, ip, " ");print ip[2]}\'';
        $ip = trim(shell_exec("{$checkDeviceCommand} && (ifconfig {$device} | {$awkCommand})"));

        if ($ip && $ip != 'false') {
            return $ip;
        }

        return '0.0.0.0';
    }

    public static function getSizeBytes($size) {
        $size = trim($size);
        if ($size == '') {
            return 0;
        }
        
        $last = strtolower($size[strlen($size) - 1]);
        switch($last) {
            case 'g':
                $size *= 1024 * 1024 * 1024;
            case 'm':
                $size *= 1024 * 1024;
            case 'k':
                $size *= 1024;
        }

        return $size;
    }
}<commit_msg>COPY COPY COPY<commit_after><?php
namespace Stark\Core;

class System {
    const OS_TYPE_MAC_OS = 'Darwin';
    const OS_TYPE_LINUX  = 'Linux';

    public static function runInBackground() {
        $pid = pcntl_fork();
        if ($pid == -1) die("Unable to fork\r\n");
        elseif ($pid) exit;
        
        posix_setsid();
        usleep(100000);
        
        $pid = pcntl_fork();
        if ($pid == -1) die("Unable to fork\r\n");
        elseif ($pid) exit;           
    }

    public static function getStatus($pid) {
        $file = "/proc/{$pid}/status";

        if (file_exists($file) === false) {
            return false;
        }

        $data = array();
        $lines = file($file);
        foreach ($lines as $line) {
            $line = trim($line);
            list($name, $value) = explode(':', $line);
            $data[trim($name)] = trim($value);
        }

        return $data;
    }

    public static function getProcNumber() {
        return shell_exec("nproc");
    }

    public static function setAffinity($pid, $mask = '1-32') {
        return shell_exec("taskset -cp {$mask} {$pid}");
    }

    public static function setProcTitle($pid, $title) {
        //TODO
    }

    public static function getLocalIp($device = '') {
        $osType = ucfirst(strtolower(php_uname('s')));

        if (!$device) {
            // Linux and other OS use eth0 as default device
            $device = 'eth0';

            if ($osType == self::OS_TYPE_MAC_OS) {
                $device = 'en0';
            }
        }

        $checkDeviceCommand = "(ifconfig {$device} >> /dev/null 2>&1 || (echo false && exit 1))";
        $awkCommand = 'awk \'/inet / {ipstr = $0;gsub("addr:", "", ipstr);split(ipstr, ip, " ");print ip[2]}\'';
        $ip = trim(shell_exec("{$checkDeviceCommand} && (ifconfig {$device} | {$awkCommand})"));

        if ($ip && $ip != 'false') {
            return $ip;
        }

        return '0.0.0.0';
    }

    public static function getSizeBytes($size) {
        $size = trim($size);
        if ($size == '') {
            return 0;
        }
        
        $last = strtolower($size[strlen($size) - 1]);
        switch($last) {
            case 'g':
                $size *= 1024 * 1024 * 1024;
                break;
            case 'm':
                $size *= 1024 * 1024;
                break;
            case 'k':
                $size *= 1024;
                break;
        }

        return $size;
    }
}
{'fraction_non_alphanumeric': 0.1638036809815951, 'fraction_numerical': 0.020040899795501024, 'mean_word_length': 1.6437837837837839, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, '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': '4594027', 'n_tokens_mistral': 1599, 'n_tokens_neox': 1481, 'n_words': 359}