Skip to content

Instantly share code, notes, and snippets.

@krakjoe
krakjoe / arrayof-typehints.patch
Last active January 3, 2016 02:58
arrayof-typehints.patch
diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c
index 3f43b09..6f2ff75 100644
--- a/Zend/zend_compile.c
+++ b/Zend/zend_compile.c
@@ -1845,7 +1845,7 @@ void zend_do_end_function_declaration(const znode *function_token TSRMLS_DC) /*
}
/* }}} */
-void zend_do_receive_param(zend_uchar op, znode *varname, const znode *initialization, znode *class_type, zend_uchar pass_by_reference, zend_bool is_variadic TSRMLS_DC) /* {{{ */
+void zend_do_receive_param(zend_uchar op, znode *varname, const znode *initialization, znode *class_type, zend_uchar pass_by_reference, zend_bool is_variadic, zend_bool is_arrayof TSRMLS_DC) /* {{{ */
@krakjoe
krakjoe / fib.php
Last active June 11, 2019 09:33
SMP Fibonacci with pthreads
<?php
/**
* SMP Fibonacci
*
* Fibonacci sequencing is often used to show the virtues of such things as HHVM
*
* People think of it as a task that cannot be multi-threaded, this is flat out wrong.
*
* It can be multi-threaded, even in PHP, to great effect.
*
@krakjoe
krakjoe / nl2br.patch
Created October 30, 2013 16:02
nl2br limit
diff --git a/ext/standard/string.c b/ext/standard/string.c
index 2f05b65..5e1db9d 100644
--- a/ext/standard/string.c
+++ b/ext/standard/string.c
@@ -4210,19 +4210,20 @@ PHP_FUNCTION(hebrevc)
}
/* }}} */
-/* {{{ proto string nl2br(string str [, bool is_xhtml])
+/* {{{ proto string nl2br(string str [, bool is_xhtml [, integer limit]])
@krakjoe
krakjoe / get_network_interfaces_unix_all.patch
Last active December 26, 2015 16:39
get_network_interfaces
diff --git a/Zend/Zend.m4 b/Zend/Zend.m4
index 945409e..ed4c0d7 100644
--- a/Zend/Zend.m4
+++ b/Zend/Zend.m4
@@ -106,6 +106,25 @@ ZEND_FP_EXCEPT
ZEND_CHECK_FLOAT_PRECISION
+AC_MSG_CHECKING([for usable ifaddrs.h])
+ AC_TRY_LINK([
@krakjoe
krakjoe / anon.php
Last active December 23, 2015 23:09
anon classes demo
<pre>
<?php
class Outer {
protected $data;
public function __construct(&$data) {
/* array access will be implemented by the time we get to here */
$this->data = &$data;
}
@krakjoe
krakjoe / gist:6577810
Last active December 23, 2015 04:08
Testing something ...
<?php
/* creating 50 threads is nearly always a bad idea */
class WebRequest extends Thread {
public $url;
public $data;
public $runtime;
public function __construct($url) {
$this->url = $url;
}
@krakjoe
krakjoe / pthreads.md
Last active August 30, 2023 18:30
pthreads.md

Multi-Threading in PHP with pthreads

A Brief Introduction to Multi-Threading in PHP

  • Foreword
  • Execution
  • Sharing
  • Synchronization
  • Pitfalls
@krakjoe
krakjoe / monte.php
Last active December 17, 2015 18:29
An example of why threading is better ...
<?php
/*
* This class wraps a number that should be changed exclusively by each context
*/
class AtomicNumber extends Stackable {
public $value;
public function __construct($value) { $this->value = $value; }
public function run(){}
@krakjoe
krakjoe / leak.php
Last active December 17, 2015 07:59
<?php
class Job extends \Stackable {
function run() {
$this->isComplete = TRUE;
}
}
class MyWorker extends \Worker {
function run() {}
}
@krakjoe
krakjoe / stacking_error_handlers.patch
Created April 23, 2013 08:13
stacking error handlers
--- php-src/Zend/zend.h 2013-04-15 17:22:35.094419723 +0100
+++ php-fork/Zend/zend.h 2013-04-22 15:29:38.679615669 +0100
@@ -296,6 +296,34 @@
# define zend_error_noreturn zend_error
#endif
+/* {{{ zend_error_t */
+typedef struct zend_error_t {
+ zend_bool handled;
+ zend_ushort level;