Most Popular
1500 questions
1885
votes
48 answers
How can I count all the lines of code in a directory recursively?
We've got a PHP application and want to count all the lines of code under a specific directory and its subdirectories.
We don't need to ignore comments, as we're just trying to get a rough idea.
wc -l *.php
That command works great for a given…
user77413
- 28,715
- 16
- 44
- 51
1885
votes
49 answers
Detecting an "invalid date" Date instance in JavaScript
I'd like to tell the difference between valid and invalid date objects in JS, but couldn't figure out how:
var d = new Date("foo");
console.log(d.toString()); // shows 'Invalid Date'
console.log(typeof d); // shows 'object'
console.log(d instanceof…
orip
- 69,626
- 21
- 116
- 145
1884
votes
21 answers
How can I remove a commit on GitHub?
I "accidentally" pushed a commit to GitHub.
Is it possible to remove this commit?
I want to revert my GitHub repository as it was before this commit.
hectorsq
- 70,306
- 19
- 42
- 46
1881
votes
14 answers
Undo working copy modifications of one file in Git?
After the last commit, I modified a bunch of files in my working copy, but I want to undo the changes to one of those files, as in reset it to the same state as the most recent commit.
However, I only want to undo the working copy changes of just…
hasen
- 155,371
- 64
- 187
- 227
1880
votes
16 answers
How to do case insensitive search in Vim
I'd like to search for an upper case word, for example COPYRIGHT in a file. I tried performing a search like:
/copyright/i # Doesn't work
but it doesn't work. I know that in Perl, if I give the i flag into a regex it will turn the regex into a…
Haiyuan Zhang
- 38,486
- 40
- 103
- 133
1878
votes
50 answers
Can't bind to 'ngModel' since it isn't a known property of 'input'
I have this simple input in my component which uses [(ngModel)] :
And I get the following error when I launch my app, even if the component is not displayed.
zone.js:461 Unhandled Promise…
Anthony Brenelière
- 55,119
- 14
- 43
- 55
1877
votes
16 answers
What is the 'new' keyword in JavaScript?
The new keyword in JavaScript can be quite confusing when it is first encountered, as people tend to think that JavaScript is not an object-oriented programming language.
What is it?
What problems does it solve?
When is it appropriate and when…
Alon Gubkin
- 54,770
- 52
- 188
- 285
1875
votes
62 answers
What is the best way to detect a mobile device?
Is there a way to detect whether or not a user is using a mobile device in jQuery? Something similar to the CSS @media attribute? I would like to run a different script if the browser is on a handheld device.
The jQuery $.browser function is not…
superUntitled
- 21,855
- 29
- 82
- 108
1873
votes
27 answers
What is a NullReferenceException, and how do I fix it?
I have some code and when it executes, it throws a NullReferenceException, saying:
Object reference not set to an instance of an object.
What does this mean, and what can I do to fix this error?
John Saunders
- 159,224
- 26
- 237
- 393
1868
votes
5 answers
What is TypeScript and why would I use it in place of JavaScript?
Can you please describe what the TypeScript language is?
What can it do that JavaScript or available libraries cannot do, that would give me reason to consider it?
Mohammed Thabet
- 20,819
- 7
- 26
- 41
1867
votes
26 answers
How do I fix a Git detached head?
I was doing some work in my repository and noticed a file had local changes. I didn't want them anymore so I deleted the file, thinking I can just checkout a fresh copy. I wanted to do the Git equivalent of
svn up .
Using git pull didn't seem to…
Daniel
- 21,535
- 9
- 34
- 32
1864
votes
15 answers
Why does this code using random strings print "hello world"?
The following print statement would print "hello world".
Could anyone explain this?
System.out.println(randomString(-229985452) + " " + randomString(-147909649));
And randomString() looks like this:
public static String randomString(int i)
{
…
0x56794E
- 20,265
- 12
- 40
- 56
1864
votes
11 answers
How can I delete all of my Git stashes at once?
How can I delete all of my Git stashes at once?
Specifically I mean, with typing in one command.
Rebekah Waterbury
- 20,256
- 5
- 22
- 28
1860
votes
8 answers
What is the difference between Bower and npm?
What is the fundamental difference between bower and npm? Just want something plain and simple. I've seen some of my colleagues use bower and npm interchangeably in their projects.
Games Brainiac
- 75,856
- 32
- 131
- 189