Most Popular
1500 questions
1231
votes
13 answers
How to have 'git log' show filenames like 'svn log -v'
SVN's log has a "-v" mode that outputs filenames of files changed in each commit, like so:
jes5199$ svn log -v
------------------------------------------------------------------------
r1 | jes5199 | 2007-01-03 14:39:41 -0800 (Wed, 03 Jan 2007) | 1…
jes5199
- 18,324
- 12
- 36
- 40
1230
votes
32 answers
How to create a generic array in Java?
Due to the implementation of Java generics, you can't have code like this:
public class GenSet {
private E a[];
public GenSet() {
a = new E[INITIAL_ARRAY_LENGTH]; // error: generic array creation
}
}
How can I implement…
tatsuhirosatou
- 25,149
- 14
- 39
- 40
1228
votes
28 answers
How do you remove all the options of a select box and then add one option and select it with jQuery?
Using core jQuery, how do you remove all the options of a select box, then add one option and select it?
My select box is the following.
EDIT: The following code was helpful with chaining. However, (in…
Jay Corbett
- 28,091
- 21
- 57
- 74
1227
votes
39 answers
Converting from a string to boolean in Python
How do I convert a string into a boolean in Python? This attempt returns True:
>>> bool("False")
True
Joan Venge
- 315,713
- 212
- 479
- 689
1227
votes
59 answers
React-router URLs don't work when refreshing or writing manually
I'm using React-router and it works fine while I'm clicking on link buttons, but when I refresh my webpage it does not load what I want.
For instance, I am in localhost/joblist and everything is fine because I arrived here pressing a link. But if I…
DavidDev
- 12,605
- 4
- 14
- 15
1227
votes
34 answers
Center a column using Twitter Bootstrap
How do I center a div of one column size within the container (12 columns) in Twitter Bootstrap 3?
.centered {
background-color: red;
}
bsr
- 57,282
- 86
- 216
- 316
1227
votes
24 answers
How to sort an object array by date property?
Say I have an array of a few objects:
var array = [{id: 1, date: Mar 12 2012 10:00:00 AM}, {id: 2, date: Mar 8 2012 08:00:00 AM}];
How can I sort this array by the date element in order from the date closest to the current date and time down? Keep…
ryandlf
- 27,155
- 37
- 106
- 162
1226
votes
19 answers
How do I use extern to share variables between source files?
I know that global variables in C sometimes have the extern keyword. What is an extern variable? What is the declaration like? What is its scope?
This is related to sharing variables across source files, but how does that work precisely? Where do I…
shilpa
1224
votes
15 answers
How do I turn a C# object into a JSON string in .NET?
I have classes like these:
class MyDate
{
int year, month, day;
}
class Lad
{
string firstName;
string lastName;
MyDate dateOfBirth;
}
And I would like to turn a Lad object into a JSON string like this:
{
…
Hui
- 13,887
- 8
- 25
- 20
1224
votes
14 answers
How can I revert uncommitted changes including files and folders?
Is there a Git command to revert all uncommitted changes in a working tree and index and to also remove newly created files and folders?
MEM
- 30,529
- 42
- 121
- 191
1224
votes
8 answers
What is the difference between 'typedef' and 'using' in C++11?
I know that in C++11 we can now use using to write type alias, like typedefs:
typedef int MyInt;
Is, from what I understand, equivalent to:
using MyInt = int;
And that new syntax emerged from the effort to have a way to express "template…
Klaim
- 67,274
- 36
- 133
- 188
1223
votes
21 answers
Check if a variable is of function type
Suppose I have any variable, which is defined as follows:
var a = function() {/* Statements */};
I want a function which checks if the type of the variable is function-like. i.e. :
function foo(v) {if (v is function type?) {/* do something…
Jesufer Vn
- 13,200
- 6
- 20
- 26
1223
votes
54 answers
How do I "select Android SDK" in Android Studio?
After a successful import of an Eclipse-Android-Project into "Android Studio 1.4", I get the error
"Please select Android SDK"
when I click on the button to run the application in the simulator, I can't find any way of doing that.
This dialog opens…
delete
- 18,144
- 15
- 48
- 79
1222
votes
7 answers
Ukkonen's suffix tree algorithm in plain English
I feel a bit thick at this point. I've spent days trying to fully wrap my head around suffix tree construction, but because I don't have a mathematical background, many of the explanations elude me as they start to make excessive use of mathematical…
Nathan Ridley
- 33,766
- 35
- 123
- 197
1221
votes
28 answers
Getting a random value from a JavaScript array
Consider:
var myArray = ['January', 'February', 'March'];
How can I select a random value from this array using JavaScript?
Sarah
- 12,401
- 3
- 17
- 8