Most Popular

1500 questions
1555
votes
13 answers

What is the purpose of Node.js module.exports and how do you use it?

What is the purpose of Node.js module.exports and how do you use it? I can't seem to find any information on this, but it appears to be a rather important part of Node.js as I often see it in source code. According to the Node.js…
mrwooster
  • 23,789
  • 12
  • 38
  • 48
1555
votes
34 answers

How do I vertically align text in a div?

I am trying to find the most effective way to align text with a div. I have tried a few things and none seem to work. .testimonialText { position: absolute; left: 15px; top: 15px; width: 150px; height: 309px; vertical-align:…
shinjuo
  • 20,498
  • 23
  • 73
  • 104
1554
votes
17 answers

Create a dictionary with comprehension

Can I use list comprehension syntax to create a dictionary? For example, by iterating over pairs of keys and values: d = {... for k, v in zip(keys, values)}
flybywire
  • 261,858
  • 191
  • 397
  • 503
1552
votes
19 answers

How does the 'Access-Control-Allow-Origin' header work?

Apparently, I have completely misunderstood its semantics. I thought of something like this: A client downloads JavaScript code MyCode.js from http://siteA - the origin. The response header of MyCode.js contains Access-Control-Allow-Origin:…
mark
  • 59,016
  • 79
  • 296
  • 580
1550
votes
34 answers

Interface vs Abstract Class (general OO)

I have recently had two telephone interviews where I've been asked about the differences between an Interface and an Abstract class. I have explained every aspect of them I could think of, but it seems they are waiting for me to mention something…
Houman
  • 64,245
  • 87
  • 278
  • 460
1547
votes
35 answers

How do I make a redirect in PHP?

Is it possible to redirect a user to a different page through the use of PHP? Say the user goes to www.example.com/page.php and I want to redirect them to www.example.com/index.php, how would I do so without the use of a meta refresh? Is it…
Sam
  • 18,417
  • 5
  • 22
  • 11
1546
votes
18 answers

How to convert a string to number in TypeScript?

Given a string representation of a number, how can I convert it to number type in TypeScript? var numberString: string = "1234"; var numberValue: number = /* what should I do with `numberString`? */;
Paul0515
  • 23,515
  • 9
  • 32
  • 47
1542
votes
11 answers

Use of *args and **kwargs

So I have difficulty with the concept of *args and **kwargs. So far I have learned that: *args = list of arguments - as positional arguments **kwargs = dictionary - whose keys become separate keyword arguments and the values become values of these…
MacPython
  • 17,901
  • 10
  • 42
  • 48
1541
votes
41 answers

What is the difference between concurrency and parallelism?

What is the difference between concurrency and parallelism?
StackUnderflow
  • 24,080
  • 14
  • 54
  • 77
1540
votes
10 answers

How to force Docker for a clean build of an image

I have build a Docker image from a Docker file using the below command. $ docker build -t u12_core -f u12_core . When I am trying to rebuild it with the same command, it's using the build cache like: Step 1 : FROM ubuntu:12.04 --->…
Pavan Gupta
  • 17,663
  • 4
  • 22
  • 29
1540
votes
8 answers

What are the differences between type() and isinstance()?

What are the differences between these two code snippets? Using type: import types if type(a) is types.DictType: do_something() if type(b) in types.StringTypes: do_something_else() Using isinstance: if isinstance(a, dict): …
abbot
  • 27,408
  • 6
  • 54
  • 57
1539
votes
12 answers

Get the current year in JavaScript

How do I get the current year in JavaScript?
Satch3000
  • 47,356
  • 86
  • 216
  • 346
1539
votes
10 answers

What is setup.py?

What is setup.py and how can it be configured or used?
Software Enthusiastic
  • 25,147
  • 16
  • 58
  • 68
1539
votes
10 answers

What are bitwise shift (bit-shift) operators and how do they work?

I've been attempting to learn C in my spare time, and other languages (C#, Java, etc.) have the same concept (and often the same operators)... At a core level, what does bit-shifting (<<, >>, >>>) do, what problems can it help solve, and what…
1534
votes
15 answers

How do I check if a directory exists in Python?

How do I check if a directory exists in Python?
David542
  • 104,438
  • 178
  • 489
  • 842