Most Popular
1500 questions
3784
votes
54 answers
3760
votes
6 answers
Catch multiple exceptions in one line (except block)
I know that I can do:
try:
# do something that may fail
except:
# do this if ANYTHING goes wrong
I can also do this:
try:
# do something that may fail
except IDontLikeYouException:
# say please
except YouAreTooShortException:
#…

inspectorG4dget
- 110,290
- 27
- 149
- 241
3748
votes
7 answers
Iterate through a HashMap
What's the best way to iterate over the items in a HashMap?

burntsugar
- 57,360
- 21
- 58
- 81
3723
votes
31 answers
How do I POST JSON data with cURL?
I use Ubuntu and installed cURL on it. I want to test my Spring REST application with cURL. I wrote my POST code at the Java side. However, I want to test it with cURL. I am trying to post a JSON data. Example data is like…

kamaci
- 72,915
- 69
- 228
- 366
3704
votes
61 answers
How can I create a memory leak in Java?
I just had an interview where I was asked to create a memory leak with Java.
Needless to say, I felt pretty dumb, having no idea how to start creating one.
What would an example be?

MatBanik
- 26,356
- 39
- 116
- 178
3702
votes
21 answers
3701
votes
81 answers
How do I correctly clone a JavaScript object?
I have an object x. I'd like to copy it as object y, such that changes to y do not modify x. I realized that copying objects derived from built-in JavaScript objects will result in extra, unwanted properties. This isn't a problem, since I'm copying…

soundly_typed
- 39,257
- 5
- 28
- 36
3696
votes
32 answers
How do I stash only one file out of multiple files that have changed?
How do I stash only one of the multiple changed files on my branch?

Rachel
- 100,387
- 116
- 269
- 365
3694
votes
26 answers
Get the current URL with JavaScript?
All I want is to get the website URL. Not the URL as taken from a link. On the page loading I need to be able to grab the full, current URL of the website and set it as a variable to do with as I please.
dougoftheabaci
3680
votes
24 answers
Convert bytes to a string in Python 3
I captured the standard output of an external program into a bytes object:
>>> from subprocess import *
>>> stdout = Popen(['ls', '-l'], stdout=PIPE).communicate()[0]
>>> stdout
b'total 0\n-rw-rw-r-- 1 thomas thomas 0 Mar 3 07:03 file1\n-rw-rw-r--…

Tomas Sedovic
- 42,675
- 9
- 40
- 30
3676
votes
25 answers
How do I create a remote Git branch?
I created a local branch. How do I push it to the remote server?
UPDATE: I have written a simpler answer for Git 2.0 here.

Jesper Rønn-Jensen
- 106,591
- 44
- 118
- 155
3671
votes
19 answers
Set cellpadding and cellspacing in CSS?
In an HTML table, the cellpadding and cellspacing can be set like this:
How can the same be accomplished using CSS?