Highest scored questions

Filter by
Sorted by
Tagged with
27496 votes
25 answers
2.0m views

In this C++ code, sorting the data (before the timed region) makes the primary loop ~6x faster: #include <algorithm> #include <ctime> #include <iostream> int main() { // ...
GManNickG's user avatar
  • 506k
27140 votes
104 answers
16.4m views

I accidentally committed the wrong files to Git but haven't pushed the commit to the server yet. How do I undo those commits from the local repository?
20362 votes
41 answers
13.2m views

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....
14020 votes
37 answers
3.7m views

What are the differences between git pull and git fetch?
Pablo Fernandez's user avatar
13112 votes
50 answers
3.5m views

What functionality does the yield keyword in Python provide? For example, I'm trying to understand this code1: def _get_child_candidates(self, distance, min_dist, max_dist): if self._leftchild and ...
Alex. S.'s user avatar
  • 148k
12224 votes
51 answers
13.5m views

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's user avatar
  • 135k
11984 votes
41 answers
6.3m views

How can 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 ...
Forrest's user avatar
  • 129k
11653 votes
40 answers
4.0m views

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 ...
Oli's user avatar
  • 241k
11582 votes
39 answers
6.3m views

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's user avatar
  • 159k
10243 votes
26 answers
1.0m views

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. ...
9939 votes
55 answers
9.5m views

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 ...
Jakub Troszok's user avatar
9768 votes
64 answers
4.0m views

Can I use comments inside a JSON file? If so, how?
Michael Gundlach's user avatar
9560 votes
30 answers
2.0m views

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 ...
mattshane's user avatar
  • 95.6k
8938 votes
9 answers
802k views

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"> ...
user456584's user avatar
  • 89.3k
8866 votes
47 answers
9.5m views

How do I check out the remote test branch? I can see it with git branch -r. I tried: git checkout test, which does nothing git checkout origin/test gives * (no branch)
Juri Glass's user avatar
  • 92.2k
8739 votes
67 answers
3.3m views

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's user avatar
8586 votes
37 answers
2.7m views

I put a file that was previously being tracked by Git onto the .gitignore list. However, the file still shows up in git status after it is edited. How do I force Git to completely forget the file?
Ivan's user avatar
  • 105k
8540 votes
32 answers
1.2m views

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, ...
Mark Rogers's user avatar
  • 97.9k
8407 votes
40 answers
5.0m views

What does this do, and why should one include the if statement? if __name__ == "__main__": print("Hello, World!") If you are trying to close a question where someone should be ...
Devoted's user avatar
  • 185k
8370 votes
43 answers
3.7m views

How do I delete untracked local files from the current working tree?
readonly's user avatar
  • 358k
8107 votes
32 answers
3.1m views

Is there a ternary conditional operator in Python?
Devoted's user avatar
  • 185k
7743 votes
87 answers
2.8m views

I always thought Java uses pass-by-reference. However, I read a blog post which claims that Java uses pass-by-value. I don't think I understand the distinction the author is making. What is the ...
7706 votes
57 answers
12.1m views

How do I find all files containing a specific string of text within their file contents? The following doesn't work. It seems to display every single file in the system. find / -type f -exec grep -H '...
Nathan's user avatar
  • 79.4k
7694 votes
58 answers
8.1m views

How can I redirect the user from one page to another using jQuery or pure JavaScript?
venkatachalam's user avatar
7670 votes
42 answers
1.2m views

I've recently started maintaining someone else's JavaScript code. I'm fixing bugs, adding features and also trying to tidy up the code and make it more consistent. The previous developer used two ways ...
Richard Garside's user avatar
7640 votes
27 answers
4.3m views

I wrote the wrong thing in a commit message. How can I change the message? The commit has not been pushed yet.
Laurie Young's user avatar
7612 votes
11 answers
820k views

