StackOverflow.com

VN:F [1.9.22_1171]
Rating: 9.2/10 (11 votes cast)

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

Implementing a zero-extended vector/wrapper in Eigen

12 October 2025 @ 10:48 pm

I would like to zero-extend a custom vector and give it a MatrixBase interface such that the extended vector can be used passed to the SparseLU solver. Essentially, my attempt looks like this template<typename Lhs> struct ZeroExtendedVector // Unable to determine the correct base class { EIGEN_DEVICE_FUNC ZeroExtendedVector(const Lhs& lhs_, Eigen::Index numZeros_) : lhs(lhs_) , numZeros(numZeros_) { } // Coefficient Access (The Zero-Copy Extension Logic) EIGEN_DEVICE_FUNC const typename Lhs::Scalar coeff(Eigen::Index row, Eigen::Index col) const { if (row < lhs.rows()) { return lhs.coeff(row, 0); } return 0.0; } const Lhs& lhs; const Eigen::Index numZeros; // The number of zeros to append }; Of course

Continuous profiling with async-profiler. Generate heatmap for several JFRs

12 October 2025 @ 10:40 pm

tl;dr: I'm trying to create a single daily heatmap by combining multiple hourly JFR files from async-profiler's continuous profiling feature. When I pass multiple files to jfrconv, the output only contains data from the last file provided. Is there a correct way to merge them into a single daily heatmap? Long version: Does anyone use the new continuous profiling feature in async-profiler? I recently learned that you can generate a heatmap from a JFR file. I enabled profiling for my application with the following command: -agentpath:/path/to/async-profiler-4.0-linux-x64/lib/libasyncProfiler.so=start,event=cpu,alloc=2m,loop=1h,file=profile-%%t.jfr this generates a series of files for every hour of my application's runtime, like so: profile-20251010-180649.jfr

C# Project using Spinnaker SDK (for win-x64 and linux-arm64)

12 October 2025 @ 10:31 pm

I am currently trying to utilize the Spinnaker SDK in a C# .NET8.0 application. My goal is to make a cross-platform application that runs on both Windows-x64 and NVIDIA Jetson Orin (Linux ARM64) I have previously successfully utilized the Python version (PySpin) on both of these systems, so I would like to work on getting a C# .NET8.0 application working. I've managed to get it somewhat working on the Windows side of things after installing the Spinnaker SDK and using the SpinnakerNET nuget package and including the "C:\\Program Files\\Teledyne\\Spinnaker\\bin64\\vs2015\\SpinnakerNET_v140.dll" in my .csproj , but I'm having trouble finding documentation and resources to setup my project so it can be built and published for my NVIDIA Jetson (ubuntu 20.04 arm64) system Some pointers in the right direction would be helpful, thank you.

Writing sommething in the serial monitor in the setup of arduino for ESP32

12 October 2025 @ 10:23 pm

I want to write a questionary by using UART comunication between an esp32 and my computer. For that I need to write the title of the questionary once and then press enter to start the quizz but I can't make that the title and the rules of the questionary wrote once before the quizz start. I try putting it in the setup void so it run once but it dont work. Pleas somme one help me! this is my code, help me fix it. void setup() { // put your setup code here, to run once: Serial.begin(9600); while (!Serial) { ; // wait for serial port to connect. Needed for native USB port only } Serial.println ("Quiz UART - Répondez aux 4 questions."); Serial.println ("Tapez A, B, C ou D."); Serial.println ("tapper Enter pour commencer"); } void loop() { // put your main code here, to run repeatedly: }

Celery connection refused to Azure Redis with SSL - "No connection could be made because the target machine actively refused it"

12 October 2025 @ 10:22 pm

I'm trying to connect Celery to Azure Redis with SSL, but getting connection refused errors. The Celery app is configured with SSL but fails to connect. Error: ConnectionRefusedError: [WinError 10061] No connection could be made because the target machine actively refused it Celery Configuration (app/celery_app.py): def create_celery_app(): app = Celery( "MyApp", broker=settings.CELERY_BROKER_URL, backend=settings.CELERY_RESULT_BACKEND, ) CERT_CONFIG = { 'ssl_cert_reqs': ssl.CERT_NONE, 'ssl_ca_certs': None, 'ssl_certfile': None, 'ssl_keyfile': None, } app.conf.broker_use_ssl = CERT_CONFIG app.conf.result_backend_use_ssl = CERT_CONFIG return app app = create_celery_app() Configuration (app/core/config.py):

