Highest scored questions
24,158,475 questions
7586
votes
40
answers
3.4m
views
How do I remove a property from a JavaScript object?
Given an object:
let myObject = {
"ircEvent": "PRIVMSG",
"method": "newURI",
"regex": "^http://.*"
};
How do I remove the property ...
7530
votes
26
answers
1.3m
views
What are metaclasses in Python?
What are metaclasses? What are they used for?
7403
votes
3
answers
8.4m
views
How to check whether a string contains a substring in JavaScript?
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?
7347
votes
41
answers
6.1m
views
How do I check whether a file exists without exceptions?
How do I check whether a file exists or not, without using the try statement?
7126
votes
45
answers
3.7m
views
How do I merge two dictionaries in a single expression in Python?
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 ...
6902
votes
36
answers
5.4m
views
How do I change the URI (URL) for a remote Git repository?
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 ...
6771
votes
26
answers
2.0m
views
Move the most recent commit(s) to a new branch with Git
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
/
...
6744
votes
44
answers
2.2m
views
How do I return the response from an asynchronous call?
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 ...
6480
votes
41
answers
4.6m
views
How do I discard unstaged changes in Git?
How do I discard changes in my working copy that are not in the index?
6462
votes
42
answers
3.7m
views
What is the difference between POST and PUT in HTTP?
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 ...
6431
votes
35
answers
1.5m
views
What is the difference between px, dip, dp, and sp?
What is the difference between the units of measure
px, dip, dp, and sp?
6414
votes
82
answers
2.9m
views
How do I get the directory where a Bash script is located from within the script itself?
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 ...
6413
votes
38
answers
2.4m
views
What is the difference between "let" and "var"?
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 ...
6381
votes
72
answers
4.5m
views
How do I include a JavaScript file in another JavaScript file?
How do I include a JavaScript file inside another JavaScript file, similar to @import in CSS?
6293
votes
66
answers
5.2m
views
How do I execute a program or call a system command?
How do I call an external command within Python as if I had typed it in a shell or command prompt?