All Questions

26559 votes
27 answers
1.7m views

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 &...
user avatar
  • 482k
24653 votes
100 answers
11.5m views

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?
19447 votes
41 answers
10.2m views

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....
user avatar
13313 votes
38 answers
3.2m views

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

What are the differences between git pull and git fetch?
user avatar
  • 270k
12196 votes
48 answers
3.0m views

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 ...
user avatar
  • 138k
11240 votes
38 answers
3.5m views

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 ...
user avatar
  • 230k
10854 votes
136 answers
10.3m views

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.
user avatar
  • 120k
10654 votes
38 answers
4.4m views

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 ...
user avatar
  • 116k
10625 votes
37 answers
4.5m views

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?
user avatar
  • 146k
9815 votes
28 answers
931k views

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. ...
9084 votes
30 answers
1.8m views

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 ...
user avatar
  • 90.9k
9046 votes
57 answers
3.2m views

Can comments be used in JSON?

Can I use comments inside a JSON file? If so, how?
user avatar
8845 votes
50 answers
6.9m views

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 ...
user avatar
8479 votes
10 answers
716k views

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: <body bgcolor="chucknorris"> ...
user avatar
8428 votes
65 answers
3.0m views

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?
user avatar

15 30 50 per page
1
2 3 4 5
1527662