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
60%
+1 −0
Q&A How to group a flat list of attributes into a nested lists?

You could create a dictionary to map each attribute to its respective list of items. Then you get the dictionary values to create the final list. Something like this: import re pattern = re.comp...

posted 1mo ago by hkotsubo‭  ·  edited 1mo ago by hkotsubo‭

Answer
77%
+5 −0
Q&A How to log first n lines of a stack trace in Java?

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

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

Answer
81%
+7 −0
Q&A How to delete a remote branch in git?

The other answer already provides the more straighforward solution (push with --delete option). But there's an older syntax that also works: git push <remote-name> :<branch-name> N...

posted 2mo ago by hkotsubo‭

Answer
71%
+3 −0
Q&A How to overwrite lines of STDOUT in Python?

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

posted 7mo ago by hkotsubo‭  ·  edited 7mo ago by hkotsubo‭

Answer
85%
+10 −0
Q&A Git: How to clone only a few recent commits?

How do I clone the repository with only part of the history? It depends on what part you want. It's possible to have shallow clones (which is exactly what you need, only a part of the commit h...

posted 8mo ago by hkotsubo‭  ·  edited 8mo ago by hkotsubo‭

Answer
80%
+6 −0
Q&A Why is git merge from rather than to?

I can't speak for the people who designed it, but I guess it was made this way because you can merge multiple branches all at once. Let's say I've created multiple branches: C---D => ...

posted 9mo ago by hkotsubo‭  ·  edited 9mo ago by hkotsubo‭

Answer
84%
+9 −0
Q&A How to verify if a year is leap in Java?

There are many ways to do it, it depends on what data you already have and/or the Java version. I have only the year's numeric value If you already have a value as a number (int or long), and i...

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

Answer
81%
+7 −0
Q&A How to verify if a year is leap in Java?

How to verify if a year is leap? Given a numeric value (such as 2023) or some object that represents a date (such as Date, Calendar, LocalDate, etc), how can I do it?

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

Question java date
77%
+5 −0
Q&A How to use grep to print only specific word from a string

I wouldn't use grep. As the other answers already said, it's not the right tool for this job. Considering your specific case (fields separated by /), basename is the most straighforward way, as st...

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

Answer
83%
+8 −0
Q&A What is [{options}] in JavaScript?

Given the link where the code comes from (based on your other question), this is just a, let's say, "free-form/pseudo-code/documentation example". It's not a valid JavaScript code. It's more like...

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

Answer
75%
+4 −0
Q&A How to make this treewalker code having a regular for loop or a forEach() method?

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

posted 2y ago by hkotsubo‭

Answer
75%
+4 −0
Q&A How this recursive treewalker works?

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

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

Answer
77%
+5 −0
Q&A Recursion without a procedure ("function") in JavaScript

Yes, it's possible. In a more general way, every recursive algorithm can be converted to an iterative one (and vice-versa). You just need to use a stack. Internally, a recursive function will use...

posted 2y ago by hkotsubo‭

Answer
77%
+5 −0
Q&A Does a for...of loop must contain a variable without assignment sign, and why?

Does a for...of loop must contain a variable without assignment sign (=) Yes. and why? Because that's the syntax defined by the language specification. The people who defined it decided ...

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

Answer
77%
+5 −0
Q&A What are the types of DOM nodes?

any DOM "tree" node is actually a "branch" Not exactly. Document Object Model and Nodes According to the MDN documentation, the DOM (Document Object Model) is "the data representation of the...

posted 2y ago by hkotsubo‭

Answer
66%
+2 −0
Q&A Delete all occurrences of a character in a webpage with vanilla JavaScript

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

posted 2y ago by hkotsubo‭

Answer
71%
+3 −0
Q&A Move to the edit webpage of a webpage via the keyboard with vanilla JavaScript

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

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

Answer
60%
+1 −0
Q&A How to uncollapse the first and second tiers of a link tree in JavaScript?

According to the documentation, the hasAttribute method expects only one argument (the attribute's name), and it tells only if that attribute is present, regardless of its value. Hence, the return ...

posted 2y ago by hkotsubo‭

Answer
66%
+2 −0
Q&A How can the Caesar cipher be implemented in Java?

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

posted 2y ago by hkotsubo‭

Answer
50%
+0 −0
Q&A Mocking methods with arguments

Based on your answer, I guess you just wanted to have a list of unique arguments that were passed to B::add. In that case, you could use a Set instead of a List: // "Type" is whatever type B:add r...

posted 2y ago by hkotsubo‭

Answer
80%
+6 −0
Q&A Is it OK to use scanf with a void pointer?

I've created a function that calls scanf passing a void pointer as argument: void read(const char *format, void *p) { scanf(format, p); } And tested it with different types: int n; read...

2 answers  ·  posted 2y ago by hkotsubo‭  ·  last activity 2y ago by Lundin‭

Question c pointers scanf
81%
+7 −0
Q&A When using the compare function in Array.prototype.sort, how to avoid an element to be processed more than once?

PS: for small arrays and/or if the function is fast and doesn't cause performance bottlenecks, none of the below is really necessary (see the analysis in the end). That said, let's see how to sol...

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

Answer
80%
+6 −0
Q&A When using the compare function in Array.prototype.sort, how to avoid an element to be processed more than once?

When using the Array.prototype.sort method, we can pass a compare function as argument. Then, this function can be used to process array's elements, so the comparison is made using some custom crit...

2 answers  ·  posted 2y ago by hkotsubo‭  ·  last activity 10mo ago by matthewsnyder‭

80%
+6 −0
Q&A Why object-oriented instead of class-oriented?

Why object-oriented instead of class-oriented? tl;dr Because you can "do OOP" without classes. Long answer A class is one possible way to implement object oriented programming. But it's n...

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

Answer
83%
+8 −0
Q&A How to deeply clone an array in Angular / TypeScript?

By "deeply clone", I assume you mean "also make copies of whatever nested structures the object might have". And for those, I guess libraries like Lodash are more reliable and appropriate if you wa...

posted 2y ago by hkotsubo‭

Answer