Skip to content

Instantly share code, notes, and snippets.

# app/models/enums.py
class IndicatorType(StrEnum):
PEOPLE = 'PEOPLE'
QUANTITY = 'QUANTITY'
QUALITY = 'QUALITY'
FINANCE = 'FINANCE'
# app/services/indicators/evaluators/base.py
Evaluable = TypeVar('Evaluable') # Это может быть Client, Account, Project, etc.
@goroba
goroba / operators.py
Last active December 17, 2023 21:08
Operators for data types that are leveraged in business rules
# уже реализован в app.models.enums
class Operator(Enum):
EQ = 'EQ'
...
# уже реализован в app.models.enums
class DataType(Enum):
INTEGER='INTEGER'
...
@goroba
goroba / RequestListener.php
Last active August 7, 2019 11:31
Replace request ip with X-REAL-IP header value, used by Docker to pass real outer IP to containers in Symfony Application (if you or your DevOps don't wonna to bother with `fastcgi_param REMOTE_ADDR $http_x_real_ip;` stuff).
<?php
namespace App\EventSubscriber;
use App\Manager\SettingManager;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\HttpKernel\KernelEvents;
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\Routing\RouterInterface;
@goroba
goroba / Media.php
Last active July 31, 2019 13:37
Using UUID as identifier for SonataMediaBundle media entity. File path generates in `/context/year-month/day/filename.ext ` way.
<?php
namespace App\Entity;
use Doctrine\ORM\Mapping as ORM;
use Sonata\MediaBundle\Entity\BaseMedia as BaseMedia;
/**
* @ORM\Entity(repositoryClass="App\Repository\MediaRepository")
*/