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 hkotsubo‭

Type On... Excerpt Status Date
Edit Post #285105 Post edited:
about 3 years ago
Edit Post #285105 Post edited:
about 3 years ago
Edit Post #285105 Initial revision about 3 years ago
Answer A: What does a variable followed by parentheses ("ptr()") mean?
`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 empty parentheses defines). Then, `ptr = PrintHello` assigns the `PrintHello` function to the `p...
(more)
about 3 years ago
Suggested Edit Post #285104 Suggested edit:
Remove clutter and try to come up with a better title
(more)
helpful about 3 years ago
Comment Post #285019 @#36363 Could you add a link to the website, so we can at least check the HTML and try to see what the problem is? Because your code *should* work. Just double checking the basic stuff: what does `document.querySelector("#example")` return? When you run your code, does any error message appear in th...
(more)
about 3 years ago
Comment Post #285019 Maybe - and that's a *wild guess* - the JavaScript code is running before the HTML is loaded, and it can't find the input field. Check if the `script` tag is before the form and change it to be after. Or add an event listener to run after the page is loaded: ```javascript document.addEventListene...
(more)
about 3 years ago
Comment Post #284981 @#36363 I've made a simple test: ```javascript var old = document; document.write('abc'); console.log(old === document); // true ``` Which means that the document didn't change (only its child nodes). Another test to check if child nodes changed: ```javascript // keep reference to origina...
(more)
about 3 years ago
Comment Post #284981 @#36363 My understanding is that the document itself is not removed, only its child nodes. But I'll make more tests as soon as I can
(more)
about 3 years ago
Edit Post #284981 Post edited:
about 3 years ago
Edit Post #284981 Initial revision about 3 years ago
Answer A: document.open() and the DOM tree of the loaded (closed) browser window on which it works
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 removed from the document. And once removed, you can't retrieve them. Making a test in this page, ...
(more)
about 3 years ago
Edit Post #284941 Post edited:
Typo
about 3 years ago
Edit Post #284941 Post edited:
about 3 years ago
Edit Post #284941 Post edited:
about 3 years ago
Edit Post #284941 Initial revision about 3 years ago
Answer A: Understanding createTreeWalker method in the context of replacing strings (or parts of them)
> How does storing replaced strings in the `node` variable makes a change in the text appearing to the end user? In your case, you're changing the `textContent` property. When accessed, it returns the text content of a node, concatenated with the text content of its descendants, and changing its v...
(more)
about 3 years ago
Edit Post #284928 Post edited:
about 3 years ago
Edit Post #284928 Post edited:
about 3 years ago
Edit Post #284928 Initial revision about 3 years ago
Question Code block in comments is highlighted only when viewed in the thread's link
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 this post I clicked on the comment thread to expand it, and the code block is not highlighted: code...
(more)
about 3 years ago
Comment Post #284911 @#53305 To add a little bit more pedantry, the filter predicate doesn't have to be exactly a boolean, because in Python [any object can be tested for truth value](https://docs.python.org/3/library/stdtypes.html#truth-value-testing). Which means I can do this: ```python values = ['abc', '', [], ['...
(more)
about 3 years ago
Comment Post #284853 @#36363 You're welcome, glad to help!
(more)
about 3 years ago
Edit Post #284842 Post edited:
Change title to make more clear what the question is about
about 3 years ago
Suggested Edit Post #284842 Suggested edit:
Change title to make more clear what the question is about
(more)
helpful about 3 years ago
Edit Post #284853 Post edited:
some "future-proof" stuff
about 3 years ago
Edit Post #284853 Post edited:
some "future-proof" stuff
about 3 years ago
Edit Post #284853 Post edited:
about 3 years ago
Edit Post #284853 Initial revision about 3 years ago
Answer A: Change font-family with JavaScript
To do that, you could change the selector from `body` to ``, as the other answer said. By selecting only `body`, it won't change child elements that has defined a more specific rule, and that's why you need to set the style for all of them. But there are some corner cases that I think it's worth e...
(more)
about 3 years ago
Comment Post #284806 @#54649 I've made [this test](https://ideone.com/EkRHga) and surprisingly using string slices is faster than doing the math. Try to change the algorithm and see if it makes some difference
(more)
about 3 years ago
Comment Post #284806 @#54649 For quick performance tests you can use the [`timeit` module](https://docs.python.org/3/library/timeit.html). I've made [a simple example](https://ideone.com/xjEhaR), and creating the function inside the loop was about 50%~60% slower.
(more)
about 3 years ago
Comment Post #284806 You're creating the function inside the loop, so for every iteration a new function is created. But that's not needed at all, creating it just once outside the loop is enough. Not sure how much it'll improve performance, but it certainly won't make it worse
(more)
about 3 years ago
Edit Post #284803 Post edited:
Improve title, make text more concise, add tags
about 3 years ago
Edit Post #284804 Post edited:
about 3 years ago
Suggested Edit Post #284803 Suggested edit:
Improve title, make text more concise, add tags
(more)
helpful about 3 years ago
Edit Post #284804 Initial revision about 3 years ago
Answer A: Separate digits of a number in groups with different sizes
Before we start, I'd like to be a little bit pedantic regarding `00002451018` being a number. When we talk about numeric types/values, the zeroes at the beginning are irrelevant: `2`, `02` and `000002` all refer to the number two. The numeric value is `2`, and only the representation - the way the...
(more)
about 3 years ago
Edit Post #284710 Post edited:
about 3 years ago
Edit Post #284710 Post edited:
about 3 years ago
Edit Post #284710 Initial revision about 3 years ago
Answer A: How do I support tab completion in a python CLI program?
It depends. Do you want to have autocomplete on the shell the program runs in, or do you want the program to intercept the TAB key and do the autocomplete by itself? Shell autocomplete If you're running your program in a Linux shell, and want to autocomplete in the shell's command line (such ...
(more)
about 3 years ago
Comment Post #284612 I agree that having some way to indicate the relevant versions can be useful in many cases, but I don't know what's the best way to do it (if I come up with something, I'll certainly post an answer). SE's attempt seems to be convoluted, but I guess only time will tell...
(more)
about 3 years ago
Edit Post #284649 Post edited:
about 3 years ago
Edit Post #284649 Post edited:
about 3 years ago
Edit Post #284649 Initial revision about 3 years ago
Answer A: What is the purpose of `if __name__ == '__main__'`?
It makes difference if the script is being imported. Let's suppose I have a file `myfile.py`: ```python myfile.py def somefunction(): print('do some stuff') print('calling function:') somefunction() ``` If I execute it directly (such as `python myfile.py`), the output is: ```n...
(more)
about 3 years ago
Edit Post #284633 Post edited:
minor fixes (removed duplicated "when", added punctuation, etc)
about 3 years ago
Suggested Edit Post #284633 Suggested edit:
minor fixes (removed duplicated "when", added punctuation, etc)
(more)
helpful about 3 years ago
Edit Post #282066 Post edited:
fix typo
about 3 years ago