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.

Posts by Moshi‭

52 posts
91%
+19 −0
Q&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 [num if num != 11 else 22 for num in hand] We are actually usin...

posted 3y ago by Moshi‭

Answer
86%
+11 −0
Q&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, poin...

posted 3y ago by Moshi‭

Answer
86%
+11 −0
Q&A When would one not want to return an interface?

Consider the following method as an example: List<int> Foo() { // ... } Are there any disadvantages of returning an interface instead of a concrete implementation in C#? IList<i...

3 answers  ·  posted 2y ago by Moshi‭  ·  last activity 1y ago by matthewsnyder‭

85%
+10 −0
Q&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: vh->Vehic...

posted 2y ago by Moshi‭

Answer
85%
+10 −0
Q&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 visibi...

posted 3y ago by Moshi‭

Answer
85%
+10 −0
Q&A Open file in script's own folder

You can use the pathlib standard module with __file__ to make things simple. from pathlib import Path scriptFolder = Path(__file__).parent with open(scriptFolder / 'data.txt') as file: dat...

posted 3y ago by Moshi‭

Answer
84%
+9 −0
Q&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. The #[cfg(test)] anno...

posted 2y ago by Moshi‭  ·  edited 1y ago by Moshi‭

Answer
83%
+8 −0
Q&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. ...

posted 1y ago by Moshi‭

Answer
83%
+8 −0
Q&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 s...

posted 1y ago by Moshi‭  ·  edited 1y ago by Moshi‭

Answer
83%
+8 −0
Q&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, ...

posted 2y ago by Moshi‭  ·  edited 2y ago by Moshi‭

Answer
83%
+8 −0
Meta How to inhibit auto link generation?

Method 1: <span> (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. <span&gt...

posted 3y ago by Moshi‭  ·  edited 3y ago by Moshi‭

Answer
81%
+7 −0
Q&A 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 commi...

3 answers  ·  posted 3y ago by Moshi‭  ·  last activity 3y ago by Hyperlynx‭

81%
+7 −0
Q&A 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...

1 answer  ·  posted 2y ago by Moshi‭  ·  last activity 2y ago by deleted user

81%
+7 −0
Q&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 equalit...

posted 3y ago by Moshi‭  ·  edited 3y ago by Moshi‭

Answer
80%
+6 −0
Q&A 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: interface Foo<A, B> { (a: A, b: B): any } function test<...

0 answers  ·  posted 2y ago by Moshi‭  ·  edited 6mo ago by Moshi‭

80%
+6 −0
Meta 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 po...

1 answer  ·  posted 4y ago by Moshi‭  ·  last activity 3y ago by Trilarion‭

80%
+6 −0
Q&A Is it possible to undo a git reset?

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...

posted 2y ago by Moshi‭

Answer
80%
+6 −0
Q&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...

posted 2y ago by Moshi‭  ·  edited 2y ago by Moshi‭

Answer
80%
+6 −0
Meta 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 p...

posted 2y ago by Moshi‭

Answer
80%
+6 −0
Q&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 ...

posted 3y ago by Moshi‭  ·  edited 3y ago by Moshi‭

Answer
80%
+6 −0
Q&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. for row in self.diagram: # row is str here for row in self.seed_diagram: # row is list[str] here Renaming one or the other m...

posted 2y ago by Moshi‭  ·  edited 2y ago by Moshi‭

Answer
77%
+5 −0
Q&A Why can't a derived class add a const qualifier to a method?

Say we have an abstract class Foo declared as so: class Foo { public: virtual void test() = 0; }; Let's say that we make a derived concrete class FooDerived, and decide to mark it's ve...

2 answers  ·  posted 2y ago by Moshi‭  ·  last activity 2y ago by Dirk Herrmann‭

77%
+5 −0
Q&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 ...

posted 8mo ago by Moshi‭

Answer
77%
+5 −0
Q&A 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). using Value = std::variant<std::monostate, int, double, std::strin...

1 answer  ·  posted 2y ago by Moshi‭  ·  last activity 1y ago by Baum mit Augen‭

Question c++ variant
77%
+5 −0
Meta 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 and the tag wiki for...

3 answers  ·  posted 4y ago by Moshi‭  ·  last activity 4y ago by Alexei‭