Most Popular

1500 questions
7395
votes
38 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
  • 96,212
  • 12
  • 54
  • 76
7328
votes
55 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
  • 73,987
  • 14
  • 40
  • 69
7262
votes
25 answers

What are metaclasses in Python?

What are metaclasses? What are they used for?
Bite code
  • 578,959
  • 113
  • 301
  • 329
7012
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
  • 77,143
  • 9
  • 27
  • 19
6790
votes
43 answers

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 dictionaries, only the value y[k] should be kept.
Carl Meyer
  • 122,012
  • 20
  • 106
  • 116
6623
votes
42 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
  • 795,719
  • 175
  • 1,089
  • 1,143
6402
votes
22 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
  • 82,413
  • 11
  • 44
  • 46
6334
votes
32 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?
6265
votes
42 answers

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 as a new subordinate of the resource identified by…
alex
  • 74,215
  • 9
  • 49
  • 57
6246
votes
71 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
  • 94,115
  • 39
  • 120
  • 184
6164
votes
40 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.
  • 108,298
  • 33
  • 122
  • 127
6156
votes
41 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
  • 343,444
  • 107
  • 203
  • 205
6134
votes
75 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
  • 74,485
  • 42
  • 169
  • 190
6041
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
6037
votes
34 answers

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 URI of "origin" in the settings of "local" so it will now…
Bite code
  • 578,959
  • 113
  • 301
  • 329