Most Popular
1500 questions
1706
votes
32 answers
How can I Remove .DS_Store files from a Git repository?
How can I remove those annoying Mac OS X .DS_Store files from a Git repository?
John Topley
- 113,588
- 46
- 195
- 237
1705
votes
39 answers
How do I get time of a Python program's execution?
I have a command line program in Python that takes a while to finish. I want to know the exact time it takes to finish running.
I've looked at the timeit module, but it seems it's only for small snippets of code. I want to time the whole program.
john2x
- 22,546
- 16
- 57
- 95
1704
votes
42 answers
How do I debug Node.js applications?
How do I debug a Node.js server application?
Right now I'm mostly using alert debugging with print statements like this:
sys.puts(sys.inspect(someVariable));
There must be a better way to debug. I know that Google Chrome has a command-line…
Fabian Jakobs
- 28,815
- 8
- 42
- 39
1703
votes
43 answers
How can I replace each newline (\n) with a space using sed?
How can I replace a newline ("\n") with a space ("") using the sed command?
I unsuccessfully tried:
sed 's#\n# #g' file
sed 's#^$# #g' file
How do I fix it?
hhh
- 50,788
- 62
- 179
- 282
1700
votes
32 answers
How can I convert a stack trace to a string?
What is the easiest way to convert the result of Throwable.getStackTrace() to a string that depicts the stacktrace?
ripper234
- 222,824
- 274
- 634
- 905
1700
votes
24 answers
Selecting multiple columns in a Pandas dataframe
How do I select columns a and b from df, and save them into a new dataframe df1?
index a b c
1 2 3 4
2 3 4 5
Unsuccessful attempt:
df1 = df['a':'b']
df1 = df.ix[:, 'a':'b']
user1234440
- 22,521
- 18
- 61
- 103
1699
votes
21 answers
How do I revert a merge commit that has already been pushed to remote?
git revert alone won't work. Apparently, -m must be specified.
Yaz
- 17,126
- 3
- 16
- 11
1695
votes
16 answers
How do I write JSON data to a file?
How do I write JSON data stored in the dictionary data to a file?
f = open('data.json', 'wb')
f.write(data)
This gives the error:
TypeError: must be string or buffer, not dict
user1530318
- 25,507
- 15
- 37
- 48
1694
votes
28 answers
Why not inherit from List?
When planning out my programs, I often start with a chain of thought like so:
A football team is just a list of football players. Therefore, I should represent it with:
var football_team = new List();
The ordering of this list…
Superbest
- 25,318
- 14
- 62
- 134
1691
votes
55 answers
How to add days to Date?
How to add days to current Date using JavaScript? Does JavaScript have a built in function like .NET's AddDay()?
Ashesh
- 16,995
- 3
- 18
- 8
1689
votes
34 answers
startsWith() and endsWith() functions in PHP
How can I write two functions that would take a string and return if it starts with the specified character/string or ends with it?
For example:
$str = '|apples}';
echo startsWith($str, '|'); //Returns true
echo endsWith($str, '}'); //Returns true
Ali
- 261,656
- 265
- 575
- 769
1687
votes
30 answers
What is the difference between const and readonly in C#?
What is the difference between const and readonly in C#?
When would you use one over the other?
readonly
- 343,444
- 107
- 203
- 205
1685
votes
19 answers
What is the difference between UNION and UNION ALL?
What is the difference between UNION and UNION ALL?
Brian G
- 53,704
- 58
- 125
- 140
1683
votes
34 answers
Sorting an array of objects by property values
I've got the following objects using AJAX and stored them in an array:
var homes = [
{
"h_id": "3",
"city": "Dallas",
"state": "TX",
"zip": "75201",
"price": "162500"
}, {
"h_id": "4",
…
TomHankers
1680
votes
24 answers
Save plot to image file instead of displaying it
This displays the figure in a GUI:
import matplotlib.pyplot as plt
plt.plot([1, 2, 3], [1, 4, 9])
plt.show()
But how do I instead save the figure to a file (e.g. foo.png)?
Homunculus Reticulli
- 65,167
- 81
- 216
- 341