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
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 1 year ago
Edit Post #286940 Post edited:
Formatting
over 1 year ago
Suggested Edit Post #286940 Suggested edit:
Formatting
(more)
helpful over 1 year ago
Edit Post #286911 Initial revision over 1 year 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 1 year ago
Edit Post #286905 Initial revision over 1 year 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 1 year ago
Edit Post #286817 Initial revision almost 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)
almost 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)
almost 2 years ago
Edit Post #286727 Post edited:
almost 2 years ago
Edit Post #286727 Initial revision almost 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)
almost 2 years ago
Edit Post #286677 Post edited:
almost 2 years ago
Edit Post #286677 Initial revision almost 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)
almost 2 years ago
Edit Post #286552 Initial revision almost 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)
almost 2 years ago
Comment Post #286433 Created a GitHub issue at https://github.com/codidact/qpixel/issues/795
(more)
almost 2 years ago
Edit Post #286395 Initial revision almost 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)
almost 2 years ago
Edit Post #286386 Post edited:
I misunderstood the cppreference page
almost 2 years ago
Edit Post #286386 Post edited:
fixed some small copy-paste errors
almost 2 years ago
Edit Post #286386 Initial revision almost 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)
almost 2 years ago
Edit Post #286291 Post edited:
about 2 years ago
Edit Post #286291 Initial revision about 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)
about 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)
about 2 years ago
Comment Post #286151 See https://stackoverflow.com/a/3749272. Are you compiling from the source root directory?
(more)
about 2 years ago
Edit Post #286093 Initial revision about 2 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)
about 2 years ago
Edit Post #286092 Post edited:
fixed typo
about 2 years ago
Edit Post #286092 Initial revision about 2 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)
about 2 years ago
Edit Post #285275 Initial revision over 2 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)
over 2 years ago
Suggested Edit Post #285217 Suggested edit:
Quotation blocks should be used for quotations
(more)
helpful over 2 years ago
Edit Post #285100 Post edited:
Formatted code block
over 2 years ago
Suggested Edit Post #285100 Suggested edit:
Formatted code block
(more)
helpful over 2 years ago
Edit Post #285087 Initial revision over 2 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)
over 2 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)
over 2 years ago
Edit Post #285062 Initial revision over 2 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)
over 2 years ago
Edit Post #284911 Initial revision over 2 years ago
Answer A: Why are list comprehensions written differently if you use `else`?
It's not a matter of order; Python simply does not directly allow `else` clauses as part of list comprehensions (docs). When we use ```python [num if num != 11 else 22 for num in hand] ``` We are actually using Python's version of the ternary operator; the `if` and `else` are not part of the ...
(more)
over 2 years ago
Comment Post #284844 @#36363 Actually, "body" just goes on the body element, but child elements inherit their CSS from it unless overridden.
(more)
over 2 years ago
Edit Post #284844 Initial revision over 2 years ago
Answer A: Change font-family with JavaScript
Without knowing your use case, the simplest modification would just be to target everything: ```javascript document.querySelectorAll("").forEach((e) => { e.style.fontFamily = "arial"; }); ``` (As an aside, if you want to target the body element, just use `document.body`. No need for sel...
(more)
over 2 years ago