Random snippets of all sorts of code, mixed with a selection of help and advice.
Qt - Scrolling area leaves a a lot of empty space
7 December 2025 @ 6:31 am
I am developing a chatbot using Qt in C++. When I ask a question, and the LLM returns a response, there is always a empty space left out between the last sentence and the input area as attached screenshot.
I am currently deisgning the chat window using QScrollArea, I searched online and it mentions we can solve the issue by using stretch. However, I have tried it but still could not solve the issue. Is there any way to fix the empty space in a fixed height, e.g. 20px, from the input area? Or is this a limitation in Qt?
Should I switch to other setups e.g. using different Qt libraries instead of QScrollArea to solve the issue?
Below are the code snippets related to the setup:
m_messagesLayout->setContentsMargins(64, 16, 64, 0);
m_messagesLayout->setSpacing(8);
m_messagesLayout->setAlignment(Qt::AlignTop);
m_scrollArea->setWidget(m_messagesContainer);
m_scrollArea = new QScrollArea(this);
m_scrollArea->setWidgetResizable(true);
How to check if value is valid for a number input
7 December 2025 @ 6:04 am
When assigning a value to a number input via JS, is there a way to validate the value to meet the input's requirements - min, max and step - without doing it manually.
For example, consider this input
<input type="number" min="0" max="100" step="10">
If the value is to be set by js and by whatever logic it comes out to say 19, I need a way to know 19 is not valid for this input and even better if the function can return nearest valid value - in this case 20. JS does not throw any error for invalid inputs.
input.value = 19;
I know validation will be done when form is submitted and this input will throw an error but that error will have to be resolved by the user.
I've tried searching for it online, but Google just returns results to check if value is a number. Again, I can do all the checks manually but need to know if ther
Why does my custom object's __bool__ affect conditional evaluation order in Python if statements?
7 December 2025 @ 5:59 am
I’m experimenting with custom truth values in Python by overriding __bool__ on a class. However, when using multiple conditions in an if statement, Python seems to stop evaluating earlier than I expect:
class A:
def __init__(self, v):
self.v = v
def __bool__(self):
print("checking bool:", self.v)
return self.v > 5
x = A(3)
y = A(10)
if x and y:
print("ok")
Questions:
1. Is this short-circuit behavior always guaranteed in Python, even with custom __bool__ or __len__ methods?
2. Does Python evaluate left-to-right for all logical operators (and, or) inside if statements?
3. Is there any situation where Python would evaluate both operands even if the first already determines the result?
update programmatically value of a field in wooCommerce checkout blocks
7 December 2025 @ 5:59 am
In WooCommerce Checkout Blocks, suppose I have added a custom text-input field using woocommerce_register_additional_checkout_field, and I want to update the value of that input via js.
The update should occur in response to a user action (for example, when the user selects a pickup point from a popup that I generated with createElement inside ExperimentalOrderShippingPackages).
From what I understand, this should be done with setExtensionData, but I do not fully understand how it is supposed to work.
How can I correctly update the value of a custom checkout field when using Checkout Blocks?
Error message when doing Update-Database in Blazor using VIsual Studio [duplicate]
7 December 2025 @ 5:28 am
when I run Update-Database command after creating a new migration, I get the following error:
Introducing FOREIGN KEY constraint 'FK_Booking_Employee_EmployeeId' on table 'Booking' may cause cycles or multiple cascade paths. Specify ON DELETE NO ACTION or ON UPDATE NO ACTION, or modify other FOREIGN KEY constraints.
Could not create constraint or index. See previous errors.
However, I am not quite sure how to fix this.
My Booking model:
using System.ComponentModel.DataAnnotations.Schema;
namespace SpaWebsite.Models
{
public class Booking
{
public int BookingId { get; set; }
[ForeignKey("Service")]
public int ServiceId { get; set; }
public Service? Service { get; set; }
[ForeignKey("Customer")]
public int CustomerId { get; set; }
public Customer? Customer { get; set; }
[ForeignKey("Employee")]
public int EmployeeId { g
Android WebView: mong muốn mở link Facebook bằng Intent nhưng bị giữ lại trong WebView
7 December 2025 @ 5:26 am
I make web next js, running on facebook web view, the deeplink function to open via app does not work when using intent, the case is as follows: if the app is not installed then fallback via play store, if the app is installed then open the app, but the fallback case does not work (only on facebook webview, browser works normally) intent example: intent://scan/#Intent;scheme=zxing;package=com.google.zxing.client.android;S.browser_fallback_url=http%3A%2F%2Fzxing.org;end, please help me
“Tailwind CSS v4: Why are larger text sizes (text-5xl, text-6xl, etc...) not being generated?”
7 December 2025 @ 5:23 am
I'm currently learning tailwind css, but i'm facing an issue. I have read the documentations; i could not find a good answer on how to make it work. I'm using tailwind css V4 to create some typography, but only the text-4xl works; the one above it does not work.
Is there anyone who can help me with that?
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="../dist/output.css">
<title>Document</title>
</head>
<body>
<!--FONT SIZE - text-XS-->
<!--xs, sm, base, lg, xl, 2xl-9x1 -->
<div class="text-xs">
Lorem ipsum dolor sit amet consectetur adipisicing elit.
</div>
<div class="text-sm">
Lorem ipsum dolor sit amet consectetur adipisici
Am I incorrectly using BetterAuth's useSession()?
7 December 2025 @ 5:17 am
Working on a new project with SolidStart and running into an issue.
I'm currently importing the useSession() function from my client-side Better-Auth instance. According to documentation, I should just be able to use something like:
const { data: session } = useSession()
However, when I try this, I get a TypeScript error specifying:
Property 'data' does not exist on type 'Accessor<{ data: ...
The documentation for SolidJS also states that it's not a good idea to destructure reactive stuff because it is likely to lose reactivity.
The alternative is the following:
import { useSession } from '~/utils/auth-client'
export default function QuickButtons() {
const session = useSession()
return (
<ul class="menu menu-horizontal border-r border-gray-500">
<li>
<a>{session() ? `${session().data?.user.username}` : 'nothing!'}</a>
<
Executed line confusion
7 December 2025 @ 4:36 am
In the Python program below:
a = 3
if a > 10:
print("gt10")
elif a > 5:
print("gt5 lt10")
elif a > 2:
print("bw25")
else: # Line 9
pass
when I run formal code coverage tool SlipCover, when a is 3, the line 9 is not listed as missing line, but when it makes the previous conditionals evaluate to true such as a = 10, line 9 is listed as unexecuted line this time. I am really confused about this behaviour, in any case the body of else statement is not executed. Could you explain me the reason why else is in one case not listed as unexecuted, but in the second case listed as unexecuted?
The Photo doesn't visible when I try to print in webpage
7 December 2025 @ 2:49 am
Every thing was right but when I try to print the photo which submitted by form it doesn't print but the URL of the image work properly when I print directly it will work.
function add(Request $request)
{
if ($request->hasFile('file')) {
$path = $request->file('file')->store('public');
$fileName = basename($path); // abc.jpg
$imgUrl = asset('storage/' . $fileName);
return view('random', ['img' => $imgUrl]);
} else {
return 'upload the file ';
}
}
<div>
{{$img}}
<img src="{{$img}}">
</div>