Most Popular
1500 questions
3112
votes
20 answers
What is the difference between Python's list methods append and extend?
What's the difference between the list methods append() and extend()?

Claudiu
- 224,032
- 165
- 485
- 680
3109
votes
27 answers
How to set, clear, and toggle a single bit
How can I set, clear, and toggle a bit?

JeffV
- 52,985
- 32
- 103
- 124
3103
votes
19 answers
What does " 2>&1 " mean?
To combine stderr and stdout into the stdout stream, we append this to a command:
2>&1
e.g. to see the first few errors from compiling g++ main.cpp:
g++ main.cpp 2>&1 | head
What does 2>&1 mean, in detail?

Tristan Havelick
- 67,400
- 20
- 54
- 64
3080
votes
31 answers
`git fetch` a remote branch
The remote repository contains various branches such as origin/daves_branch:
$ git branch -r
origin/HEAD -> origin/master
origin/daves_branch
origin/master
How do I switch to daves_branch in the local repository so that it tracks…

David
- 34,836
- 11
- 47
- 77
3075
votes
12 answers
When should static_cast, dynamic_cast, const_cast, and reinterpret_cast be used?
What are the proper uses of:
static_cast
dynamic_cast
const_cast
reinterpret_cast
(type)value (C-style cast)
type(value) (function-style cast)
How does one decide which to use in which specific cases?

e.James
- 116,942
- 41
- 177
- 214
3069
votes
69 answers
How do I split a list into equally-sized chunks?
How do I split a list of arbitrary length into equal sized chunks?
See also: How to iterate over a list in chunks.
To chunk strings, see Split string every nth character?.

jespern
- 32,466
- 3
- 23
- 12
3064
votes
54 answers
Is there a unique Android device ID?
Do Android devices have a unique ID, and if so, what is a simple way to access it using Java?

Tyler
- 31,237
- 8
- 21
- 22
3051
votes
40 answers
How can I know which radio button is selected via jQuery?
I have two radio buttons and want to post the value of the selected one.
How can I get the value with jQuery?
I can get all of them like this:
$("form :radio")
How do I know which one is selected?

juan
- 80,295
- 52
- 162
- 195
3046
votes
24 answers
How to store objects in HTML5 localStorage/sessionStorage
I'd like to store a JavaScript object in HTML5 localStorage, but my object is apparently being converted to a string.
I can store and retrieve primitive JavaScript types and arrays using localStorage, but objects don't seem to work. Should…

Kristopher Johnson
- 81,409
- 55
- 245
- 302
3045
votes
30 answers
What is the difference between #include and #include "filename"?
What is the difference between using angle brackets and quotes in an include directive?
#include
#include "filename"

quest49
- 49,608
- 5
- 21
- 14
3042
votes
39 answers
How can I check if a program exists from a Bash script?
How would I validate that a program exists, in a way that will either return an error and exit, or continue with the script?
It seems like it should be easy, but it's been stumping me.

gregh
- 35,767
- 9
- 31
- 27
3041
votes
36 answers
ssh "permissions are too open"
I get the following error from ssh:
Permissions 0777 for '/Users/username/.ssh/id_rsa' are too open.
It is recommended that your private key files are NOT accessible by others.
This private key will be ignored.
What permissions should I give to the…

Yannick Schall
- 32,601
- 6
- 29
- 42
3026
votes
47 answers
Is there a standard function to check for null, undefined, or blank variables in JavaScript?
Is there a universal JavaScript function that checks that a variable has a value and ensures that it's not undefined or null? I've got this code, but I'm not sure if it covers all cases:
function isEmpty(val){
return (val === undefined || val ==…

Alex
- 34,699
- 13
- 75
- 158
3022
votes
24 answers
HTTP GET with request body
I'm developing a new RESTful webservice for our application.
When doing a GET on certain entities, clients can request the contents of the entity.
If they want to add some parameters (for example sorting a list) they can add these parameters in the…

Evert
- 93,428
- 18
- 118
- 189
3022
votes
16 answers
How can I check for "undefined" in JavaScript?
What is the most appropriate way to test if a variable is undefined in JavaScript?
I've seen several possible ways:
if (window.myVariable)
Or
if (typeof(myVariable) != "undefined")
Or
if (myVariable) // This throws an error if undefined. Should…

makerofthings7
- 60,103
- 53
- 215
- 448