Most Popular

1500 questions
1272
votes
37 answers

How do you get the index of the current iteration of a foreach loop?

Is there some rare language construct I haven't encountered (like the few I've learned recently, some on Stack Overflow) in C# to get a value representing the current iteration of a foreach loop? For instance, I currently do something like this…
Matt Mitchell
  • 40,943
  • 35
  • 118
  • 185
1272
votes
20 answers

Can I hide the HTML5 number input’s spin box?

Is there a consistent way across browsers to hide the new spin boxes that some browsers (such as Chrome) render for HTML input of type number? I am looking for a CSS or JavaScript method to prevent the up/down arrows from appearing.
Alan
  • 12,952
  • 3
  • 18
  • 13
1272
votes
3 answers

How to list branches that contain a given commit?

How can I query git to find out which branches contain a given commit? gitk will usually list the branches, unless there are too many, in which case it just says "many (38)" or something like that. I need to know the full list, or at least whether…
Andrew Arnott
  • 80,040
  • 26
  • 132
  • 171
1271
votes
34 answers

How to install Java 8 on Mac

Editors note: This question was asked in 2014, and the answers may be outdated. I want to do some programming with the latest JavaFX, which requires Java 8. I'm using IntelliJ 13 CE and Mac OS X 9 Mavericks. I ran Oracle's Java 8 installer, and…
user3763100
  • 13,037
  • 3
  • 13
  • 9
1271
votes
26 answers

Count the number of occurrences of a character in a string

How do I count the number of occurrences of a character in a string? e.g. 'a' appears in 'Mary had a little lamb' 4 times.
Mat
  • 82,161
  • 34
  • 89
  • 109
1270
votes
25 answers

How to clear the canvas for redrawing

After experimenting with composite operations and drawing images on the canvas I'm now trying to remove images and compositing. How do I do this? I need to clear the canvas for redrawing other images; this can go on for a while so I don't think…
richard
  • 14,050
  • 8
  • 37
  • 39
1269
votes
25 answers

Converting array to list in Java

How do I convert an array to a list in Java? I used the Arrays.asList() but the behavior (and signature) somehow changed from Java SE 1.4.2 (docs now in archive) to 8 and most snippets I found on the web use the 1.4.2 behaviour. For example: int[]…
Alexandru
  • 25,070
  • 18
  • 69
  • 78
1267
votes
37 answers

How to execute a JavaScript function when I have its name as a string

I have the name of a function in JavaScript as a string. How do I convert that into a function pointer so I can call it later? Depending on the circumstances, I may need to pass various arguments into the method too. Some of the functions may take…
Kieron
  • 26,748
  • 16
  • 78
  • 122
1267
votes
38 answers

Reference - What does this error mean in PHP?

What is this? This is a number of answers about warnings, errors, and notices you might encounter while programming PHP and have no clue how to fix them. This is also a Community Wiki, so everyone is invited to participate adding to and maintaining…
hakre
  • 193,403
  • 52
  • 435
  • 836
1265
votes
6 answers

In TypeScript, what is the ! (exclamation mark / bang) operator when dereferencing a member?

When looking at the source code for a tslint rule, I came across the following statement: if (node.parent!.kind === ts.SyntaxKind.ObjectLiteralExpression) { return; } Notice the ! operator after node.parent. Interesting! I first tried compiling…
Mike Chamberlain
  • 39,692
  • 27
  • 110
  • 158
1265
votes
17 answers

Converting 'ArrayList to 'String[]' in Java

How might I convert an ArrayList object to a String[] array in Java?
Alex
  • 16,375
  • 7
  • 22
  • 19
1265
votes
42 answers

How can I develop for iPhone using a Windows development machine?

Is there any way to tinker with the iPhone SDK on a Windows machine? Are there plans for an iPhone SDK version for Windows? The only other way I can think of doing this is to run a Mac VM image on a VMWare server running on Windows, although I'm not…
ryan
  • 5,039
  • 13
  • 35
  • 42
1265
votes
13 answers

How do I return dictionary keys as a list in Python?

With Python 2.7, I can get dictionary keys, values, or items as a list: >>> newdict = {1:0, 2:0, 3:0} >>> newdict.keys() [1, 2, 3] With Python >= 3.3, I get: >>> newdict.keys() dict_keys([1, 2, 3]) How do I get a plain list of keys with Python 3?
user2015601
1265
votes
16 answers

How can I sanitize user input with PHP?

Is there a catchall function somewhere that works well for sanitizing user input for SQL injection and XSS attacks, while still allowing certain types of HTML tags?
Brent
  • 23,354
  • 10
  • 44
  • 49
1264
votes
60 answers

Could not find a part of the path ... bin\roslyn\csc.exe

I am trying to run an ASP.NET MVC (model-view-controller) project retrieved from TFS (Team Foundation Server) source control. I have added all assembly references and I am able to build and compile successfully without any error or warning. But I…
Eyad
  • 13,440
  • 6
  • 26
  • 43