StackOverflow.com

VN:F [1.9.22_1171]
Rating: 8.9/10 (12 votes cast)

Random snippets of all sorts of code, mixed with a selection of help and advice.

How can I add API common prefix for controllers

18 November 2025 @ 6:35 am

I want to add an API common prefix for all controllers, e.g. /api/v1. I am using inversify with the @inversify/http-express package. Here is my current base server adapter setup: class Server { private adapter: InversifyExpressHttpAdapter; constructor(private readonly container: Container) { this.adapter = new InversifyExpressHttpAdapter(this.container, { useCookies: true, useJson: true, }); this.adapter.applyGlobalMiddleware(CorsMiddleware); this.adapter.applyGlobalMiddleware(HelmetMiddleware); this.adapter.applyGlobalMiddleware(RateLimitMiddleware); this.adapter.applyGlobalMiddleware(CookieParserMiddleware); this.adapter.applyGlobalMiddleware(LoggerMiddleware); const swaggerProvider: SwaggerUiProvider = new SwaggerUiProvider({ api: { openApiObject: { info: { title: "My Backend",

Can TDengine Database Further Reduce Memory Usage?

18 November 2025 @ 6:18 am

TDengine Usage Environment: Testing TDengine Version: 3.3.6.0 Operating System and Version: Ubuntu 20.04 (WSL2) Deployment Method: container/non-container deployment Non-container Number of Cluster Nodes: 1 Number of Cluster Replicas: 1 Using Python to connect to the database, inserting data (over 20 million messages, data files approximately 4 GB) into the database. According to the "Server Memory Requirements", the database creation parameters such as vgroups, buffer, pages, etc., have been adjusted to be as small as possible. The memory usage of the taosd process is monitored every 5 seconds, with an average memory usage of about 150 MB. Are there any other parameters that can be adjusted or other methods to further reduce the memory usage of the database server?

I can't create objectbox-jni-windows-x64

18 November 2025 @ 6:17 am

I am building a KMP project with ObjectBox. When I run the jvmApp module directly (e.g., from the IDE), the ObjectBox .dll file is found and loaded correctly. However, when I build a distributable package for deployment (e.g., using jpackage), the .dll file seems to be missing from the final package, causing it to fail at runtime. What could be the problem? settings.gradle.kts(root) pluginManagement { repositories { google { content { includeGroupByRegex("com\\.android.*") includeGroupByRegex("com\\.google.*") includeGroupByRegex("androidx.*") } } mavenCentral() gradlePluginPortal() } resolutionStrategy { eachPlugin { if (requested.id.id == "io.objectbox") { useModule("io.objectbox:objectbox-gradle-plug

When using SELECT INTO in Apache IoTDB to write back aggregated query results, the timestamp becomes 1970, how to insert the current `time` instead?

18 November 2025 @ 6:09 am

I am using Apache IoTDB 1.3.4's SELECT ... INTOstatement (write-back feature) to write aggregated query results to new time series. The original data looks like this: select * from `root.sg`.** +-----------------------------+-------------+-------------+ | `Time`|`root.sg.d1.s1`|`root.sg.d1.s2`| +-----------------------------+-------------+-------------+ |2025-10-21T08:00:00.000+08:00| 10.0| 20.0| |2025-10-21T09:00:00.000+08:00| 15.0| 25.0| |2025-10-21T10:00:00.000+08:00| 12.0| 22.0| +-----------------------------+-------------+-------------+ The write-back statement I used is: SELECT AVG(s1) AS avg_s1,AVG(s2) AS avg_s2 INTO `root.sg_copy.d1`(avg_s1),`root.sg_copy.d1`(avg_s2) FROM `root.sg.d1`; The execution succeeds, and the aggregated values are written to the target series, but the timestamp defaults to 1

why nextjs is sending async prop from a component to a suspended child component

18 November 2025 @ 5:46 am

import {Suspense} from "react" type Props = { params: Promise<{joblistingId: string }> } export default function JoblistingPage(props: Props) { return ( <Suspense> <SuspendedPage (...props) /> </Suspense> ) } async function SuspendedPage({params}: Props) { const {jobListingId} = await params const joblisting = await getJoblisting(joblistingId) } in this we are awaiting params which are promise.why it is passed down as promise?

See the query sent to SQL Server

18 November 2025 @ 5:43 am

Is there a way to check SQL Server logs to see what query is sent to the server? I have a query that fails to execute with the error Incorrect syntax near @P2 The query is SELECT name FROM sys.key_constraints WHERE type = 'PK' AND parent_object_id = OBJECT_ID(?.?.?); So I'd like to see what is sent to fix the problem.

Which window can I passing a `WM_SYSCOMMAND` to carry out system commands?

18 November 2025 @ 3:43 am

An application can carry out any system command at any time by passing a WM_SYSCOMMAND message to DefWindowProc. If I don't have any windows, which window can I post/send WM_SYSCOMMAND to carry out system commands? First, GetDesktopWindow() doesn't work. Second, while GetForegroundWindow() works most of the time, it won't work if the foreground window decides to intercept WM_SYSCOMMAND or has a higher integrity level. And HWND_BROADCAST is the worst option. So what about GetShellWindow()? Or, can I direct call DefWindowProcW(RANDOM_WINDOW, WM_SYSCOMMAND, ...)? It seems that this will work as long as RANDOM_WINDOW is any valid HWND, and the integrity level is no higher than caller. ( I'm raising this quest

How to increase space between an ordered list item''s marker and content whilst using list-style-position: inside?

18 November 2025 @ 3:35 am

I have an ordered list (<ol>). <div class="wrapper"> <ol> <li>List item</li> </ol> </div> I'd like to remove the indent of the <ol> and increase the distance between the number and the text on each <li>, eg: 1. List item". I have tried the following, but though I get close there seems to always be compromises. ol { padding-left: 0px; } li { padding-inline-start: 8px; } ^ This does introduce space between the text and the number, but places the number outside of the .wrapper element. I could apply padding-left to the ol to counter it but would like to avoid that if possible. ol { padding-left: 0px; list-style-position: inside; } li { padding-inline-start: 8px; } ^ This places the number inside the .wrapper element, but the spacing between the n

Install additional package in an existing virtual environment created by pipenv

18 November 2025 @ 2:08 am

I currently have a base conda environment and a (virtual) environment called Work-8uAjguag that was created with pipenv. Now I want to install a package (say openpyxl) in the environment Work-8uAjguag. From my understanding, I need to activate that environment Work-8uAjguag first. However, when I run the command conda activate Work-8uAjguag in anaconda prompt , I got an error message: EnvironmentNameNotFound: Could not find conda environment I guess it was because Work-8uAjguag was not created by conda, thus it wasn't recognised. My question is: how can I install a package in an existing virtual environment (Work-8uAjguag) created by pipenv? PS: How can I reply to a reply/comment? I tried to click on the reply symbol in @Silikazi's second reply

Build a rust doc test from multiple snippets in the same comment

18 November 2025 @ 1:54 am

Suppose I want to write a doc comment such as this: //! This type can be used to write a function such as: //! ``` //! fn example() -> MyType { ... } //! ``` //! Then the function can be used as: //! ``` //! example() //! ``` Currently the doc test of the second snippet does not compile because the example function from the first snippet is not in scope. However, in my concrete example the first snippet is quite long, so it's tedious to copy/paste the first snippet into the second to make the latter compile. Is there a way to import things defined in a snippet into scope in another snippet?