Most Popular
1500 questions
1467
votes
8 answers
Check if element exists in jQuery
How do I check if an element exists if the element is created by .append() method?
$('elemId').length doesn't work for me.
Nick
- 15,765
- 5
- 22
- 15
1467
votes
27 answers
Difference between Constructor and ngOnInit
Angular provides life cycle hook ngOnInit by default.
Why should ngOnInit be used, if we already have a constructor?
Haseena P A
- 16,858
- 4
- 18
- 35
1465
votes
31 answers
Is there a way to get the source code from an APK file?
The hard drive on my laptop just crashed and I lost all the source code for an app that I have been working on for the past two months.
All I have is the APK file that is stored in my email from when I sent it to a friend.
Is there any way to…
Frank Bozzo
- 15,033
- 6
- 25
- 29
1464
votes
32 answers
How do I sort a dictionary by key?
How do I sort a dictionary by its keys?
Example input:
{2:3, 1:89, 4:5, 3:0}
Desired output:
{1:89, 2:3, 3:0, 4:5}
Antony
- 15,257
- 4
- 17
- 18
1464
votes
12 answers
Naming Classes - How to avoid calling everything a "Manager"?
A long time ago I have read an article (I believe a blog entry) which put me on the "right" track on naming objects: Be very very scrupulous about naming things in your program.
For example if my application was (as a typical business app) handling…
froh42
- 5,190
- 6
- 30
- 42
1463
votes
16 answers
Using Git with Visual Studio
As a long-time Visual SourceSafe user (and hater) I was discussing switching to SVN with a colleague; he suggested using Git instead. Since, apparently, it can be used as peer-to-peer without a central server (we are a 3-developer team).
I have not…
Herb Caudill
- 50,043
- 39
- 124
- 173
1463
votes
17 answers
How to cherry-pick multiple commits
I have two branches. Commit a is the head of one, while the other has b, c, d, e and f on top of a. I want to move c, d, e and f to first branch without commit b. Using cherry pick it is easy: checkout first branch cherry-pick one by one c to f and…
tig
- 25,841
- 10
- 64
- 96
1462
votes
3 answers
Proper MIME media type for PDF files
When working with PDFs, I've run across the MIME types application/pdf and application/x-pdf among others.
Is there a difference between these two types, and if so what is it? Is one preferred over the other?
I'm working on a web app which must…
friedo
- 65,762
- 16
- 114
- 184
1459
votes
13 answers
Get a random item from a JavaScript array
var items = Array(523, 3452, 334, 31, ..., 5346);
How do I get random item from items?
James
- 42,081
- 53
- 136
- 161
1459
votes
17 answers
Send HTTP POST request in .NET
How can I make an HTTP POST request and send data in the body?
Hooch
- 28,817
- 29
- 102
- 161
1458
votes
34 answers
Activity restart on rotation Android
In my Android application, when I rotate the device (slide out the keyboard) then my Activity is restarted (onCreate is called). Now, this is probably how it's supposed to be, but I do a lot of initial setting up in the onCreate method, so I need…
Isaac Waller
- 32,709
- 29
- 96
- 107
1458
votes
8 answers
What does the exclamation mark do before the function?
I found this code:
!function () {}();
What is the purpose of the exclamation mark here?
Sebastian Otto
- 15,139
- 4
- 18
- 21
1458
votes
9 answers
1458
votes
39 answers
How to round a number to n decimal places in Java
What I would like is a method to convert a double to a string which rounds using the half-up method - i.e. if the decimal to be rounded is 5, it always rounds up to the next number. This is the standard method of rounding most people expect in most…
Alex Spurling
- 54,094
- 23
- 70
- 76
1458
votes
10 answers
Object comparison in JavaScript
What is the best way to compare objects in JavaScript?
Example:
var user1 = {name : "nerd", org: "dev"};
var user2 = {name : "nerd", org: "dev"};
var eq = user1 == user2;
alert(eq); // gives false
I know that two objects are equal if they refer to…
spankmaster79
- 21,555
- 10
- 42
- 73