Most Popular
1500 questions
7138
votes
35 answers
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 regex to end up with the following myObject?
let myObject = {
"ircEvent": "PRIVMSG",
"method": "newURI"
};

johnstok
- 93,232
- 12
- 53
- 76
6956
votes
24 answers
What are metaclasses in Python?
What are metaclasses? What are they used for?

e-satis
- 559,793
- 108
- 291
- 328
6894
votes
53 answers
How to find all files containing specific text (string) on Linux
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 'text-to-find-here' {} \;

Nathan
- 71,603
- 13
- 37
- 57
6759
votes
40 answers
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?

spence91
- 74,289
- 8
- 27
- 19
6456
votes
43 answers
How do I merge two dictionaries in a single expression?
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 dictionaries, only the value y[k] should be kept.

Carl Meyer
- 117,074
- 19
- 104
- 114
6442
votes
43 answers
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 inside the function and returning that one, but none…

Felix Kling
- 768,774
- 171
- 1,068
- 1,114
6251
votes
33 answers
What is the difference between px, dip, dp, and sp?
What is the difference between the units of measure
px, dip, dp, and sp?

capecrawler
- 66,473
- 7
- 30
- 34
6101
votes
21 answers
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
/
master A - B

Mark A. Nicolosi
- 79,163
- 10
- 43
- 46
6081
votes
40 answers
What is the difference between POST and PUT in HTTP?
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 as a new subordinate of the resource identified by the Request-URI in the…

alex
- 72,129
- 9
- 49
- 57
6067
votes
68 answers
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?

Alec Smart
- 91,436
- 38
- 118
- 181
5915
votes
45 answers
How to disable text selection highlighting
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 highlighting effect if the user accidentally selects the…
anon
5908
votes
39 answers
What is the difference between "let" and "var"?
ECMAScript 6 introduced the let statement.
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 differences? When should let be used instead of var?

TM.
- 104,642
- 30
- 122
- 128
5867
votes
39 answers
How do I discard unstaged changes in Git?
How do I discard changes in my working copy that are not in the index?

readonly
- 331,320
- 107
- 203
- 204
5843
votes
74 answers
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 to the one where the Bash script is located, so I…

Jiaaro
- 72,127
- 41
- 165
- 189
5790
votes
64 answers
How do I execute a program or call a system command?
How do I call an external command within Python as if I'd typed it in a shell or command prompt?

freshWoWer
- 59,629
- 10
- 35
- 34