Random snippets of all sorts of code, mixed with a selection of help and advice.
What are the best options to manage secret configuration variables within a .NET web-api using docker
22 March 2026 @ 9:04 pm
I am a full blown novice when it comes to secret management within my repos, as up until now I have not needed to leverage them, wondering what the best options would be for the following scenario.
My application is an .NET web-api, currently using appsettings.json to hold config variables, one of which is a private RSA key.
I have setup a dockerfile and my intention is to create CI/CD to automatically publish this to dockerhub after tests etc.
The way I am intending on running this is via Kubernetes as I have other services planned in a microservices style architecture, along with a RabbitMQ message bus.
The Kubernetes yaml files for container orchestration will also be stored in a github repo if that adds to potential options.
question regarding parent and child class
22 March 2026 @ 9:02 pm
Given a class Child which is derived from class Parent. When creating an object from class Parent, select the correct type for the variable dan which will be assigned the reference to the Parent object, knowing that object will ONLY be used to execute the Parent implementation of toString().
Object
Parent
Child
Turn Contact Email on Checkout to Email or Phone Woocommerce
22 March 2026 @ 9:02 pm
I am developing a site, and i want to turn checkout contact email which is required, to email or phone number so anyone who dont have email can enter phone number and place order
How to test compatibility of a custom SignalR client implementation with the SignalR server?
22 March 2026 @ 8:46 pm
I am making my own SignalR client in C++ since the official one with cpprestsdk in backend is long abandoned and is unlikely to be maintained. Is there a test suite implemented on the server side that I could use to fill the missing gaps in my implementation? Or is a "blank" server with some form of "hello world" implemented on it enough to do the task?
My goal is to implement as much as possible in the communication protocol, so a test suite with maximum coverage would be preferred. I'm targeting ASP.NET Core servers with long-term .NET behind them.
How can I resolve the CORS issue between my React frontend and Node.js backend?
22 March 2026 @ 8:25 pm
I’m building a full-stack application where my frontend is built with React, and the backend is built using Node.js (with Express). I am facing a CORS issue when trying to make an API request from the React frontend to the Node.js backend.
Here’s the error I am encountering in the browser’s console:
Access to fetch at 'http://localhost:5000/api/data' from origin 'http://localhost:3000' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
Steps I’ve taken:
In my Node.js backend (Express), I’ve installed the cors middleware and used it globally:
const cors = require('cors');
app.use(cors());
In my React frontend, I am using fetch to make an API call:
fetch('http://localhost:5000/api/data')
.then(response => response.json())
.then(data => console.log(data))
How to perform std::swap on elements of a modified with std::views::transform container?
22 March 2026 @ 8:11 pm
I implement quicksort algorithm. It works normally on simple ranges: std::vector, etc.
template <typename R, typename Comp = std::ranges::less>
void quicksort(R&& range, Comp comp = {}) {
namespace rng = std::ranges;
if (rng::size(range) <= 1) {
return;
}
auto pivot = HoarePartition(range, comp);
quicksort(rng::subrange(rng::begin(range), pivot), comp);
quicksort(rng::subrange(pivot + 1, rng::end(range)), comp);
}
template <typename R, typename Comp>
std::ranges::iterator_t<R> HoarePartition(R&& range, Comp comp) {
namespace rng = std::ranges;
auto pivot = rng::begin(range) + rng::size(range) / 2; // NB: Median of Medians -> 3:7
auto i = rng::begin(range);
auto j = rng::begin(range) + rng::size(range) - 1;
while (rng::distance(i, j) > 0) {
while (comp(*i, *pivot)) {
++i;
}
whi
Most efficient way to determine if a file exists only with a given extension
22 March 2026 @ 12:40 pm
I have a little problem to crack that turns out to be less trivial than I thought - even to formulate as a question for the title of this ticket, in fact!
Here's the background: I mount my iPhone via ifuse under Linux, to manage my photo collection. That is, I'll not only copy photos from the phone, but also delete certain ones from within my photo collection manager (Digikam). Evidently it will only delete the photos (or videos), but not the associated file(s) that iOS likes to create, e.g. the *.AAE files.
I set out to write a shell script that would delete all the "orphaned" .AAE files (i.e. which no longer have the .JPG or .MOV file they belonged to). I thought this could be done with a simple globbing pattern like *.[^A]* and maybe that would indeed suffice if I were interested in finding all matching files with another extension but I can't seem to figure out how to do this for my use case.
So the q
.NET MAUI .NET 10 – project.assets.json missing targets for Android, iOS, Windows and Mac Catalyst (NETSDK1005)
22 March 2026 @ 10:24 am
I'm working on a .NET MAUI project targeting .NET 10, but I'm running into a restore/build issue where the project.assets.json file does not contain any of my target frameworks.
My .csproj:
<TargetFrameworks>net10.0-maccatalyst;net10.0-ios;net10.0-android</TargetFrameworks>
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows'))">$(TargetFrameworks);net10.0-windows10.0.19041.0</TargetFrameworks>
<OutputType>Exe</OutputType>
<RootNamespace>Orbis.Mobile</RootNamespace>
<UseMaui>true</UseMaui>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'ios'">14.2</SupportedOSPlatformVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'maccatalyst'">14.0</SupportedOSPlatformVersion>
<Supp
SQLAlchemy query to get keys from a JSON as an array, not separate rows
21 March 2026 @ 3:29 am
Suppose I have a SQLAlchemy model that looks like this:
class MyModel(meta.Base)
id = Column(BigInteger, autoincrement=True, primary_key=True)
extra_data = Column(postgresql.JSON, nullable=False)
Here is my application code:
import model
from sqlalchemy import func
model.MyModel(extra_data={"key1": "value1", "key2": "value2"})
model.MyModel(extra_data={"key3": "value3", "key4": "value4"})
results = meta.session.query(
model.MyModel.id,
func.jsonb_object_keys(model.MyModel.extra_data).label('keys')
).all()
print(f"Result rows:")
for row in results:
print(f"Row ID: {row.id}, Keys: {row.keys}")
This produces the following output:
Result rows:
Row ID: 1, Keys: <bound method Row.keys of (1, 'key1')>
Row ID: 1, Keys: <bound method Row.keys of (1, 'key2')>
Row ID: 2, Keys: <b
How to key a floating-point (double) value in a std::map?
20 March 2026 @ 10:56 am
I inherited a project where someone has keyed a numerical value as a double in a structure that is used as a key of a std::map. The values are human entered and should not have more precision than 8 digits. Somehow when the values are sent to us, some numerical noise has been added to some values so they are slightly different from others i.e. two values that should be identical could differ by 2.0e-13 for example, but they should be considered equal for the map.
Is there a way I can allow for numbers a bit close to be equal in key?
At first I coded a less operator to allow tolerance:
if (o1.m_dblval - o2.m_dblval < - factor * std::numeric_limits<double>::epsilon()) {
return true;
}
else if (o1.m_dblval - o2.m_dblval > factor * std::numeric_limits<double>::epsilon()) {
return false;
}
... (continuation of the less implementation)
but