Most Popular
1500 questions
7023
votes
33 answers
How do I remove a property from a JavaScript object?
Say I create an object as follows:
let myObject = {
"ircEvent": "PRIVMSG",
"method": "newURI",
"regex": "^http://.*"
};
How should I remove the property regex to end up with new myObject as follows?
let myObject = {
"ircEvent": "PRIVMSG",
…
johnstok
- 91,872
- 12
- 52
- 76
6790
votes
24 answers
What are metaclasses in Python?
What are metaclasses? What are they used for?
e-satis
- 551,433
- 107
- 289
- 326
6712
votes
54 answers
How do I find all files containing specific text on Linux?
I'm trying to find a way to scan my entire Linux system for all files containing a specific string of text. Just to clarify, I'm looking for text within the file, not in the file name.
When I was looking up how to do this, I came across this…
Nathan
- 73,640
- 12
- 33
- 52
6640
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
- 73,009
- 8
- 26
- 19
6363
votes
43 answers
How to return the response from an asynchronous call
I have a function foo which makes an asynchronous request. How can I return the response/result from foo?
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…
Felix Kling
- 756,363
- 169
- 1,062
- 1,111
6286
votes
48 answers
How do I merge two dictionaries in a single expression (take union of dictionaries)?
I want to merge two dictionaries into a new dictionary.
x = {'a': 1, 'b': 2}
y = {'b': 10, 'c': 11}
z = merge(x, y)
>>> z
{'a': 1, 'b': 10, 'c': 11}
Using x.update(y) modifies x in-place instead of creating a new dictionary. I also want the…
Carl Meyer
- 114,562
- 19
- 103
- 114
6212
votes
35 answers
What is the difference between "px", "dip", "dp" and "sp"?
What is the difference between these Android units of measure?
px
dip
dp
sp
capecrawler
- 66,075
- 7
- 30
- 34
5992
votes
39 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
- 71,149
- 9
- 48
- 57
5972
votes
68 answers
How do I include a JavaScript file in another JavaScript file?
Is there something in JavaScript similar to @import in CSS that allows you to include a JavaScript file inside another JavaScript file?
Alec Smart
- 90,128
- 37
- 118
- 180
5963
votes
21 answers
Move the most recent commit(s) to a new branch with Git
I'd like to move the last several commits I've committed to master to a new branch and take master back to before those commits were made. Unfortunately, my Git-fu is not strong enough yet, any help?
I.e. How can I go from this
master A - B - C - D…
Mark A. Nicolosi
- 77,725
- 10
- 43
- 46
5830
votes
50 answers
How to disable text selection highlighting
For anchors that act like buttons (for example Questions, Tags, Users, etc. which are located on the top of the Stack Overflow page) or tabs, is there a CSS standard way to disable the highlighting effect if the user accidentally selects the text?
I…
anon
5767
votes
37 answers
What's the difference between using "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.
- 102,836
- 30
- 121
- 127
5738
votes
74 answers
How can I get the source directory of a Bash script 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
- 71,020
- 40
- 161
- 188
5730
votes
37 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
- 326,166
- 107
- 202
- 204
5689
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
- 58,579
- 10
- 34
- 33