Skip to content

Instantly share code, notes, and snippets.

View rela589n's full-sized avatar

Yevhen Sidelnyk rela589n

View GitHub Profile
@rela589n
rela589n / composer.json
Created April 15, 2025 11:55
composer scripts
{
"scripts": {
"auto-scripts": {
"cache:clear": "symfony-cmd",
"assets:install %PUBLIC_DIR%": "symfony-cmd"
},
"post-install-cmd": [
"@auto-scripts"
],
"post-update-cmd": [
Second Input Processed Left Rejected
1 300 200 0 100
2 301 200 0 101
3 337 200 0 137
Second Input Processed Left Rejected
1 300 300 0 0
2 301 300 0 1
3 337 300 0 37
Second Input Processed Left
1 300 200 100
2 400 200 200
3 500 200 300
Second Input Processed Left
300 600 300 300
301 601 300 301
Second Input Processed Left
1 301 300 1
2 302 300 2
3 303 300 3
@rela589n
rela589n / scratch.sql
Created August 1, 2024 14:10
Postgresql group by overlapping date periods
WITH period_ranges AS (
SELECT
id,
tstzrange(period_start, period_end) AS period
FROM
your_table
), recursive_group AS (
SELECT
id,
period,
@rela589n
rela589n / source.php
Last active June 15, 2024 11:55
Non-blocking http requests in PHP
<?php
final class PricesHttpClient implements PricesClient
{
public function __construct(
// AMPHP http client (https://github.com/amphp/http-client)
private HttpClient $httpClient,
) {
}
@rela589n
rela589n / source.php
Created May 22, 2024 17:29
Doctrine stop removing foreign key
#[AsDoctrineListener(event: ToolEvents::postGenerateSchema)]
final readonly class QuestionForeignKeyListener
{
/** @throws SchemaException */
public function postGenerateSchema(GenerateSchemaEventArgs $eventArgs): void
{
$schema = $eventArgs->getSchema();
$table = $schema->getTable('answers');
@rela589n
rela589n / gist:a38ac8d34acf8778a4e994dd4985bb9a
Created May 22, 2024 13:24
Manually initializing relationship on doctrine entity
// warning: this approach is error-prone in case if there's a doctrine's lazy-entity proxy!
// when trying to call getQuestion() method on such non-initialized object, "property not initialized" error will come up
trait ManyToOneOtherEntityRelationshipMappingTrait
{
protected Question $question;
#[ORM\Column(type: 'uuid')]
private Uuid $questionId;