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 #283669 Post edited:
29 days ago
Edit Post #291075 Post edited:
about 1 month ago
Edit Post #291075 Post edited:
about 1 month ago
Edit Post #291075 Initial revision about 1 month ago
Answer 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: ```python import re pattern = re.compile(r'attr\d+') just to simulate a "file" file = [ 'attr1 apple 1', 'attr1 banana 2',...
(more)
about 1 month ago
Edit Post #290969 Post edited:
about 2 months ago
Edit Post #290969 Initial revision about 2 months ago
Answer 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 `getStackTrace()` method. For the current thread, you can use `Thread.currentThread().getStackTrace()`,...
(more)
about 2 months ago
Edit Post #290953 Initial revision about 2 months ago
Answer 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: ```bash git push : ``` Note that there's the `:` character before the branch name. Example: ```bash git push origin :my-branch ``` This ...
(more)
about 2 months ago
Comment Post #281551 @#64628 It depends on what data the application considers "valid". If I want to be very strict and allow, let's say, only "valid text in a specific set of languages" (or anything closer to that), preventing zalgo text would be a good start, as it wouldn't allow lots of non-sense gibberish (it won't p...
(more)
4 months ago
Edit Post #279716 Post edited:
4 months ago
Edit Post #281552 Post edited:
4 months ago
Comment Post #289928 @#64628 You suggested an alternative that leads to the same problem, I just thought this was worth mentioning (not only for you, but for any future readers). Otherwise, one could read this and think that your solution would avoid the problems caused by a forced push (which is not the case).
(more)
6 months ago
Comment Post #289928 @#64628 This doesn't eliminate the problem. Let's suppose the remote has 3 commits: ``` A <-- B <-- C (main) ``` And suppose that lots of people already pulled it (so they all have the 3 commits in their local repos). If I reset main to commit A (either by force push or directly in the ser...
(more)
6 months ago
Comment Post #289928 If the previous commits (the ones that got lost after `reset`) were already pushed, you can't avoid a forced push. The only way to avoid it, AFAIK, is to not rewrite history that's already pushed (don't `rebase`/`reset` if it affects already-pushed commits). Instead, you could `revert` the commits...
(more)
6 months ago
Edit Post #289929 Post edited:
6 months ago
Edit Post #289929 Post edited:
6 months ago
Comment Post #289928 Actually, this solution is not restricted to `main`, as it works for any branch. Regarding `push --force`, just [be aware of the risks before you do it](https://www.gitkraken.com/learn/git/problems/git-push-force#the-risks-of-git-push-force).
(more)
6 months ago
Edit Post #289929 Post edited:
6 months ago
Edit Post #289929 Initial revision 6 months ago
Answer 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: ```python print("this is some text", end="\r") print("abc") ``` Testing this in a Linux terminal, the output is: ```n...
(more)
6 months ago
Comment Post #289780 To shift the elements, you could also use `System.arrayCopy` as below: ```java int array[] = // some array int indexToRemove = // index to be removed int newSize = array.length - 1; System.arraycopy(array, indexToRemove + 1, array, indexToRemove, newSize - indexToRemove); // then you can do a...
(more)
7 months ago
Comment Post #289778 Complementing the answer from @#53034 below, if removing is a common operation that needs to be done lots of times, consider using a `List` instead of an array.
(more)
7 months ago
Comment Post #289491 @#64926 Actually, a commit is a snapshot (references: [1](https://git-scm.com/book/en/v2/Getting-Started-What-is-Git%3F), [2](https://github.blog/2020-12-17-commits-are-snapshots-not-diffs/)): it contains a pointer to a tree object, which represents the state of the whole working dir - BTW, a tree co...
(more)
8 months ago
Edit Post #289491 Post edited:
8 months ago
Edit Post #289491 Post edited:
8 months ago
Edit Post #289491 Initial revision 8 months ago
Answer 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 history), and the documentation says there are the following options: > `--depth ` > Create a shall...
(more)
8 months ago
Edit Post #289295 Post edited:
8 months ago
Comment Post #289289 I didn't add this to [my answer](/posts/289289/289295#answer-289295), but one of the reasons *could be*: most commands manipulate the current branch you're working on (`add`, `commit`, `revert`, `status`, `log`, `rebase`, etc), and making `merge` work different would be confusing in that matter.
(more)
8 months ago
Edit Post #289295 Post edited:
8 months ago
Edit Post #289295 Post edited:
8 months ago
Edit Post #289295 Post edited:
8 months ago
Edit Post #289295 Initial revision 8 months ago
Answer 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: ```none C---D => b1 / / E---F => b2 | / A--B--G--H => master \ ...
(more)
8 months ago
Comment Post #289229 In some languages, the assignment also yields a value. For example, in JavaScript `console.log(sum = a + b + c)` will assign the value of `a + b + c` to `sum` and yield its value, so `console.log` will print it. In this case, the whole thing `sum = a + b + c` would also be considered an expression?
(more)
9 months ago
Comment Post #287932 As a side note, the documentation calls it ["Old string formatting"](https://docs.python.org/3/tutorial/inputoutput.html#old-string-formatting). Nowadays, you can use `str.format` method (since Python 2.6) or [*f-strings*](https://docs.python.org/3/reference/lexical_analysis.html#f-strings) (since Py...
(more)
about 1 year ago
Edit Post #287904 Post edited:
about 1 year ago
Edit Post #287904 Post edited:
about 1 year ago
Edit Post #287904 Post edited:
about 1 year ago
Edit Post #287904 Post edited:
about 1 year ago
Edit Post #287904 Post edited:
about 1 year ago
Edit Post #287904 Initial revision about 1 year ago
Answer 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 is using Java >= 8, you can use the `java.time.Year` class, which has the static method `isLeap...
(more)
about 1 year ago
Edit Post #287903 Initial revision about 1 year ago
Question 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?
(more)
about 1 year ago
Comment Post #287682 Actually, hours and minutes are not being used, so you could also remove them: https://jsfiddle.net/86x0jtu7/1/
(more)
over 1 year ago
Comment Post #287682 `getSeconds`, `getMinutes` and `getHours` are functions (actually methods, but anyway), and they need to have parenthesis to be called - so change them to `getSeconds()`, `getMinutes()` and `getHours()`, and it'll work: https://jsfiddle.net/7tar9uvw/
(more)
over 1 year ago
Comment Post #286994 > "*The strikethrough on 'd'?*" Yes! One idea to make it easier to find: the line that was changed has a different highlighting, which means the system *already knows* that the difference is on that specific line. Maybe it could show only that line (or have an option to toggle between "show all...
(more)
over 1 year ago