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 hkotsubo
It's not clear where this stack trace comes from (either from an exception or the current thread), but it doesn't matter, the way to do it is the same. Both Exception's and Thread's have the getSt...
Instead of replacing the brackets, you could do just one loop, and keep a stack with the opening brackets. Every time you find a closing bracket, check if it corresponds to the stack top: if it's n...
I personally think its syntax is confusing. Well, it's just a matter of getting used to it, I guess :-) Anyway, this code is just looping through all childNodes and in each iteration it cal...
At the documetation you linked, if you click on "which will clear the document", it'll go to the documentation for document.open, and that page says in the beginning: All existing nodes are remo...
Code blocks inside comments are hightlighted only if I'm on the comment's thread page. If I view it on the post itself (after expanding the respective thread), it's not highlighted. Example: in ...
How this recursive treewalker works? To understand what the code does, we need to first see what problem it's trying to solve and why it needs to be solved this way. Let's consider this HTML:...
The basic ideia is to create an input with a "fake" placeholder, and a span that will serve as the actual placeholder text. Then you group both inside a label, like this: <label> <inpu...
TL;DR To count the number of li items, just do: console.log(document.querySelectorAll('ul.example > li').length); That's all, no need to complicate with filter.call (but I'll explain that t...
Assignment (=) = is the assignment operator: it assigns a value to "something". One important detail is that an assignment expression not only assigns a value, but it also returns it. This allows...
I've got a HTTP Error 500 when trying to access this post. Here's the quote error ID's: ef4f6ec1-8d0f-4be3-9553-36e01b5f01c4 and bbeb9bf9-2c58-43b1-be05-c9e914bb80bf. I've browsed to another pos...
When posting this question, I noticed a difference between editor's preview and the post's final render. When editing, the preview correctly shows the Zalgo Text: But after the post is saved, i...
tl;dr The purpose of addEventListener is to define what happens when an event is triggered at some element. But it also allows us to implement event delegation, due to the bubbling/propagation beh...
void (*ptr)() defines a function pointer. It says that ptr is a pointer to a function. But that function must have a void return type, and take an arbitrary number of parameters (that's what the em...
The solution proposed by the other answer works, but there's a corner case. If the last message is shorter than the previous one, you might not get what you want. Example: print("this is some text...
Is it better to use static method? I don't like to think of static (or any other language feature/mechanism) in terms of bad/worse and good/better (although I do that too, I constantly try to ...
After I wrote this answer, I could notice that, when there's inline code in the last line of a paragraph, sometimes the border-bottom of the inline code text is not displayed. One case is when the...
The problem described below occurs in Windows 10 and Chrome 87.0.4280.66 (64 bits, JavaScript enabled). I could post this question only in mobile (Chrome/iOS 14.2), where the problem doesn't occur....
You're getting close, just need a few adjustments. Instead of using the hostname property, I prefer to use host, because it also includes the port (in case the URL has one) - check the documentati...
As you're using userscripts, I'm assuming this code is supposed to run in a browser. Hence, you could download the scripts and add its contents to the page's DOM (by using a script element). For t...
Some comments and your answer are doing this: document.body.innerHTML = document.body.innerHTML.replace(/x/g, '*'); But as explained in the comments, this is not a good solution, because it can...
Caesar Cipher originally deals only with letters (ASCII "A" to "Z", without diacritics/accents), so I'm not sure why you included ۤ$%& in your answer. And using indexOf (as you did) is not ver...
Yesterday I answered this question. This morning, when I visited site, the question has disappeared, so my guess is that it was deleted. But now I saw that it was undeleted (I initially thought t...
I've seen that recently two requests to add syntax highlight to some languages were deferred (this and this). According to the status-deferred tag description: "the requested feature will not be i...
Currently, Java 16 is the latest version, and there's no support to branch reset yet. But one - still far from ideal - alternative is to use lookarounds: Pattern pattern = Pattern.compile("([aeiou...
I've tried to post a comment in this question, and when I clicked in "Post" button, I've got this error message: 500 Internal Server Error If you are the administrator of this website, then ple...
- ← Previous
- 1
- 2
- 3
- 4
- Next →