Most Popular

1500 questions
2150
votes
27 answers

What is the scope of variables in JavaScript?

What is the scope of variables in javascript? Do they have the same scope inside as opposed to outside a function? Or does it even matter? Also, where are the variables stored if they are defined globally?
lYriCAlsSH
  • 55,956
  • 10
  • 25
  • 20
2145
votes
30 answers

Daylight saving time and time zone best practices

I am hoping to make this question and the answers to it the definitive guide to dealing with daylight saving time, in particular for dealing with the actual change overs. If you have anything to add, please do Many systems are dependent on keeping…
Oded
  • 477,625
  • 97
  • 867
  • 998
2140
votes
26 answers

How does JavaScript .prototype work?

I'm not that into dynamic programming languages but I've written my fair share of JavaScript code. I never really got my head around this prototype-based programming, does any one know how this works? var obj = new Object(); obj.prototype.test =…
John Leidegren
  • 58,171
  • 19
  • 126
  • 149
2139
votes
20 answers

How to delete from a text file, all lines that contain a specific string?

How would I use sed to delete all lines in a text file that contain a specific string?
A Clockwork Orange
  • 22,153
  • 6
  • 23
  • 25
2135
votes
22 answers

How to exit in Node.js

What is the command that is used to exit? (i.e terminate the Node.js process)
700 Software
  • 81,209
  • 77
  • 221
  • 333
2135
votes
33 answers

Limiting floats to two decimal points

I want a to be rounded to 13.95. I tried using round: >>> a 13.949999999999999 >>> round(a, 2) 13.949999999999999
kevin
2128
votes
12 answers

Do I commit the package-lock.json file created by npm 5?

npm 5 was released today and one of the new features include deterministic installs with the creation of a package-lock.json file. Is this file supposed to be kept in source control? I'm assuming it's similar to yarn.lock and composer.lock, both of…
rink.attendant.6
  • 40,889
  • 58
  • 100
  • 149
2127
votes
18 answers

How can I symlink a file in Linux?

I want to make a symbolic link in Linux. I have written this Bash command where the first path is the folder I want link into and the second path is the compiled source. ln -s '+basebuild+'/IpDome-kernel/kernel…
chrisg
  • 38,411
  • 35
  • 84
  • 106
2122
votes
36 answers

Importing files from different folder

I have the following folder structure. application ├── app │   └── folder │   └── file.py └── app2 └── some_folder └── some_file.py I want to import some functions from file.py in some_file.py. I've tried from…
Ivan
  • 25,417
  • 6
  • 23
  • 21
2122
votes
37 answers

How to check if a variable is set in Bash

How do I know if a variable is set in Bash? For example, how do I check if the user gave the first parameter to a function? function a { # if $1 is set ? }
prosseek
  • 169,389
  • 197
  • 542
  • 840
2120
votes
70 answers

How do I calculate someone's age based on a DateTime type birthday?

Given a DateTime representing a person's birthday, How do I calculate their age in years?
Jeff Atwood
  • 62,295
  • 46
  • 147
  • 153
2120
votes
21 answers

How to change permissions for a folder and its subfolders/files in one step

I would like to change the permissions of a folder and all its subfolders and files in one step (command) in Linux. I have already tried the below command but it works only for the mentioned folder: chmod 775 /opt/lampp/htdocs Is there a way to set…
Adam Halasz
  • 55,145
  • 63
  • 144
  • 211
2110
votes
8 answers

C++11 introduced a standardized memory model. What does it mean? And how is it going to affect C++ programming?

C++11 introduced a standardized memory model, but what exactly does that mean? And how is it going to affect C++ programming? This article (by Gavin Clarke who quotes Herb Sutter) says that, The memory model means that C++ code now has a…
Nawaz
  • 341,464
  • 111
  • 648
  • 831
2110
votes
41 answers

How do I format a Microsoft JSON date?

I'm taking my first crack at Ajax with jQuery. I'm getting my data onto my page, but I'm having some trouble with the JSON data that is returned for Date data types. Basically, I'm getting a string back that looks like…
Mark Struzinski
  • 32,365
  • 34
  • 104
  • 135
2110
votes
27 answers

Viewing unpushed Git commits

How can I view any local commits I've made, that haven't yet been pushed to the remote repository? Occasionally, git status will print out that my branch is X commits ahead of origin/master, but not always. Is this a bug with my install of Git, or…
Josh Buhler
  • 25,368
  • 9
  • 28
  • 45