Posts

Showing posts from January, 2024

HTML - How to add placeholder to dropdown (select) with selectpicker

First time in my life I needed to add placeholder for dropdown O.o I even didn`t know that it exists. But, anyway, I need to implement this case. I selected selectpicker from bootstrap to have ability to use live searching in dropdown. HTML for adding dropdown: <select class="dropdown" data-live-search="true">     <option class="hide" value="" disabled selected hidden>Placeholder</option>     <option value="option1">Option 1</option> </select>  Javascript: const select = $('select').selectpicker(); $('.dropdown').on('click', function () { $('.dropdown').find('.hide').hide(); });

List of Queue Managers (Queue Services, Streaming Systems, MQTT)

Image
Apache Kafka A distributed streaming platform designed for high-throughput, fault-tolerant, and scalable data streaming. It uses a publish-subscribe model and is widely used for real-time data processing. ActiveMQ An open-source message broker that supports Java Message Service (JMS) and provides features like message persistence, clustering, and diverse communication patterns. ZeroMQ A lightweight messaging library that allows for asynchronous message passing between applications. It provides various messaging patterns and is known for its simplicity and high performance. Apache Pulsar A distributed messaging and event streaming platform that enables scalable and durable messaging with multi-tenancy support. It is designed for high-throughput and low-latency use cases. NATS (NATS.io) A lightweight and high-performance messaging system for cloud-native applications. NATS supports publish-subscribe and point-to-point communication patterns and is known for simplici

Symfony - Doctrine - How to save SQL query to Session

If you have separated ajax table sheet with data and filters, sometimes, you need to keep this filtered data between requests. In my case, I needed to be able to download file in CSV format, after choosing all necessary filters in table. So, it is possible to store SQL query in client Session after applying all filters and receive data from DB via DQL. To store DQL in session: $query = $this->createQueryBuilder('i')->select('COUNT(i)'); $_SESSION['query'] = $query->getQuery()->getDQL(); $_SESSION['query_params'] = $query->getQuery()->getParameters(); To get data from DB: $data = $this->createQuery($_SESSION['query'])->setParameters($_SESSION['query_params'])->getResult();

jQuery UI - Dialog - How to hide autofocus

The simplest way, just add hidden input with autofocus attribute . < input type ="hidden" autofocus > As it said in jQuery UI documentation, it will find this input firstly by priority and move focus on this input. But as this input hidden user does not see this. Choosing priority: The first element with the autofocus attribute The first :tabbable element within the dialog's content The first :tabbable element within the dialog's buttonpane The dialog's close button The dialog itself

Symfony - Doctrine - How to set one-to-one relation with field not exist in target table, but exist in another one

Today, I faced with a bug: Custom Field entity has a RelId column relates to two different entities: Product and Bundle. Set RelId into Custom Field directly connected to Product, but not exist in Bundle table. After Entity Manager flush(), I got an error: RelId can not be null. How come that RelId field became null, when flushing. After debugging, I realized, Doctrine checks if exist this connected RelId field in Bundle table. If not, Doctrine just set RelId to null and go on. So, we need not to set RelId directly, but using entity, like Product or Bundle, in my case. Here's a simplified example using annotations: Let's assume you have three entities: SourceEntity, TargetEntity, and RelationEntity. RelationEntity will act as the join table, holding the relationship between SourceEntity and TargetEntity. // SourceEntity.php use Doctrine\ORM\Mapping as ORM; /** * @ORM\Entity */ class SourceEntity { // ... other properties /** * @ORM\OneTo