Skip to content

Instantly share code, notes, and snippets.

View morozov's full-sized avatar

Sergei Morozov morozov

View GitHub Profile
from abc import ABC, abstractmethod
class Operation(ABC):
@abstractmethod
def apply(self, color):
pass
@abstractmethod
def __str__(self):
@morozov
morozov / Driver.php
Created November 6, 2021 01:04
External PDO driver middleware for Doctrine DBAL
<?php
use Doctrine\DBAL\Connection;
use Doctrine\DBAL\Driver as DriverInterface;
use Doctrine\DBAL\Driver\API\ExceptionConverter;
use Doctrine\DBAL\Driver\PDO\Connection as PDOConnection;
use Doctrine\DBAL\Platforms\AbstractPlatform;
class Driver implements DriverInterface
{
@morozov
morozov / benchmark.php
Last active November 12, 2020 02:47
SQL Parser Benchmark
<?php
use Doctrine\DBAL\Connection;
use Doctrine\DBAL\ExpandArrayParameters;
use Doctrine\DBAL\ParameterType;
use Doctrine\DBAL\SQL\Parser;
use Doctrine\DBAL\SQLParserUtils;
require __DIR__ . '/vendor/autoload.php';
@morozov
morozov / diff-class-map.sh
Created August 12, 2020 16:44
Generates the diff between Composer autload files from a pull request
#!/usr/bin/env bash
set -eu
if [ $# -ne 1 ]; then
echo "Usage: `basename $0` <pull>";
exit 1;
fi
PULL="$1"
@morozov
morozov / .gitignore
Last active June 20, 2020 05:03
PHPUnit and Psalm
/vendor
@morozov
morozov / .gitignore
Last active May 26, 2020 03:14
composer/package-versions-deprecated incompatible with humbug/box
/example.phar
/vendor
sudo ./sockdump.py --format string --output dump.txt ~/.phpbrew/php/php-7.4.5/var/run/php-fpm.sock
@morozov
morozov / watch-and-diff.sh
Last active October 10, 2019 21:01
Watch and Diff. A shell script for monitoring changes in configuration files
#!/usr/bin/env bash
set -euo pipefail
function __get_missing_keys {
php -- "$@" << 'EOF'
<?php
$args = $GLOBALS['argv'];
array_shift($args);
@morozov
morozov / backport.sh
Last active December 6, 2018 09:49
A shell script for back-porting Doctrine DBAL pull requests from master to older branches
#!/usr/bin/env bash
set -eu
if [ $# -ne 2 ]; then
echo "Usage: `basename $0` <pull> <branch>";
exit 1;
fi
PULL="$1"
<?php
class Sorter
{
private $callback;
public function __construct(array $orderBy)
{
$functions = [];