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 Moshi‭

Type On... Excerpt Status Date
Question When would one not want to return an interface?
Consider the following method as an example: ```cs List Foo() { // ... } ``` Are there any disadvantages of returning an interface instead of a concrete implementation in C#? ```cs IList Foo() { // ... } ``` From the caller's perspective, it doesn't really matter what the ...
(more)
almost 2 years ago
Edit Post #287586 Initial revision almost 2 years ago
Answer A: What is the purpose of grouping the tests in a `tests` module and is it possible to split them?
Grouping related items into modules is of course generally good practice, but it serves a practical purpose as well. The important part here is the [`#[cfg(test)]` annotation](https://doc.rust-lang.org/book/ch11-03-test-organization.html#the-tests-module-and-cfgtest). > The `#[cfg(test)]` annotati...
(more)
almost 2 years ago
Comment Post #287136 Does this work? ```zig .{ .{ Inner{.a = '1', .b = true} } ** D2 } ** D1 ``` Seems to work fine, but bear in mind that I don't use zig By the way, I got some compilation errors where I'm not sure what I'm doing wrong: `const Inner = struct { .a: u32, .b: bool };` (`error: expected test, com...
(more)
about 2 years ago
Edit Post #286983 Initial revision over 2 years ago
Answer A: Participate Everywhere ability without meeting the requirements?
Why do we have the "Participate Everywhere" ability when we haven't yet done anything? > Bootstrapping. Our communities are still small, so after we rolled out the abilities system we decided to put all our communities in "new community" mode, which lets everyone start with Participate Everywhere....
(more)
over 2 years ago
Edit Post #286940 Post edited:
Formatting
over 2 years ago
Suggested Edit Post #286940 Suggested edit:
Formatting
(more)
helpful over 2 years ago
Edit Post #286911 Initial revision over 2 years ago
Question Is there any benefit to using new?
I've heard that in modern C++, smart pointers are preferred to raw pointers for ownership (the so-called RAII principle, as I understand it). This makes sense, and since then I've always used them throughout my projects. This makes me realize though, that I can't really remember the last time I've...
(more)
over 2 years ago
Edit Post #286905 Initial revision over 2 years ago
Answer A: Create a list of Niven numbers in Python
Think of what your `for` loop is doing, specifically at iterations 11 and 12. ```python for i in range(1,n+2): while not g(i): i+=1;continue a.append(i) ``` In pseudo instructions: - for-loop iteration 11 - i = 11 - while-loop: - check not g(i) (i = 11, so it's true) ...
(more)
over 2 years ago
Edit Post #286817 Initial revision over 2 years ago
Question What is the Python Global Interpreter Lock?
What exactly is the Python Global Interpreter Lock (GIL)? As someone who is relatively new to Python, is this something I need to be aware of, or is this just some implementation detail of the interpreter which I shouldn't concern myself with?
(more)
over 2 years ago
Comment Post #286727 I've updated my answer with some more information @#56802, i hope that it explains what's happening here.
(more)
over 2 years ago
Edit Post #286727 Post edited:
over 2 years ago
Edit Post #286727 Initial revision over 2 years ago
Answer A: How to configure .gitignore to ignore all files except a certain directory
From the docs >Example to exclude everything except a specific directory `foo/bar` (note the `/` - without the slash, the wildcard would also exclude everything within `foo/bar`): >``` > $ cat .gitignore > # exclude everything except directory foo/bar > / > !/foo > /foo/ > ...
(more)
over 2 years ago
Edit Post #286677 Post edited:
over 2 years ago
Edit Post #286677 Initial revision over 2 years ago
Answer A: What allows a string slice (&str) to outlive its scope?
tl;dr, the lifetime of `"second"` is `static` The heart of your confusion is this: > Since we are taking a long-lived reference r to a string slice inner which is destroyed at the end of its scope, `inner` is gone at the end of its scope, yes. However, its value still lives on. We have to...
(more)
over 2 years ago
Edit Post #286552 Initial revision over 2 years ago
Answer A: Is it possible to undo a git reset?
From the Git docs > "reset" copies the old head to `.git/ORIGHEAD` To restore that commit, you can run ``` $ git reset ORIGHEAD ``` If you want to restore more than one reset, then you'll have to look for the commit id. If you already know it, you can just do ``` $ git reset ``` ...
(more)
over 2 years ago
Comment Post #286433 Created a GitHub issue at https://github.com/codidact/qpixel/issues/795
(more)
over 2 years ago
Edit Post #286395 Initial revision over 2 years ago
Question Why can't a derived class add a const qualifier to a method?
Say we have an abstract class `Foo` declared as so: ```cpp class Foo { public: virtual void test() = 0; }; ``` Let's say that we make a derived concrete class `FooDerived`, and decide to mark it's version of `test` as `const` as it doesn't modify its state. ```cpp class FooDerive...
(more)
over 2 years ago
Edit Post #286386 Post edited:
I misunderstood the cppreference page
over 2 years ago
Edit Post #286386 Post edited:
fixed some small copy-paste errors
over 2 years ago
Edit Post #286386 Initial revision over 2 years ago
Question How should one match a specialized version of a variant?
Let's say I have a variant that can hold a bunch of different types of values (say I got them from parsing a JSON or similar). ```cpp using Value = std::variant; ``` Let's also say that I have another variant that is a strict subset of the first. ```cpp using Numeric = std::variant; ``` ...
(more)
over 2 years ago
Edit Post #286291 Post edited:
over 2 years ago
Edit Post #286291 Initial revision over 2 years ago
Question TypeScript is unable to infer the correct type for a mapped tuple
I was playing around with mapped tuples and came across an interesting case where TypeScript cannot infer the types used: ```typescript interface Foo { (a: A, b: B): any } function test(...args: { [K in keyof Bs]: Foo }) {} let add: Foo = (a, b) => a + b; test(add); ``` ``` erro...
(more)
over 2 years ago
Comment Post #286151 Try going back a directory. I imagine that you have some top-level directory for your entire project, right? You should compile from there.
(more)
over 2 years ago
Comment Post #286151 See https://stackoverflow.com/a/3749272. Are you compiling from the source root directory?
(more)
over 2 years ago
Edit Post #286093 Initial revision almost 3 years ago
Answer A: Why does pushing to one array affect all the arrays in my two-dimensional array?
The problem is that the `fill` function is filling the array with references to the same empty array[^1], and therefore modifying that array will affect every entry because all of them are actually the same entry. To get around this, you need to explicitly create a new array for each index, for in...
(more)
almost 3 years ago
Edit Post #286092 Post edited:
fixed typo
almost 3 years ago
Edit Post #286092 Initial revision almost 3 years ago
Question Why does pushing to one array affect all the arrays in my two-dimensional array?
I was trying to initialize a simple two dimensional array as follows: ```javascript const arrays = Array(3).fill([]); ``` However, when I tried to push an entry into one of the arrays, it seems like it gets pushed to all of them for some reason: ```javascript arrays[0].push('foo'); conso...
(more)
almost 3 years ago
Edit Post #285275 Initial revision about 3 years ago
Answer A: Open file in script's own folder
You can use the `pathlib` standard module with `file` to make things simple. ```python from pathlib import Path scriptFolder = Path(file).parent with open(scriptFolder / 'data.txt') as file: data = file.read() ```
(more)
about 3 years ago
Suggested Edit Post #285217 Suggested edit:
Quotation blocks should be used for quotations
(more)
helpful about 3 years ago
Edit Post #285100 Post edited:
Formatted code block
about 3 years ago
Suggested Edit Post #285100 Suggested edit:
Formatted code block
(more)
helpful about 3 years ago
Edit Post #285087 Initial revision about 3 years ago
Answer A: Hash sign as a path component in a user script's @match command prevents the script from running
The part after the hashtag is called a URI fragment. Unfortunately, Tampermonkey does not allow you to match hashtags. This is arguably for good reason. The hashtag can easily change (and for single page applications, often does easily change) without a page reload. Since userscript managers load ...
(more)
about 3 years ago
Comment Post #285054 @#53177 The change event is not always dispatched when an input field's value it via code, so this is a valid question IMO.
(more)
about 3 years ago
Edit Post #285062 Initial revision about 3 years ago
Answer A: How to fire the change event for an input field?
You can use the `dispatchEvent` method. ```javascript const inputField = document.querySelector("#example"); inputField.value = "X"; inputField.dispatchEvent(new Event('change')); ``` jsfiddle
(more)
about 3 years ago