All Questions

Filter by
Sorted by
Tagged with
5698 votes
27 answers
3.8m views

How do I create a directory, and any missing parent directories?

How do I create a directory at a given path, and also create any missing parent directories along that path? For example, the Bash command mkdir -p /path/to/nested/directory does this.
Parand's user avatar
  • 105k
5692 votes
20 answers
6.1m views

How do I push a new local branch to a remote Git repository and track it too?

How do I: Create a local branch from another branch (via git branch or git checkout -b). Push the local branch to the remote repository (i.e. publish), but make it trackable so that git pull and git ...
Roni Yaniv's user avatar
  • 59.2k
5645 votes
47 answers
2.2m views

Which equals operator (== vs ===) should be used in JavaScript comparisons?

I'm using JSLint to go through JavaScript, and it's returning many suggestions to replace == (two equals signs) with === (three equals signs) when doing things like comparing idSele_UNVEHtype.value....
bcasp's user avatar
  • 57.4k
5532 votes
26 answers
4.8m views

How to determine the URL that a local Git repository was originally cloned from

I pulled a project with several forks on GitHub, but forgot which fork it was. How do I determine which fork I pulled?
Tim's user avatar
  • 55.6k
5511 votes
11 answers
689k views

The definitive guide to form-based website authentication [closed]

Moderator note: This question is not a good fit for our question and answer format with the topicality rules which currently apply for Stack Overflow. We normally use a "historical lock" for ...
5502 votes
46 answers
3.9m views

How do I squash my last N commits together?

How do I squash my last N commits together into one commit?
markdorison's user avatar
5497 votes
28 answers
4.6m views

How to access the index value in a 'for' loop?

How do I access the index while iterating over a sequence with a for loop? xs = [8, 23, 45] for x in xs: print("item #{} = {}".format(index, x)) Desired output: item #1 = 8 item #2 = ...
Joan Venge's user avatar
  • 326k
5473 votes
50 answers
4.6m views

How do I replace all occurrences of a string in JavaScript?

