Communities

Writing
Writing
Codidact Meta
Codidact Meta
The Great Outdoors
The Great Outdoors
Photography & Video
Photography & Video
Scientific Speculation
Scientific Speculation
Cooking
Cooking
Electrical Engineering
Electrical Engineering
Judaism
Judaism
Languages & Linguistics
Languages & Linguistics
Software Development
Software Development
Mathematics
Mathematics
Christianity
Christianity
Code Golf
Code Golf
Music
Music
Physics
Physics
Linux Systems
Linux Systems
Power Users
Power Users
Tabletop RPGs
Tabletop RPGs
Community Proposals
Community Proposals
tag:snake search within a tag
answers:0 unanswered questions
user:xxxx search by author id
score:0.5 posts with 0.5+ score
"snake oil" exact phrase
votes:4 posts with 4+ votes
created:<1w created < 1 week ago
post_type:xxxx type of post
Search help
Notifications
Mark all as read See all your notifications »

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.

Activity for celtschk‭

Type On... Excerpt Status Date
Comment Post #287289 First, immediate feedback: `README.md` is missing.
(more)
over 1 year ago
Comment Post #287122 It solves the same problem that any strong typing system solves: Catching errors.
(more)
over 1 year ago
Comment Post #286940 The first vector isn't shown completely in your screenshot. So it cannot show what it is intended to show according to the text. You should have copy-pasted the output instead of posting a meaningless (and data wasting) screenshot. Even better, post the actual length of the vectors instead of...
(more)
over 1 year ago
Edit Post #286865 Initial revision over 1 year ago
Answer A: How to manage user-specific application data on Linux?
Just as an additional information: If you are writing Python code, there's the useful package `appdirs` that provides a platform-agnostic interface to user-specific application data directories. For Linux, it implements the XDG specification.
(more)
over 1 year ago
Comment Post #286685 Well, as I had mentioned in the Github thread, starting a new thread is what I had expected to happen, so that would be a point for option 2. Obviously someone who understands the code will have to say what is practical to do.
(more)
over 1 year ago
Comment Post #286773 You're welcome.
(more)
over 1 year ago
Edit Post #286773 Initial revision over 1 year ago
Answer A: How to use grep to print only specific word from a string
While I agree with Dirk Herrmann that `basename` is the right tool for the job, I think it is still worthwhile to know how to do it with `grep`, because you might one day encounter a sufficiently similar situation that is not covered by a specialised tool. The question can be broken into two quest...
(more)
over 1 year ago
Comment Post #286727 It is a slash, followed by an asterisk. From the man page: > The slash / is used as the directory separator. Separators may occur at the beginning, middle or end of the .gitignore search pattern. And: > If there is a separator at the beginning or middle (or both) of the pattern, then the pat...
(more)
over 1 year ago
Comment Post #286588 In principle, there's also the option to write a command line tool accepting sendmail-compatible options which does the signing before passing it on to whatever you use for sending mail, and instruct git to use that as sendmail executable. Maybe there already exists such an executable somewhere.
(more)
almost 2 years ago
Comment Post #286575 Sorry, I misread. But then, `r->s` is *not* `const char*`. It is `char* const`. And while it does have a top-level const, that doesn't matter because you are just returning the value anyway. Indeed, your code compiles just fine. And it does so even if you remove `discard_const` completely, changin...
(more)
almost 2 years ago
Comment Post #286575 Note that `const struct t*` is *not* a const type, but a *non-const* pointer to a const type. Therefore there's no top-level `const` to discard. You can easily see the non-constness by adding the statement `r = 0;` to the function. If `r` were of a const type, that wouldn't compile.
(more)
almost 2 years ago
Comment Post #286552 Thank you for your answer; while the other answer gave me the understanding I needed to do it, the information in your answer made actually correcting my mistake far more easy than it would have been otherwise.
(more)
almost 2 years ago
Comment Post #286551 Thank you for the very helpful and informative explanation.
(more)
almost 2 years ago
Edit Post #286550 Initial revision almost 2 years ago
Question Is it possible to undo a git reset?
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 HEAD1 So far, so good. However, by mistake I issued the command a second time, thus deleting also an earlier commit. It also turned out that I had forgotten to ...
(more)
almost 2 years ago
Comment Post #286529 Thank you for your feedback. You've got a few good points. I didn't actually think of double-registering observers, and I don't think in my actual use the order would matter. I would have expected bound member functions not to be allowed in a set (because, after all, you can change the object afterwa...
(more)
almost 2 years ago
Comment Post #286530 Thank you for your feedback. However I don't see how you get from the term "actions" to "imperative commands". "Actions" here are actions *on* the state machine, not actions *of* the state machine. "Event" may be a better name here, but then, in the code I plan to use it, the term is already used for...
(more)
almost 2 years ago
Comment Post #286511 The goal is to use it for my game, but not as game AI, but to manage different phases. I started out with just values for the current state, which originally were only used to report a result (was the level won, lost, saved or quit, was the menu quit or terminates, etc.), then moved on to also encode...
(more)
almost 2 years ago
Edit Post #286511 Initial revision almost 2 years ago
Question A state machine in Python
I've written the following code implementing a state machine in Python, and I'd like some feedback on it. The basic idea is that each state has a set of corresponding actions that trigger a state change. You can register observer functions with states, which are then called whenever the state is e...
(more)
almost 2 years ago
Comment Post #286440 As far as I can tell, you fork exactly one child process, and the function you call for the child process only calculates and outputs the area exactly once. After return from that function, you exit the child process. No matter what the parent process does, I see absolutely no way to get more than on...
(more)
almost 2 years ago
Comment Post #286433 @#53196 Thank you.
(more)
almost 2 years ago
Edit Post #286433 Initial revision almost 2 years ago
Question Reaction comment doesn't appear if previous comment for retracted reaction was deleted
On this answer I just reacted with “works for me” with comment, but then retracted it because of what finally turned out to be a mistake on my end, and deleted also the comment (and thus the comment thread). After figuring out my mistake, I gave again the “works for me” reaction with comment, but thi...
(more)
almost 2 years ago
Edit Post #286429 Initial revision almost 2 years ago
Question Is it possible to write protocols for enumerations in Python?
Having recently learned about protocols in Python, I now wonder if you can write a protocol for enumerations. That is, a protocol that says that you are supposed to pass an enum that has certain items with certain values, but doesn't specify a specific enum. To explain how I mean it, here's some n...
(more)
almost 2 years ago
Edit Post #285813 Initial revision about 2 years ago
Answer A: Are there references in C?
C does have references, but it does not have pass by reference. A reference is simply an expression that references an object (object here is meant in the general sense, not in the OO sense; for example, a variable is an object). In C, references are implemented using pointers. However C does n...
(more)
about 2 years ago
Comment Post #285801 A workaround could be to start your python script with a custom shell script, e.g. ``` #!/bin/bash source ~/.env exec python3 yourprogram.py "$@" ```
(more)
about 2 years ago
Comment Post #285801 Note that with `getenv` you need to use parentheses `()` instead of square brackets `[]`. Doing so should solve the TypeError.
(more)
about 2 years ago
Comment Post #285580 @#53629 A program consists of several translation units. As far as the C standard is concerned, a program consists of nothing but translation units written in C and the standard library supplied by the implementation. It doesn't say there needs to be a separate linking step; a compiler that required ...
(more)
about 2 years ago
Edit Post #285580 Initial revision about 2 years ago
Answer A: C Language Standard Linking Specifications
The standard does not talk about object files and/or linking, but it does talk about translation units. In typical compilers, a single translation unit translates into a single object file. Obviously the C standard does not talk about translation units that are not themselves C; that's what a plat...
(more)
about 2 years ago
Comment Post #285566 Actually given that vim is an editor, I doubt it is possible at all. To allow this, the developers would have to define what it means to edit a file while you're still reading it, and that seems to me something that isn't worth the effort. However there is a tool called [less.vim](https://github.c...
(more)
about 2 years ago
Comment Post #285351 @#8176 The alignment requirement just tells you where the allocated memory has to start, the end of the allocation does not need to be aligned. The implementation would be allowed to use the very next byte after the allocation for its own purposes, independent of its alignment. Or if the platform all...
(more)
over 2 years ago
Edit Post #285351 Initial revision over 2 years ago
Answer A: What is malloc's standard-defined behavior with respect to the amount of memory it allocates?
Since accessing the memory allocated by `malloc` beyond the size given to the call is undefined behaviour (which means that the standard poses no restriction to the behaviour of a program that does this), and since there's no standard way to determine the length of the allocated block, malloc is inde...
(more)
over 2 years ago
Comment Post #285243 You don't even need memory-mapped registers to get such effects. Even on a conventional stack layout, an out of bounds access might go to the stored address of the parent stack frame, or to the return address. Changing the first one may cause the stack pointer being changed to a wrong value later(!),...
(more)
over 2 years ago
Edit Post #285240 Initial revision over 2 years ago
Answer A: Behavior of Pointer Arithmetic on the Stack
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, after all). Try it online! – Try It Online")
(more)
over 2 years ago
Edit Post #285137 Initial revision over 2 years ago
Answer A: Why does fopen return NULL?
Besides the possible issues that Lundin told you, there is also the possibility that the current directory of the program is not what you think it is (note that the current directory is not necessarily the directory the executable is in, nor is it necessarily your user directory). This problem is unl...
(more)
over 2 years ago
Edit Post #285102 Initial revision over 2 years ago
Answer A: Invalid memory access when trying to dereference a pointer obtained through a function call
Your function returns a pointer to a local non-static variable. Such a variable exists only during execution of the function and is removed on return. This means you are left with a so-called dangling pointer, a pointer that points to a no longer valid address. Note that using such a pointer is un...
(more)
over 2 years ago
Comment Post #284552 Obvious to a reasonable person with the knowledge level of the OP.
(more)
over 2 years ago
Comment Post #284552 On the other hand, if it isn't obvious what the OP should have searched, then IMHO the downvote is not justified.
(more)
over 2 years ago
Comment Post #277341 Another point: Compilers are also allowed to give diagnostics on correct programs, as long as they generate working code otherwise. A compiler that always outputs the diagnostic “This program might contain errors” is completely conforming as long as it correctly compiles correct code. In other wor...
(more)
over 2 years ago
Comment Post #284510 Well, the extra information you added spells out the crucial bit (closing of file handles that weren't closed before; thanks to that now I have an idea what went wrong before), therefore have my +1. Links are not that relevant (except when not using them would violate a license or result in plagia...
(more)
over 2 years ago