StackOverflow.com

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

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

How to do hierarchical queries with arrays

28 February 2026 @ 3:56 pm

I have an JavaScript array like this: let myArray = [ { name: 'Alice', children: ['Bob', 'Bill'] }, { name: 'Bob', children: 'Cindy' }, { name: 'Bill', children: [] }, { name: 'Cindy', children: ['David', 'Don'] }, { name: 'David' }, { name: 'Don' }, ] I like to get hierarchical data from it, i.e. I like to show the array like this Alice Bob Cindy David Don Bill or Alice Alice -> Bob Alice -> Bob -> Cindy Alice -> Bob -> Cindy -> David Alice -> Bob -> Cindy -> Don Alice -> Bill Many relational databases provide such function, for example Oracle CONNECT BY clause or MongoDB $gr

Make clion format for() enter { into allman style

28 February 2026 @ 3:50 pm

I want to make it so clion formats for(int i = 0; i < n; ++i) enter { into for(int i = 0; i < n; ++i) { } Basically codeblocks style. Havent found anything online for it. Right now it enters for(int i = 0; i < n; ++i) {}

How can one create mini quiz app project with pure vanilla JavaScript. i'm a learner, after the structuring the html / css i couldn't continue

28 February 2026 @ 3:40 pm

How can i create a mini quiz app with pure vanilla JavaScript which takes questions and presents options which include the correct answer and output the scores with a next button which switches the questions and options including an updated scores if any

PostgreSQL: How to efficiently update nested JSONB array elements without replacing entire array?

28 February 2026 @ 3:38 pm

I am working with PostgreSQL 14.10 and storing nested structures in a JSONB column. I need to update a specific object within a JSONB array based on a field value (e.g., id), rather than the array index. Currently, using jsonb_set requires knowing the exact array index, which forces me to replace the entire JSONB blob. This causes performance issues with large arrays and concurrency conflicts when multiple users update different elements in the same array. Schema & Sample Data: CREATE TABLE user_profiles ( user_id SERIAL PRIMARY KEY, username VARCHAR(100), profile_data JSONB ); INSERT INTO user_profiles (username, profile_data) VALUES ('john_doe', '{ "settings": {"notifications": true, "theme": "dark"}, "addresses": [ {"id": 1, "type": "home"

How to change the tab bar background color from a content page in MAUI

28 February 2026 @ 3:30 pm

I am implementing the possibility to change the color of buttons in an MAUI app in C#. I would like to simultaneously change the tab bar background color when I update the color of the buttons. I use <TabBar> in the "AppShell.xaml" and have several content pages. I have a bindable proporty named "buttoncolor" In the "AppShell.xaml". How can I change it from a content page in the AppShell <TabBar>? AppShell.xaml <?xml version="1.0" encoding="UTF-8" ?> <Shell x:Class="SleepDiary.AppShell" xmlns="http://schemas.microsoft.com/dotnet/2021/maui" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" xmlns:local="clr-namespace:SleepDiary" Shell.FlyoutBehavior="Disabled" Shell.TabBarTitleColor="{Binding buttontextcolor}" Shell.TabBarUnselectedColor="LightGray" Shell.TabBarBackgroundCol

How to filter Keycloak users by custom attribute date range for an automated email reminder?

28 February 2026 @ 3:29 pm

Problem: I need to implement a scheduler that sends an email verification reminder to Keycloak users 30 days after their initial registration (if they haven't verified their email yet). My Requirements: Identify users where email_verified is false. Filter these users based on a custom attribute email-sent-date Re-trigger the verification email using the Keycloak Admin API. The Dilemma: I looked into the Keycloak Admin REST API and found the q parameter for searching custom attributes. However, it seems the API only supports exact matches (e.g., q=last-sent:2024-01-01) and does not support date range or inequality filters (e.g.,

Next.js caching with LinkedIn API - images BATCH-GET

28 February 2026 @ 2:55 pm

In my Next.js 15 website I added a LinkedIn feed viewer. As per my understanding, linkedin has posts FINDER to retrive all posts, but its response is not ideal for rendering as the posts image are returned in a form of urn:li:image:XXXXX instead of the usable image link https://media.licdn.com/dms/image/v2/XXXXX). To achieve my goal I planned to call the posts FINDER and then retrieve all images ID to then call the images BATCH-GET API. In my code, I menaged to achieve the posts and image retrieving, but I get some problems with caching. I can call posts FINDER 100 times in 24h but images get only 2 in 24h. I was planning to use caching to avoid calling the API too many times. With my solution I still call the API more then 300 times a day if a hit fails, and the API stops working after some time. I don't have much error handling in my code. What is the best solution

CarPlay CPListImageRowItem causes Inverted Scrolling and Side Button malfunction

28 February 2026 @ 2:27 pm

In my CarPlaySceneDelegate.swift, I have two tabs: The first tab uses a CPListImageRowItem with a CPListImageRowItemRowElement. The scroll direction is inverted, and the side button does not function correctly. The second tab uses multiple CPListItem objects. There are no issues: scrolling works in the correct direction, and the side button behaves as expected. Steps To Reproduce Launch the app. Connect to CarPlay. In the first tab, scroll up and down, then use the side button to navigate. In the second tab, scroll up and down, then use the side button to navigate. As observed, the scrolling behavior is different between the two tabs. Code Example: import CarPlay import UIKit class CarPlaySceneDelegate: UIResponder, CPTemplateApplicationSceneDele

Crazy attempt: I want to crack the system of Casio electronic dictionary (reverse engineering) and turn it into a real "computer"

28 February 2026 @ 2:21 pm

https://github.com/ZKK640/Casio-System-files-/tree/main Crazy attempt: I want to crack the system of Casio electronic dictionary (reverse engineering) and turn it into a real "computer".I have extracted the system file (BIN) from the dictionary and used Ghidra to reverse compile it into C language, but I still don't know how to modify it.

Type of the array extension in C++

28 February 2026 @ 2:10 pm

As far as I know, the type of N in T[N] is std::size_t. I'm using C++17, in case it matters. template<class T, T N> void check(char const (&)[N]) { std::cout << std::is_same_v<std::size_t, T> << '\n'; } int main() { char c[5]; check(c); return 0; } This prints 1. However, this fails to compile: template<std::size_t N> void check(char const (&)[N]) { std::cout << "std::size_t"; } template<int N> void check(char const (&)[N]) { std::cout << "int"; } int main() { char c[5]; check(c); return 0; } <source>: In function 'int main()': <source>:17:12: error: call of overloaded 'check(char [5])' is ambiguous check(c); ^ <source>:9:6: note: candidate: 'void check(const char (&)[N]) [with long unsigned int N = 5]' void check(char const (&a