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
I have seen this construct quite a lot: int *p = (int*) malloc(n * sizeof(int)); Is this how it should be? What is the proper way to use malloc? I have also seen this: int *p = malloc(n * size...
As a (for now at least) casual user, I can report that a bad first impression is that there are way too many "500 server errors". Within a few tens of minutes I ran into two, one for some profile ...
You can use the pathlib standard module with __file__ to make things simple. from pathlib import Path scriptFolder = Path(__file__).parent with open(scriptFolder / 'data.txt') as file: dat...
For some reason, I just wanted to undo a commit on my git repository, which I've done with the following command: git reset --soft HEAD~1 So far, so good. However, by mistake I issued the comma...
Using Vim, I am trying to search for all instances of a specific string, except for those that fall somewhere in between two other specific strings. For example, I want to determine all instances ...
If you've committed, then the commit is in the git repo regardless. All git reset does is change what commit the HEAD references. If you find the hash corresponding to the commit you'd like HEAD to...
tl;dr I'd like to learn a compact, cross-compiler way of selectively suppressing compiler warnings. Consider the case where you really mean to make an exact floating-point comparison using ==, o...
I was fooling around with the following C code on my trusty old x86 PC: #include <stdint.h> #include <stdio.h> int main (void) { uint32_t u32 = 0xAABBCCDD; uint8_t* ptr = (u...
Python doesn't support extending the mechanics of how f-strings are parsed; the reference doesn't give the specific mechanism, but it doesn't say that there's any connection between the parsing of ...
tl;dr Although it can be done with regex (and work for "most" cases), I still prefer to use a parser. Long answer I'd use something such as DOMParser to do the job: let validTags = ['p', 'span', 'b...
When posting a lot of code on the site, the "code format window" is much too small: 1 I'm talking about this thing 2 3 4 5 6 7 8 9 10 11 12 13 14 15 The scroll bar appears after...
As discussed on Meta, should Software.codidact allow reviewing working code as a question? Traffic is probably not high enough to warrant it's own Codereview community. The existing communities out...
These examples have undefined behavior and unspecified behavior all at once! Operator precedence has nothing to do with the order of execution, see What is the difference between operator precedenc...
Is it correct to destroy a mutex which is referenced but not owned by an unique_lock as in this code? { std::unique_ptr<std::mutex> mutex = std::make_unique<std::mutex>(); std::u...
Yes, the second line invokes undefined behavior. First of all, according to C17 6.5.2.1 regarding array subscripting, an expression E1[E2] is just "syntactic sugar" for *((E1)+(E2))). So what appli...
It's meant to include all programming and scripting. By calling it Software Development we wanted to convey that it's not just code but also those other things. I'll adjust the description of the...
I don't have a py command on my system; for purposes of this answer I assume it's an alias to the python executable. Running a script from a file is not quite the same as importing it. A script giv...
There is one thing to clarify when mapping a float interval to an integer interval, namely how the boundaries of the float interval shall be mapped to the boundaries of the integer interval. Takin...
It would be much better split into separate questions. Users have to scroll, ctrl-f search, or wade through a lot of info that irrelevant to their problem to get to the section that helps them. ...
I am developing an application that targets Linux-based OS, and I need to store the user's configuration, metadata and other things in a persistent way (i.e. on the file system). I know that one c...
What's going on is that the compiler is deciding on what function to call at compile time rather than runtime. Since the type of vh is Vehicle *, it is essentially creating this call: vh->Vehic...
While any piece of software receiving input from an untrusted source is additional attack surface, generally speaking git pull is not a security threat. Three things happen when you git pull: a gi...
In C++11 the nullptr keyword was added as a more type safe null pointer constant, since the previous common definition of NULL as 0 has some problems. Why did the standards committee choose not to...
There are two major sections to this answer: the Git part and the conflict resolution part. It wasn't clear at first which one was intended by the question, but both are important for a full answer...
Suppose you have a largish git repository with many files of different types (both text and images) distributed among a number of nested directories. Parallel development has occurred on two branc...