Most Popular
1500 questions
4577
votes
33 answers
Undo a Git merge that hasn't been pushed yet
Within my master branch, I did a git merge some-other-branch locally, but never pushed the changes to origin master. I didn't mean to merge, so I'd like to undo it. When doing a git status after my merge, I was getting this message:
# On branch…
Matt Huggins
- 78,024
- 36
- 145
- 216
4558
votes
45 answers
How to clone all remote branches in Git
I have a master and a development branch, both pushed to GitHub. I've cloned, pulled, and fetched, but I remain unable to get anything other than the master branch back.
I'm sure I'm missing something obvious, but I have read the manual and I'm…
Peter Coulton
- 52,881
- 11
- 53
- 71
4519
votes
41 answers
How do you get a timestamp in JavaScript?
Something similar to Unix's timestamp, that is a single number that represents the current time and date. Either as a number or a string.
pupeno
- 267,428
- 120
- 345
- 578
4518
votes
19 answers
What's the difference between tilde(~) and caret(^) in package.json?
After I upgraded to the latest stable node and npm, I tried npm install moment --save. It saves the entry in the package.json with the caret ^ prefix. Previously, it was a tilde ~ prefix.
Why are these changes made in npm?
What is the difference…
Fizer Khan
- 80,049
- 27
- 138
- 151
4517
votes
62 answers
How do I read / convert an InputStream into a String in Java?
If you have a java.io.InputStream object, how should you process that object and produce a String?
Suppose I have an InputStream that contains text data, and I want to convert it to a String, so for example I can write that to a log file.
What is…
Johnny Maelstrom
- 46,021
- 5
- 20
- 18
4510
votes
15 answers
"Thinking in AngularJS" if I have a jQuery background?
Suppose I'm familiar with developing client-side applications in jQuery, but now I'd like to start using AngularJS. Can you describe the paradigm shift that is necessary? Here are a few questions that might help you frame an answer:
How do I…
Mark Rajcok
- 356,856
- 113
- 487
- 490
4451
votes
43 answers
Setting "checked" for a checkbox with jQuery
I'd like to do something like this to tick a checkbox using jQuery:
$(".myCheckBox").checked(true);
or
$(".myCheckBox").selected(true);
Does such a thing exist?
tpower
- 54,762
- 19
- 66
- 100
4418
votes
31 answers
How do I update or sync a forked repository on GitHub?
I forked a project, applied several fixes and created a pull request which was accepted. A few days later, another change was made by another contributor. So my fork doesn't contain that change.
How can I get that change into my fork? Do I need to…
Lea Hayes
- 59,710
- 16
- 58
- 108
4341
votes
8 answers
Why does Google prepend while(1); to their JSON responses?
Why does Google prepend while(1); to their (private) JSON responses?
For example, here's a response while turning a calendar on and off in Google Calendar:
while (1);
[
['u', [
['smsSentFlag', 'false'],
['hideInvitations', 'false'],
…
Jess
- 41,028
- 6
- 35
- 51
4328
votes
55 answers
Which "href" value should I use for JavaScript links, "#" or "javascript:void(0)"?
The following are two methods of building a link that has the sole purpose of running JavaScript code. Which is better, in terms of functionality, page load speed, validation purposes, etc.?
function myJsFunc() {
alert("myJsFunc");
}
2cBGj7vsfp
- 2,737
- 3
- 17
- 5
4311
votes
33 answers
Difference between @staticmethod and @classmethod
What is the difference between a function decorated with @staticmethod and one decorated with @classmethod?
Daryl Spitzer
- 133,599
- 75
- 153
- 171
4304
votes
27 answers
How to delete a remote tag?
How do you delete a Git tag that has already been pushed?
markdorison
- 127,186
- 27
- 54
- 71
4295
votes
67 answers
Avoiding NullPointerException in Java
I use object != null a lot to avoid NullPointerException.
What is an alternative to:
if (someobject != null) {
someobject.doCalc();
}
Goran Martinic
- 3,787
- 4
- 20
- 14
4249
votes
35 answers
Understanding slicing
I need a good explanation (references are a plus) on Python slicing.
Simon
- 75,273
- 25
- 86
- 117
4240
votes
44 answers
Change a HTML5 input's placeholder color with CSS
Chrome supports the placeholder attribute on input[type=text] elements (others probably do too).
But the following CSS doesn't do anything to the placeholder's value:
input[placeholder], [placeholder], *[placeholder] {
color: red…
David Murdoch
- 85,416
- 39
- 144
- 188