Why does the error "patterns require matching on different types" when using lazy lists Nil and (::)?

12 October 2025 @ 5:03 pm

This works in Idris 2 : intersperse : a -> LazyList a -> LazyList a intersperse _ Nil = Nil intersperse _ (x :: Nil) = x :: Nil intersperse sep (x :: y :: xs) = x :: sep :: intersperse sep (y :: xs) This does not : intersperse : a -> LazyList a -> LazyList a intersperse _ Nil = Nil intersperse _ (x :: Nil) = x :: Nil intersperse sep (x :: xs) = x :: sep :: intersperse sep xs It would work with List instead of LazyList, but here yields the following compile error : Error: Patterns for intersperse require matching on different types. pointing to the first clause. Does anybody know why and how to make it work ? Even with qualifying all Nil and (::) and trying to hide the List versions of those constructors, it does not work.

FFT in swift/Accelerate gives strange result

11 October 2025 @ 6:03 pm

I am trying to use FFT transformation in swift, using the accelerate framework from Apple, but I get strange results. When I use fftw3 in a small C program, everything looks fine. As a test case, I try to transform a rotating unity vector doing one revolution. I expect the FFT to return a spectrum containing a single non-negative amplitude at index 1. Fftw3 does this fine. Here is my C program using fftw3: #include <fftw3.h> #include <math.h> #include <stdio.h> #define N 32 int main(int argc, char *argv[]) { fftw_complex *in = (fftw_complex*) fftw_malloc(sizeof(fftw_complex) * N); for (int i=0; i < N; i++) { in[i][0] = cos((double)i/(double)N* 2.0 * M_PI); in[i][1] = sin((double)i/(double)N* 2.0 * M_PI); } printf("Input\n"); for (int i=0; i < N ; i++) printf("%6.2f %6.2f\n", in[i][0], in[i][1]); fftw_compl

The scanf function in C language uses a width specifier for char

11 October 2025 @ 3:55 pm

There is a code where I enter ABCDEFGH and press enter, and the final result is HGF. When I use debug mode to observe variables. When executing the first sentence input, x='A'. After the next step, x='D', y='C'. After the next step, x='H', y='G', z='F'。 #include <stdio.h> int main() { char x, y, z; scanf("%2c", &x); scanf("%3c", &y); scanf("%4c", &z); printf("%c%c%c", x, y, z); return 0; } I am currently very confused as to why this is happening. As far as I know, "%3c" means to read in 3 characters, but only store the first one and discard the last two. I'm not sure if there's a problem with this code. Can you explain why the output is like this, regardless of whether the code was written incorrectly or not?

AWS Quicksight: ArgMax Calculated Field

10 October 2025 @ 10:11 pm

I would like to write a calculated field which returns the value of a string column corresponding to the maximum of a date column, subject to the date being between two parameters. So, for example, if I have a table: enter image description here And my maxdate parameter is 9/30/2025 and my mindate parameter is 9/27/2025, then I want the calculated field to return StringB because it has the latest date within that range, when grouped by pID and cID. It is possible to do this in QuickSight? If so, can you provide an example?

Error seeding data: [AppwriteException: Invalid document structure: Missing required attribute "image"]

4 October 2025 @ 10:41 pm

Working on a react native app and having issues with the Appwrite database. here is the error: ERROR Error seeding data: [AppwriteException: Invalid document structure: Missing required attribute "image"] import { ID } from "appwrite"; import { databases, config } from "./appwrite"; import { agentImages, galleryImages, propertiesImages, reviewImages } from "./data"; const COLLECTIONS = { AGENT: config.agentsCollectionId, REVIEWS: config.reviewsCollectionId, GALLERY: config.galleriesCollectionId, PROPERTY: config.propertiesCollectionId, }; const propertyTypes = [ "House", "Townhome", "Condo", "Duplexe", "Studio", "Villa", "Apartment", "Other", ]; const facilities = [ "Laundry", "Car-parking", "Sports-center", "Cutlery", "Gym", "Swimming-pool&qu