Skip to content

Instantly share code, notes, and snippets.

Crell / benchmark.php
Last active Dec 30, 2020 — forked from olleharstedt/benchmark.js
Clone benchmark
View benchmark.php
const ITERS = 1000000;
class QueryBuilder {
public $select;
public $from;
public $where;
public function withSelect($sel) {
View error.txt
FetchError: request to http://solr.internal:8080/solr/maincore/update? failed, reason: connect ECONNREFUSED
at ClientRequest.<anonymous> (/app/node_modules/node-fetch/lib/index.js:1455:11)
at ClientRequest.emit (events.js:314:20)
at Socket.socketErrorListener (_http_client.js:469:9)
at Socket.emit (events.js:314:20)
at emitErrorNT (internal/streams/destroy.js:100:8)
at emitErrorCloseNT (internal/streams/destroy.js:68:3)
at processTicksAndRejections (internal/process/task_queues.js:80:21) {
type: 'system',
View Enum1.php
enum Option {
case None = new class {};
case Some = new class($val) {
public function __construct(private $val) {}
public function value() { return $val; }
public function value{} { throw new TypeError; }
echo "Installing Additional Plugins"
cd plugins
while read -r line; do
[ "$line" = "\#*" ] && continue
git clone --depth=1 $line
done < grep -v -- "^#" "$file"
cd ..
View zend_compile.c
void zend_compile_call(znode *result, zend_ast *ast, uint32_t type) /* {{{ */
zend_ast *name_ast = ast->child[0];
zend_ast *args_ast = ast->child[1];
znode name_node;
// If this is a partial function call, convert it to a special partial opcode.
zend_ast_list *arglist = zend_ast_get_list(args_ast);
for (int i; i < arglist->children; ++i) {
Crell / after.php
Created Mar 24, 2020
Constructor promotion
View after.php
class Doer
public function __construct(protected Connection $database) {}
Crell / 1_single-attribute.php
Last active Mar 9, 2020
3 test implementations of PHP Attributes for Tukio
View 1_single-attribute.php
class ProviderBuilder {
public function addListenerService(string $serviceName, string $methodName, string $type, int $priority = 0, string $id = null): string
// ...
public function addSubscriber(string $class, string $serviceName): void
View command line
$ php -d ffi.enable=preload -d opcache.preload="dummy-preload.php" dummy-test.php
PHP Fatal error: Uncaught FFI\Exception: Failed loading scope 'DUMMY' in /home/crell/temp/php-ffi-test/dummy.php:11
Stack trace:
#0 /home/crell/temp/php-ffi-test/dummy.php(11): FFI::scope()
#1 /home/crell/temp/php-ffi-test/dummy-test.php(7): Dummy->__construct()
#2 {main}
thrown in /home/crell/temp/php-ffi-test/dummy.php on line 11
Crell / DoctrineProjectLoad.php
Created Aug 14, 2019
Is this too clever for its own good?
View DoctrineProjectLoad.php
namespace App\EventListener;
use App\Entity\Project;
use App\PlatformClient;
use Doctrine\Common\Persistence\Event\LifecycleEventArgs;
use Psr\Log\LoggerInterface;
use Symfony\Component\Messenger\MessageBusInterface;
View RegionType.php
namespace App\Form\Type;
use App\PlatformClient;
use Platformsh\Client\Model\Region;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\OptionsResolver\OptionsResolver;