This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
declare(strict_types=1); | |
return (static function (\Rector\Config\RectorConfig $rectorConfig): void { | |
$rectorConfig->paths([ | |
'/home/hans/projects/php-ml/', | |
]); | |
$rectorConfig->sets([ | |
\Rector\Set\ValueObject\LevelSetList::UP_TO_PHP_82, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
declare(strict_types=1); | |
function fix_encoding(string $str): string | |
{ | |
//return $str; | |
return mb_convert_encoding($str, 'UTF-8', 'ISO-8859-1'); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#define _GNU_SOURCE | |
#include <iostream> | |
#include <pthread.h> | |
#include <chrono> | |
#include <vector> | |
#include <unistd.h> | |
#include <sched.h> | |
#include <stdexcept> | |
#include <climits> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# see https://github.com/php/php-src/issues/12450 | |
FROM ubuntu:20.04 | |
ENV DEBIAN_FRONTEND=noninteractive | |
RUN apt-get update -y | |
RUN apt-get -y full-upgrade; | |
RUN apt-get -y install apt-utils | |
RUN apt-get -y install golang build-essential git autoconf bison re2c make cmake automake libtool libpsl-dev libpsl5 | |
RUN bash -c 'set -e;\ | |
git clone -b curl-8_6_0 --single-branch --depth 1 https://github.com/curl/curl.git; \ | |
cd curl; \ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
declare(strict_types=1); | |
/** | |
* better version of shell_exec(), | |
* supporting both stdin and stdout and stderr and os-level return code | |
* | |
* @param string $cmd | |
* command to execute |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <fstream> | |
#include <thread> | |
#include <vector> | |
#include <string> | |
#include <cstdlib> | |
char **global_argv; | |
void testMemory() { | |
std::cout << "Starting Memory Test" << std::endl; | |
std::vector<char*> allocations; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
declare(strict_types=1); | |
$dir = realpath(__DIR__ . '/..'); | |
$files = shell_exec("find " . escapeshellarg($dir) . " -print0"); | |
$files = explode("\x00", rtrim($files, "\x00")); | |
$files = array_filter($files, function ($filepath) { | |
if (!preg_match("/page/", $filepath)) { | |
return false; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
declare(strict_types=1); | |
$dir = realpath(__DIR__ . '/..'); | |
$files = shell_exec("find " . escapeshellarg($dir) . " -print0"); | |
$files = explode("\x00", rtrim($files, "\x00")); | |
$files = array_filter($files, function ($filepath) { | |
if(!preg_match("/page/", $filepath)) { | |
return false; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env php | |
<?php | |
declare(strict_types=1); | |
use function var_dump as d; | |
function dd(...$args) | |
{ | |
$trace = debug_backtrace(0, 1)[0]; // odd, i really expected (0, 2)[1] ... but it works | |
$line = $trace['line']; | |
$file = $trace['file']; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"percent_sick_if_tested_positive": 4.458833791853989, | |
"percent_healthy_if_tested_positive": 48.80539325842697, | |
"percent_sick_if_tested_negative": 0.0011333259793069787, | |
"percent_healthy_if_tested_negative": 49.99971666368849, | |
"percent_tested_positive_and_sick": 49.719416386083054, | |
"percent_tested_positive_and_healthy": 1.9703818540227784, | |
"percent_tested_negative_and_sick": 1.1037527593818985, | |
"percent_tested_negative_and_healthy": 49.49240211146362, | |
"total_population": 5408000, |
NewerOlder