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.

Pytorch Sentiment analysis model AcceleratorError: CUDA error: device-side assert triggered

7 November 2025 @ 11:25 am

import torch from torch import nn from transformers import AutoTokenizer from torch.utils.data import DataLoader, TensorDataset, Dataset from torch.nn.utils.rnn import pad_sequence import pandas as pd device = torch.device("cuda" if torch.cuda.is_available() else "cpu") print(f"Using device : {device}") ds = pd.read_csv("YoutubeCommentsDataSet.csv") def clean(ds): n_comments = [] n_things = [] for comment, sentiment in zip(ds['Comment'],ds['Sentiment']): if type(comment) == str and len(comment) < 512: n_comments.append(comment) if sentiment == "positive": n_things.append(1) elif sentiment == "negative": n_things.append(0) else: n_things.append(2) return n_comments, n_things comments, sentiments = clean(ds) tokeniser = AutoTokenizer.from_pretrained("bert-base-uncased") def encoder(xs): encoded = [] for x in xs: enco

MacOS client (Remote Desktop Protocol) screen sharing using SignalR

7 November 2025 @ 11:17 am

Animations and typing delayed (no WebRTC) I’m building a Remote desktop app for macOS, where the screen is captured, H.264 encoded, and streamed to a web client using SignalR. For some reasons I cannot use WebRTC, so I’m manually handling encoding, transport, and decoding. The stream works, but it’s laggy and stutters — animations, typing, and cursor movement are noticeably delayed. The architecture consists of three main parts: a macOS client, a SignalR server, and a web client. The macOS app uses ScreenCaptureKit to capture the screen and VideoToolbox (H.264) to encode frames, which are then sent as binary data to the SignalR server using the Swift SignalR client. The .NET 8 SignalR server simply relays these encoded frames to connected web clients and also forwa

TypeError: Cannot read properties of undefined (reading 'data') - Cant login in my aplication

7 November 2025 @ 11:15 am

My errors that I get, I was searching web what might Err_connected_timed_out might say, and everything that is connected with internet stability is off, because I checked it already. What my problem is, is that I cant login in my app : -> Denying load of chrome-extension://aggiiclaiamajehmlfpkjmlbadmkledi/popup.js. Resources must be listed in the web_accessible_resources manifest key in order to be loaded by pages outside the extension.Understand this error ->Denying load of chrome-extension://aggiiclaiamajehmlfpkjmlbadmkledi/tat_popup.js. Resources must be listed in the web_accessible_resources manifest key in order to be loaded by pages outside the extension.Understand this error chrome-extension://invalid/:1 ->Failed to load resource: net::ERR_FAILEDUnderstand this error 172.20.8.103:7100/api/Auth/login?email=manager1%40gmail.com&password=1234:1 ->Failed to load resource: net::ERR_CONNECTION_TIMED_OUTUnderstand th

How to prevent data coming from Pixhawk to overflow?

7 November 2025 @ 11:10 am

I receive data from Pixhawk through MAVLink and I send it to a react application through a websocket. However, it overflows due too much data and the application gets laggy to a point that it is not usable anymore. I want to be able to show all the Pixhawk registries and their sub data. This can be done once and stop the stream but since websocket has continues stream of data I haven't find a way to prevent that issue. Tested it with setInterval() to reduce the times of data being sent but it does not seem to have any effect. What I also had in mind is implementing GraphQl to it and requesting the data only once but I feel it is still not a good solution. Do you have any suggestions with the approach I can take?

Laravel migration creates wrong columns and data mismatch in employers table

7 November 2025 @ 11:08 am

I’m building a job board project in Laravel, and I’m trying to establish a one-to-one relationship between User and Employer. However, my database table is not being generated correctly — the columns appear mismatched. Here’s what I did: Migration (database/migrations/xxxx_xx_xx_create_employers_table.php) use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; return new class extends Migration { public function up(): void { Schema::create('employers', function (Blueprint $table) { $table->id(); $table->foreignIdFor(\App\Models\User::class); $table->string('name'); $table->timestamps(); }); } public function down(): void { Schema::dropIfExists('employers'); } }; But after running: php artisan migrate:fresh --seed My database ta

setup F5vpn using key stored in TPM?

7 November 2025 @ 10:47 am

Can I setup an F5VPN connection using a key generated and stored inside the TPM of my Linux laptop? Platform is Debian 13? AFAICT f5fpc is based upon openssl (which could imply PKCS#11 support), but the documentation doesn't mention it. https://techdocs.f5.com/en-us/edge-client-7-2-4-1/big-ip-access-policy-manager-edge-client-and-application-configuration-7-2-4-1/clients-for-linux.html The openconnect F5 implementation is not an option, unfortunately, due to company policy.

C# EFCore nullable type return vs not found or multiple database record

7 November 2025 @ 10:39 am

I have the following use case. The database contains a record with a nullable field and I would like to request only that filed value from the database for a single record. This can easally be done using this Linq-query: var value = await context.Table .Where(r => r.Id == recordId) .Select(r => r.Field) .SingleOrDefaultAsync(); This wil return the field value or 'null' when the record does nog exist. So when the field has a value, one gets that value. But when the field is 'null', you also get 'null'. And that's where my probleme kicks in. I want to distinct between the situation where the field value is 'null' and when the record doens't exist (error). You can try this try { var value = await context.Table .Where(r => r.Id == recordId) .Select(r => r.Field) .SingleAsync(); } catch { throw new NotFoundException(""); }

Using SUM and EXCEPT in one query

7 November 2025 @ 10:35 am

I'm using Microsoft SQL Server. I have two tables and I want to remove some rows from table 1 if the ID exist in table 2, and then do a sum of the AMT column for the remaining rows. I currently have two queries to do this which works: Query 1: SELECT ID, AMT INTO #temptable FROM table1 EXCEPT SELECT ID, AMT FROM table2; Query 2: SELECT SUM(AMT) FROM #temptable; However, is there a way to combine these two queries into one to make it more efficient?

Sum of a binary tree

7 November 2025 @ 10:29 am

I have a binary tree which leafs have a size of 1, and the parent double in size at each level. I project those nodes on a linear axe (memory space). I need to get the equation that gives the adress of the node with the id of the node. Here is the tree : 7 <- size=8 3 11 <- size=4 1 5 9 13 <- size=2 0 2 4 6 8 10 12 14 <- size=1 The address space with the sizes of the nodes : 1 2 1 4 1 2 1 8 1 2 1 4 1 2 1 So the first results are : f(0) = 0 f(1) = 1 f(2) = 3 f(3) = 4 f(4) = 8 f(5) = 9 f(6) = 11 f(7) = 12 f(8) = 20 What is the formula of this layout ?

How to read a spicific text file format in C

7 November 2025 @ 10:22 am

I just wanted to ask if it's possible to read to a specific file format, say if I wanted to read from a file that has a format of something "info.uc" or "main.uc", how would I go about doing that in C? This is a little something I am making and I want to know how to read from a specific text file format: #include "include/load_uc_file.h" bool find_file_format() { FILE* fileptr; fileptr = fopen("", "r"); if (fileptr == NULL) { printf("The file was not found"); } return false; } If anyone has an answer to this, that would be great. Thank You! -ShizamDa_Geek