Most Popular
1500 questions
3020
votes
9 answers
How do I see the differences between two branches?
How do I see the differences between branches branch_1 and branch_2?
isuruanu
- 30,273
- 3
- 14
- 4
3020
votes
25 answers
Deleting an element from an array in PHP
Is there an easy way to delete an element from an array using PHP, such that foreach ($array) no longer includes that element?
I thought that setting it to null would do it, but apparently it does not work.
Ben
- 66,838
- 37
- 84
- 108
3001
votes
14 answers
What is the --save option for npm install?
I saw some tutorial where the command was:
npm install --save
What does the --save option mean?
Dmitri
- 34,780
- 9
- 39
- 55
3000
votes
41 answers
How do I pass command line arguments to a Node.js program and receive them?
I have a web server written in Node.js and I would like to launch with a specific folder. I'm not sure how to access arguments in JavaScript. I'm running node like this:
$ node server.js folder
here server.js is my server code. Node.js help says…
milkplus
- 33,007
- 7
- 30
- 31
2999
votes
33 answers
Using async/await with a forEach loop
Are there any issues with using async/await in a forEach loop? I'm trying to loop through an array of files and await on the contents of each file.
import fs from 'fs-promise'
async function printFiles () {
const files = await getFilePaths() //…
Saad
- 49,729
- 21
- 73
- 112
2995
votes
44 answers
Length of a JavaScript object
I have a JavaScript object. Is there a built-in or accepted best practice way to get the length of this object?
const myObject = new Object();
myObject["firstname"] = "Gareth";
myObject["lastname"] = "Simpson";
myObject["age"] = 21;
Gareth Simpson
- 36,943
- 12
- 47
- 50
2981
votes
20 answers
How do I clone a Git repository into a specific folder?
The command git clone git@github.com:whatever creates a directory named whatever containing a Git repository:
./
whatever/
.git
I want the contents of the Git repository cloned into my current directory ./ instead:
./
.git
David Smith
- 38,044
- 11
- 44
- 61
2981
votes
27 answers
How to change the commit author for a single commit?
I want to change the author of one specific commit in the history. It's not the latest commit.
Related: How do I change the author and committer name/email for multiple commits?
MicTech
- 42,457
- 14
- 62
- 79
2978
votes
21 answers
How do I modify the URL without reloading the page?
Is there a way I can modify the URL of the current page without reloading the page?
I would like to access the portion before the # hash if possible.
I only need to change the portion after the domain, so it's not like I'm violating cross-domain…
Robin Rodricks
- 110,798
- 141
- 398
- 607
2977
votes
16 answers
What is the difference between the 'COPY' and 'ADD' commands in a Dockerfile?
What is the difference between the COPY and ADD commands in a Dockerfile, and when would I use one over the other?
COPY
The COPY instruction will copy new files from and add them to the container's filesystem at path
ADD…
Steve
- 53,375
- 33
- 96
- 141
2977
votes
3 answers
Why is printing "B" dramatically slower than printing "#"?
I generated two matrices of 1000 x 1000:
First Matrix: O and #.
Second Matrix: O and B.
Using the following code, the first matrix took 8.52 seconds to complete:
Random r = new Random();
for (int i = 0; i < 1000; i++) {
for (int j = 0; j < 1000;…
Kuba Spatny
- 26,618
- 9
- 40
- 63
2975
votes
61 answers
How do I get the current date in JavaScript?
How do I get the current date in JavaScript?
Suresh
- 38,717
- 16
- 62
- 66
2974
votes
41 answers
How do I change the author and committer name/email for multiple commits?
How do I change the author for a range of commits?
Flávio Amieiro
- 41,644
- 8
- 32
- 24
2964
votes
12 answers
Why is "1000000000000000 in range(1000000000000001)" so fast in Python 3?
It is my understanding that the range() function, which is actually an object type in Python 3, generates its contents on the fly, similar to a generator.
This being the case, I would have expected the following line to take an inordinate amount of…
Rick
- 43,029
- 15
- 76
- 119
2934
votes
13 answers
Find the current directory and file's directory
How do I determine:
the current directory (where I was in the shell when I ran the Python script), and
where the Python file I am executing is?
John Howard
- 61,037
- 23
- 50
- 66