Skip to content

Instantly share code, notes, and snippets.

Joe Watkins krakjoe

Block or report user

Report or block krakjoe

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@krakjoe
krakjoe / crawler.php
Last active Jun 11, 2019
parallel Futures, Channels (buffered, unbuffered, synchros), Events using parallel producer/consumer pattern
View crawler.php
<?php
use \parallel\{Runtime, Future, Channel, Events};
/* usage php crawler.php [http://example.com] [workers=8] [limit=500] */
$page = $argv[1] ?: "https://blog.krakjoe.ninja"; # start crawling this page
$workers = $argv[2] ?: 8; # start this number of threads
$limit = $argv[3] ?: 500; # stop at this number of unique pages
$timeout = $argv[4] ?: 3; # socket timeout for producers
@krakjoe
krakjoe / example.php
Last active Jun 29, 2019
Executor Service with Parallel and Channels
View example.php
<?php
use \parallel\{Runtime, Channel};
class ExecutorService {
public function __construct(int $workers, string $channel = __CLASS__, int $backlog = Channel::Infinite) {
if ($backlog == 0) {
/*
* execute() will block until a worker is ready
*/
@krakjoe
krakjoe / log.diff
Last active Jan 20, 2019
pcov vs xdebug comparison
View log.diff
--- pcov.log 2019-01-20 14:28:58.444851609 +0100
+++ xdebug.log 2019-01-20 14:25:27.607884120 +0100
@@ -1,8 +1,8 @@
-time php vendor/bin/phpunit --coverage-text --colors=never 2>&1 > pcov.log
+time php vendor/bin/phpunit --coverage-text --colors=never 2>&1 >xdebug.log
PHPUnit 7.5.2 by Sebastian Bergmann and contributors.
-Runtime: PHP 7.2.15-dev
+Runtime: PHP 7.2.15-dev with Xdebug 2.7.0beta2-dev
@krakjoe
krakjoe / document.php
Last active Apr 15, 2019
for generating stubs for a loaded extension
View document.php
<?php
/*
usage: php document.php --ext name [--output document.txt]
*/
function prototype(Reflector $reflector) {
$elements = [];
switch (get_class($reflector)) {
case "ReflectionClass":
if ($reflector->isFinal()) {
@krakjoe
krakjoe / opcache.diff
Created Apr 14, 2017
7.1.0 ... 7.1.4 ext/opcache
View opcache.diff
diff --git a/ext/opcache/Optimizer/block_pass.c b/ext/opcache/Optimizer/block_pass.c
index 77b02cc99f..38c2ecb124 100644
--- a/ext/opcache/Optimizer/block_pass.c
+++ b/ext/opcache/Optimizer/block_pass.c
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| Zend OPcache |
+----------------------------------------------------------------------+
- | Copyright (c) 1998-2016 The PHP Group |
+ | Copyright (c) 1998-2017 The PHP Group |
View mm.patch
diff --git a/src/gdhelpers.c b/src/gdhelpers.c
index 20fff5c..a64278b 100644
--- a/src/gdhelpers.c
+++ b/src/gdhelpers.c
@@ -14,6 +14,33 @@
#define SEP_TEST (separators[*((unsigned char *) s)])
+static inline void* gd_malloc_wrapper(size_t size)
+{
View variance-correct-probably.patch
diff --git a/Zend/tests/object_types/variance_in_param.phpt b/Zend/tests/object_types/variance_in_param.phpt
index bcc528e..cf28dd8 100644
--- a/Zend/tests/object_types/variance_in_param.phpt
+++ b/Zend/tests/object_types/variance_in_param.phpt
@@ -15,6 +15,7 @@ class Bar extends Foo {
var_dump(new Bar);
?>
--EXPECTF--
+Warning: Declaration of Bar::qux(Qux $qux) should be compatible with Foo::qux(object $object) in %s on line 10
object(Bar)#%d (0) {
@krakjoe
krakjoe / starfield.d
Created Nov 8, 2016
Starfield in D, uses krakjoe/dui (or any other 1:1 module)
View starfield.d
import std.random;
import andlabs.libui;
struct Star {
double X;
double Y;
double V;
bool F;
double G;
View test.md

ui

Build Status

This extension wraps the very excellent libui to provide PHP 7 with an API for the creation of cross platform native look-and-feel interfaces.

TODO

  • queue for pthreads
View starfield.php
<?php
use UI\App;
use UI\Window;
use UI\Point;
use UI\Size;
use UI\Area;
use UI\Controls\Box;
use UI\Draw\Pen;
use UI\Draw\Brush;
use UI\Draw\Path;
You can’t perform that action at this time.