October 23, 2024
Chicago 12, Melborne City, USA
C#

Does malloc assign memory in the same location if you use the same variable name again on every iteration of a loop?

I am writing code to take in a weighted adjacency list in c. Each edge is stored in the form of a struct. I created a an array of pointers where each pointer leads to the list for a node. Here’s what I did: #include<stdio.h> #include<stdlib.h> struct edge{ int u; int v; int w; };

Read More
java

Postgres drop type XX000 “cache lookup failed for type”

I’m using Quarkus and Hibernate to work with PostgreSQL/PostGIS. I have an entity Geofence that contains a Polygon field. The issue occurs when running tests with Cucumber. The problem: When running the tests, I get the following error on the second and subsequent examples within the test scenarios: javax.persistence.PersistenceException: org.hibernate.exception.GenericJDBCException: could not execute statement ...

Read More
python

rolling sum with right-closed interval in duckdb

In Polars / pandas I can do a rolling sum where row each row the window is (row - 10 minutes, row]. For example: import polars as pl data = { "timestamp": [ "2023-08-04 10:00:00", "2023-08-04 10:05:00", "2023-08-04 10:10:00", "2023-08-04 10:10:00", "2023-08-04 10:20:00", "2023-08-04 10:20:00", ], "value": [1, 2, 3, 4, 5, 6], } df

Read More
javascript

Regex that detects if the key has a missing character

const placeholders = { "Luke": "{{candidate_first_name}}", "xxx@gmail.com": "{{candidate_email}}", } const text = <div>Hi&nbsp; Luke ,</div><div><strong>Email: </strong>xxx@gmail.com</div> export default function removeTextPlaceholders( text: string, placeholders: any ) { try { for (const [key, value] of Object.entries(placeholders)) { if (value) { const regex = new RegExp(`^${key}(?:\\s*|.{0,1})$`, 'g'); // Check if the key is a complete match before replacing

Read More
SQL

How to flatten a json array string in Redshift

I have a table like this: id stage(varchar) 1 ["a","b"] 2 ["c"] and I need to retrieve the data as the following format: id stage 1 a 1 b 2 c How should I write my SQL in AWS Redshift? You need to sign in to view this answers

Read More
HTML

Why don't flex items shrink past content size?

The following input shrink with the browser window, but at some point they stop shrinking and the horizontal scroll bar appears. I feel this this is weird because they don’t have any width applied. <div class="flex w-full flex-col items-start justify-start gap-2 md:flex-row"> <div class="relative flex w-full flex-col items-start justify-start gap-2"> <label class="text-sm font-semibold">Foreground Color</label> <div

Read More
Android

Flutter serial connection for hc05 bluetooth module?

I want to build a bluetooth app that connect to ardunio with hc05 bluetooth module. I added some packages for bluetooth from pub.dev to build the application. Like flutter_bluetooth_serial: ^0.4.0. When i run the project, it doesn’t run. Can anyone help to how can i use hc05 module to connect to flutter application? You need

Read More
C#

Read a file with unknown number of lines in C using fscanf

I tried to search for the answer here and elsewhere on the Internet, but didn’t get exactly what I am looking for. I have a data file that looks like this: 0,4 0,6 0,9 0,10 1,5 1,7 1,9 2,6 2,8 2,10 3,4 3,7 I can read this file line by line using fscanf() without any

Read More
java

Why one to many data not go to backend?

I currently creating supplier form that we can add supplier and assign him to different brand and categories.that mean supplier related with one to many relation with supplier_has_brand_category. but i face this issue. frontend supplier obj pass correctly without any other issue. but backend supplier_has_brand_category is null. Supplier Entity import jakarta.persistence.Column; import jakarta.persistence.Entity; import jakarta.persistence.GeneratedValue;

Read More
python

NiceGUI Table Dynamic Title

I’m using NiceGUI and trying to create a table with a dynamic title. I want to be able to change the title of the table dynamically, just like I can update the columns and rows properties. # Create the table with an initial title existing_table_route = ui.table( columns=[], rows=[], row_key='Route/Variant', title="Existing - Rate / SKU

Read More