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
In git you can put your current changes aside for a moment with git stash. This is really neat but what often ends up happening is that you forget what was in there, and what was the state of the b...
Let's say I have a client/server application with a data structure on the server side: type User = { name: string; superSecretGovernmentIdNumber: string; }; These fields are both non-nul...
This sounds to me like someone had a problem once and they've decided upon a somewhat silly way to keep that from ever happening again. The big repository hosts have a different way of addressing ...
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 ...
C prohibits accessing an array out of bounds even if measures were taken to ensure that what should lie outside those bounds were known: struct MyStruct { int x[2]; int y, z; }; static...
Global variables make the code hard to reason about This is especially visible when debugging. Say you have a function which errors. The stacktrace tells you where the function got it's arguments,...
Not only does the C language not guarantee it, it also will fail on actual compilers, as soon as you enable optimisation (which you'll generally want to do because you want your code run fast, afte...
The simple explanation would be that you simply don't have write access to the path, which is one possibility. Another weird phenomenon that may happen is that you are running a very old C...
You're matching the regex pattern of /-/, so it just matches every individual hyphen, regardless of where. You want to match the entire entry if it's only hyphens, or /^-+$/. ^ – Beginning of line...
I was playing around with mapped tuples and came across an interesting case where TypeScript cannot infer the types used: interface Foo<A, B> { (a: A, b: B): any } function test<...
The awk gsub function takes as its first argument a regular expression indicating the substring to be replaced, and replaces a matching substring with the value of the second argument, which is the...
When using the Array.prototype.sort method, we can pass a compare function as argument. Then, this function can be used to process array's elements, so the comparison is made using some custom crit...
Yes, it is guaranteed to evaluate to true. All variables with static storage duration are set to zero in case of arithmetic types or set to null in case they are pointers. The relevant part is C17 ...
TL;DR You should use int *p = malloc(n * sizeof *p); for two reasons The cast (int*) is not necessary, which means it's clutter. Using sizeof *p instead of sizeof(int) removes code duplica...
Consider this code: #include <stdio.h> int main(void) { static void *ptr; if(ptr == NULL) puts("It's NULL!"); } I wonder if this is guaranteed to print "It's NULL!" I know ...
To do that, you could change the selector from body to *, as the other answer said. By selecting only body, it won't change child elements that has defined a more specific rule, and that's why you ...
There is an external program I'm calling from within my C/C++ program, by using fork() and execl(), and redirecting the stdio with dup2() to be able to read the output from the external program. I...
In my opinion, all of the downsides boil down to two objections: It isn't idiomatic (in C# and VB.NET) It's slightly less performant The fact that it isn't idiomatic means that, as you note...
Before we start, I'd like to be a little bit pedantic regarding 00002451018 being a number. When we talk about numeric types/values, the zeroes at the beginning are irrelevant: 2, 02 and 000002 al...
I have recently stumbled across the Maybe (or Optional) modal usage in .NET Code: example code or this one example article Based on everything I read, there are multiple advantages on relyi...
From the Git docs "reset" copies the old head to .git/ORIG_HEAD To restore that commit, you can run $ git reset ORIG_HEAD If you want to restore more than one reset, then you'll have to l...
Let's consider the following code: const char a[][4] = {"aa", "aaa"}; const char *b[] = {"bb", "bbb"}; const char *const c[] = {"cc", "ccc"}; For shared libraries, both b and c arrays require...
Context This Q&A from SO suggests that throwing exceptions is incredibly expensive when compared to returning values (return codes): that with return codes instead of exceptions the same pr...
Ignoring the numerous forms of undefined behavior that casting away const might invoke, the blunt but simple and standard solution is just to cast to (void*). char* foo (const char* str) { r...
Hello. Total noob here and noob to this site. I've written a non-trivial program in Python. Code review didn't take the whole thing (400+ lines of code). Should I post a link to my Github repo ...