If I run the following program, which parses two date strings referencing times 1 second apart and compares them: public static void main(String[] args) throws ParseException { SimpleDateFormat sf ...
Freewind's user avatar
  • 199k
7610 votes
86 answers
1.6m views

How would you explain JavaScript closures to someone with a knowledge of the concepts they consist of (for example functions, variables and the like), but does not understand closures themselves? I ...
7607 votes
41 answers
12.7m views

How do I revert from my current state to a snapshot made on a certain commit? If I do git log, then I get the following output: $ git log commit a867b4af366350be2e7c21b8de9cc6504678a61b` Author: Me &...
Crazy Serb's user avatar
  • 76.3k
7595 votes
67 answers
1.4m views

What are the differences between these two, and which one should I use? string s = "Hello world!"; String s = "Hello world!";
7580 votes
40 answers
3.4m views

Given an object: let myObject = { "ircEvent": "PRIVMSG", "method": "newURI", "regex": "^http://.*" }; How do I remove the property ...
johnstok's user avatar
  • 98.5k
7516 votes
26 answers
1.2m views

What are metaclasses? What are they used for?
Bite code's user avatar
  • 600k
7403 votes
3 answers
8.3m views

Usually I would expect a String.contains() method, but there doesn't seem to be one. What is a reasonable way to check for this?
7323 votes
41 answers
6.0m views

How do I check whether a file exists or not, without using the try statement?
spence91's user avatar
  • 80.6k
7114 votes
45 answers
3.6m views

I want to merge two dictionaries into a new dictionary. x = {'a': 1, 'b': 2} y = {'b': 3, 'c': 4} z = merge(x, y) >>> z {'a': 1, 'b': 3, 'c': 4} Whenever a key k is present in both ...
Carl Meyer's user avatar
  • 127k
6851 votes
36 answers
5.3m views

I have a repo (origin) on a USB key that I cloned on my hard drive (local). I moved "origin" to a NAS and successfully tested cloning it from here. I would like to know if I can change the ...
Bite code's user avatar
  • 600k
6752 votes
26 answers
2.0m views

How do I move my recent commits on master to a new branch, and reset master to before those commits were made? e.g. From this: master A - B - C - D - E To this: newbranch C - D - E / ...
Mark A. Nicolosi's user avatar
6742 votes
44 answers
2.2m views

How do I return the response/result from a function foo that makes an asynchronous request? I am trying to return the value from the callback, as well as assigning the result to a local variable ...
Felix Kling's user avatar
6459 votes
41 answers
4.6m views

How do I discard changes in my working copy that are not in the index?
readonly's user avatar
  • 358k
6458 votes
42 answers
3.7m views

Background Information Analysis: According to RFC 2616, § 9.5, POST is used to create a resource: The POST method is used to request that the origin server accept the entity enclosed in the request ...
alex's user avatar
  • 76.4k
6430 votes
35 answers
1.5m views

What is the difference between the units of measure px, dip, dp, and sp?
capecrawler's user avatar
  • 68.3k
6396 votes
82 answers
2.8m views

How do I get the path of the directory in which a Bash script is located, inside that script? I want to use a Bash script as a launcher for another application. I want to change the working directory ...
6394 votes
38 answers
2.4m views

ECMAScript 6 introduced the let declaration keyword. I've heard that it's described as a local variable, but I'm still not quite sure how it behaves differently than the var keyword. What are the ...
TM.'s user avatar
  • 112k
6380 votes
72 answers
4.5m views

How do I include a JavaScript file inside another JavaScript file, similar to @import in CSS?
Alec Smart's user avatar
  • 96.2k
6276 votes
66 answers
5.2m views

How do I call an external command within Python as if I had typed it in a shell or command prompt?
freshWoWer's user avatar
  • 64.6k
6167 votes
46 answers
2.8m views

For anchors that act like buttons (for example, the buttons on the sidebar of this Stack Overflow page titled Questions, Tags, and Users) or tabs, is there a CSS standard way to disable the ...
user avatar
5970 votes
27 answers
7.2m views

How do I reset my local branch to be just like the branch on the remote repository? I tried: git reset --hard HEAD But git status claims I have modified files: On branch master Changes to be ...
hap497's user avatar
  • 165k
5885 votes
37 answers
3.3m views

How can I revert a modified file to its previous revision at a specific commit hash (which I determined via git log and git diff)?
Hates_'s user avatar
  • 69.3k
5836 votes
19 answers
1.8m views

What is the maximum length of a URL for each browser? Is a maximum URL length part of the HTTP specification?
Sander Versluys's user avatar
5832 votes
21 answers
6.8m views

How do I: Create a local branch from another branch (via git branch or git checkout -b). Push the local branch to the remote repository (i.e. publish), but make it trackable so that git pull and git ...
Roni Yaniv's user avatar
  • 60.6k

15 30 50 per page
1
2 3 4 5
483790