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.
Search
Sometimes code needs to assign (or otherwise use) a value that depends on some condition. The naive approach is to use explicit branching, which in Python would look like: if some_condition(): ...
Is this for purely technical reasons as there would have to be at least 2 Semigroup instances (for addition and multiplication), but type classes cannot be implemented multiple times for the same...
r~~'s answer is good, and I absolutely agree that the condition provided in the question is ridiculous and I've never seen anyone suggest it as a generic replacement for if(var). But I think the ac...
Recently I had to push a new Docker image to our GitLab registry. I have the Maintainer role on that project. I had created a new token and used it to log in to Docker. However, when trying ...
The library module itertools provides a function called dropwhile(). The example they give is: dropwhile(lambda x: x<5, [1,4,6,3,8]) → 6 3 8 So, to get a list of numbers greater than 4, d...
Is there some sane way to allow Python to import from subfolders in projects that don't have a package? I have many Python programs that I implemented as Python files inside a directory, without a...
There are many reasons why this error may occur. In my case, my new token had the read_registry scope but not the write_registry scope. I created a new token that had the read_registry and write_...
The first line of a file is head -1. But you probably also want the file name. So something like: for file in glob do first_line="$(head -1 "$file")" printf "%s: %s\n" "$file" "$first_l...
Context Our team is developing a solution mainly composed of several microservices relying on ASP.NET Core. We have decided that the simplest and most cost-effective solution would be for service...
The existing answer is fine, but you can achieve similar results in many ways using some of TypeScript's utility types. Required<T> While you cannot use (only) Partial to do this, TypeScrip...
Understanding distutils and setuptools: the history The short version of "why does installing Setuptools fix the problem?" is that Setuptools provides its own distutils package, overriding anythin...
There's nothing as elegant as if constexpr, unfortunately. However, it is possible to achieve the practical effects (member functions and data only present conditionally). Start by creating a clas...
#ifdef sections can, of course, be used to include or exclude chunks of code based on some criteria known at compile time. One big problem is that when the condition is evaluated to false, the chun...
A handful of standard library modules either have been, or will soon be, removed from the Python standard library, as part of a general cleanup effort. These modules are seen as out of date and no ...
I have Box drive on Windows. I use it as a regular folder on the computer. I can store images there. When I store a small number of images (on the order of a couple hundreds) and I do not wait lon...
There's not always a Spark cluster on hand to test Spark code. Is there some simple program that you can install locally, which has the same behavior as Spark (can run normal Spark scripts) withou...
include_directories works on all targets in the current CMakeLists.txt file, whereas target_include_directories only adds them for the specified target. include_directories is fine to use for simp...
Although they sound similar, they serve different purposes. You are correct in thinking that putting uiMode into your android:configChanges allows your app to handle light/dark mode changes. It al...
It depends on what you are distributing. There are two types of distributions: Binary (application is already compiled) Source (users download raw source code and compile themselves) Becaus...
"Scope" is too broad in that it has other definitions that would cause confusion. For example, "scope" often refers to when a variable in a computer program is accessible to the code at a particul...
To have a successful "training session", these should cooperate. I.e. model generates an output from the input data, the loss function says, how bad or good is it, and then the optimizer tunes...
Casting the shaded class to its original is not possible, even though they are exactly similar. One will hit classCastExceptions while doing so The simplest and easiest way is to serialize the sha...
It seems matching lines starting with "test", but not the ones ending with it (or containining it somewhere). Yes, re.match matches lines that start with the described pattern: If zero or m...
The microservices I am working on use multiple PostgreSQL databases on the same instance. Some of them require some cron jobs. I have decided to use the pg_cron PostgreSQL extension, but when tryin...
gh repo create doesn't have a flag to set GitHub Pages with GitHub Actions. Is there a way to do so, or am I have to visit the setting page to set it manually?