StackOverflow.com

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

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

Kafka doesn't throw exception when authentication fails

12 May 2025 @ 5:16 am

I am using some C# code that can pull data from a Kafka connection if I provide the right credentials. However, if I provide incorrect credentials, I can see the error messages in the console, but the code does not throw an exception, so I have no way of handling the case where bad credentials have been provided. here is the code: using Confluent.Kafka; namespace KafkaTest { internal class Program { static void Main(string[] args) { var conf = new ConsumerConfig { GroupId = "mygroupid", BootstrapServers = "myserver:9092", SecurityProtocol = SecurityProtocol.SaslSsl, SaslMechanism = SaslMechanism.Plain, SaslUsername = "myusername", SaslPassword = "wrongpassword", AutoOffsetReset = AutoOffsetReset.Earliest, }; using (var c = new ConsumerBuil

How to resolve 'grad strides mismatching' warning in custom Kronecker Linear layer using torch.einsum?

12 May 2025 @ 5:12 am

I'm implementing a more efficient version of lokr.Linear from the LoKr module in PEFT. The current implementation uses torch.kron to construct the delta_weight before applying rank dropout, but this approach does not leverage the potential efficiency of mixed Kronecker matrix-vector products if rank dropout is ignored in several circumstances. Specifically, LoKr currently materializes the full Kronecker product, leading to unnecessary memory and compute overhead. Instead, I’m attempting to implement the computation using torch.einsum to directly evaluate the mixed Kroneck

Accessing disabled fields in Datadog synthetic testing

12 May 2025 @ 5:12 am

Problem: I'm currently creating my first synthetic tests in datadog. I'm encountering some difficulty testing whether a form field is disabled or not. I can't select disabled elements for assertions. This is the element I'm trying to select: <input type="text" name="phoneNumber" id="phoneNumber" placeholder="" class="..." disabled="" inputmode="numeric" value="410 111 1111"> Form fields that are not disabled like this are selectable: <input type="text" name="ssnLastFour" id="ssnLastFour" placeholder="" class="" inputmode="numeric" value=""> What I've tried: When I click on the element in datadog's GUI after clicking on add an assertion, the pink outline appears around both of the above text fields (as in the image), but I can

clojure.lang.ExceptionInfo: Error on key :app.migrations/migrations when building system (core.cljc:410)

12 May 2025 @ 5:05 am

I am trying to deploy penpot on a local minikube cluster using the following yaml file: apiVersion: v1 kind: Namespace metadata: name: penpot --- apiVersion: v1 kind: Service metadata: name: postgres namespace: penpot spec: ports: - port: 5432 selector: app: postgres --- apiVersion: apps/v1 kind: Deployment metadata: name: postgres namespace: penpot spec: replicas: 1 selector: matchLabels: app: postgres template: metadata: labels: app: postgres spec: containers: - name: postgres image: postgres:latest env: - name: POSTGRES_DB value: penpot - name: POSTGRES_USER value: penpot - name: POSTGRES_PASSWORD value: penpot ports: - containerPort: 5432 volumeMounts: - mountPath: /var/lib/postgresql/data name: post

Javascript TypeError undefined on for loop only [duplicate]

12 May 2025 @ 5:04 am

I have a function that gets called when you click a button. I'm checking to see if the clicked item has the class "itm-active". If it does, don't do anything. Else check for elements that have it and remve the class from them. Also change the text of the button one the class has been removed. The issue comes in when I'm trying to change the text of the button. If I hardcode an item, in this case items[0], I am able to change the text of the button. If I try to do the same thing within the for loop, I'm getting the error "Uncaught TypeError: items[i] is undefined" NOTE: If I comment out the line items[i].innerHTML = "test";. The line above it doesn't give any error. I left comments on the lines in question to make it easy to see. function activeStatus (event) { let activeItem = event.srcElement.classList.contains("itm-active"); if (activeItem) {

PostgreSQL table size

12 May 2025 @ 5:04 am

I created a table using the like option (like prod_events including all ) No records were inserted. The table prod_events does have indexes and a JSONB column. When I executed the query - select schemaname as table_schema, relname as table_name, pg_size_pretty(pg_total_relation_size(relid)) as total_size, pg_relation_size(relid) as data_size, pg_size_pretty(pg_total_relation_size(relid) - pg_relation_size(relid)) as external_size from pg_catalog.pg_statio_user_tables order by pg_total_relation_size(relid) desc, pg_relation_size(relid) desc limit 10; The newly created table has data_size of 0, but total_size/external_size of 32 KB. What would explain that? PostgreSQL Version is 13.15

BCNF decomposition - am I right?

12 May 2025 @ 5:03 am

Consider the relation R(A, B, C, D, E, F) with the following set F of functional dependencies: {AD → B, A → E, C → E, DEF → A, F → D}. Statement: the BCNF decomposition of R is ABD, ADEF, DF, CE and CF My opinion: this is not in BCNF because of ADEF will include F.D A->E (A is not a super key), but in answers it is given that it is in indeed in BCNF, please let me know if I am making any mistake anywhere.

Flutter iOS simulator launch error: arm64 not compatible with x86_64 + slow startup

12 May 2025 @ 4:58 am

I’m facing delays launching my Flutter app on the iOS simulator. Here's the key error: Error creating LLDB target... target architecture: arm64: not compatible with x86_64-apple-ios12.0.0-simulator... Using an empty LLDB target instead but this can cause slow memory reads. Also getting: [FirebaseCore][I-COR000012] Could not locate configuration file: 'GoogleService-Info.plist'. Details: macOS (M2), Dart Version: 3.7.2 Flutter Version: 3.29.2, Xcode Version 16.3 (16E140) iOS simulator (x86_64) vs app built for arm64 Tried: flutter clean, rebuilt Removed DerivedData Added GoogleService-Info.plist (still warning) Questions: How to fix arm64 vs x86_64 mismatch? Is LLDB target issue slowing down launch? Can I ignore the Firebase config warning?

UI Widget Flutter - page layout appears messy

12 May 2025 @ 4:56 am

enter image description here After the app is built into an APK, sometimes the page layout appears messy like this. It doesn’t happen often, but it’s quite annoying because I have to refresh the page. This usually happens when I go back by pressing the button in the middle of the phone screen Please help me. I'm not sure how to check this because I've never encountered this issue before

Interpolation x and y values with n time duration

12 May 2025 @ 4:54 am

if x values change from 3 to 9 over a 60 seconds duration , and y values change from 4 to 6 in the same duration time (60 seconds ). what time n will make x = y ? I tried , X3 = X1 + ((Y3 - Y1) * ((X2 - X1) / (Y2 - Y1)) , but where the time n first in the formula ? I FOUND THAT AFTER 15 seconds Both X and Y will equal 4.5, but how to get that time using code or formula ?