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: Why does RFC 3986 (URI generic syntax) declare the "host" component to be case-insensitive when the syntax rules show it to be case-sensitive?
This question probably stems from misunderstanding what case sensitivity is. Being case insensitive does not mean only allowing one case - in fact, it implies the opposite! If one case was treated differently from the other, that would be the definition of case sensitivity. What case insensitivity...
(more)
about 1 month ago
Answer A: VS Code: How to open a file and folder in a new window?
Use `--add`/`-a` to add a folder ```shell code -n -a ```
(more)
7 months ago
Answer A: Name for host + path (parts of a URL)
RFC 3986 defines a suffix reference as follows (emphasis my own): >### 4.5. Suffix Reference >The URI syntax is designed for unambiguous reference to resources and extensibility via the URI scheme. However, as URI identification and usage have become commonplace, traditional media (television, ...
(more)
8 months ago
Answer A: What are statements and expressions?
Statements and expressions are two syntactic categories that are used by many programming languages. Since they are syntactic, they depend on the programming language's syntax. In a real sense, a statement is "anything that can be used as a statement" and an expression is "anything that can be used a...
(more)
9 months ago
Question VS Code can't find node installation due to dynamically setting the PATH
I installed Node.js using NVS to manage my node installations. This works great, except that I haven't been able to figure out how to debug using VS Code. When trying to launch, I receive this error: Can't find Node.js binary "node": path does not exist. This makes sense, since NVS functions...
(more)
9 months ago
Answer A: How to resolve the mypy error "Returning Any from function declared to return 'Dict[str, Any]'" in Python?
You can cast the result of the expression to the desired type ```py def loadjsondata(filepath: str) -> Dict[str, Any]: with open(filepath) as jsondata: return cast(Dict[str, Any], json.load(jsondata)) ``` You can also just ignore the error ```py def loadjsondata(filepath: st...
(more)
9 months ago
Question Updating the database reverses previous changes
The Code ```cs using Microsoft.EntityFrameworkCore; public class BloggingContext : DbContext { public DbSet Blogs { get; set; } public DbSet Posts { get; set; } public string DbPath { get; } public BloggingContext() { DbPath = "blogging.db"; } ...
(more)
about 1 year ago
Question Adding elements to wrapper after calling wrap doesn't work
I'm trying to do some DOM manipulation in jQuery, but am having issues with creating wrapper elements. For some reason, prepending to the wrapper doesn't work after I call `wrap`. Code ```html Text ``` ```js const wrapper = $(''); const newText = $('New Text'); $('p').wrap(w...
(more)
about 1 year ago
Answer A: How to define an object with different subclasses in an if-statement?
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: ```cpp vh->Vehicle::print(); ``` There are a couple of different solutions to this, but the simplest is pr...
(more)
about 1 year ago
Question EF-core Find method doesn't include other entities
(Full code available for cloning here) I've run into some odd behavior of EF-core's `Find` method. It seems like the returned entity doesn't include the rest of the data. MWE Models ```cs using Microsoft.EntityFrameworkCore; public class BloggingContext : DbContext { public Db...
(more)
over 1 year ago
Answer A: What's causing mypy to give an `[assignment]` error in this nested for loop?
The problem is that you are using `row` twice with different types. ```py for row in self.diagram: # row is str here ``` ```py for row in self.seeddiagram: # row is list[str] here ``` Renaming one or the other makes the error go away. Why does this happen? Python has some somewhat cou...
(more)
over 1 year ago
Question interface and interface-type tags
My most recent question was tagged with interface-type. I had seen the interface tag when I was creating the question, but the usage information says > Please avoid using this tag, as it is too general (e.g. software interfaces like the ones in Java, .NET and C++, components entry points, hardw...
(more)
over 1 year ago
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)
over 1 year 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)
over 1 year 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 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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
Question Is it a good idea to have a permanent branch for a feature?
I'm rather new to using git, so I'm not sure about the best practices regarding it. I have a feature branch branched off, and periodically when the feature needs to be updated I will add some commits to the branch and then create a pull request.[^1] Is it a good idea to have a permanent branch for...
(more)
over 2 years ago
Answer A: How do I ask git-show-branch to display a commit range?
According to the docs, you could use the `--more` flag If you just want to look at some commits past the common ancestor, then you can add the `--more` flag to it. From the git-scm docs for git-show-branch, > `--more=` > > Usually the command stops output upon showing the commit that is th...
(more)
over 2 years ago
Answer A: Why does Firefox block based on a restrictive default-src directive, when more specific, more permissive *-src exist?
Each header is checked independently Having multiple Content Security Policy headers can only make it more restrictive I assume that each `Content-Security-Policy:` line you have is a separate CSP header. If you send each separately, then a source will be checked on each CSP separately. For ...
(more)
over 2 years ago
Answer A: What's the difference between =, == and === operators in JavaScript?
Assignment `=` `=` is the assignment operator. There's nothing much to say here. Abstract Equality `==` `==` is abstract equality - it will attempt to perform a type conversion before evaluating equality. E.g. ```javascript 1 == '1' 1 == true null == undefined ``` Objects only ...
(more)
almost 3 years ago
Answer A: Why use an asterisk after a type?
> Here I used asterisk after Node. Actually, why asterisk used for? What if I don't put any asterisk after Node (Both Node are structure). It's a pointer. A pointer, like its name implies, points to an actual object in memory. (More technically, it holds an address to the memory location). I...
(more)
almost 3 years ago
Answer A: How to set text-align for whole column of HTML table?
You cannot set `text-align` on a column element (Well, you can, but it won't have any effect) There are only a couple of properties that have an effect, namely `border`, `background`, `width`, and `visibility`. If you need to style a column outside of those attributes, MDN notes some pos...
(more)
almost 3 years ago
Answer A: How to inhibit auto link generation?
Method 1: `` (or other HTML tag) It appears that Markdown isn't detected within HTML tags, so you can wrap the URL-like in a span or other tag and it won't turn into a link. `dead.sh` -> dead.sh `dead.sh` -> dead.sh etc. Method 2: `&#46;` (period escape) You can also escape the peri...
(more)
about 3 years ago
Answer A: What is the point of tagging a question with both a parent and a child tag?
An answer on a related Meta suggestion, Remove parent tags from a post where a child tag is present, provides a case where you might want to tag both. > For example, if mammal is a parent of deer, but a question is about how non-deer mammals in general and deer in particular get along with one ano...
(more)
over 3 years ago
Answer A: Are hyphens and/or underscores valid in golang package names?
Disclaimer: I don't know Go. This is all just me reading the specification. In the Go specification under Packages, it defines `PackageName`. > ``` > PackageName = identifier > ``` Under Identifiers > ``` > identifier = letter { letter | unicodedigit } . > ``` Under Letters ...
(more)
over 3 years ago
Question What is our policy on tags?
I've come to realize that tags began changing pretty rapidly recently. In the past 3 days alone, these happened: - [[urlrewrite] was changed to a more generic [url-rewriting] tag](https://software.codidact.com/questions/278727) and the tag wiki for it was deleted. - [[sheets] was changed to [go...
(more)
over 3 years ago
Answer A: Code Reviews: ‘it's fine’
Put it in a comment if it's just "It's fine, no problems here". As with most answers that aren't substantial enough to warrant their own answer post, I'd say to just leave a comment. As you said, knowing that n people find it fine has value in itself, but probably not enough value to warrant n ans...
(more)
over 3 years ago
Answer A: Will my implementation of a Spring Boot app work after being deployed on the Internet?
> Now of course this will directly work only within my network. But if I upload this project to Heroku or something similar, would it still work as intended? I'll assume that you actually have the project working on your network. The only advice I can really give you here is, "Try it and see if it...
(more)
over 3 years ago
Answer A: Is there an equivalent way of returning early in a MySQL stored procedure?
I don't know any SQL at all, so credits go to the top answer of Mysql - How to quit/exit from stored procedure on StackOverflow. You can simply wrap the code in a label and LEAVE the label, ex. ```sql CREATE PROCEDURE ExampleProc() proclabel:BEGIN IF THEN LEAVE proclabel; ...
(more)
over 3 years ago
Answer A: Give actionable feedback when closing questions
This is a current limitation of the software. Right now, there is simply no way to add detailed feedback to the close reason. There is a list of pre-written close reasons (which can be set per site). If you feel like there is an issue with the wording of a close reason, then feel free to suggest w...
(more)
over 3 years ago
Question Styling with classes vs styling with CSS
I've noticed that a lot of sites have something like this going on: ```html ... ... ... ``` ```css .has-margin-0 { margin: 0; } .has-padding-4 { padding: 4px; } ``` I'm a beginner who's self taught / internet searched most of their HTML and CSS knowledge. Cur...
(more)
over 3 years ago
Answer A: Nodejs wrap async function in synchronous function
> What are my options here? Do I need to switch the module I'm using to access the db? Do I need to write C code? Or is there a really clever technique to directly solve this problem, using only nodejs? Generally, you shouldn't be turning asynchronous functions into synchronous ones. I would sugge...
(more)
over 3 years ago
Answer A: Meaning of the tag software practices?
(The user who created the tag) The tag was to make it clear that (somewhat) opinion-based questions are allowed on site, with the [software-practices] marking which questions are about "best practices", "pros and cons", and other such questions where there is no "right" answer, but there can defin...
(more)
over 3 years ago
Answer A: Function call; `this` gets bound to unexpected value
Why parenthesis don't work as you expect You seem to have a rough idea how the `this` keyword is resolved, so I'll skip explaining that and go straight to your question. > I was surprised to find that when the above function is called, `this` is still bound to `obj`! It seems that here, `(obj.a...
(more)
over 3 years ago
Question Code Challenges Category (Code Golfing & others)
I was inspired by the contests on Outdoors and Writing, and thought that having some challenges over here would be fun as well. What do you all think about adding a new category where people can post some coding challenges to the site? We could start by having a monthly contest, like on the other sit...
(more)
over 3 years ago