Most Popular

1500 questions
2213
votes
27 answers

How can I save username and password in Git?

I want to use a push and pull automatically in Git Extensions, Sourcetree or any other Git GUI without entering my username and password in a prompt, every time. So how can I save my credentials in Git?
Edson Cezar
  • 22,484
  • 5
  • 17
  • 25
2209
votes
18 answers

What is a non-capturing group in regular expressions?

How are non-capturing groups, i.e., (?:), used in regular expressions and what are they good for?
never_had_a_name
  • 85,690
  • 100
  • 264
  • 377
2208
votes
23 answers

What is the best way to give a C# auto-property an initial value?

How do you give a C# auto-property an initial value? I either use the constructor, or revert to the old syntax. Using the Constructor: class Person { public Person() { Name = "Initial Name"; } public string Name { get;…
bentford
  • 31,968
  • 7
  • 58
  • 57
2206
votes
14 answers

How can I select an element with multiple classes in jQuery?

I want to select all the elements that have the two classes a and b. So, only the elements that have both classes. When I use $(".a, .b") it gives me the union, but I want the intersection.
Mladen
  • 24,908
  • 11
  • 38
  • 47
2203
votes
18 answers

HTML 5: Is it
,
, or
?

I've tried checking other answers, but I'm still confused — especially after seeing W3schools HTML 5 reference. I thought HTML 4.01 was supposed to "allow" single-tags to just be and
. Then XHTML came along with and
(where…
ehm
  • 23,779
  • 5
  • 27
  • 30
2201
votes
7 answers

How does PHP 'foreach' actually work?

Let me prefix this by saying that I know what foreach is, does and how to use it. This question concerns how it works under the bonnet, and I don't want any answers along the lines of "this is how you loop an array with foreach". For a long time I…
DaveRandom
  • 86,228
  • 11
  • 149
  • 173
2196
votes
18 answers

How do I empty an array in JavaScript?

Is there a way to empty an array and if so possibly with .remove()? For instance, A = [1,2,3,4]; How can I empty that?
akano1
  • 38,208
  • 18
  • 49
  • 65
2195
votes
23 answers

How to recover a dropped stash in Git?

I frequently use git stash and git stash pop to save and restore changes in my working tree. Yesterday I had some changes in my working tree that I had stashed and popped, and then I made more changes to my working tree. I'd like to go back and…
Greg Hewgill
  • 890,778
  • 177
  • 1,125
  • 1,260
2195
votes
32 answers

Vim clear last search highlighting

After doing a search in Vim, I get all the occurrences highlighted. How can I disable that? I now do another search for something gibberish that can't be found. Is there a way to just temporarily disable the highlight and then re-enable it when…
Gabriel Solomon
  • 28,117
  • 15
  • 56
  • 78
2193
votes
17 answers

How to decide when to use Node.js?

I am new to this kind of stuff, but lately I've been hearing a lot about how good Node.js is. Considering how much I love working with jQuery and JavaScript in general, I can't help but wonder how to decide when to use Node.js. The web application I…
Legend
  • 109,064
  • 113
  • 265
  • 394
2193
votes
34 answers

How do you assert that a certain exception is thrown in JUnit 4 tests?

How can I use JUnit4 idiomatically to test that some code throws an exception? While I can certainly do something like this: @Test public void testFooThrowsIndexOutOfBoundsException() { boolean thrown = false; try { foo.doStuff(); } catch…
SCdF
  • 54,293
  • 24
  • 75
  • 111
2192
votes
27 answers

PostgreSQL: Show tables in PostgreSQL

What's the equivalent to show tables (from MySQL) in PostgreSQL?
flybywire
  • 247,088
  • 187
  • 391
  • 495
2192
votes
26 answers

What are valid values for the id attribute in HTML?

When creating the id attributes for HTML elements, what rules are there for the value?
Mr Shark
  • 25,144
  • 5
  • 30
  • 37
2191
votes
9 answers

How do I break a string in YAML over multiple lines?

In YAML, I have a string that's very long. I want to keep this within the 80-column (or so) view of my editor, so I'd like to break the string. What's the syntax for this? In other words, I have this: Key: 'this is my very very very very very very…
jjkparker
  • 23,945
  • 6
  • 27
  • 29
2189
votes
31 answers

JavaScript check if variable exists (is defined/initialized)

Which method of checking if a variable has been initialized is better/correct? (Assuming the variable could hold anything (string, int, object, function, etc.)) if (elem) { // or !elem or if (typeof elem !== 'undefined') { or if (elem != null) {
Samuel Liew
  • 72,637
  • 105
  • 156
  • 238