Random snippets of all sorts of code, mixed with a selection of help and advice.
How to write test code for Prisma version 7
28 November 2025 @ 8:42 pm
For testing Prisma, I used prismock or prisma-mock . But those packages are compatible with Prisma version 6 or earlier. I visit the Prisma Official website, and they are suggesting using jest-mock-extended or vitest-mock-extended.
This is fully manual and time-consuming. Do you have any soluation for this?
iOS 26.1: In TabView, NavigationStack animation breaks when intercepting tab selection to show fullScreenCover
28 November 2025 @ 8:40 pm
I'm trying to show a fullScreenCover when the user taps the third tab instead of actually switching to that tab. The issue is that resetting selectedTab = oldValue in onChange breaks the NavigationStack push/pop animations in the previous tab.
The Problem
When I reset the tab selection synchronously, the NavigationStack in the previous tab loses its animations - no push/pop transitions work anymore until I switch tabs away and back.
Broken code:
struct ContentView: View {
@State private var selectedTab: Int = 0
@State private var showSheet: Bool = false
var body: some View {
TabView(selection: $selectedTab) {
Tab("First", systemImage: "1.circle.fill", value: 0) {
FirstTabView()
}
Tab("Second", systemImage: "2.circle.fill", value: 1) {
SecondTabView()
}
Tab("Sheet", sys
Implementing ACID with Transactions in Modular Monolitic Backend
28 November 2025 @ 8:32 pm
I've got a modular monolithic backend in golang. The project it's in the beginning but our plans for the backend is to migrate it to microservices WHEN it's necessary and do it gradually.
Here's how my app is modularized:
The app has some modules: core, health, safety, hr, etc.
Core handles the general entities in the app, such as: tenant, user, person_info, subscriptions, roles, etc
Health handles all about health, safety about safety and so on.
In the backend, each one of this modules are Bounded Context, so I have something like this:
internal/
|- modules/
|-core/
|-tenant/
|-user/
|-health/
|-patient/
...
The problem I'm facing is implementing ACID the right way, without breaking any patterns or best pratices.
For ex:
When creating a Tenant I need to:
Store tenant info
Bind tenant with the selec
How do I use Socket.io with Fastay? I can’t access the server instance
28 November 2025 @ 8:32 pm
I’m trying to run Fastay.js as a separate backend, and I really need Socket.io because my app depends on real-time features. But I’m stuck: Fastay doesn’t give me access to the underlying HTTP server, and Socket.io needs that to start.
Fastay boots up fine, but I have no way to grab the server instance to pass into Socket.io.Does anyone know how to fix this? Is there ANY way to access the internal server?
Really need to get this working ASAP. Thanks!
// src/index.ts
import { createApp } from '@syntay/fastay';
import { Server as SocketServer } from 'socket.io';
void (async () => {
const app await createApp({
apiDir: './src/api',
baseRoute: '/',
port: 3000
});
const io = new SocketServer(app); // breaks because "server" doesn't exist
io.on('connection', socket => {
console.log('User connected:', socket.id);
});
})();
Why Does Trying to Load rJava Keep Resulting in an Error?
28 November 2025 @ 8:29 pm
I am trying to run r5r for a transit network based analysis.
I am using R 4.4.3 in Positron on Fedora 41.
Some context for me is that I have a couple years of R underneath my belt, but I am absolutely terrible at understanding what I am doing with my Linux setup, so that is probably the root of the problem here.
When I run:
install.packages("rJava")
I get the following messages in the console:
Installing package into ‘/home/[USER]/R/x86_64-redhat-linux-gnu-library/4.4’
(as ‘lib’ is unspecified)
trying URL 'https://cran.rstudio.com/src/contrib/rJava_1.0-11.tar.gz'
Content type 'application/x-gzip' length 634103 bytes (619 KB)
==================================================
downloaded 619 KB
* installing *source* package ‘rJava’ ...
** package ‘rJava’ successfully unpacked and MD5 sums checked
** using staged insta
comparison (<) is possible only for atomic and list types
28 November 2025 @ 8:18 pm
I have the error "comparison (<) is possible only for atomic and list types" in this loop in R. I am trying to do wilcoxon test, t-student test and sign test but gives me the error. In this case all the necessary packages are activated: nortest, moments y exactRankTests. Finally, put a condition no not calculate NA is not too correct because then i would be missing datas to the mean of p-values of the 1000 samples.
n<-15
n_muestras<-1000
muestras<- replicate(n_muestras,rnorm(2,1.5))
pval_WIL <- numeric(n_muestras)
pval_TSTD<- numeric(n_muestras)
pval_SIGN <- numeric(n_muestras)
rechazos_WIL <- logical(n_muestras)
rechazos_TSTD <- logical(n_muestras)
rechazos_SIGN <- logical(n_muestras)
alpha <- 0.05
# Bucle
for (i in 1:n_muestras) {
x <- muestras[, i]
sigma_est <- sd(x)
p_wil <- wilcox.exact(muestras, mu=1, alternative="two.sided")$p.value
p_tstd <- t.test(muestras, mu = 1, alternativ
Why does "message:successful_payment" event work randomly?
28 November 2025 @ 8:14 pm
As you can see in my short video example event message:successful_payment sometimes doesn't run after payment. In my video example there was only one execution after 3 payments (only the second payment trigger message:successful_payment , u can see in logs telegram_payment_charge_id).
short video example
Here is my code:
This is StoreModule, here i register 2 events
@Module({
imports: [ProductModule, PaymentModule, GatewayModule],
providers: [StoreService],
controllers: [StoreController],
})
export class StoreModule implements OnModuleInit {
constructor(
@Inject(PROVIDERS.TG_PROVIDER) private readonly tgProvider: TgProvider,
private readonly storeService: StoreService,
) {}
private onTgBotInit() {
this.tgProvider.bot.on('pre_checkout_
Qemu: Bad system call (statx) supposedly in network request
28 November 2025 @ 8:07 pm
I installed Debian under Termux on my Android phone. Under Debian I cross-compiled some apps with target x86_64-unknown-linux-gnu and executed it by qemu-x86_64 under Termux. Whenever it doesn't make network requests, it works. But if it makes a network request, it crashes in statx system call with a message Bad system call. For example 21667 statx(3,"",AT_EMPTY_PATH|AT_STATX_SYNC_AS_STAT,STATX_ALL,0x0000007b44a2bc90)Bad system call. What could it be? Thanks in advance.
diverging std::atan2's unit of least precision
28 November 2025 @ 8:07 pm
I write a cross-platform program for Windows and Linux, and I would like it to behave as similar on both platforms as possible. I use some mathematics in the program, e.g. std::atan2 function calls, and I observed that for the same input values it produces sometimes the result diverging in the unit of least precision depending on the platform or optimization settings.
Consider this reduced example:
#include <print>
#include <cmath>
int main() {
// 0.14189707 with GCC on Linux
// 0.14189705 with MSVC (and compile-time evaluation in GCC)
std::print( "{}", std::atan2( 1.f, 7.f ) );
}
Online demo. Although the difference between results is small, it is amplified by the following computations in my program, so I would like to avoid the difference completely.
Are implementations allow
Can somebody explain this code and the related concept of variable length list of template parameter
28 November 2025 @ 8:07 pm
Template Parameter Pack Example
template <typename... Types>
auto maketuple(Types&&... args){
return std::tuple<Types...>(std::forward<Types>(args)...);
}
int main(){
auto myTuple=maketuple(1,2,3,4,5);
}
I was starting out to learn modern cpp. Can somebody explain what does this code do? Here is the related text :-
C++17 introduced a new syntax for handling variable-length lists of template parameters. This can be used to create a tuple with a variable number of elements.