Most Popular
1500 questions
1004
votes
42 answers
How to validate phone numbers using regex
I'm trying to put together a comprehensive regex to validate phone numbers. Ideally it would handle international formats, but it must handle US formats, including the following:
1-234-567-8901
1-234-567-8901 x1234
1-234-567-8901 ext1234
1 (234)…

Nicholas Trandem
- 2,805
- 5
- 29
- 32
1003
votes
20 answers
How do I remove/delete a folder that is not empty?
I am getting an 'access is denied' error when I attempt to delete a folder that is not empty. I used the following command in my attempt: os.remove("/folder_name").
What is the most effective way of removing/deleting a folder/directory that is not…

Amara
- 12,813
- 9
- 31
- 26
1003
votes
54 answers
Find the min/max element of an array in JavaScript
How can I easily obtain the min or max element of a JavaScript array?
Example pseudocode:
let array = [100, 0, 50]
array.min() //=> 0
array.max() //=> 100

HankH
- 10,073
- 4
- 16
- 4
1003
votes
9 answers
How to find time complexity of an algorithm?
I have gone through Google and Stack Overflow search, but nowhere I was able to find a clear and straightforward explanation for how to calculate time complexity
What do I know already?
Say for a code as simple as the one below:
char h = 'y'; //…

Yasser Shaikh
- 45,188
- 44
- 194
- 274
1002
votes
33 answers
Converting from a string to boolean in Python?
Does anyone know how to do convert from a string to a boolean in Python? I found this link. But it doesn't look like a proper way to do it. I.e. using built-in functionality, etc.
The reason I'm asking this is because I learned about int("string")…

Joan Venge
- 287,345
- 204
- 453
- 665
1002
votes
1 answer
What are the new features in C++17?
C++17 is now feature complete, so unlikely to experience large changes. Hundreds of proposals were put forward for C++17.
Which of those features were added to C++ in C++17?
When using a C++ compiler that supports "C++1z", which of those features…

Yakk - Adam Nevraumont
- 248,063
- 26
- 299
- 489
1002
votes
19 answers
What's the difference between a POST and a PUT HTTP REQUEST?
They both seem to be sending data to the server inside the body, so what makes them different?

fuentesjr
- 47,840
- 27
- 73
- 80
1001
votes
27 answers
How to detect Safari, Chrome, IE, Firefox and Opera browser?
I have 5 addons/extensions for FF, Chrome, IE, Opera, and Safari.
How can I recognize the user browser and redirect (once an install button has been clicked) to download the corresponding addon?

FrankC
- 10,405
- 4
- 14
- 19
1001
votes
19 answers
Why is setTimeout(fn, 0) sometimes useful?
I've recently run into a rather nasty bug, wherein the code was loading a

Dan Lew
- 83,187
- 29
- 180
- 174
1001
votes
39 answers
Error: Can't set headers after they are sent to the client
I'm fairly new to Node.js and I am having some issues.
I am using Node.js 4.10 and Express 2.4.3.
When I try to access http://127.0.0.1:8888/auth/facebook, i'll be redirected to http://127.0.0.1:8888/auth/facebook_callback.
I then received the…

DjangoRocks
- 11,858
- 7
- 35
- 52
1001
votes
14 answers
List comprehension vs. lambda + filter
I happened to find myself having a basic filtering need: I have a list and I have to filter it by an attribute of the items.
My code looked like this:
my_list = [x for x in my_list if x.attribute == value]
But then I thought, wouldn't it be better…

Agos
- 17,427
- 10
- 52
- 68
1001
votes
31 answers
Git push error '[remote rejected] master -> master (branch is currently checked out)'
Yesterday, I posted a question on how to clone a Git repository from one of my machines to another, How can I 'git clone' from another machine?.
I am now able to successfully clone a Git repository from my source (192.168.1.2) to my destination…

hap497
- 139,035
- 43
- 78
- 92
1001
votes
26 answers
How to download a file over HTTP?
I have a small utility that I use to download an MP3 file from a website on a schedule and then builds/updates a podcast XML file which I've added to iTunes.
The text processing that creates/updates the XML file is written in Python. However, I use…

Owen
- 20,737
- 13
- 39
- 47
1000
votes
1 answer
Escape curly brace '{' in String.Format
How do I display a literal curly brace character when using the String.Format method?
Example:
sb.AppendLine(String.Format("public {0} {1} { get; private set; }",
prop.Type, prop.Name));
I would like the output to look like this:
public Int32…

PhilB
- 11,233
- 2
- 18
- 14
1000
votes
6 answers
Definition of "downstream" and "upstream"
I've started playing with Git and have come across the terms "upstream" and "downstream". I've seen these before but never understood them fully. What do these terms mean in the context of SCMs (Software Configuration Management tools) and source…

brendan
- 11,343
- 3
- 24
- 25