Most Popular
1500 questions
2419
votes
5 answers
What are the differences between .gitignore and .gitkeep?
What are the differences between .gitignore and .gitkeep? Are they the same thing with a different name, or do they both serve a different function?
I don't seem to be able to find much documentation on .gitkeep.
Matty
- 31,623
- 12
- 62
- 92
2419
votes
19 answers
How to "git clone" including submodules?
I'm trying to put a submodule into a repo. The problem is that when I clone the parent repo, the submodule folder is entirely empty.
Is there any way to make it so that git clone parent_repo actually puts data in the submodule folder?
For example,…
None
- 1
- 30
- 155
- 213
2418
votes
5 answers
How do I lowercase a string in Python?
Is there a way to convert a string to lowercase?
"Kilometers" → "kilometers"
Benjamin Didur
- 24,393
- 3
- 13
- 5
2406
votes
30 answers
What's the difference between @Component, @Repository & @Service annotations in Spring?
Can @Component, @Repository and @Service annotations be used interchangeably in Spring or do they provide any particular functionality besides acting as a notation device?
In other words, if I have a Service class and I change the annotation from…
Colin McCree
- 24,117
- 3
- 13
- 3
2395
votes
8 answers
What is The Rule of Three?
What does copying an object mean?
What are the copy constructor and the copy assignment operator?
When do I need to declare them myself?
How can I prevent my objects from being copied?
fredoverflow
- 246,999
- 92
- 370
- 646
2386
votes
33 answers
How to change the output color of echo in Linux
I am trying to print a text in the terminal using echo command.
I want to print the text in a red color. How can I do that?
satheesh.droid
- 27,109
- 9
- 33
- 33
2385
votes
35 answers
How to update each dependency in package.json to the latest version?
I copied package.json from another project and now want to bump all of the dependencies to their latest versions since this is a fresh project and I don't mind fixing something if it breaks.
What's the easiest way to do this?
The best way I know is…
Raine Revere
- 27,477
- 4
- 33
- 48
2383
votes
42 answers
How can I make a div not larger than its contents?
I have a layout similar to:
I would like for the div to only expand to as wide as my table becomes.
George Snider
2380
votes
29 answers
How do I declare and initialize an array in Java?
How do I declare and initialize an array in Java?
bestattendance
- 25,073
- 5
- 24
- 23
2379
votes
56 answers
How to print a number with commas as thousands separators in JavaScript
I am trying to print an integer in JavaScript with commas as thousands separators. For example, I want to show the number 1234567 as "1,234,567". How would I go about doing this?
Here is how I am doing it:
function numberWithCommas(x) {
x =…
Elias Zamaria
- 89,268
- 31
- 107
- 141
2378
votes
23 answers
How to retrieve the hash for the current commit in Git?
I would like to retain (for now) the ability to link Git changesets to workitems stored in TFS.
I already wrote a tool (using a hook from Git) in which I can inject workitem identifiers into the message of a Git changeset.
I would also like to store…
Sardaukar
- 26,314
- 4
- 27
- 31
2377
votes
10 answers
Why are elementwise additions much faster in separate loops than in a combined loop?
Suppose a1, b1, c1, and d1 point to heap memory, and my numerical code has the following core loop.
const int n = 100000;
for (int j = 0; j < n; j++) {
a1[j] += b1[j];
c1[j] += d1[j];
}
This loop is executed 10,000 times via another outer…
Johannes Gerer
- 24,910
- 5
- 26
- 33
2362
votes
25 answers
How do I chop/slice/trim off last character in string using Javascript?
I have a string, 12345.00, and I would like it to return 12345.0.
I have looked at trim, but it looks like it is only trimming whitespace and slice which I don't see how this would work. Any suggestions?
Phill Pafford
- 80,991
- 89
- 259
- 379
2361
votes
17 answers
How do I revert all local changes in Git managed project to previous state?
I have a project in which I ran git init.
After several commits, I did git status which told me everything was up to date and there were no local changes.
Then I made several consecutive changes and realized I wanted to throw everything away and…
Jacques René Mesrine
- 43,765
- 26
- 63
- 102
2360
votes
8 answers
What are the basic rules and idioms for operator overloading?
Note: The answers were given in a specific order, but since many users sort answers according to votes, rather than the time they were given, here's an index of the answers in the order in which they make the most sense:
The General Syntax of…
sbi
- 212,637
- 45
- 247
- 432