Skip to content

Instantly share code, notes, and snippets.

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;
View prop_access.out
krakjoe@fiji:/usr/src/php-src$ sapi/cli/php -n prop.php
empty_loop 0.060
write_prop1() 0.085 0.025
write_prop2() 0.070 0.010
write_prop3() 0.058 -0.002
------------------------
Total 0.274
krakjoe@fiji:/usr/src/php-src$ sapi/cli/php -n prop.php
empty_loop 0.059
write_prop1() 0.086 0.027
View datetimeabstract.patch
diff --git a/ext/date/php_date.c b/ext/date/php_date.c
index 2f52353..930c9f1 100644
--- a/ext/date/php_date.c
+++ b/ext/date/php_date.c
@@ -326,7 +326,7 @@ ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(arginfo_timezone_offset_get, 0, 0, 2)
ZEND_ARG_OBJ_INFO(0, object, DateTimeZone, 0)
- ZEND_ARG_OBJ_INFO(0, datetime, DateTimeInterface, 0)
+ ZEND_ARG_OBJ_INFO(0, datetime, DateTimeAbstract, 0)
View phpdbg.txt
> It's just terrible to use the opcodes could be hidden, maybe toggle with a verbosity level flag e.g -v2.
They are hidden by default, you are shown opcodes when it's appropriate to show you opcodes or on request, if there's a bug, please report it.
> It's not smooth like pdb in python - having to 'eval' everything doesnt feel right.
You appear to be complaining that this isn't like some other software you have used, I'm not sure what to do with that.
Having to eval everything makes sense from the perspective that not all input is code, this is not a REPL, this is a debugger. What for example do we do with the input "run" if there is a run constant defined !? The answer is; nothing that makes sense in all situations. What does make sense, is eval'ing code.
View pool.md

Easy pthreads Pools

The final solution !!

Since the first version of pthreads, PHP has had the ability to initialize Worker threads for users. Onto those Worker threads are stacked objects of class Stackable for execution concurrently.

The objects stacked onto workers do not have their reference counts changed, pthreads forces the user to maintain the reference counts in userland, for the extremely good reason that this enables the programmer to keep control of memory usage; and so, execute indefinitely.

This is the cause of much heartache for newcomers to pthreads; if you do not maintain references properly you will, definitely, experience segmentation faults.

@krakjoe
krakjoe / mandel.md
Last active Oct 8, 2015
mandel pthreads
View mandel.md

This is a rather extreme test ... still, was fun ...

[joe@fiji pthreads]$ time php-zts ../php-src/mandrel.php 0 128

real	0m11.441s
user	0m11.386s
sys	0m0.043s
[joe@fiji pthreads]$ time php-zts ../php-src/mandrel.php 1 128
View workers.php
<?php
define("SECOND", 1000000);
class Task extends Stackable {
public function run() {
/* some random data */
$this->data = md5(
mt_rand() * microtime());
}
}
@krakjoe
krakjoe / generics-parser.patch
Last active Jan 3, 2016
generics-parser.patch
View generics-parser.patch
diff --git a/Zend/zend_language_parser.y b/Zend/zend_language_parser.y
index 752e27f..989296d 100644
--- a/Zend/zend_language_parser.y
+++ b/Zend/zend_language_parser.y
@@ -45,7 +45,7 @@ static YYSIZE_T zend_yytnamerr(char*, const char*);
%}
%pure_parser
-%expect 3
+%expect 5
@krakjoe
krakjoe / arrayof-perf.md
Last active Sep 11, 2020
arrayof-perf.md
View arrayof-perf.md

Arrayof Performance

<?php
function arrayof_foo(Foo[] $fooze) {
    foreach ($fooze as $foo) {
    	$foo->bar();
    }
}