Most Popular

1500 questions
1819
votes
15 answers

When looking at most sites (including SO), most of them use: instead of: What are the main differences between the two, if any? Are there valid reasons to use one instead of the other? Are there valid…
Aron Rotteveel
  • 77,970
  • 17
  • 103
  • 128
1814
votes
39 answers

How to measure elapsed time in Python?

What I want is to start counting time somewhere in my code and then get the passed time, to measure the time it took to execute few function. I think I'm using the timeit module wrong, but the docs are just confusing for me. import timeit start =…
gilbert8
  • 18,173
  • 3
  • 13
  • 3
1814
votes
62 answers

Sort a Map by values

I am relatively new to Java, and often find that I need to sort a Map on the values. Since the values are not unique, I find myself converting the keySet into an array, and sorting that array through array sort with a custom comparator…
Abe
  • 2,463
  • 4
  • 19
  • 16
1813
votes
19 answers

Proper use of the IDisposable interface

I know from reading Microsoft documentation that the "primary" use of the IDisposable interface is to clean up unmanaged resources. To me, "unmanaged" means things like database connections, sockets, window handles, etc. But, I've seen code where…
cwick
  • 25,316
  • 12
  • 36
  • 40
1813
votes
34 answers

How can I set the default value for an HTML element below would cause the