All Questions

Filter by
Sorted by
Tagged with
25143
votes
26answers
1.6m 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 miraculously makes the code almost six times faster: #include <algorithm> #include &...
22034
votes
88answers
9.1m 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 can I undo those commits from the local repository?
17542
votes
39answers
8.5m views

How do I delete a Git branch locally and remotely?

I want to delete a branch both 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 ...
12283
votes
38answers
2.9m views

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

What are the differences between git pull and git fetch?
10780
votes
42answers
2.4m views

What does the “yield” keyword do?

What is the use of the yield keyword in Python, and 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....
10532
votes
36answers
3.0m views

What is the correct JSON content type?

I've been messing around with JSON for some time, just pushing it out as text and it hasn't hurt anybody (that I know of), but I'd like to start doing things properly. I have seen so many purported "...
9436
votes
37answers
3.4m 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. Is there a way to undo this, so these files won't be included in the commit?
9244
votes
24answers
830k 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. ...
9032
votes
34answers
3.2m views

How do I rename a local Git branch?

I don't want to rename a remote branch, as described in Rename master branch for both local and remote Git repositories. How can I rename a local branch which hasn't been pushed to a remote branch? ...
8934
votes
101answers
7.5m views

How can I remove a specific item from an array?

I have an array of numbers and I'm using the .push() method to add elements to it. Is there a simple way to remove a specific element from an array? I'm looking for the equivalent of something like: ...
8349
votes
29answers
1.6m views

What and where are the stack and heap?

Programming language books explain that value types are created on the stack, and reference types are created on the heap, without explaining what these two things are. I haven't read a clear ...
7996
votes
54answers
2.5m views

Can comments be used in JSON?

Can I use comments inside a JSON file? If so, how?
7972
votes
59answers
2.8m views

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

Is it possible to toggle the visibility of an element, using the functions .hide(), .show() or .toggle()? How would you test if an element is visible or hidden?
7879
votes
9answers
619k views

Why does HTML think “chucknorris” is a color?

How come certain random strings produce colors when entered as background colors in HTML? For example: <body bgcolor="chucknorris"> test </body> ...produces a document with a red ...
7727
votes
28answers
1.1m views

What does “use strict” do in JavaScript, and what is the reasoning behind it?

Recently, I ran some of my JavaScript code through Crockford's JSLint, and it gave the following error: Problem at line 1 character 1: Missing "use strict" statement. Doing some searching, I ...

15 30 50 per page
1
2 3 4 5
1373583