Most Popular
1500 questions
2587
votes
32 answers
Scroll to an element with jQuery
I have this input element:
Then I have some other elements, like other text inputs, textareas, etc.
When the user clicks on that input with #subject, the page should scroll…
DiegoP.
- 43,947
- 34
- 88
- 105
2581
votes
17 answers
What's the difference between dependencies, devDependencies and peerDependencies in npm package.json file?
This documentation answers my question very poorly. I didn't understand those explanations. Can someone say in simpler words? Maybe with examples if it's hard to choose simple words?
EDIT also added peerDependencies, which is closely related and…
Vitalii Korsakov
- 42,460
- 19
- 70
- 88
2580
votes
18 answers
How can I recursively find all files in current and subfolders based on wildcard matching?
How can I recursively find all files in current and subfolders based on wildcard matching?
john
- 30,030
- 12
- 43
- 60
2577
votes
32 answers
Homebrew install specific version of formula?
How do I install a specific version of a formula in homebrew? For example, postgresql-8.4.4 instead of the latest 9.0.
Gravis
- 27,951
- 5
- 22
- 20
2574
votes
22 answers
How do I get the last element of a list?
How do I get the last element of a list?
Janusz
- 182,484
- 112
- 300
- 368
2570
votes
29 answers
Set a default parameter value for a JavaScript function
I would like a JavaScript function to have optional arguments which I set a default on, which get used if the value isn't defined (and ignored if the value is passed). In Ruby you can do it like this:
def read_file(file, delete_after = false)
#…
Tilendor
- 46,925
- 16
- 49
- 58
2564
votes
34 answers
How do I split a string on a delimiter in Bash?
I have this string stored in a variable:
IN="bla@some.com;john@home.com"
Now I would like to split the strings by ; delimiter so that I have:
ADDR1="bla@some.com"
ADDR2="john@home.com"
I don't necessarily need the ADDR1 and ADDR2 variables. If…
stefanB
- 73,317
- 26
- 115
- 141
2564
votes
36 answers
From inside of a Docker container, how do I connect to the localhost of the machine?
So I have a Nginx running inside a docker container, I have a mysql running on the host system, I want to connect to the MySql from within my container. MySql is only binding to the localhost device.
Is there any way to connect to this MySql or any…
Phil
- 39,334
- 32
- 103
- 162
2560
votes
29 answers
How do I determine whether an array contains a particular value in Java?
I have a String[] with values like so:
public static final String[] VALUES = new String[] {"AB","BC","CD","AE"};
Given String s, is there a good way of testing whether VALUES contains s?
Mike Sickler
- 32,166
- 19
- 61
- 89
2556
votes
32 answers
Renaming column names in Pandas
How do I change the column labels of a pandas DataFrame from:
['$a', '$b', '$c', '$d', '$e']
to
['a', 'b', 'c', 'd', 'e'].
user1504276
- 25,655
- 3
- 13
- 7
2553
votes
16 answers
How can I remove a key from a Python dictionary?
Is there a one-line way of deleting a key from a dictionary without raising a KeyError?
if 'key' in my_dict:
del my_dict['key']
Tony
- 34,025
- 9
- 47
- 82
2551
votes
38 answers
Extract filename and extension in Bash
I want to get the filename (without extension) and the extension separately.
The best solution I found so far is:
NAME=`echo "$FILE" | cut -d'.' -f1`
EXTENSION=`echo "$FILE" | cut -d'.' -f2`
This is wrong because it doesn't work if the file name…
ibz
- 41,253
- 24
- 67
- 84
2542
votes
23 answers
How do I call one constructor from another in Java?
Is it possible to call a constructor from another (within the same class, not from a subclass)? If yes how? And what could be the best way to call another constructor (if there are several ways to do it)?
ashokgelal
- 77,504
- 26
- 70
- 83
2538
votes
16 answers
How to mkdir only if a directory does not already exist?
I am writing a shell script to run under the KornShell (ksh) on AIX. I would like to use the mkdir command to create a directory. But the directory may already exist, in which case I do not want to do anything. So I want to either test to see that…
Spike Williams
- 32,747
- 13
- 45
- 59
2528
votes
31 answers
What does O(log n) mean exactly?
I am learning about Big O Notation running times and amortized times. I understand the notion of O(n) linear time, meaning that the size of the input affects the growth of the algorithm proportionally...and the same goes for, for example, quadratic…
Andreas Grech
- 102,667
- 98
- 290
- 358