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 r~~‭

Type On... Excerpt Status Date
Answer A: Why does `let map f = id >=> switch f` work in F#?
> when I look at the type signatures, it is not supposed to work. The types work because they're parameterized. The types of the combinators involved are (renaming all parameters to be unique for clarity): ``` id : 'a -> 'a switch : ('b -> 'c) -> 'b -> Result (>=>) : ('d -> Result) -> ...
(more)
about 1 month ago
Answer A: How to implement `map` using the fish (>=>, Kleisli composition) operator in F#?
> Is there a "cleaner" implementation similar to `map`'s? Yes: ``` let map f = id >=> switch f ``` This follows from two of your other equations: ``` map f = bind (switch f) g >=> h = g >> bind h ``` So if you want to get `bind (switch f)` out of `(>=>)`, you can start by making `...
(more)
about 1 month ago
Answer A: Why does `Zip` require `Semialign`
There's good reason to believe this is simply historical accident. The `Semialign` class came first, and used to include `zip` and `zipWith` directly. When those members were separated out into their own class, the motivation was types that had `align` but not `zip` (one example is `NEMap`), so `Zip`...
(more)
3 months ago
Answer A: What does "namespace" mean?
A namespace is a category to which a name can belong. Think of family names for people: I may be friends with several Jims, and if only one of them is present I can just call him Jim. But if multiple are present, I can disambiguate which I mean by saying Jim Jones or Jim Smith. ‘Jones’ and ‘Smith’ ar...
(more)
5 months ago
Answer A: Set transform of SVG element
`` does seem to be a bit finicky for this case, doesn't it? You can use `` if you set the `values` attribute on it instead of the `to` attribute, like this: ``` ```
(more)
7 months ago
Answer A: Is it okay to use python operators for tensorflow tensors?
No, you can't use `and` for this. In Python, `a and b` always, always, always means `b if a else a`. It cannot be overridden and cannot mean anything else. Likewise `not`, and any other boolean keywords, as opposed to operators. You could instead write `a & b`, which should mean the same thing ...
(more)
8 months ago
Answer A: Replace leaf arrays with joined strings in a nested structure in jq
As the `walk` documentation describes: > When an array is encountered, f is first applied to its elements and then to the array itself In other words, `walk` is bottom-up. So when you apply your filter to your nested-array input, first you're flattening the innermost arrays into strings. Then ...
(more)
8 months ago
Answer A: How can I schedule a later task in Python?
If `systemd-run` works for you, that is probably the simplest thing you can do here. Otherwise, you can use `os.fork()` from within Python to spawn a child that stays alive after the parent exits. If someone else is reading this based on the title, but is writing an industrial Python applicatio...
(more)
9 months ago
Answer A: How can a Python program send itself to the background?
Use `os.fork()`. Example: ```python import os import time pid = os.fork() if pid == 0: os.setsid() # Prevents the child from being killed if the parent dies time.sleep(10) os.system('somecmd') os.exit(os.EXOK) # This is important after a fork; otherwise Python cleans up it...
(more)
9 months ago
Answer A: Is it possible to get the current function in a trace function?
CPython only very recently started keeping a reference on frames to function objects internally, and that reference isn't exposed from inside Python. There's an old PEP that would have defined a `function` local, which, combined with the `flocals` field on frame objects, probably would have done w...
(more)
12 months ago
Answer A: How do I get something similar to dictionary views, but for sequences?
It isn't writable (but then again, neither are the dictionary views), but you might be interested in moreitertools.SequenceView.
(more)
about 1 year ago
Answer A: Adding elements to wrapper after calling wrap doesn't work
Remember that jQuery selectors in general can match more than one element. If you had multiple `` elements in your page, `$('p').wrap(wrapper)` would put wrapper divs around each of them. So `.wrap` uses its argument as a template to clone new wrappers for each match. Other jQuery DOM manipulation...
(more)
about 1 year ago
Answer A: Dealing with code maintenance when saving a large and complex entity in a single business transaction
Chain of Responsibility doesn't strike me as appropriate for this problem, at least as I understand it. You want to use CoR if you have multiple different requirements for the processing of the same data—authentication, logging, A-B testing—things we generally call concerns. What it sounds like you'r...
(more)
over 1 year ago
Answer A: When would one not want to return an interface?
`IList` is not necessarily representative of the general case; it's an interface that is (A) widely implemented by a variety of classes from a variety of sources, which themselves (B) tend to add additional functionality or constraints not captured by the signature of `IList`. There is, in my opinion...
(more)
over 1 year ago
Answer A: How to distinguish between single and multiple file media?
You could trivially create a view that wraps the `media` table and includes a column that indicates if the media entry has more than one file associated with it. ```sql CREATE VIEW IF NOT EXISTS "mediaread" AS SELECT "media"., count("file"."uuid") > 1 AS "ismultifile" FROM "media" LEFT J...
(more)
over 1 year ago
Answer A: Should we allow answers generated by ChatGPT?
Good question, but solid ‘meh’ on the issue. I don't think a preemptive ban is warranted. It's not as if we're being flooded, and it's also not as if that one ChatGPT answer is worse than the median human answer here. I'd say let's upvote and downvote answers per usual without any particular restrict...
(more)
over 1 year ago
Answer A: Qt Button changes drastically when setting its `border-radius`.
See this comment: https://forum.qt.io/topic/60546/qpushbutton-default-windows-style-sheet#3 > Stylesheets are a totally different beasts. The default native drawing doesn't use stylesheets. They are a way to override native style dependent painting with HTML-like drawing. Usually if you change ...
(more)
over 1 year ago
Answer A: What does this function definition mean in Haskell?
`fn x [] = []` means that if the second argument to `fn` is an empty list, return an empty list. `fn x (True:ys) = x : fn x ys` means that if the second argument to `fn` starts with `True`, return a list that starts with the first argument to `fn` and continues with `fn x` applied to the remainder...
(more)
over 1 year ago
Answer A: Why does my code show an error at deriving (eq)? (SOLVED) NEW ERROR: At SimpleEnigma & SteckeredEnigma constructors which I need help on :")
`Eq` is a type class, and type class names are capitalized (like types and constructors). Changing `eq` to `Eq` should get you past that error. Conversely, in ```hs SimpleEnigma = SimpleEnigma rotor1 rotor2 rotor3 reflectorB offsets SteckeredEnigma = SteckeredEnigma rotor1 rotor2 rotor3 r...
(more)
over 1 year ago
Answer A: Child div doesn't inherit parent's div background-color
It's because of this rule: ```css { background: rgb(3, 28, 87); } ``` That applies the darker blue background to every element individually, and that isn't overridden when you change the background of a parent element. Consider applying your default background color to the `body` eleme...
(more)
over 1 year ago
Answer A: How to add vertical lines for visual separation in pandas plot
I don't think this is possible using just the Pandas plotting API. You can use the lower-level Matplotlib API to do just about anything you can imagine: ```py ax = df.plot.bar() vlines = [2.5, 5.5] # x-positions of the group separators ax.vlines(vlines, 0, 1, transform=ax.getxaxistrans...
(more)
almost 2 years ago
Answer A: Is it possible to write protocols for enumerations in Python?
There's one big difficulty with the proposed pattern. Enum instances are singleton instances of their particular class, and in general two enums from different classes are not equal even if they wrap the same int value. So an expression like `foobar == EnumProtocol.FOO` is never going to be true if `...
(more)
almost 2 years ago
Answer A: What is Backus–Naur form as applied in computer programming?
For writing pseudocode? No. BNF is a notation—in practice, a family of similar notations, like how Markdown is a family of similar markup languages—for defining grammars. In software development and computer science, a grammar is a set of rules for determining whether a sequence of symbols (charac...
(more)
almost 2 years ago
Answer A: Algorithmically generating the grid formed by the vertices of a dodecahedron (Hunt The Wumpus)
Here is an animation of a cube with faces subdivided into two rectangles, morphing into a rhombic dodecahedron, with the Platonic dodecahedron as an intermediate state. This demonstrates that the edge graph of the Platonic dodecahedron is the same as the edge graph of the subdivided cube. There ar...
(more)
about 2 years ago
Answer A: Is it OK to use scanf with a void pointer?
From section 7.21.6.2 of this draft: > [T]he result of the conversion is placed in the object pointed to by the first argument following the `format` argument that has not already received a conversion result. If this object does not have an appropriate type, or if the result of the conversion ...
(more)
about 2 years ago
Answer A: Migrating HTML strings to a more secure alternative
Switching from HTML to Markdown to minimize risk of HTML injection doesn't make a lot of sense to me, since most Markdown implementations support a subset of HTML inline anyway. The better ones control what subset of HTML to allow by using a sanitizing library, such as (to take just one random exampl...
(more)
about 2 years ago
Answer A: When stored procedures are preferred over application layer code?
There are a few reasons for wanting to move computation closer to data. One is performance, which you've mentioned. Another is security. Databases enforce their own security boundary, and data that don't leave the database are data that can't be exfiltrated if your application layer is exploited some...
(more)
over 2 years ago
Answer A: How can I modify the code above to accept string as user input and use strcmp to compare with the contents of the text file & then delete that line?
Assuming you're actually looking for a substring of a line in the file and not a word (which would require, as @elgonzo indicated, figuring out how to deal with spacing and word boundaries in general), you should look up information about the function `strstr`. But also, `strstr` wants to accept a...
(more)
over 2 years ago
Answer A: Problems with data structures and filestreams.
My advice to you is to break this down into smaller problems and try to solve them one at a time, making sure you have a program that can compile and run at each step. First: figure out how to successfully read and write a single book. Write a function that reads book information from stdin and re...
(more)
over 2 years ago
Answer A: How to clear the contents of a file?
Simply opening a file for writing (using `fopen`) will clear it (‘truncate to zero length’, per the standard). Only opening a file in read or append mode will preserve its contents. See section 7.21.5.3 of a recent C standard (like this draft) to get it straight from the horse's mouth, or any of t...
(more)
over 2 years ago
Answer A: Data structure implementation with Linked lists.
```c struct listNode{ char data; struct listNode nextPtr }; ``` Computer, when I tell you that any region of memory is a struct called `listNode`, that means that the region of memory contains a `char`, which I will read from and write to using the name `data`. The region of memory also...
(more)
over 2 years ago
Answer A: How to submit form data with Ajax?
See the first example in this section: ```js const form = new FormData(document.getElementById('login-form')); fetch('/login', { method: 'POST', body: form }); ``` To adapt this example to your code, you'll need to change the URL being provided to `fetch` from `'/login'` to the URL of...
(more)
over 2 years ago
Answer A: Are there any downsides related to using Maybe or Optional monads instead of nulls?
In my opinion, all of the downsides boil down to two objections: It isn't idiomatic (in C# and VB.⁠NET) It's slightly less performant The fact that it isn't idiomatic means that, as you noted, it'll often need to be translated at API boundaries. It also means that your coding style might vary ...
(more)
over 2 years ago
Answer A: How to append HTML to the DOM with JavaScript?
Use `fetch()` to request the HTML file from the server. Call `.text()` on the `Response` object you get from the `fetch` in order to get the HTML contents as a string. You can then insert the string into a DOM node with `.insertAdjacentHTML()` (which is recommended over anything involving `.innerHTML...
(more)
over 2 years ago
Answer A: How are we supposed to give feedback for poor questions if such comments are deleted?
I remember reading @meriton's comments on that question and thinking they were good feedback; if I hadn't seen them there, I would have written something similar. This is also an argument against making question feedback private: which is more likely to make people feel defensive, receiving public...
(more)
about 3 years ago
Answer A: What is a typeless programming language?
‘This language doesn't have types’ and ‘This language only has one type’ are English sentences that communicate the same underlying concept: a typeless language doesn't have a way to distinguish categories of values from each other, either statically (before running the program) or dynamically (while...
(more)
about 3 years ago
Answer A: Warn of implicit cast in a function's arguments with GCC?
From the page you linked: > `-Wconversion` > > Warn for implicit conversions that may alter a value. This includes conversions between real and integer, like `abs (x)` when `x` is `double`; conversions between signed and unsigned, like `unsigned ui = -1`; and conversions to smaller types, like `sq...
(more)
about 3 years ago
Answer A: How can I find git branches where all branch-local commits are from specific people?
From the command line, the following command will give you a list of all authors who have made local-only commits to a branch `some-branch`: git log some-branch --not --remotes --format="%an" And to get a clean list of branches suitable for scripting: git branch --format="%(refname:s...
(more)
about 3 years ago
Answer A: Is *nix a formal term?
The term is cultural, not technical. From Wikipedia: > There is no standard for defining the term, and some difference of opinion is possible as to the degree to which a given operating system or application is "Unix-like". There do exist standards, most notably the various POSIX standards and...
(more)
about 3 years ago
Answer A: How to read lines into an array in Bash
Your code is correct. You have declared your variable as an array, and you are successfully appending to it. To display all of the elements of your variable, try `echo "${myarray[@]}"`. (Another answer suggests `declare -p` for this, but `declare -p` will possibly give you more information than yo...
(more)
about 3 years ago
Answer A: How can software track [1] how many subscribers to subreddits, [2] if subreddit is private, [3] if submissions are restricted?
It's entirely possible that there's some no-code product being developed out there that supports connecting to Reddit's API, so that you could collect the information you want without writing an actual program. But you're on the Software Development Codidact, so I'm going to assume that you're her...
(more)
over 3 years ago
Answer A: How to override default string formatter?
Python doesn't support extending the mechanics of how f-strings are parsed; the reference doesn't give the specific mechanism, but it doesn't say that there's any connection between the parsing of f-strings and other formatting tools like `string.Formatter`, other than a superficial use of the same f...
(more)
over 3 years ago
Answer A: How do I find the order that yields the shortest path?
This looks like it's a slightly restricted version of the circular dilation minimization problem in the theory of graph drawing. See, for example, https://doi.org/10.1080/00207168808803629. Specifically, your problem can be expressed as finding a vertex numbering with minimal circular dilation for...
(more)
over 3 years ago
Question Add syntax highlighting for Cypher
[]()There have now been two questions about Cypher, the Neo4j query language. Highlight.js doesn't support Cypher syntax highlighting out of the box, but they do offer a drop-in highlightjs-cypher module which adds support. Can we use it here?
(more)
over 3 years ago
Answer A: Union of queries depending on variable in list
Yes, you can achieve this using `UNWIND` and `CALL`, in the following pattern: ```cypher UNWIND ['Canada', 'Europe'] AS region CALL { WITH region query } RETURN ``` You can replace `RETURN ` with any other end-of-query clause, of course, if you want to order or limit your results fo...
(more)
over 3 years ago
Answer A: Search paths where all nodes are in a relationship with same node
Something like this query should work for you: ``` MATCH (a:Person)-[:ISSON]->()-[:WASBORN]->(b:Country) WITH a, count(DISTINCT b) AS birthplaces WHERE birthplaces = 1 RETURN a ``` Note that this query would return people who have parents with unknown birthplaces, since those paths won't b...
(more)
over 3 years ago
Answer A: What would the pros and cons of storing the compiled CSS output of SASS in version control?
One thing to consider if you decide to store the CSS in version control is how to make sure that the CSS is always updated whenever the SASS is updated. (Of course this is true of the more general question, not just about CSS and SASS.) My preferred way to do that is to add a pre-commit hook to the p...
(more)
over 3 years ago
Question Code Reviews: ‘it's fine’
(Elsewhere...) You look over a post on Code Reviews, and you don't find any problems. Should you post an ‘it's fine’ answer, stay silent, or do something else? Seems to me there's some value in having a signal that n people have reviewed this code and found no issues; better for the asker to s...
(more)
over 3 years ago
Answer A: Community feedback: What type of questions can I ask here?
> Off-topic > questions about which tools, frameworks, or technologies to use, unless they are directly related to development (e.g. code, schema changes documentation tools) I propose removing this entirely, as I believe it is adequately covered by the existing > Off-topic > questions abou...
(more)
over 3 years ago
Answer A: Community feedback: What type of questions can I ask here?
I propose adding, at the top of the list: > On-topic > questions about writing software, where software is understood to include any means of specifying to a computer actions to be performed later. (This includes general-purpose programming languages as well as, for example, SQL, shell scripts, ...
(more)
over 3 years ago