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.

Assign a variable inside configure.ac

28 May 2026 @ 9:41 pm

I'm writing a cross-platform software in C++ and on *nix I rely on running configure and make. I was working with the IDE called Anjuta which created everything for me. Many packages can be installed in different places and there are multiple ways of identifying that place. When I needed to link to an external library I tried to identify where that external dependency is installed. Checking the docmentation and asking question in the ML I identified that the library in question when installed also installs the program odbc_config. OK, good. So then I used the output of odbc_config --cflags and odbc_config --libs inside Makefile.am. And for a while it was good. After sometime I tried to install different distro and unfortunately it fail. From researching, I was told to use pkg-config. OK, fine. So after reading the docs I wrote following code inside configure.ac : AC

Icon guidelines for Dynamic App Shortcuts in Android

28 May 2026 @ 9:12 pm

I can't seem to get my head around how to design the icons for my app shortcuts that I handle dynamically at runtime. When reviewing most of Google apps, I can't see consistency in the designs: some shortcuts come with a custom background some shortcuts have colored icons some shortcuts have very small icons And what's worse, is that depending on the Android version, the OEM and possibly the launcher, the visual rendering may differ! During my research, I stumbled upon this document https://commondatastorage.googleapis.com/androiddevelopers/shareables/design/app-shortcuts-design-guidelines.pdf that seems legit and clear enough. Basically it stipulates: size : 48x48dp gray centered circle of 44x44dp cen

Return Json in a web api application [closed]

28 May 2026 @ 8:50 pm

.Net core. Have a web api project returning a object including a list. From Postman's running result, the list does not return. Here is my code: [HttpGet] public IActionResult GetNested() { var rv = new RuleViewDTO { Id = 3, Pth = "", Ttl = "ere", Lvl = 1, Sev = "", ErrMsg = "", Formulas = {new ViewParam //this list is missing from Postman { RId = 3, Opd = "", Opr = "", Idx =1, RRId = 2 } } }; var aq = new JsonResult(rv); // return Ok(rv); return aq; } Any help welcomed!

HtmlAgilityPack HtmlWeb exception

28 May 2026 @ 4:07 pm

I have a Visual Studio ASP.NET website and a Maui app (previously an Xamarin app until I upgraded it 2 years ago), each with code like this: HtmlAgilityPack.HtmlWeb htmlapWeb = new HtmlAgilityPack.HtmlWeb(); HtmlAgilityPack.HtmlDocument htmlDocHP; htmlDocHP = htmlapWeb.Load("http://www.wordreference.com"); string sOuterHTML = htmlDocHP.DocumentNode.OuterHtml; This has been working fine for 6-7 years. A few days ago the attempt to access htmlDocHP.DocumentNode.OuterHtml started throwing an exception. If I debug and look in htmlDocHP.DocumentNode, I see that ID, InnerHtml, InnerLength, OuterHtml and OuterLength are all throwing exceptions. I put the code into a new simple wizard generated console app and the same thing happens. Interestingly, if I debug the Maui app on either an Ios simulator or a physic

How should modules be conditionally imported based on output of a later-defined function?

28 May 2026 @ 4:29 am

I need to emulate the auto-detection functionality for os.path (ntpath vs posixpath) but with support for the file being run within an MSYS2 environment (if running the Python release specific to any environment other than msys like ucrt64, all standard libraries detect the environment as Windows-based). I have a function to detect the family of the environment that the program is running in. However, running the following code will result in a NameError as get_osfamily() has not been defined as of its calling: import os osfamily = get_osfamily() if (osfamily == "unix"): import posixpath as osp # os.path == osp elif (osfamily == "windows"): import ntpath as osp def get_osfamily() -> str: """Return either 'unix' or 'windows' depending on platform.""" if (os.name == "posix"

Why does my Java while loop keep repeating even after entering the correct value?

27 May 2026 @ 9:25 pm

I'm learning Java and practicing loops and user input with Scanner. I created a simple program that asks the user to enter a password. The loop should stop when the correct password is entered, but sometimes it keeps repeating unexpectedly. Here is my code: import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner input = new Scanner(System.in); String password = "java123"; String userInput = ""; while (!userInput.equals(password)) { System.out.println("Enter password:"); userInput = input.nextLine(); System.out.println("Incorrect password"); } System.out.println("Access granted"); } } The output looks like this when I enter the correct password: Enter password: java123 Incorrect password Access granted Observed behavior:

Trying to sync mutliple audio tracks to a movie but often gets stuck in buffering

27 May 2026 @ 4:47 pm

I have a one and a half hour movie that is dubbed into several languages, and each dub is 5.1 Dolby which almost has the music, sfx and voice on separate channels, which I have separated as separate files (front, center, back). I had the idea of providing an experience where certain groups of people in the movie would speak their own language and people watching could choose these languages. So that it would be available to anyone I programmed this whole shuffling of audio tracks in Javascript. I know, web is not meant to keep track and synchronize that many lengthy media tracks, but that is pretty much the only cross-platform programming language I am familiar with enough to put this together in. So far I've managed to be fairly successful in playing at least a quarter or a fifth of it before it needs a moment to buffer all the tracks, but if I were to seek to somewhere into the middle or more it seems to get absolutely stuck in buffering. At first I simply ffmp

JavaScript variables sent to PHP via fetch API and XHR POST synchronous methods do not appear in POST variables on server side

24 May 2026 @ 9:22 pm

My goal is to have the user be able to submit data in a form, which can then be processed and modified in PHP and the output could be displayed without refreshing the page. I have found two synchronous POST methods in JavaScript: fetch and XHR. When I type into the form, then press the submission button, there is a response, but the variable does not pass to PHP successfully. I use print_r($_POST); to test if the variable has been passed, and the output is always "Array ( )", meaning there are no POST variables. With the alert() and console.log() functions, I can see the PHP file was successfully contacted, but why aren't the variables showing in PHP under POST? I've tried sending FormData object, JSON strings, normal strings and none of them POST. I know I could pass the variable from PHP to JS using JSON, and change the page in JS, but I'm surprised the string in the php script does not echo to the page after clicking the button. Can anyone explain why?

How can I avoid redundant comparisons when checking rectangle overlaps in C#?

22 May 2026 @ 8:11 pm

I’m currently practicing C# console applications and trying to improve my problem-solving skills as a beginner programmer. I created a small project that reads button data from a CSV file and checks whether any buttons overlap on a form-like coordinate system. Most parts of the program already work correctly, such as file reading, object creation, statistics, minimum area calculation and file writing, but I’m struggling with the overlap detection logic. The program stores buttons with properties like Left, Top, Width and Height, and I’m trying to determine whether two buttons intersect each other. This is my current code: namespace buttons_console { internal class Program { static void Main(string[] args) { List < ButtonData > buttons = ReadData(); Console.WriteLine($"Task 3: The file contains {buttons.Count} buttons."); Console.WriteL

What is the difference between extern inline int foo() and extern int foo()?

22 May 2026 @ 7:31 pm

Looking through this, this, and this, I understand that inline int foo() {} is different from the usual int foo() {}, as it imposes additional syntactic requirements, such as an extern declaration somewhere in the code. I also understand that the difference between static inline int foo() {} and static int foo() {} is that the former is simply more likely to be inlined within its translation unit. What is the difference between extern inline int foo() {} and extern int foo() {}, according to the standard? Does it suggest inlining within the translation unit? Is i