Most Popular
1500 questions
2889
votes
11 answers
How do you push a tag to a remote repository using Git?
I have cloned a remote Git repository to my laptop, then I wanted to add a tag so I ran
git tag mytag master
When I run git tag on my laptop the tag mytag is shown. I then want to push this to the remote repository so I have this tag on all my…
Jonas
- 109,920
- 93
- 295
- 369
2881
votes
10 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
C-style cast (type)value
Function-style cast type(value)
How does one decide which to use in which specific cases?
e.James
- 113,058
- 40
- 174
- 210
2879
votes
25 answers
How do I change the size of figures drawn with Matplotlib?
How do I change the size of figure drawn with Matplotlib?
tatwright
- 34,501
- 6
- 20
- 9
2876
votes
12 answers
Manually raising (throwing) an exception in Python
How can I raise an exception in Python so that it can later be caught via an except block?
TIMEX
- 238,746
- 336
- 750
- 1,061
2855
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
- 57,578
- 48
- 205
- 437
2850
votes
69 answers
How do you split a list into evenly sized chunks?
How do I split a list of arbitrary length into equal sized chunks?
Related question: What is the most “pythonic” way to iterate over a list in chunks?
jespern
- 30,268
- 3
- 22
- 12
2847
votes
31 answers
What is the difference between #include and #include "filename"?
In the C and C++ programming languages, what is the difference between using angle brackets and using quotes in an include statement, as follows?
#include
#include "filename"
quest49
- 46,418
- 4
- 19
- 14
2835
votes
19 answers
In the shell, what does " 2>&1 " mean?
In a Unix shell, if I want to combine stderr and stdout into the stdout stream for further manipulation, I can append the following on the end of my command:
2>&1
So, if I want to use head on the output from g++, I can do something like this:
g++…
Tristan Havelick
- 63,483
- 19
- 53
- 64
2832
votes
17 answers
How to modify a specified commit?
I usually submit a list of commits for review. If I have the following commits:
HEAD
Commit3
Commit2
Commit1
...I know that I can modify head commit with git commit --amend. But how can I modify Commit1, given that it is not the HEAD commit?
Sam Liao
- 40,117
- 15
- 51
- 60
2825
votes
40 answers
How to add images to README.md on GitHub?
Recently I joined GitHub. I hosted some projects there.
I need to include some images in my README File. I don't know how to do that.
I searched about this, but all I got was some links which tell me to "host images on web and specify the image path…
Midhun MP
- 97,760
- 30
- 152
- 197
2822
votes
43 answers
Length of a JavaScript object
I have a JavaScript object. Is there a built-in or accepted best practice way to get the length of this object?
const myObject = new Object();
myObject["firstname"] = "Gareth";
myObject["lastname"] = "Simpson";
myObject["age"] = 21;
Gareth Simpson
- 35,073
- 12
- 45
- 49
2820
votes
20 answers
How do I modify the URL without reloading the page?
Is there a way I can modify the URL of the current page without reloading the page?
I would like to access the portion before the # hash if possible.
I only need to change the portion after the domain, so it's not like I'm violating cross-domain…
Robin Rodricks
- 105,357
- 137
- 385
- 594
2818
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
- 32,389
- 12
- 66
- 145
2812
votes
32 answers
Git fetch remote branch
My colleague and I are working on the same repository. We've branched it into two branches, each technically for different projects, but they have similarities, so we'll sometimes want to commit back to the *master from the branch.
However, I have…
David
- 31,534
- 10
- 42
- 70
2807
votes
56 answers
How do I print colored text to the terminal?
How can I output colored text to the terminal in Python?
aboSamoor
- 28,271
- 3
- 16
- 10