Random snippets of all sorts of code, mixed with a selection of help and advice.
How to achieve this result in Postgresql query?
26 March 2025 @ 12:37 am
I have this table.
I want to achieve this result.
cal_val1 formula is (daily_return / 100) + 1
cal_val2 formula is cal_val1 * cal_val2 in previous row
Note: in the first row, cal_val2 is automatically set to cal_val1 since it is the first and no previous row
Any help or example fiddle examples would be appreciated.


tailwind v4 custom breakpoint was not successfully applied
26 March 2025 @ 12:36 am
I defined my own breakpoint use @theme:
--breakpoint-tablet: 52.125rem;
--breakpoint-desktop: 90rem;
Then I defined my own class in @layer components:
.mobile-container {
max-width: 317px;
margin: 0 auto;
}
.tablet-container {
max-width: 658px;
margin: 0 auto;
}
.desktop-container {
max-width: 1128px;
margin: 0 auto;
}
When I use them, I find the format was not correctly applied:
<nav className="mobile-container flex items-center justify-between tablet:tablet-container desktop:desktop-container">
but if I don't use custom classes, it works:
<nav className="mobile-container flex items-center justify-between tablet:max-w-[658px] desktop:max-w-[1128px]">
I don't understand the reason?
I need help using Replit
26 March 2025 @ 12:36 am
I entered my prompt and the Agent ran for 2 hours. It ran into several bugs and could not get a page to render. It finally created a static test page and I got a message that I had reached my free usage limit. I had expectations that a non-programmer could use natural language to try to create something but my experience was very poor. Any suggestions?
How to read the latest data with UDP socket in SFML?
26 March 2025 @ 12:35 am
I want to figure out how to read the "latest" data from a udp socket. As in my client reads data using SFML's udp socket but it reads old data. I read up that you should try flushing the buffer like mentioned here: Avoid accumulation of data in udp socket or read newest data from udp socket and then just read the latest data but I can't seem to do that without hanging my client doing something like
while (socket.receive(,,_) != sf::socket::status::error) and flushing goes on forever and hangs my client and that makes sense as the server keeps sending data faster than the client can. And with this, if I freeze my client or somehow manage to stall it for a bit, it doesn't pull the latest data from the server and renders only the old data so I just want to know how can I fix this, as far as I understand sf::udpSocket doesn't provide
how to remove escape char \" that is added by aws api gateway integration response
26 March 2025 @ 12:32 am
I have this template:
#set($context.responseOverride.header.A = 'ab "cd"')
In Postman I see a header A with value "ab \"cd\"".
I want to see in Postman a header A with value ab "cd".
tcp dump -z always results in permission error
26 March 2025 @ 12:27 am
My objective is to run sudo tcpdump -i eno1 -G 5 -w "/var/captures/capture-%Y-%m-%d_%H-%M-%S.pcap" -z /var/test.sh and process the pcap files as they are generated.
For some reason, I keep getting a permission error:
tcpdump: listening on eno1, link-type EN10MB (Ethernet), snapshot length 262144 bytes
compress_savefile: execlp(/var/captures/test.sh, /var/captures/capture-2025-03-25_19-05-55.pcap) failed: Permission denied
compress_savefile: execlp(/var/captures/test.sh, /var/captures/capture-2025-03-25_19-06-00.pcap) failed: Permission denied
compress_savefile: execlp(/var/captures/test.sh, /var/captures/capture-2025-03-25_19-06-05.pcap) failed: Permission denied
I've tried to assign ownership of the test.sh to root, to TCP dump, but no matter what I do, it results in the same error.
I also tried switching completely to root and trying it out, but it's not working.
Any advice is deeply appreciated.
How do I avoid CPU for loops when inputs are a function of previous outputs?
26 March 2025 @ 12:21 am
I have a simple model in pytorch that makes decisions about where it wants to be and receives its current position (e.g. from a GPS) as an input. For the sake of this example let's just assume it can just move anywhere at any point (ie. it can just specify its position). In the real example we'd either output a movement or the activation would augment the desired position to what is achievable.
class Traveller(torch.nn.Module):
def __init__(
self,
num_inputs: int,
hidden_size: int,
num_layers: int,
dropout: float,
):
super(DeepStatefulMVO, self).__init__()
# The first LSTM layer
self.lstm_layers = torch.nn.LSTM(
input_size=num_inputs + 2,
hidden_size=hidden_size,
num_layers=num_layers,
dropout=dropout,
batch_first=True
)
self.output_layer = torch.nn.Linear(
in_features=hidden_size,
ou
How to display items in listbox using VLookup from another sheet in VBA
26 March 2025 @ 12:21 am
I have here Sheet1 that contains dynamic items from Columns A to D. I have Column D with Teachers names but also blanks in it. I also have Sheet2 that contains Teachers names. I would like to display only items from A to D according to the current month but I would like to display items where Teacher cells are blank and NOT EQUAL to Teacher names in Sheet2.
Sheet1
A
B
C
D
Name
Color
Date
Teacher
Liam
Red
2/15/2025
Ms. Brown
Jayden
Blue
3/16/2025
Kennedy
Blue
3/17/2025
Ms. Taylor
Lincoln
Red
3/18/2025
Mr. Powell
Olivia
Yellow
3/19/2025
Brynn
Green
Skeleton is not visible on page change through pagination
26 March 2025 @ 12:19 am
This is the product listing page with pagination:
=> app/category/page.js
import PageWrapper from "@/app/UI/PageWrapper";
import ProductGrid from "@/components/ProductGrid";
import Pagination from "@/components/Pagination/Pagination";
import { getCategoryProducts } from "@/lib/graphql/product";
import { Suspense } from "react";
import PLPSkeleton from "@/UI/skeleton/PLPSkeleton";
import { notFound } from "next/navigation";
const PAGE_SIZE = 2;
const CategoryPage = async ({ searchParams }) => {
const category_id = searchParams?.category_id || "";
const page = Number(searchParams?.page) || 1;
if (!category_id) {
return notFound();
}
const categorySlugDecoded = decodeURIComponent(category_id);
const apiParameters = {
currentPage: page,
id: categorySlugDecoded,
filters: { category_uid: { eq: categorySlugDecoded } },
pageSize: P
Why is this post build command not working when trying to copy the SDL3.dll to the same folder as the exe (premake)
25 March 2025 @ 11:40 pm
filter "system:windows"
cppdialect "C++17"
staticruntime "On"
systemversion "latest"
defines
{}
postbuildcommands {
"{COPYFILE} vendor/SDL3/lib/SDL3.dll bin/Debug-windows-x86_64"
}
I'm trying to learn premake and having troubles copying over a dll file with a post build command.
Above is the post build command im using (you can see it at the bottom of the code snippet). However, when trying to run the application after running the premake file and generating the solution, it says 'The system cannot find the path specified.'. Seems like it either cant find the SDL3.dll or the exe itself.
What could be happening here and what im doing wrong?