Random snippets of all sorts of code, mixed with a selection of help and advice.
SpringBoot Model Advice (already got the solution)
24 January 2026 @ 9:04 pm
So I'm new to SpringBoot and in my Database i have a table called Category:
CategoryId(pk), name, parent_id.
For the Code I am planning, that I can select a Categord (e.g Car) and then I get all the subcategorys (e.g car_insurance) which has the categoryid from Car.
Now you cannot save something with the Parent ID, but there are some Categories, that don't have any child categories.
I am wondering If i should do 2 models:
Category and SubCategory or one Model with then all the columns above.
I hope the question is understandable, as this is one of my first small projects.
Thank you in advance and please let me know if something is missleading or wrong ^^
How to return a rich view/custom view from AppEntity's EntityQuery for Shortcuts app to display?
24 January 2026 @ 8:49 pm
When I create an AppEntity and have it conform to EntityQuery, a Find AppIntent is created for that entity which can be used in the Shortcuts app. Currently, when this intent is used, it only creates text. However, when I use the default Calendar app's Find intent, it returns a rich view like this:
How do I return a rich view like this? I already tried using a Snippet view on some other AppIntents but that does not work because it shows the snippet on top of the Shortcuts app, not embedded into the Shortcuts app like this.
Additionally, when I click on a calendar event, I can see more details like this:
How can I do this for my AppEntities too? I suspect it might be related to QuickLook because when I hold the event from the list, it shows
How do I return a rich view like this? I already tried using a Snippet view on some other AppIntents but that does not work because it shows the snippet on top of the Shortcuts app, not embedded into the Shortcuts app like this.
Additionally, when I click on a calendar event, I can see more details like this:
How can I do this for my AppEntities too? I suspect it might be related to QuickLook because when I hold the event from the list, it shows Equality of type with equal indices do not typecheck
24 January 2026 @ 8:42 pm
I have two discrete systems. The first one (B1) is composed of sequences
starting with 0 and where steps are either +2 or "no-op". For instance :
0 → 2 → 4 → 6...
0 → 0 → 2 → 4 → 4 → 4 → 6...
0 → 0 → 2 → 2 → 2 → 2...
The second one (B2) is composed of sequences starting with 0 and where
steps are either +1 or "no-op". For instance:
0 → 1 → 2 → 3...
0 → 1 → 1 → 2 → 2 → 2 → 3...
0 → 0 → 0 → 0...
Now I have a function h : nat → nat, defined as:
h(n) = ⌊ n/2 ⌋ * 2
h(0)=0, h(1)=0, h(2)=2, h(3)=2, h(4)=4...
f : B2 → B1 is the obvious "extension" of h.
For instance, f maps the B2 sequence
0 → 1 → 1 → 2 → 2 → 2 → 3 → 4...
to the B1 sequence
0 → 0 → 0 → 2 → 2 → 2 → 2 → 4...
I want to show that B2 refines B1 under f, meaning that:
Reading data more efficiently from a csv file in python
24 January 2026 @ 8:24 pm
I am programming an neural network to recognise digits trained on the MNIST dataset. At the moment I am reading each line separately using the following code:
file = np.loadtxt(dataLocation, delimiter=",", dtype="float128")
count = 0
print("Starting training")
for row in file:
count += 1
data = []
for item in row:
data.append([item/255]) #This takes an array like [1,2,3,4] and makes it [[1],[2],[3],[4]] which is necessary for this program
desired = self.Transformer(data.pop(0)) #Look at transformer method to understand
where self.transformer() calls a function that takes the first element from a line e.g 2 and outputs this in the vector [[0],[0],[1],[0],[0],[0],[0],[0],[0],[0]]. What I wanted to know is whether there is a more efficient way to read this as with my current program, one epoch takes about 30 minutes and that means that fo
Fastify demo app DB migration part doesn't work
24 January 2026 @ 8:22 pm
I am trying to create the demo app: https://github.com/fastify/demo
I copied the .env.example and created an .env file with the following contents, modified the database connection part to fit my DB credentials:
# Must always set to production
# @see {@link https://www.youtube.com/watch?v=HMM7GJC5E2o}
NODE_ENV=production
CAN_CREATE_DATABASE=1
CAN_DROP_DATABASE=1
CAN_SEED_DATABASE=1
# Database
MYSQL_HOST=localhost
MYSQL_PORT=3306
MYSQL_DATABASE=test_db
MYSQL_USER=my_user
MYSQL_PASSWORD=my_password
# Server
FASTIFY_CLOSE_GRACE_DELAY=1000
LOG_LEVEL=info
# Security
COOKIE_SECRET=my_secret
COOKIE_NAME=session_id
RATE_LIMIT_MAX=4 # 4 is for tests, increase if you need more
The connection is working because npm run db:create creates the schema test_db, but when I run the next command npm run db:migrate, I see
MongoDb Connection failed : Error: querySrv ECONNREFUSED
24 January 2026 @ 2:55 pm
MongoDb Connection failed : Error: querySrv ECONNREFUSED
How can I solve this error? My node v24.13.0 and mongoose 9.1.5 are the latest versions. Also I changed my network dns to Google's dns number 8.8.8.8, and in my mongodb atlas network acc ip address is 0.0.0.0/0 so that any ip address can access and install Locally in my system.
Here is the connection code:
import express from "express";
import mongoose from "mongoose";
import cors from "cors";
import dotenv from "dotenv";
dotenv.config({ path: "./.env" });
const app = express();
const MONGO = process.env.MONGO_URL;
mongoose
.connect(MONGO)
.then(() => {
console.log("Database Successfully connected");
})
.catch((error) => {
console.error(`MongoDb Connection failed : ${error}`);
});
app.use(express.json());
app.use(cors());
GitHub Actions for autoconf project on Windows [closed]
24 January 2026 @ 2:18 pm
Using GitHub Actions to build a project based on autoconf using Linux is straightforward.
jobs:
ubuntu-autoconf:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: configure
run: ./configure
- name: make
run: make
For Windows, i.e. replacing ubuntu-latest with windows-latest, the same code does not work.
Configure is not properly executed:
Run ./configure
./configure
shell: C:\Program Files\PowerShell\7\pwsh.EXE -command ". '{0}'"
The following make fails obviously, too.
What is missing? Some dependencies or more code? I could not find any related documentation.
psql select integer in selected arrays
24 January 2026 @ 11:43 am
I have these two tables:
t1: id, x1 (integer)
t2: id, a2 (integer[])
This SQL command:
SELECT id
FROM t1s
WHERE x1 IN (SELECT a2 FROM t2s WHERE id = #{id});
causes an error:
operator does not exist: bigint = integer[]
The problem is caused by SELECT a2 FROM t2s WHERE id = #{id} returning an array of arrays (or maybe a list of arrays), but the IN clause in the outer command is looking for an array of integers.
[a2] = SELECT a2 FROM t2s WHERE id = #{id}
It would work if it were:
a2 = SELECT a2 FROM t2s WHERE id = #{id}
The problem remains the same if I tell psql that (SELECT a2 FROM t2s WHERE id = #{id}) is only one row by (SELECT a2 FROM t2s WHERE id = #{id} FETCH FIRST 1 ROW ONLY).
So how to convert the list of arrays with one element [a2] to i
Api Integration in Shopify
22 January 2026 @ 5:43 am
I need assistance with implementing an API key to connect to a supplier's website and update stock levels on my Shopify site. This project requires attention to detail and the ability to troubleshoot any integration issues that may arise.
kindly please explain about it in details
Passing a matrix from python to R through rpy2
20 January 2026 @ 4:59 pm
I am trying to find out how to pass the list below exactly as it looks from python into R through rpy2 for further processing into the R script and then get the resulting value back to python.
[[6.99392345e-01 5.49632800e-01 5.06689159e-01]
[8.99550859e-01 4.80455778e-01 1.63756626e-03]
[2.41446967e-04 4.57143249e-01 9.02994382e-01]
[9.23099294e-01 2.97094556e-02 4.04195476e-01]
[2.17356714e-08 3.55494425e-06 1.01591254e+00]
[4.77737570e-01 6.70860436e-02 8.94129347e-01]
[3.27139377e-03 9.02816866e-01 4.49089069e-01]
[5.21335453e-01 8.64285916e-01 6.80395398e-03]
[5.20486609e-04 1.01774510e+00 3.68351896e-06]
[1.03490286e+00 2.54819339e-02 8.03965100e-03]]
I am running the code below where 'res' is the list above:
from rpy2 import robjects
R_float_vec = robjects.vectors.FloatVector(res)
python_float_list = list(R_float_vec)
print(python_float_list)
I get back the following:
[0.699392345195757, 0