Most Popular
1500 questions
2018
votes
14 answers
How does data binding work in AngularJS?
How does data binding work in the AngularJS framework?
I haven't found technical details on their site. It's more or less clear how it works when data is propagated from view to model. But how does AngularJS track changes of model properties without…
Pashec
- 22,889
- 3
- 24
- 26
2018
votes
9 answers
How can I git stash a specific file?
How can I stash a specific file leaving the others currently modified out of the stash I am about to save?
For example, if git status gives me this:
younker % gst
# On branch master
# Your branch is ahead of 'origin/master' by 1 commit.
#
#…
ynkr
- 22,906
- 4
- 31
- 30
2015
votes
38 answers
Copy array by value
When copying an array in JavaScript to another array:
var arr1 = ['a','b','c'];
var arr2 = arr1;
arr2.push('d'); //Now, arr1 = ['a','b','c','d']
I realized that arr2 refers to the same array as arr1, rather than a new, independent array. How can I…
Dan
- 20,437
- 5
- 17
- 16
2014
votes
14 answers
What is the optimal algorithm for the game 2048?
I have recently stumbled upon the game 2048. You merge similar tiles by moving them in any of the four directions to make "bigger" tiles. After each move, a new tile appears at random empty position with a value of either 2 or 4. The game terminates…
nitish712
- 19,010
- 5
- 25
- 34
2007
votes
15 answers
Comparing Java enum members: == or equals()?
I know that Java enums are compiled to classes with private constructors and a bunch of public static members. When comparing two members of a given enum, I've always used .equals(), e.g.
public useEnums(SomeEnum a)
{
…
Matt Ball
- 344,413
- 96
- 627
- 693
2005
votes
29 answers
Short circuit Array.forEach like calling break
[1,2,3].forEach(function(el) {
if(el === 1) break;
});
How can I do this using the new forEach method in JavaScript? I've tried return;, return false; and break. break crashes and return does nothing but continue iteration.
Scott Klarenbach
- 34,443
- 14
- 59
- 89
2004
votes
19 answers
How to remove an element from a list by index
How do I remove an element from a list by index?
I found list.remove(), but this slowly scans the list for an item by value.
Joan Venge
- 292,935
- 205
- 455
- 667
2003
votes
17 answers
How to reload .bashrc settings without logging out and back in again?
If I make changes to .bashrc, how do I reload it without logging out and back in?
Jed Daniels
- 22,876
- 5
- 23
- 24
2001
votes
28 answers
How to name and retrieve a stash by name in git?
I was always under the impression that you could give a stash a name by doing git stash save stashname, which you could later on apply by doing git stash apply stashname. But it seems that in this case all that happens is that stashname will be used…
Suan
- 30,927
- 12
- 45
- 60
2000
votes
19 answers
How to determine a Python variable's type?
How do I see the type of a variable? (e.g. unsigned 32 bit)
user46646
- 144,445
- 43
- 74
- 84
1998
votes
34 answers
Remove files from Git commit
I am using Git and I have committed few files using
git commit -a
Later, I found that a file had mistakenly been added to the commit.
How can I remove a file from the last commit?
Lolly
- 31,448
- 40
- 110
- 143
1997
votes
23 answers
Throw away local commits in Git
Due to some bad cherry-picking, my local Git repository is currently five commits ahead of the origin, and not in a good state. I want to get rid of all these commits and start over again.
Obviously, deleting my working directory and re-cloning…
David Moles
- 43,504
- 25
- 125
- 223
1992
votes
27 answers
Why is using "for...in" for array iteration a bad idea?
I've been told not to use for...in with arrays in JavaScript. Why not?
lYriCAlsSH
- 55,956
- 10
- 25
- 20
1992
votes
32 answers
Get current URL with jQuery?
I am using jQuery. How do I get the path of the current URL and assign it to a variable?
Example URL:
http://localhost/menuname.de?foo=bar&number=0
venkatachalam
- 101,903
- 30
- 71
- 76
1990
votes
36 answers
How do I break out of nested loops in Java?
I've got a nested loop construct like this:
for (Type type : types) {
for (Type t : types2) {
if (some condition) {
// Do something and break...
break; // Breaks out of the inner loop
}
}
}
Now…
boutta
- 23,451
- 7
- 36
- 48