Welcome to Software Development on Codidact!
Will you help us build our independent community of developers helping developers? We're small and trying to grow. We welcome questions about all aspects of software development, from design to code to QA and more. Got questions? Got answers? Got code you'd like someone to review? Please join us.
General Q&A about programming, scripting, software design & architecture, process, tools, testing, and more.
Filters (None)
Suppose I have some code in a file myscript.py like: def my_function(): print("Test") What steps do I need to take in order to make my_function run? That is to say: how do I get Python to ...
I just noticed that ISO 9899:2024 6.7.4 has this weird text added, which wasn't there previously: The intended use of the restrict qualifier (like the register storage class) is to promote optim...
I'm creating a flatpak-builder manifest wherein I want to do some "pre-processing" steps of the source code in a given module before the build system is invoked. In particular, I want to "merge" th...
As a loose follow-up to Why force designation of a remote main branch?, is there a Git-native way to configure a branch for GitHub's so-called "triangular" workflow? The triangular workflow is mea...
In embedded systems, dynamic memory allocation is discouraged (or forbidden) due to various reasons. A better idea is to statically allocate a chunk of memory whose size is known at compile time -...
I have written a generic device driver for a uart peripheral with a source file usart.c and a header file usart.h. I don't want a user of these files have to tamper with them. I want to use the us...
I run a site with a small annuity loan calculator written in plain JavaScript. It shows two numbers: the monthly payment, and the total interest paid over the term. The payment comes from the stan...
To manage libmagic's magic_t aka magic_set* cookie with a unique_ptr and a custom deleter in a RAII wrapper, I have: struct MagicDeleter { // magic_t is already a pointer (magic_set*) ...
I've read in a guide that "the use of indeterminate memory for anything, including apparently harmless comparison or arithmetic, can have undefined behavior if the value can be a trap representatio...
I have the following code in my project typedef enum { RELAY_CHANNEL_PIN_5, RELAY_CHANNEL_PIN_6, RELAY_CHANNEL_PIN_7, RELAY_CHANNEL_PIN_8, RELAY_CHANNELS_N } relay_channel_pin_t; ...
Note: This is a general question about Markdown formatting for any Markdown renderer (e.g., Gitlab, Github, Codidact). So this is not just a question about Codidact's renderer. When displaying she...
I’d like to call an external executable from a Python script. If it exits with a nonzero code, I’d like an exception containing the return code and the stderr output. The exception will be caught...
In older C and C++ standards, the auto keyword simply meant automatic storage duration. As in the compiler automatically handles where the variable is stored, typically on the stack or in a registe...
How can I compress each column of a dataframe to the output of a function (i.e., mean), preserving columns? MWE import pandas as pd data = {"A": [1, 2, 3, 4], "B": [5, 6, 7, 8]} df = pd.Data...
How do I generate a table in its own figure from a pandas dataframe? I can generate a bar plot with a table below it, like so: import pandas as pd import numpy as np import matplotlib.pyplot as...
I have multiple installations of Python on my machine. When I run Python, what determines which installation is used? How can I control this?
I'm working on an app for Linux phone operating systems like postmarketOS and publishing it as a Flatpak on Flathub. What steps do I need to take to make it appear as a "mobile friendly" app in the...
I've turned the tables movies and scenes into media and now I don't know what to do with the movies_scenes relation. CREATE TABLE IF NOT EXISTS "movies_scenes" ( `movie_id` integer, `sce...
I've just learned about algorithms, ranges and views (from a book), including execution policy such as std::execution::par and I naively tried: import std; int main() { auto values {std::r...
For example, say I have this CSS: .ocean {} .land {} .sky {} I want to give each of them a background-color, so I use multi-cursors and type: .ocean { background-color: } .land { background...
Many languages discourage global variables. Why is this?
I have an 8-bit microcontroller with 100 pins. Each pin belongs to a port with a unique address and each pin has a number from 0 to 7. I want to create a scheme where in the code each pin is a stru...
Here is the reasoning: Compiler error is syntax error Language server can catch all syntax error Therefore, all compiler errors can be caught by language server I have the feeling that this...
I am implementing a state machine for an electrical relay control board and am trying to follow the principles/structure presented by Lundin here for doing that in C. My machine has currently four...
I am at a complete dead end with Rails sessions. I have an old Rails project. It started with Rails 3 or 4, and it is now running on Rails 6.1.7.10, the code has been updated carefully. I use sess...
I am contemplating on purchasing a personal copy of the MISRA C guideline document. Looking at their website shows several different versions - MISRA C:2025, MISRA C:2012 3rd ed., MISRA C:2004, etc...
I tried installing package-installation-test[1] using Pip, and it appeared to be successful. But I can't use it as advertised, either by itself or by importing it from my code: Failed attempts ...
The question is about libraries that extend the data type system to ensure physically realistic computations. Think std::chrono but for distance and mass and other things as well as for time. Inste...
I've seen some regular expressions (regex) using \s when they want to match a space, but I noticed that it also matches line breaks. Example: the regex [a-z]\s[0-9] (lowercase ASCII letter, follow...
I heard strncpy(3) is bad, and also heard that C23 added memccpy(3) to replace it. However, I also heard memccpy(3) is even more terrible than strncpy(3). Are these functions really bad? How so?...
I'm using SimpleDateFormat to parse a string containing a date/time, but the result has a different date, hour, minute, second and millisecond: SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM...
When reading questions about C programming from beginners, I very often see them describing peculiar run-time errors and crashes, segmentation faults and similar. They have spent a lot of time chas...
The solution to this is probably easy, but I haven't been able to find it. Using SymPy, I am trying to solve this equation: $$ {x_1}^2 + {x_2}^2 + {x_3}^2 + 3 = a $$ with this constraint: $$ ...
This was inspired by the SO question Can you ever assume typecasting pointers is safe? I started to write an answer there, but I realized I'd rather post it here instead, so here's a self-answered ...
I'm building an automated content pipeline that publishes daily video briefings from a headless Arch Linux server. The pipeline already works for other platforms (Bluesky, Mastodon, PieFed, Telegra...
I'm creating a Chrome Dino-style game inside a PDF using JavaScript form fields . The ground is implemented using two adjacent button widgets that should continuously scroll left to create an infin...
My organisation uses Moodle as their online e-learning system on which teachers share resources, and oftentimes numerous documents that we need to view/download are posted there. The default way of...
I'm automating posts to PieFed and I can't get tags/labels to actually show up on the created post. What I'm doing I'm POSTing to create a post with a body that includes hash-style tags, somethin...
Currently I am using One Click Page to PDF to get the job done, although the lack of working open-source tools fit for this task has led me to creating my own; the web page "that won't print" is th...
In eclipse (java) Window->Preferences->Java->New new templates can be created. In the field "Pattern" I entered System.out.println("DEBUG ${label}"); ${cursor} I like old-style debug...
en.wikipedia.org/w/index.php?title=List_of_URI_schemes states that: Many URI schemes are registered with the IANA; however, there exist many unofficial URI schemes as well. Everyone knows how...
When searching the Internet, I came across this SO post Rounding in C Preprocessor but immediately noted that none of the answers are showing a way to perform actual rounding - rather, they are doi...
There are SaaS providers for building and hosting websites made with WYSIWYG and LLM-prompt website builders, such as WordPress.com, Webflow, etc. I guess these services should be secure-by-default...
I occasionally hear the split between framework and metaframework, and then the split between client-side framework and server-side framework. Are they just the same? Sources use "metaframework": ...
I'm trying to build a proper understanding of what an OLAP[1] datastore vs an OLAP data engine is. I tend to put too much value on keywords like "engine" vs "data store." If it has "engine," I thin...
In the current version of OpenJDK's JEP 401: Value Classes and Objects (Preview), it is said that value classes can leak data stored in their fields, and that this is potentially a security concern...
How to verify if a year is leap? Given a numeric value (such as 2023) or some object that represents a date (such as Date, Calendar, LocalDate, etc), how can I do it?
I have an old Ruby on Rails project currently running on Rails 6.1. It isn't very large. I have got the old asset pipeline, 2.7 MB of Javascript in a node_modules folder and 3.7 MB of files in the ...
What is wrong in the following code: package oren; import java.util.Scanner; import javax.swing.JOptionPane; public class Main { public static void main(String[] args) { double x,y,z...
I've gained responsibility for some services at work that run on Node.js. I am wondering if anyone could recommend a book on Node. The website documentation is pretty good but I like the structure ...
