Random snippets of all sorts of code, mixed with a selection of help and advice.
Java thinks a squared prime over 100k has factor under 30k
2 May 2026 @ 11:26 pm
I made an intelliJ project in Java 11. I ran the following code:
long bigSquaredPrime = 100151 * 100151;
System.out.println(bigSquaredPrime % 50207);
System.out.println(bigSquaredPrime % 28687);
Even though 100151 is prime, and therefore bigSquaredPrime should have that as its only factor besides 1 and itself, both of these lines are returning 0. (28,687 and 50,207 are both prime. I chose those specific numbers because a method I wrote for finding prime factors was returning them as the prime factors of 100151 squared.)
Why is this happening? If modulus cannot be trusted when working with big numbers, what is a better way to search for divisibility when checking for prime factors?
.NET MAUI Android App not registering for Push notifications
2 May 2026 @ 11:20 pm
I am following the instructions found at https://learn.microsoft.com/en-us/dotnet/maui/data-cloud/push-notifications?view=net-maui-10.0 to set up an .Net MAUI Android application to receive push notifications. I believe I have followed all steps in the article to the letter (for all of the Android parts anyway, I've skipped IOS) however when I click the "Register" button on the demo app I receive an error message in the app as follows:
"One or more errors occurred. (Response status code does not indicate success: 422 (Unprocessable Entity).)"
If I trail the logs in the API app running in Azure I can see the corresponding error
2026-05-02 14:51:56.203 +00:00 [Trace] Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker: Executing action method PushNotificationsA
How to make markdown ` ` double space really visible in IDEA/VS Code?
2 May 2026 @ 11:19 pm
How to make markdown double space really visible while editing .md files ?
Yes, it is possible to enable something called "show white spaces",
but that will show all spaces,
but what I need is to only see line breaks are indeed are in those lines I intended.
Do you noticed how I did this in this SO question? I used only for 2 lines that start with "Yes", "but". And now this line too.
I want the same while editing.
I use IDEA, occasionally VS Code.
And it would be nice, if one day, we can have in SO and all online editors.
P.S. Similar is resolved for vim
MySQL Grouping with Aggregate not giving the right answer ( what i am looking for )
2 May 2026 @ 11:04 pm
Hello there Stack Overflow community.
I wanted to ask your help as I am struggling to get my MySQL query working in the way I would like it to do. Its a bit challenging topic to understand but maybe you can help.
I have a database of Magic the gathering card prices. I am trying to do a query of lowest price by each seller and populate this to another table. However I get quite weird response from the query.
I think I would need to do some sort of subquery instead. But I cannot get my head around how.
Here is simplified output. Hopefully it looks clear
My database looks something like this:
UUID | Seller | Price
1bfaaddc-9064-53f2-a55d-bfb972ea5aa9 cardkingdom 0.04
2559fbbd-08dd-54c7-b6ae-657e0689e605 cardkingdom 0.04
25d0bf7f-1a5d-579f-97f3-f4b18db45d25 cardkingdom 0.04
1c8ebaac-e166-54d6-9b78-29df71faa1c6 cardmarket 0.023368
892764f6-77b2-501b-bc48-c0d61954addc cardmarket
With aiosmtpd, how to detect spoofed "From:" addresses without relying on SPF, DMARC, or DKIM?
2 May 2026 @ 11:04 pm
I'm using the latest aiosmtpd module under Python 3.12 in LinuxMint to run a limited, special-purpose email server that only performs an extremely small number of very specialized functions.
There are only a couple dozen or so specific email addresses that I accept incoming messages from, and my specialized server rejects all incoming messages from other senders.
I want to make sure that the "From:" address that is being supplied in each of these incoming emails is genuine, and not being spoofed.
The emails I want to accept originate from a number of servers that I have no control over, and in most (maybe all) cases, the owners of the email addresses that I accept don't know this information. These senders consist of some individuals, some organizations, and some businesses, and few, if any of the people sending these emails have knowledge of SMTP, network issues, etc. And I cannot rely on these senders to always include any kind of authen
How to stack column arrays of variable rows returned by a user defined LAMBDA function using VSTACK? Is there an alternative?
2 May 2026 @ 10:27 pm
First of all sorry for using Excel Android while asking questions.
My Goal:
From the text in B3 and B11, I want to create an array in which each element represents a line of the combined text excluding empty lines.
Expected Result:
Here in B3, we have total of 7 lines (5 lines having text and 2 empty lines), and in B11 we have 7 lines (5 with text and 2 empty) in total as well. So my array should have 5 + 5 = 10 rows.
What I got:
As you can see in the cell E19, I got an array of just 2 elements having carrying only the first line of the contents of B3 and B11.
My code:
=LET(itr,LAMBDA(LP,res,arr,i,IF(i=3,res,LET(ele,INDEX(arr,i),nx,LP(LP,res,arr,i+1),IF(ele=0,nx,LET(ele_process,TEXTSPLIT(ele,,C
My Goal:
From the text in B3 and B11, I want to create an array in which each element represents a line of the combined text excluding empty lines.
Expected Result:
Here in B3, we have total of 7 lines (5 lines having text and 2 empty lines), and in B11 we have 7 lines (5 with text and 2 empty) in total as well. So my array should have 5 + 5 = 10 rows.
What I got:
As you can see in the cell E19, I got an array of just 2 elements having carrying only the first line of the contents of B3 and B11.
My code:
=LET(itr,LAMBDA(LP,res,arr,i,IF(i=3,res,LET(ele,INDEX(arr,i),nx,LP(LP,res,arr,i+1),IF(ele=0,nx,LET(ele_process,TEXTSPLIT(ele,,CModel accuracy and loss_fn is not increasing [closed]
2 May 2026 @ 10:08 pm
So i started my model , a dummy model to be specific as i am learning DL.
However i keep getting stuck at a point in training loop of acc and loss
enter image description hereenter image description hereenter image description hereenter image description hereenter image description hereenter image description hereenter image description here
Why is the map method returning my array as undefined?
2 May 2026 @ 9:26 pm
Why does the error message appear TypeError: can't access property "map", headers is undefined?
I have defined headers inside a state variable, passed it as props and used it inside a component so has been declared every step of the way.
I don't understand why I am getting this error message.
import { useState } from "preact/hooks";
export function Transcription() {
const [active, setActive] = useState("B");
const [isOpen, setIsOpen] = useState(true);
const [clickedHeader, setClickedHeader] = useState(0);
const [headers, setHeaders] = useState(
Array.from({ length: 10 }, (x, i) => i + 1),
);
const removeHeader = function (e) {
e.preventDefault();
setClickedHeader(+e.target.id);
// [1,2,3,4,5,6,7]
setHeaders(function (headers) {
headers.slice().filter((x, i) => x !== clickedHeader);
return;
});
return;
};
return (
<div>
<Table
Why Does SQL Date Value Become NULL When Using AddWithValue?
2 May 2026 @ 8:46 pm
if (connection.State == ConnectionState.Closed)
{
connection.Open();
string signup = "INSERT INTO TABLE (ID,NAME,SURNAME,MAIL,PASSWORD) VALUES (@ID,@NAME,@SURNAME,@MAIL,@PASSWORD)";
SqlCommand command = new SqlCommand(signup, connection);
command.Parameters.AddWithValue("@ID", ID.Text);
command.Parameters.AddWithValue("@NAME", NAME.Text);
command.Parameters.AddWithValue("@SURNAME", SURNAME.Text);
command.Parameters.AddWithValue("@MAIL", MAIL.Text);
command.Parameters.AddWithValue("@PASSWORD", PASSWORD.Text);
command.Parameters.AddWithValue("@DATE",dateTimePicker11.Value);
command.ExecuteNonQuery();
MessageBox.Show("REGISTRATION SUCCESSFUL", "Message", MessageBoxButtons.OKCancel, MessageBoxIcon.Information);
connection.Close();
}
I defined an SQL query like this, but the DATE value always returns null. How can I solve this
How should I interpret SELECT vs INSERT/UPDATE/DELETE ratios when designing indexes for an OLTP workload?
2 May 2026 @ 5:40 pm
I'm analyzing a SQL Server 2022 OLTP database and trying to refine my indexing strategy based on actual workload patterns.
The exact schema and queries cannot be shared, but the observed ratios and workload patterns are accurate. I collected these numbers from Query Store, by grouping captured statements from sys.query_store_query_text and their execution counts from sys.query_store_runtime_stats.
Using Query Store / DMVs, I observed the following distribution of operations:
* SELECT: ~53%
* INSERT: ~20%
* UPDATE: ~25%
* DELETE: ~5%
Context:
* Application: transactional (tasks/projects management)
* Tables: moderate size for now, but expected to grow significantly
* Workload: mixed read/write (roughly 50/50)
* Current concern: balancing read performance vs write overhead due to non-clustered indexes
I understand that indexing improves reads