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

81 posts
72%
+6 −1
Q&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 em...

posted 2y ago by hkotsubo‭  ·  edited 2y ago by Martin Bonner‭

Answer
75%
+4 −0
Q&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 remo...

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

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

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

Answer
75%
+4 −0
Meta 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 ...

0 answers  ·  posted 2y ago by hkotsubo‭  ·  edited 1y ago by Monica Cellio‭

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

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

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

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

Answer
88%
+13 −0
Q&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'r...

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

Answer
91%
+20 −0
Q&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 my_file.py: # my_file.py def some_function(): print('do some stuff') print('calling function:') some_fun...

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

Answer
92%
+22 −0
Q&A What is HEAD in Git?

First, we need to understand what a Git repository actually is. For that, refer to this article: it explains that a Git repository is actually a DAG (Directed Acyclic Graph). I'm not going into the...

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

Answer
92%
+24 −0
Q&A What is HEAD in Git?

In Git documentation, there are lots of references to the term "HEAD". But what exactly is it? Some places refer to it as "a pointer to the current branch". So it's a branch? What is it used for?

1 answer  ·  posted 2y ago by hkotsubo‭  ·  last activity 1y ago by hkotsubo‭

Question git terminology
81%
+7 −0
Q&A What problem does innerHTML solves?

tl;dr According to the documentation, innerHTML property "gets or sets the HTML or XML markup contained within the element". Basically, "that's all", but let's see it in more detail. It makes...

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

Answer
60%
+1 −0
Q&A Are there practical reasons for designing a method-only class/object?

It depends. Regarding "grouping functions/methods": as a general rule, you should group things that make sense to be together. Yes, it's a very broad and generic rule, and somewhat subjective. How...

posted 2y ago by hkotsubo‭

Answer
72%
+6 −1
Q&A What is the main difference between event delegation to other event handling patterns in JavaScript?

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

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

Answer
77%
+5 −0
Q&A Why is the switch statement not executing the correct case blocks?

The problem is the fallthrough behaviour of case statements. Basically, once a case's condition is met, all the others after that are also executed. Example: int x = 2; switch (x) { case 1: ...

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

Answer
71%
+3 −0
Q&A What are the disadvantages of using static methods in Java?

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

posted 2y ago by hkotsubo‭

Answer
66%
+2 −0
Q&A How to run a remote JavaScript file from GitHub?

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

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

Answer
75%
+4 −0
Q&A How to make the text box such that its placeholder goes up and arranges itself in the centre of the border upon clicking?

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

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

Answer
60%
+1 −0
Q&A What input functions can I use in TIO's PHP?

You could use fgets to read from STDIN. And to print the message, just use the short tag (<?= whatever, which is a shorthand to <?php echo whatever; ?>): <?='Hello, '.fgets(STDIN).'!'...

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

Answer
66%
+2 −0
Meta Is there a workaround to highlight code blocks if the language doesn't have syntax highlight enabled?

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

0 answers  ·  posted 2y ago by hkotsubo‭  ·  edited 2mo ago by hkotsubo‭

80%
+6 −0
Q&A How to parse a date with more than 3 decimal digits in the fractions of second?

The solution depends on the Java version you're using. First, let's see the solution for earlier versions, that doesn't use SimpleDateFormat. Then we'll see why the problem happens and alternatives...

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

Answer
80%
+6 −0
Q&A How to parse a date with more than 3 decimal digits in the fractions of second?

I'm using SimpleDateFormat to parse a string containing a date/time, but the result has a different date, hour, minute, second and millisecond: SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM...

1 answer  ·  posted 2y ago by hkotsubo‭  ·  last activity 2y ago by hkotsubo‭

75%
+4 −0
Q&A Function.prototype.call()

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

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

Answer
81%
+7 −0
Meta Enable syntax highlighting for D language

According to this answer, Codidact uses highlight.js for syntax highlight, and "support whatever languages are enabled by default in that package". And according to this table (in highlight.js Git...

0 answers  ·  posted 3y ago by hkotsubo‭  ·  last activity 2y ago by Anonymous‭

83%
+8 −0
Q&A How to get string length in D?

what ways can I get a string's length in D? There are many different ways, and that will depend on the content of the strings, their types, and how you define the terms "character" and "length...

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

Answer
75%
+4 −0
Q&A What's the difference between =, == and === operators in JavaScript?

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

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

Answer