Most Popular

1500 questions
6290
votes
29 answers

How to make Git "forget" about a file that was tracked but is now in .gitignore?

There is a file that was being tracked by git, but now the file is on the .gitignore list. However, that file keeps showing up in git status after it's edited. How do you force git to completely forget about it?
Ivan
  • 77,768
  • 15
  • 47
  • 57
6178
votes
21 answers

What are metaclasses in Python?

In Python, what are metaclasses and what do we use them for?
e-satis
  • 515,820
  • 103
  • 283
  • 322
6149
votes
44 answers

How do I check whether a file exists without exceptions?

How do I check whether a file exists or not, without using the try statement?
spence91
  • 67,587
  • 8
  • 25
  • 19
6040
votes
34 answers

What is the difference between "px", "dip", "dp" and "sp"?

What is the difference between Android units of measure? px dip dp sp
6002
votes
52 answers

How do I find all files containing specific text on Linux?

I'm trying to find a way to scan my entire Linux system for all files containing a specific string of text. Just to clarify, I'm looking for text within the file, not in the file name. When I was looking up how to do this, I came across this…
Nathan
  • 65,860
  • 11
  • 32
  • 47
5960
votes
42 answers

How to return the response from an asynchronous call?

I have a function foo which makes an asynchronous request. How can I return the response/result from foo? I am trying to return the value from the callback, as well as assigning the result to a local variable inside the function and returning that…
Felix Kling
  • 705,106
  • 160
  • 1,004
  • 1,072
5692
votes
35 answers

What is the difference between POST and PUT in HTTP?

According to RFC 2616, § 9.5, POST is used to create a resource: The POST method is used to request that the origin server accept the entity enclosed in the request as a new subordinate of the resource identified by the Request-URI in the…
alex
  • 67,783
  • 9
  • 46
  • 57
5660
votes
49 answers

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.length == 0 inside of an if statement. Is there a…
bcasp
  • 57,427
  • 4
  • 17
  • 14
5650
votes
49 answers

How do I merge two dictionaries in a single expression (taking union of dictionaries)?

I have two Python dictionaries, and I want to write a single expression that returns these two dictionaries, merged (i.e. taking the union). The update() method would be what I need, if it returned its result instead of modifying a dictionary…
Carl Meyer
  • 105,276
  • 18
  • 102
  • 113
5629
votes
62 answers

How do I include a JavaScript file in another JavaScript file?

Is there something in JavaScript similar to @import in CSS that allows you to include a JavaScript file inside another JavaScript file?
Alec Smart
  • 85,672
  • 35
  • 115
  • 178
5532
votes
49 answers

How to disable text selection highlighting

For anchors that act like buttons (for example Questions, Tags, Users, etc. which are located on the top of the Stack Overflow page) or tabs, is there a CSS standard way to disable the highlighting effect if the user accidentally selects the text? I…
anon
5491
votes
15 answers

Move the most recent commit(s) to a new branch with Git

I'd like to move the last several commits I've committed to master to a new branch and take master back to before those commits were made. Unfortunately, my Git-fu is not strong enough yet, any help? I.e. How can I go from this master A - B - C - D…
Mark A. Nicolosi
  • 72,599
  • 10
  • 41
  • 46
5484
votes
12 answers

The definitive guide to form-based website authentication

Form-based authentication for websites We believe that Stack Overflow should not just be a resource for very specific technical questions, but also for general guidelines on how to solve variations on common problems. "Form based authentication for…
Michiel de Mare
  • 40,513
  • 27
  • 100
  • 132
5373
votes
71 answers

How can I get the source directory of a Bash script from within the script itself?

How do I get the path of the directory in which a Bash script is located, inside that script? I want to use a Bash script as a launcher for another application. I want to change the working directory to the one where the Bash script is located, so I…
Jiaaro
  • 67,024
  • 38
  • 154
  • 182
5310
votes
62 answers

How to execute a program or call a system command from Python

How do you call an external command (as if I'd typed it at the Unix shell or Windows command prompt) from within a Python script?
freshWoWer
  • 54,641
  • 10
  • 32
  • 33