Skip to content

Instantly share code, notes, and snippets.

@dirx
dirx / domain-story.puml
Last active April 7, 2021 18:13
Plantuml Domain Story Test
' based on https://github.com/johthor/DomainStory-PlantUML
' Styling
' ##################################
!global $iconColor = "#333333"
!global $iconScale = "0.8"
!global $iconScaleActor = "1"
!global $stepColor = "#cccccc"
<?php
/**
* just trying to parse a header file with clang bound with php ffi ... it´s a start...
* and - yes - by binding ffi with ffi.... btw ... ieaks
*
* playing around in php74 cli buster docker image ...
* requires php ffi ext (libffi-dev) installed, clang 10 (libclang-common-10-dev libclang-10-dev)
*
* libc dlsym docs
* http://manpages.ubuntu.com/manpages/bionic/man3/dlsym.3.html
@dirx
dirx / ffi-dlsym-functions-pointer-with-shared-lib.php
Last active January 6, 2020 18:10
PHP 7.4 FFI and function pointers via dlopen & dlsym & shared library
<?php
// requires https://github.com/edenhill/librdkafka installed
declare(strict_types=1);
const RTLD_LAZY = 0x00001;/* Lazy function call binding. */
const RTLD_NOW = 0x00002;/* Immediate function call binding. */
const RTLD_BINDING_MASK = 0x3;/* Mask of binding time value. */
const RTLD_NOLOAD = 0x00004;/* Do not load the object. */
@dirx
dirx / ffi-dlsym-functions-pointer.php
Last active January 5, 2020 11:15
PHP 7.4 FFI and function pointers via dlsym
<?php
declare(strict_types=1);
// see http://manpages.ubuntu.com/manpages/bionic/man3/dlsym.3.html
$ffi = FFI::cdef(
"void *dlsym(void *handle, const char *symbol);"
);
$pointer = $ffi->dlsym(null, 'zend_write'); // it´s echo ...
$zend_write = FFI::new('void*(*)(...)'); // generic function pointer
@dirx
dirx / .bash_aliases
Last active November 16, 2015 16:42
Remote xdebug php console scripts in vagrant box
XDEBUG_REMOTE_HOST=$(echo $SSH_CLIENT | cut -d "=" -f 2 | awk '{print $1}')
alias phpx="export PHP_IDE_CONFIG=serverName=*NameOfServersHostInPHPStorm*;php -dxdebug.remote_enable=1 -dxdebug.remote_host=$XDEBUG_REMOTE_HOST -dxdebug.idekey=PHPSTORM -dxdebug.remote_autostart=1 -dxdebug.remote_connect_back=1"
@dirx
dirx / gist:60414eb80da9c7dbfb19
Last active January 17, 2017 03:44
Convert multiple array() to new php 5.4 style [] in code with phpstorm
Search regexp: \barray\(([^\(]*?)\)
Replace with: [$1]
Search & replace until it´s done.
Does not work if ( is in array keys or values.