Random snippets of all sorts of code, mixed with a selection of help and advice.
Can buffers or constant sized external arrays be used to create an fully in place iterative quicksort?
23 May 2026 @ 3:24 am
Quicksort and Mergesort are both (before any optimisation) recursive algorithms that take up O(nlogn) stack space (ignoring Merge Sort's O(n) space complexity taken for the merging step). Upon curiosity, after finding out about the different types of Block Merge sorts (the one in the original paper, the simpler Sqrtsort variation, Wikisort, Grailsort, Holy Grailsort) I tried to find an inplace stable Quicksort, and it turns out someone named aphitorite already made one called Logsort.
From the Github for Logsort:
The well-known Quicksort is a O(n log n) algorithm that uses O(n) partitioning to sort data. Such partitioning schemes are easily done in-place (O(1) extra space) but are not stable, or do not preserve the order of equal elements. Stable Quicksorts can also be done in O(n log n) time, but they use an extra O(n) space for stable partitioning and are no longer in-place.
Logsort is a novel practical O(n log n) quicksort that is both in-place a
Getting an animated image to work on a WinForm tooltip
23 May 2026 @ 2:44 am
My query is quite specific, if not exceptionally niche...
What I have accomplished:
Created a custom class ImageToolTip, which displays a tool tip with an image
Even got it to work when programmatically assigned to tool strip buttons
This is not relevant to this query, but demonstrates that I am capable of working around the strict limitations of the framework
What I cannot get working is animating this darn image. I am familiar with using ImageAnimator but the usual technique of invalidating the control on the frame change event, and subsequently re-drawing the image in the OnPaint() cannot be applied to a tool tip.
Furthermore, I cannot even "jury rig" a solution based on the image's location, as the ToolTip class not provide any frame of reference of where it actually drew itself.
What I have tried (after putting the ImageAnimator.UpdateF
Best method for enter OTP
23 May 2026 @ 2:31 am
I have a question about wich method logical and practice one
I have two option:
1- in verification page should I send email data and OTP code to backend
2- in verification page we have just OTP code and id of user in cookie
wich best and resonable and logical option to use
SDL3 Sprite Motion Blur
23 May 2026 @ 1:58 am
How do I remove motion blur? It's only noticeable at frame rates of 60 and below. The lower the frame rate, the more noticeable the blur.
https://www.youtube.com/watch?v=c8zwehj_HNg - this is what the blur looks like.
Entity.h
#pragma once
#include <SDL3/SDL.h>
class Entity
{
public:
Entity(float x, float y, float w, float h);
virtual ~Entity();
void drawTexture(SDL_Renderer *renderer, SDL_Texture *texture, Uint8 textureAlpha);
void drawHitBox(SDL_Renderer *renderer, Uint8 R, Uint8 G, Uint8 B, Uint8 hitBoxAlpha);
const SDL_FRect &getHitBox() const;
protected:
SDL_FRect entity = { 0.0f, 0.0f, 0.0f, 0.0f };
float speed = 0.0f;
float dirX = 0.0f;
float dirY = 0.0f;
};
Entity.cpp
#include "Entity.h"
Entity::Entity(float x, float y, float w, float h) :
Need to disable the submit button if both fields are invalid
22 May 2026 @ 10:24 pm
I am trying to disable the submit button on a boostrap modal form until both addhostname and addipaddress fields are valid. I have tried multiple ways to detect the validity state of the addipaddress field and none work. The existing checks I have are on existing duplicate values within the database, and work already for both fields.
Do I need to have a third hidden field that holds the status of the addipaddress field, which is set when it is validated? and use and AND for binary values to detect status?
<!--- script to check hostname is already used --->
<script>
$(document).ready(function() {
// When user leaves the username input field
$('#addhostname').focusout(function() {
var hostname = $(this).val();
var $thisField = $(this);
console.log('Validate addhostname');
// Don't validate empty fields
C# RSACryptoServiceProvider errors on Decrypt with Error 31
22 May 2026 @ 10:11 pm
The RSACryptoServiceProvider*.Decrypt* is failing on an internal call to Interop.Advapi32.CryptDecrypt. The internal error code is "31". The message is a System.Security.Cryptography.CryptographicException: "A device attached to the system is not functioning.".
This library is calling an older C++ RSA implementation used by old equipment we still need.
static string? Decrypt(string pemString)
{
try
{
var cipherText = Convert.FromBase64String(@"...");
var cspParams = new CspParameters
{
ProviderType = 1, // PROV_RSA_FULL
KeyContainerName = "Test"
};
using (var rsaProvider = new RSACryptoServiceProvider(cspParams))
{
rsaProvider.ImportFromPem(pemString);
var maxChunkSize = (rsaProvider.KeySize / 8);
using (var ms = new MemoryStream())
{
AuditQuery NonUniqueResultExceptoin for ManyToOne relation
22 May 2026 @ 8:34 pm
I have a pair of entities, both audited, which look a bit like this:
@Audited
EntityA {
@Column(name = "some_string")
private String someString;
@ManyToOne(fetch = FetchType.LAZY, optional = false)
@JoinColumn(name = "entity_b_id")
@NotNull
private EntityB entityB;
}
EntityB {
@OneToMany(mappedBy = "entityB", fetch = FetchType.LAZY)
@MapKey(name = "someString")
private Map<String, EntityA> entityAs;
}
I don't know if the collection side being a Map matters. I'm using ValidityAuditStrategy.
When I query for revisions of EntityA, it eagerly fetches entityB. If entityB has multiple revisions which are valid for the given EntityA I get a NonUniqueResultException.
I tried adding @AuditJoinTable to EntityB.entityAs, but
How can I avoid redundant comparisons when checking rectangle overlaps in C#?
22 May 2026 @ 8:11 pm
I have a C# console application that reads button data from a CSV file and stores the buttons in a List<MyButton>. One part of the task is checking whether any buttons overlap on a 2D plane.
This is my current implementation:
bool hasOverlap = false;
for (int i = 0; i < buttons.Count; i++)
{
for (int j = 0; j < buttons.Count; j++)
{
if (i != j)
{
MyButton firstButton = buttons[i];
MyButton secondButton = buttons[j];
bool isOverlapping =
firstButton.Left < secondButton.Left + secondButton.Width &&
firstButton.Left + firstButton.Width > secondButton.Left &&
firstButton.Top < secondButton.Top + secondButton.Height &&
firstButton.Top + firstButton.Height > secondButton.Top;
if (isOverlapping)
{
hasOverlap = true;
}
Double responses in teams channel from parent and child copilot agent [closed]
22 May 2026 @ 4:38 pm
I am using a master agent with child agents in Microsoft Copilot Studio.
The problem is:
Child agent topics are not triggering correctly
Instructions are sometimes ignored
Parent agent sometimes answers directly instead of routing to child
Behavior is inconsistent even after configuring topics and triggers
I already tried:
Topics
Trigger phrases
Instructions
Generative orchestration settings
Is this a known limitation/bug in Copilot Studio multi-agent orchestration, or is there a recommended architecture that works reliably for parent → child delegation?
Any working production examples or best practices would help.
Designing a modular ERP with Symfony + MariaDB + Bootstrap – best practices?
22 May 2026 @ 10:28 am
I’m currently working on an ERP project at Göhltec and I’d like to get some input from the community regarding architecture and best practices.
**Stack we’re using**
Backend: Symfony (API-first approach, service-oriented architecture)
Database: MariaDB
Frontend: Twitter-Bootstrap + JavaScript (partly vanilla, partly component-based)
**Context**
The ERP system is modular (e.g. customers, inventory, invoices) and designed to scale. We currently use a mostly server-rendered approach with some dynamic frontend components.
**Questions**
I’m especially interested in your experience with:
1. Modular architecture in Symfony
Do you prefer a monolithic structure with bundles/modules or splitting into microservices early on?
2. Database choice
Have you faced limitations with MariaDB in ERP-like systems (large datasets, complex queries)?
Would PostgreSQL be a better choice long-term?
3. Fron