Most Popular

1500 questions
26621
votes
27 answers

Why is processing a sorted array faster than processing an unsorted array?

Here is a piece of C++ code that shows some very peculiar behavior. For some strange reason, sorting the data (before the timed region) miraculously makes the loop almost six times faster. #include #include #include…
GManNickG
  • 483,438
  • 51
  • 484
  • 539
24809
votes
100 answers

How do I undo the most recent local commits in Git?

I accidentally committed the wrong files to Git, but didn't push the commit to the server yet. How do I undo those commits from the local repository?
Hamza Yerlikaya
  • 48,537
  • 42
  • 142
  • 238
19556
votes
42 answers

How do I delete a Git branch locally and remotely?

Failed Attempts to Delete a Remote Branch: $ git branch -d remotes/origin/bugfix error: branch 'remotes/origin/bugfix' not found. $ git branch -d origin/bugfix error: branch 'origin/bugfix' not found. $ git branch -rd origin/bugfix Deleted remote…
Matthew Rankin
  • 439,004
  • 38
  • 121
  • 160
13368
votes
38 answers

What is the difference between 'git pull' and 'git fetch'?

What are the differences between git pull and git fetch?
pupeno
  • 271,514
  • 122
  • 354
  • 592
12259
votes
48 answers

What does the "yield" keyword do?

What is the use of the yield keyword in Python? What does it do? For example, I'm trying to understand this code1: def _get_child_candidates(self, distance, min_dist, max_dist): if self._leftchild and distance - max_dist < self._median: …
Alex. S.
  • 138,304
  • 19
  • 53
  • 61
11267
votes
38 answers

Which JSON content type do I use?

There are many "standards" for the JSON content type: application/json application/x-javascript text/javascript text/x-javascript text/x-json Which one do I use, and where? I assume security and browser support issues are a factor. Related: What…
Oli
  • 230,670
  • 62
  • 217
  • 294
10953
votes
137 answers

How can I remove a specific item from an array?

How do I remove a specific value from an array? Something like: array.remove(value); // removes all elements with value I have to use core JavaScript. Frameworks are not allowed.
Walker
  • 121,145
  • 26
  • 67
  • 94
10738
votes
38 answers

How do I rename a local Git branch?

How do I rename a local branch which has not yet been pushed to a remote repository? Related: Rename master branch for both local and remote Git repositories How do I rename both a Git local and remote branch name?
Forrest
  • 116,401
  • 20
  • 72
  • 107
10682
votes
38 answers

How do I undo 'git add' before commit?

I mistakenly added files to Git using the command: git add myfile.txt I have not yet run git commit. How do I undo this so that these changes will not be included in the commit?
paxos1977
  • 147,191
  • 27
  • 92
  • 126
9843
votes
29 answers

What is the "-->" operator in C++?

After reading Hidden Features and Dark Corners of C++/STL on comp.lang.c++.moderated, I was completely surprised that the following snippet compiled and worked in both Visual Studio 2008 and G++ 4.4. Here's the code: #include int main() { …
GManNickG
  • 483,438
  • 51
  • 484
  • 539
9106
votes
32 answers

What and where are the stack and heap?

What are the stack and heap? Where are they located physically in a computer's memory? To what extent are they controlled by the OS or language run-time? What is their scope? What determines their sizes? What makes one faster?
9088
votes
57 answers

Can comments be used in JSON?

Can I use comments inside a JSON file? If so, how?
Michael Gundlach
  • 102,914
  • 11
  • 36
  • 39
8913
votes
47 answers

How do I force "git pull" to overwrite local files?

How do I force an overwrite of local files on a git pull? My local repository contains a file of the same filename as on the server. error: Untracked working tree file 'example.txt' would be overwritten by merge
Jakub Troszok
  • 94,151
  • 10
  • 39
  • 52
8506
votes
9 answers

Why does HTML think “chucknorris” is a color?

Why do certain random strings produce colors when entered as background colors in HTML? For example, bgcolor="chucknorris" produces a red background: test Conversely, bgcolor="chucknorr" produces a yellow…
user456584
  • 84,369
  • 15
  • 75
  • 107
8447
votes
65 answers

How do I check if an element is hidden in jQuery?

How do I toggle the visibility of an element using .hide(), .show(), or .toggle()? How do I test if an element is visible or hidden?
Philip Morton
  • 126,957
  • 37
  • 88
  • 97
1
2 3
99 100