Given a string: string = "Test abc test test abc test test test abc test test abc"; This seems to only remove the first occurrence of abc in the string above: string = string.replace('abc', ...
Ali's user avatar
  • 266k
5471 votes
79 answers
4.8m views

How can I validate an email address in JavaScript?

I'd like to check if the user input is an email address in JavaScript, before sending it to a server or attempting to send an email to it, to prevent the most basic mistyping. How could I achieve this?...
5407 votes
75 answers
3.1m views

How do I create a GUID / UUID?

How do I create GUIDs (globally-unique identifiers) in JavaScript? The GUID / UUID should be at least 32 characters and should stay in the ASCII range to avoid trouble when passing them around. I'm ...
5393 votes
34 answers
5.2m views

Regular expression to match a line that doesn't contain a word

I know it's possible to match a word and then reverse the matches using other tools (e.g. grep -v). However, is it possible to match lines that do not contain a specific word, e.g. hede, using a ...
5393 votes
22 answers
1.9m views

What's the difference between tilde(~) and caret(^) in package.json?

After I upgraded to the latest stable node and npm, I tried npm install moment --save. It saves the entry in the package.json with the caret ^ prefix. Previously, it was a tilde ~ prefix. Why are ...
Fizer Khan's user avatar
  • 91.3k
5387 votes
36 answers
3.6m views

How do I resolve merge conflicts in a Git repository?

How do I resolve merge conflicts in my Git repository?
Spoike's user avatar
  • 121k
5380 votes
37 answers
1.6m views

How do I add an empty directory to a Git repository?

How do I add an empty directory (that contains no files) to a Git repository?
Laurie Young's user avatar
5378 votes
43 answers
836k views

What is a plain English explanation of "Big O" notation?

I'd prefer as little formal definition as possible and simple mathematics.
Arec Barrwin's user avatar
  • 61.8k
5371 votes
34 answers
4.4m views

How do I make a flat list out of a list of lists?

I have a list of lists like [ [1, 2, 3], [4, 5, 6], [7], [8, 9] ] How can I flatten it to get [1, 2, 3, 4, 5, 6, 7, 8, 9]? If your list of lists comes from a nested list ...
Emma's user avatar
  • 54.5k
5362 votes
13 answers
3.1m views

How do I exit Vim?

I am stuck and cannot escape. It says: type :quit<Enter> to quit VIM But when I type that it simply appears in the object body.
jclancy's user avatar
  • 51.5k
5267 votes
106 answers
4.2m views

How do I make the first letter of a string uppercase in JavaScript?

How do I make the first character of a string uppercase if it's a letter, but not change the case of any of the other letters? For example: "this is a test" → "This is a test" &...
Robert Wills's user avatar
  • 53.4k
5239 votes
27 answers
2.6m views

What is the difference between "INNER JOIN" and "OUTER JOIN"?

Also, how do LEFT OUTER JOIN, RIGHT OUTER JOIN, and FULL OUTER JOIN fit in?
Chris de Vries's user avatar
5195 votes
68 answers
4.9m views

How do I check whether a checkbox is checked in jQuery?

I need to check the checked property of a checkbox and perform an action based on the checked property using jQuery. For example, if the age checkbox is checked, then I need to show a textbox to enter ...
5161 votes
67 answers
3.0m views

What is the most efficient way to deep clone an object in JavaScript?

What is the most efficient way to clone a JavaScript object? I've seen obj = eval(uneval(o)); being used, but that's non-standard and only supported by Firefox. I've done things like obj = JSON.parse(...
5109 votes
25 answers
838k views

Reference Guide: What does this symbol mean in PHP? (PHP Syntax)

What is this? This is a collection of questions that come up now and then about syntax in PHP. This is also a Community Wiki, so everyone is invited to participate in maintaining this list. This ...
5105 votes
128 answers
4.9m views

How can I horizontally center an element?

How can I horizontally center a <div> within another <div> using CSS? <div id="outer"> <div id="inner">Foo foo</div> </div>
4978 votes
32 answers
1.3m views

What is the difference between a URI, a URL, and a URN? [closed]

What is the difference between a URL, a URI, and a URN?
Sean McMains's user avatar
  • 58.8k
4947 votes
62 answers
3.6m views

How do I check if an array includes a value in JavaScript?

What is the most concise and efficient way to find out if a JavaScript array contains a value? This is the only way I know to do it: function contains(a, obj) { for (var i = 0; i < a.length; i++...
brad's user avatar
  • 75k
4902 votes
35 answers
3.3m views

Undo a Git merge that hasn't been pushed yet

I accidentally ran git merge some_other_branch on my local master branch. I haven't pushed the changes to origin master. How do I undo the merge? After merging, git status says: # On branch master # ...
Matt Huggins's user avatar
  • 82.6k
4870 votes
31 answers
2.2m views

How can I delete a remote tag?

How can I delete a Git tag that has already been pushed?
markdorison's user avatar
4857 votes
45 answers
4.4m views

How do I get a timestamp in JavaScript?

I want a single number that represents the current date and time, like a Unix timestamp.
Pablo Fernandez's user avatar
4797 votes
48 answers
1.8m views

How do I clone all remote branches?

My master and development branches are tracked remotely on GitHub. How do I clone both these branches?
Peter Coulton's user avatar
4781 votes
9 answers
948k views

How to pass "Null" (a real surname!) to a SOAP web service in ActionScript 3

We have an employee whose surname is Null. Our employee lookup application is killed when that last name is used as the search term (which happens to be quite often now). The error received is: <...
bill's user avatar
  • 27.1k
4741 votes
66 answers
2.7m views

How do I read / convert an InputStream into a String in Java?

If you have a java.io.InputStream object, how should you process that object and produce a String? Suppose I have an InputStream that contains text data, and I want to convert it to a String, so for ...
Johnny Maelstrom's user avatar
4741 votes
32 answers
1.3m views

How do I update or sync a forked repository on GitHub?

I forked a project, made changes, and created a pull request which was accepted. New commits were later added to the repository. How do I get those commits into my fork?
Lea Hayes's user avatar
  • 63.7k
4681 votes
36 answers
1.1m views

What is the difference between @staticmethod and @classmethod in Python?

What is the difference between a method decorated with @staticmethod and one decorated with @classmethod?
Daryl Spitzer's user avatar
4609 votes
38 answers
3.1m views

How slicing in Python works

How does Python's slice notation work? That is: when I write code like a[x:y:z], a[:], a[::2] etc., how can I understand which elements end up in the slice? See Why are slice and range upper-bound ...
Simon's user avatar
  • 80.1k
4590 votes
44 answers
3.9m views

Setting "checked" for a checkbox with jQuery

I'd like to do something like this to tick a checkbox using jQuery: $(".myCheckBox").checked(true); or $(".myCheckBox").selected(true); Does such a thing exist?
tpower's user avatar
  • 56.7k
4587 votes
41 answers
1.7m views

How do I remove a submodule?

How do I remove a Git submodule? Why can't I do git submodule rm module_name?
R. Martinho Fernandes's user avatar
4502 votes
15 answers
855k views

"Thinking in AngularJS" if I have a jQuery background? [closed]

Suppose I'm familiar with developing client-side applications in jQuery, but now I'd like to start using AngularJS. Can you describe the paradigm shift that is necessary? Here are a few questions that ...
Mark Rajcok's user avatar
4490 votes
8 answers
601k views

Why does Google prepend while(1); to their JSON responses?

Why does Google prepend while(1); to their (private) JSON responses? For example, here's a response while turning a calendar on and off in Google Calendar: while (1); [ ['u', [ ['smsSentFlag', ...
Jess's user avatar
  • 42.7k
4469 votes
35 answers
3.3m views

How do I check if a directory exists or not in a Bash shell script?

What command checks if a directory exists or not within a Bash shell script?
Grundlefleck's user avatar
4458 votes
26 answers
931k views

How is Docker different from a virtual machine?

I keep rereading the Docker documentation to try to understand the difference between Docker and a full VM. How does it manage to provide a full filesystem, isolated networking environment, etc. ...
zslayton's user avatar
  • 52.3k
4435 votes
54 answers
2.5m views

Which "href" value should I use for JavaScript links, "#" or "javascript:void(0)"?

The following are two methods of building a link that has the sole purpose of running JavaScript code. Which is better, in terms of functionality, page load speed, validation purposes, etc.? ...
4421 votes
71 answers
1.4m views

How do I avoid checking for nulls in Java?

I use x != null to avoid NullPointerException. Is there an alternative? if (x != null) { // ... }
4415 votes
46 answers
6.4m views

How to find the index for a given item in a list?

Given a list ["foo", "bar", "baz"] and an item in the list "bar", how do I get its index 1?
Eugene M's user avatar
  • 48.5k
4395 votes
42 answers
2.0m views

Change an HTML input's placeholder color with CSS

Chrome v4 supports the placeholder attribute on input[type=text] elements (others probably do too). However, the following CSS doesn't do anything to the placeholder's value: input[placeholder], [...
4393 votes
36 answers
1.0m views

How to enumerate an enum?

How can you enumerate an enum in C#? E.g. the following code does not compile: public enum Suit { Spades, Hearts, Clubs, Diamonds } public void EnumerateAllSuitsDemoMethod() { ...
Ian Boyd's user avatar
  • 253k
4377 votes
41 answers
5.1m views

How do I delete a commit from a branch?

How do I delete a commit from my branch history? Should I use git reset --hard HEAD?
hap497's user avatar
  • 160k
4352 votes
130 answers
1.8m views

How can I close/hide the Android soft keyboard programmatically?

I have an EditText and a Button in my layout. After writing in the edit field and clicking on the Button, I want to hide the virtual keyboard when touching outside the keyboard. Can someone provide a ...
4347 votes
21 answers
2.1m views

Undoing a git rebase

How do I easily undo a git rebase? A lengthy manual method is: checkout the commit parent to both of the branches create and checkout a temporary branch cherry-pick all commits by hand reset the ...
webmat's user avatar
  • 59.9k
4343 votes
27 answers
3.0m views

How do I copy to the clipboard in JavaScript?

How do I copy text to the clipboard (multi-browser)? Related: How does Trello access the user's clipboard?
Santiago Corredoira's user avatar
4329 votes
17 answers
5.9m views

Iterating over dictionaries using 'for' loops

d = {'x': 1, 'y': 2, 'z': 3} for key in d: print(key, 'corresponds to', d[key]) How does Python recognize that it needs only to read the key from the dictionary? Is key a special keyword, or is ...
TopChef's user avatar
  • 45k

15 30 50 per page