Most Popular

1500 questions
1131
votes
16 answers

What is the difference between public, private, and protected?

When and why should I use public, private, and protected functions and variables inside a class? What is the difference between them? Examples: // Public public $variable; public function doSomething() { // ... } // Private private…
Adam Halasz
  • 57,421
  • 66
  • 149
  • 213
1130
votes
19 answers

How to get the sizes of the tables of a MySQL database?

I can run this query to get the sizes of all tables in a MySQL database: show table status from myDatabaseName; I would like some help in understanding the results. I am looking for tables with the largest sizes. Which column should I look at?
JPashs
  • 13,044
  • 10
  • 42
  • 65
1130
votes
29 answers

How to add 30 minutes to a JavaScript Date object?

I'd like to get a Date object which is 30 minutes later than another Date object. How do I do it with JavaScript?
Morgan Cheng
  • 73,950
  • 66
  • 171
  • 230
1129
votes
28 answers

Selecting and manipulating CSS pseudo-elements such as ::before and ::after using JavaScript

Is there any way to select/manipulate CSS pseudo-elements such as ::before and ::after (and the old version with one semi-colon) using jQuery? For example, my stylesheet has the following rule: .span::after{ content:'foo' } How can I change 'foo'…
JBradwell
  • 11,433
  • 3
  • 15
  • 8
1129
votes
17 answers

:: (double colon) operator in Java 8

I was exploring the Java 8 source and found this particular part of code very surprising: // Defined in IntPipeline.java @Override public final OptionalInt reduce(IntBinaryOperator op) { return…
Narendra Pathai
  • 41,187
  • 18
  • 82
  • 120
1128
votes
108 answers

R cannot be resolved - Android error

I just downloaded and installed the new Android SDK. I wanted to create a simple application to test drive it. The wizard created this code: package eu.mauriziopz.gps; import android.app.Activity; import android.os.Bundle; public class ggps…
1128
votes
24 answers

How is an HTTP POST request made in node.js?

How can I make an outbound HTTP POST request, with data, in node.js?
Mark
  • 67,098
  • 47
  • 117
  • 162
1128
votes
24 answers

How to create a directory if it doesn't exist using Node.js

Is the following the right way to create a directory if it doesn't exist? It should have full permission for the script and readable by others. var dir = __dirname + '/upload'; if (!path.existsSync(dir)) { fs.mkdirSync(dir, 0744); }
Whisher
  • 31,320
  • 32
  • 120
  • 201
1127
votes
11 answers

How to concatenate (join) items in a list to a single string

How do I concatenate a list of strings into a single string? For example, given ['this', 'is', 'a', 'sentence'], how do I get "this-is-a-sentence"? For handling a few strings in separate variables, see How do I append one string to another in…
alvas
  • 115,346
  • 109
  • 446
  • 738
1126
votes
30 answers

How can I get the application's path in a .NET console application?

How do I find the application's path in a console application? In Windows Forms, I can use Application.StartupPath to find the current path, but this doesn't seem to be available in a console application.
JSmyth
  • 11,993
  • 3
  • 23
  • 18
1126
votes
41 answers

Checking whether a variable is an integer or not

How do I check whether a variable is an integer?
Hulk
  • 32,860
  • 62
  • 144
  • 215
1126
votes
16 answers

Download a file with Android, and showing the progress in a ProgressDialog

I am trying to write a simple application that gets updated. For this I need a simple function that can download a file and show the current progress in a ProgressDialog. I know how to do the ProgressDialog, but I'm not sure how to display the…
Tom Leese
  • 19,309
  • 12
  • 45
  • 70
1126
votes
6 answers

How do I use $scope.$watch and $scope.$apply in AngularJS?

I don't understand how to use $scope.$watch and $scope.$apply. The official documentation isn't helpful. What I don't understand specifically: Are they connected to the DOM? How can I update DOM changes to the model? What is the connection point…
ilyo
  • 35,851
  • 46
  • 106
  • 159
1125
votes
12 answers

When should I use curly braces for ES6 import?

It seems to be obvious, but I found myself a bit confused about when to use curly braces for importing a single module in ES6. For example, in the React-Native project I am working on, I have the following file and its content: File…
TonyW
  • 18,375
  • 42
  • 110
  • 183
1125
votes
18 answers

What's the difference between git reset --mixed, --soft, and --hard?

I'm looking to split a commit up and not sure which reset option to use. I was looking at the page In plain English, what does "git reset" do?, but I realized I don't really understand what the git index or staging area is and thus the explanations…
Michael Chinen
  • 17,737
  • 5
  • 33
  • 45