Skip to content

Instantly share code, notes, and snippets.


Gabriel Ostrolucký ostrolucky

View GitHub Profile
View array_select.php
function array_select(array $array, array $filter): array
return array_map(function (array $object) use ($filter) {
$object = array_intersect_key($object, $filter);
foreach ($object as $key => $value) {
if (is_array($filter[$key])) {
$object[$key] = array_select($object[$key], $filter[$key]);
ostrolucky / transcript.txt
Created Apr 20, 2019
Using lldb to debug PHP code
View transcript.txt
Guilhermes-MacBook-Pro:orm guilhermeblanco$ lldb /usr/local/Cellar/php/7.3.2/bin/php
(lldb) target create "/usr/local/Cellar/php/7.3.2/bin/php"
Current executable set to '/usr/local/Cellar/php/7.3.2/bin/php' (x86_64).
(lldb) run ./vendor/bin/phpunit tests/Doctrine/Tests/ORM/Functional/PaginationTest.php --filter testIterateWithOutputWalkersWithRegularJoinWithComplexOrderByReferencingJoined
Process 99416 launched: '/usr/local/Cellar/php/7.3.2/bin/php' (x86_64)
PHPUnit 7.5.6 by Sebastian Bergmann and contributors.
Runtime: PHP 7.3.2 with Xdebug 2.7.0RC2
Configuration: /Users/guilhermeblanco/doctrine/orm/phpunit.xml.dist
ostrolucky / macflife.d
Created Mar 25, 2019
This script is from the DTrace book, and traces the creation and deletion of files
View macflife.d
#!/usr/sbin/dtrace -s
* maclife.d
* Example script from Chapter 5 of the book: DTrace: Dynamic Tracing in
* Oracle Solaris, Mac OS X, and FreeBSD", by Brendan Gregg and Jim Mauro,
* Prentice Hall, 2011. ISBN-10: 0132091518.
* See the book for the script description and warnings. Many of these are
* provided as example solutions, and will need changes to work on your OS.
ostrolucky /
Created Dec 15, 2018
Apply only changes which are mergeable to upper branch without conflicts
git checkout $BOTTOMBRANCH
php-cs-fixer fix $DIR --rules='{"array_syntax": {"syntax": "short"}}'
git diff > patch.patch && splitpatch patch.patch && rm patch.patch
git checkout $UPPERBRANCH --force
mkdir -p nonworkingpatches workingpatches && rm -rf nonworkingpatches/* workingpatches/*
for patchfile in *.patch*; do
ostrolucky / SoapClient.php
Last active Oct 10, 2019
SOAP with custom HTTP client
View SoapClient.php
namespace AppBundle\DataProvider;
use GuzzleHttp\Psr7\Request;
use Http\Client\Exception\HttpException;
use Http\Client\HttpClient;
* Wrapper around PHP SoapClient to use a HttpClient instead of php, allows better control over the request.
View RouteHistorySubscriber.php
namespace App\EventListener;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\HttpKernel\Event\FilterResponseEvent;
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
use Symfony\Component\HttpKernel\KernelEvents;
View StripeHttplugClient.php
namespace App\Service\Http;
use GuzzleHttp\Psr7\Request;
use GuzzleHttp\Psr7\Uri;
use Http\Client\HttpClient;
use Stripe\HttpClient\ClientInterface;
View currency mapping.xml
<doctrine-mapping xmlns=""
<embeddable name="Money\Currency">
<field name="code" length="3" />
ostrolucky / yaml-custom-tags.php
Last active Jan 3, 2018
Example usage Symfony Yaml custom tags
View yaml-custom-tags.php
require 'vendor/autoload.php';
$parsed = \Symfony\Component\Yaml\Yaml::parse(<<<YAML
a: !b64baby stuff
b: foo
ostrolucky / UniqueDTO.php
Created Dec 17, 2017
View UniqueDTO.php
namespace App\Validator\Constraints;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
* Checks if entity associatied to DTO is unique.