Most Popular

1500 questions
27072
votes
25 answers

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

In this C++ code, sorting the data (before the timed region) makes the primary loop ~6x faster: #include #include #include int main() { // Generate data const unsigned arraySize = 32768; int…
GManNickG
  • 494,350
  • 52
  • 494
  • 543
25854
votes
105 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
  • 49,047
  • 44
  • 147
  • 241
20257
votes
41 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
  • 457,139
  • 39
  • 126
  • 163
13671
votes
37 answers

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

What are the differences between git pull and git fetch?
Pablo Fernandez
  • 279,434
  • 135
  • 377
  • 622
12706
votes
50 answers

What does the "yield" keyword do in Python?

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.
  • 143,260
  • 19
  • 55
  • 62
11614
votes
150 answers

How can I remove a specific item from an array in JavaScript?

How do I remove a specific value from an array? Something like: array.remove(value); Constraints: I have to use core JavaScript. Frameworks are not allowed.
Walker
  • 128,495
  • 27
  • 68
  • 94
11461
votes
39 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
  • 235,628
  • 64
  • 220
  • 299
11359
votes
39 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
  • 122,703
  • 20
  • 73
  • 107
11151
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?
oz10
  • 153,307
  • 27
  • 93
  • 128
10074
votes
28 answers

What is the '-->' operator in C/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. I would assume this is also valid C since it…
GManNickG
  • 494,350
  • 52
  • 494
  • 543
9414
votes
52 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
  • 99,267
  • 11
  • 41
  • 53
9409
votes
59 answers

Can comments be used in JSON?

Can I use comments inside a JSON file? If so, how?
Michael Gundlach
  • 106,555
  • 11
  • 37
  • 41
9302
votes
31 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?
8678
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
  • 86,427
  • 15
  • 75
  • 107
8613
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
  • 129,733
  • 38
  • 88
  • 97
1
2 3
99 100