StackOverflow.com

VN:F [1.9.22_1171]
Rating: 8.5/10 (13 votes cast)

Random snippets of all sorts of code, mixed with a selection of help and advice.

How to create a headers exchange binding on a complex header value

8 May 2026 @ 6:26 pm

I want to be able to trace messages as they make their way through RabbitMQ. So, I turned on Firehose tracing and then publisher and consumer event messages are sent to the amq.rabbitmq.trace Exchange. I made a queue called "trace.". However, since I only want to trace certain specified messages and don't want the overhead of writing all messages to the trace queue, I decided to create a Headers Exchange (called TraceFilter), and then set up a binding on the amq.rabbitmq.trace Exchange to send all of its messages to this new Headers exchange. What I want to be able to do is add a header to the original message, called "trace" with a value of true. Only those should be sent to the trace queue. I have examined the headers of the Firehose messages and there is one called "properties" Under that there is a sub-header called "headers" and under that they list the headers of the original message. How do I set up a binding on the Trace

Call to undefined function mysqli_report()

8 May 2026 @ 6:19 pm

ese error me salió de repente sin haber movido ninguna configuración del hosting que tengo en godaddy y no e podido solucionarlo me paso en todas las paginas que tengo en el dominio algún consejo o solución

Cannot resolve symbol 'productoRepository' in Spring Boot service class

8 May 2026 @ 5:19 pm

I am working on a Spring Boot project using Spring Data JPA. Inside my service class, I am trying to access productoRepository, but IntelliJ shows the error: Cannot resolve symbol 'productoRepository' The problem happens inside my delete method when trying to retrieve products by brand id. public void delete(Long id) { if (!this.marcaRepository.findById(id).isPresent()) { throw new ResponseStatusException(HttpStatus.NOT_ACCEPTABLE); } List<Producto> productos = productoRepository.findByMarcaIdOrderByNombreAsc(id); if (!productos.isEmpty()) { throw new ResponseStatusException(HttpStatus.BAD_REQUEST); } } This is the repository interface that contains the method I am trying to call: public interface ProductoRepository extends JpaRepository<Pro

Print capture groups for every match

8 May 2026 @ 5:18 pm

These both work: echo 'jg984tj89g02jg09248gj4209jg49' | perl -0lne 'print "$_\n" for /(\d)([a-z])/gs' echo 'jg984tj89g02jg09248gj4209jg49' | perl -0lne '@m = /(\d)([a-z])/gs; print for @m' But this doesn't: echo 'jg984tj89g02jg09248gj4209jg49' | perl -0lne 'print "$1-->$2\n" for /(\d)([a-z])/gs' (Basically last command outputs the capture groups over and over again for the last match, not iterating over each match) Anyone able to explain why? It would have been nice to control formatting with the last command, it could have been a quick, simple and convenient way of preparing / structuring the data for any next command.

Confused with grammar assignement symbol to value

8 May 2026 @ 5:03 pm

I've tried to implement advanced calculator with memorizing values into variables and have some problem. In my naive grammar, if input program has symbol name not in first line, building AST crash. I tried to determine problem cause, but so far without luck. Can you help to fix code and, mainly, explain why it crashes. I have this naive grammar: %language "c++" %skeleton "lalr1.cc" %defines %define api.value.type variant %param {yy::MyLangDriver* driver} %expect 1 %code requires { #include <memory> #include <string> #include <vector> #include "ast.h" namespace yy { class MyLangDriver; class ASTNode; } } %code { #include "driver.h" namespace yy { parser::token_type yylex(parser::semantic_type* yylval, MyLangDriver* driver) { return driver->yylex(yylval); } void parser::error(const std::string& msg) { driver-&

Is DDD the "Final Form" of OOP, or a necessary abstraction to save us from it?

8 May 2026 @ 3:44 pm

we’ve used Object-Oriented Programming (OOP) to model the world through encapsulation, inheritance, and polymorphism. However, in large-scale enterprise systems, we often see OOP devolve into "Anemic Domain Models," where objects are mere data containers (POJOs/DTOs) and logic is leaked into bloated Service layers. keywords about oop and ddd image made by wordcloud.art Domain-Driven Design (DDD) arrived to shift the focus from "how objects behave" to "how the business speaks." But this raises a fundamental tension: The Granularity Conflict: OOP encourages fine-grained objects for reuse. DDD encourages Aggregates—coarse-grained clusters that enforce invariants. Does DDD inherently limit the "purity" of OOP by f

how to go about changing displayed XAML file on a WPF program

8 May 2026 @ 2:55 pm

I am building my first WPF app, I have run into a wall when it's time to change screens on the app, I have two XAML files with their respective xaml.cs files, I want to implement buttons to switch between these two UIs or screens. but I am not sure how to go about it. I think I should also mention that I am using .NET 4.8 due to convoluted reasons where I work.

How to achieve concurrent working on a job queue?

8 May 2026 @ 2:09 pm

I am new to a project. They use the following architecture in many places: write Job to a database-table (plain table, no JMS) read a batch of Jobs from the database with a @Scheduled method (lock it in the database, to ensure only once processing) process the job(s) (mark them as successful, or it gets retried later) Those scheduled jobs/the time wasted between execution are obviously not state of the art/a big waste of time. I would like to achieve concurrent working on the job table, without schedulers or batch-processing. If there is a job in the table it should be processed as soon as it is available, if an instance (its a kubernetes managed Spring-Boot application that could be scaled) of the application is idle. If there is no work the application could go to sleep for a specified amount of time. What are recommended solutions for that purpose? Is there a pattern that solves this,

How to efficiently query high-volume custom post types without hitting wp_postmeta join bottlenecks?

7 May 2026 @ 11:33 pm

I am managing a WordPress site with 100k+ entries in a custom post type. Standard WP_Query with multiple meta_query arguments is causing significant performance bottlenecks due to complex wp_postmeta joins. What are the best practices for optimization? Should I migrate to custom database tables for these specific fields, or is implementing a solution like Elasticsearch or Algolia a more scalable approach for high-frequency backend filtering? I’ve already optimized indexes, but the join overhead remains high.

Case labels only if global variables exist

7 May 2026 @ 9:15 pm

I am writing an Arduino program that takes in commands via serial. One of these commands is "Read the specified analog input". The relevant code basically looks like this: switch (Channel) { case 0: write(analogRead(A0)); break; case 1: write(analogRead(A1)); break; case 2: write(analogRead(A2)); break; case 3: write(analogRead(A3)); break; // ...... } Different boards/controllers have different numbers of analog inputs (possible non-contiguous). I don't want to have to edit the code and comment-out sections (and then potentially forget to un-comment those later) when using this for different boards. Ideally, I would like something like this: switch (Channel) { #ifdef A0 case 0: Serial.write(A0); break; #endif #ifdef A1 case 1: Serial.write(A1); break; #endif #i