Random snippets of all sorts of code, mixed with a selection of help and advice.
Gotk4 NewMessageDialog doesn't take the message_format argument
26 May 2026 @ 8:50 am
I use github.com/diamondburned/gotk4/pkg/gtk/v4. I'd like to create a modal dialog, like this:
dialog := gtk.NewMessageDialog(
&window.Window,
gtk.DialogModal|gtk.DialogDestroyWithParent,
gtk.MessageInfo,
gtk.ButtonsOK,
"Some info I want to let the user know",
)
dialog.SetTitle("Information")
dialog.SetVisible(true)
Only, NewMessageDialog() is declared like this:
func gtk.NewMessageDialog(parent *gtk.Window, flags gtk.DialogFlags, typ gtk.MessageType, buttons gtk.ButtonsType) *gtk.MessageDialog
Unkike the C function gtk_message_dialog_new(), the Go one doesn't have the message_format argument, nor the ... (parameters for message_forma
why is base case required to be stated explicitly in this code?
26 May 2026 @ 8:49 am
Here is a permutation generator which takes a whitespace-delimited list of strings on stdin:
echo a b c | perl -aE '
sub p {
@_ && # <-- why is this line needed?
map {
my $f = $_[$_];
map [$f,@$_], p(@_[0..$_-1, $_+1..$#_]);
} 0..$#_
}
say "@$_" for p(@F)
'
and outputs the permutations:
a b c
a c b
b a c
b c a
c a b
c b a
@_ can never have fewer than zero elements
$#_ will be -1 when @_ is empty
map { ... } 0..-1 performs no iterations
So it seems to me that the explicit test that @_ is not empty is unnecessary - when there are no arguments, the map should not run.
However, if I remove the check, the code produces no output. I don't understand why.
Enabling strict complai
What is the best structure for the existing code?
26 May 2026 @ 8:47 am
The Arsenal’s championship win inspired me to create a C# console application as a practice exercise.
Currently, everything is contained in a single file.
I would like to know how the project structure should be properly organized.
What is the best and most correct approach for this?
For example, is it good practice to separate the code so that one file contains the data model and another contains the application logic?
Here is the code:
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
namespace ConsoleApp1
{
public class Player
{
public string PlayerId { get; set; }
public string Name { get; set; }
public int BirthYear { get; set; }
public string Nationality { get; set; }
public string Position { get; set; }
public string ClubId { get; set; }
public string ClubName { get; set; }
public int ShirtNumber { get; set; }
p
rustnetconf_yang crate is built, but not executed upon a cargo build when it encounters a yang-models directory it should react to
26 May 2026 @ 8:41 am
I have to check if the generation of Rust sources files from YANG files is working the way we are expecting it to do.
According to the crate information below, I have to put my YANG files into a yang-models directory, and a cargo build will handle the generation, provided rustnetconf_yang is a dependency of the project:
rustnetconf-yang
YANG model code generation for rustnetconf. Generates typed Rust structs from YANG models so your network config is validated at compile time.
How it works
Place .yang model files in your project’s yang-models/ directory
Add rustnetconf-yang as a dependency
Run cargo build — the build script generates Rust structs in OUT_DIR
Use the generated types with edit_
Unity UI buttons not working for the AYN Thor
26 May 2026 @ 8:36 am
My UI button in unity doesn't work on the thor. I am using unity 6000.3.13f1.
I have tested multiple ways of trying to fix this but couldn't come up with the correct sollution.
However I have found that it does reconize where I touch the screen for both the top and bottom screen this works.
(testing with unity remote and also making builds)
I did find a half workaround, but this somehow only works for the top screen. (by simulating a click when a press is shorter than .2 seconds)
anyone who could help me further with this?
Android Compose UI Tests displaying cached/stale Firestore emulator data when running all tests together
26 May 2026 @ 8:10 am
I am writing UI integration tests for a Jetpack Compose Android application using the Firebase Firestore Emulator hosted on a local test server.
I want every single test case to start with a clean slate. Before each test runs, my local server populates the Firestore emulator with specific test data so that every test begins with the exact same database state.
The Problem
Running tests individually: If I run each test case manually one by one, they all pass
Running tests in a suite (together): If I execute the whole test class / group, the tests start to fail. The UI displays old data belong to the previous test case, even thought I verified that the Firestore emulator itself contains the correct, newly populated data.
It seem like the App is caching the data locally on the dvice between test runs, meaning the UI reads from the locale cache instead of fetching the fresh data from the emulated firestore database.
What is the rationale for std::span::operator[] being explicitly undefined for out of bounds access?
26 May 2026 @ 7:36 am
Triggered by this question I was reading about out of bounds access via std::span::operator[] here:
If idx < size() is false, the behavior is undefined.(until C++26)
Why is it specified explicitly to be undefined?
With
std::span s{ptr,size};
I see two cases:
The underlying array has only s.size() elements, attempting to call s[s.size()] is undefined, because ptr[size] is undefined. That span::operator[] is specified to be undefined does not actually change that.
The underlying array has more than s.size() elements. In that case s.data()+size can be dereferenced without problem, yet s[s.size(
seprate subscription for multiple simple subscription product using woocommerce [closed]
26 May 2026 @ 6:06 am
I have two different Simple Subscription products. When I add both products to the cart and complete the checkout, WooCommerce creates a single subscription containing two line items.
However, I need WooCommerce to create two separate subscriptions—one subscription for each Simple Subscription product purchased.
Can you suggest a custom code solution or a plugin that can achieve this behavior?
WooCommerce Version: 10.7.0
WooCommerce Subscriptions Version: 8.7.1
Product Type:
Simple Subscription
Monthly billing
No trial period
No sign-up fee
Example:
Product A (Monthly Subscription)
Product B (Monthly Subscription)
When both products are added to the cart and checkout is completed, WooCommerce creates:
Subscription #100
Product A
Product B
Required:
Subscription #101
Product A
Subscription #102
Prod
JavaScript or Typescript
25 May 2026 @ 8:44 pm
For those working with JavaScript whether client-side, server-side, or both how much of a necessity is TypeScript in 2026? I keep seeing videos and forum threads where developers swear they'll always reach for TypeScript whenever JavaScript is involved. But how true is that in practice, on an actual job? Is it just hype ?
How to prevent DELETE if record is referenced in another table?
25 May 2026 @ 8:37 pm
I want to delete a record from the selected table using an SQL query, but first I want to check whether any value is associated with that record. To do this, I need to use this validation in the SQL query ?
if (result.length > 0) {
return res.status(400).json({
"message": "The record cannot be deleted!"
});
}