Most Popular

1500 questions
2527
votes
16 answers

When to use margin vs padding in CSS

When writing CSS, is there a particular rule or guideline that should be used in deciding when to use margin and when to use padding?
Alex Angas
  • 57,781
  • 39
  • 132
  • 208
2526
votes
45 answers

PowerShell says "execution of scripts is disabled on this system."

I am trying to run a cmd file that calls a PowerShell script from cmd.exe, but I am getting this error: Management_Install.ps1 cannot be loaded because the execution of scripts is disabled on this system. I ran this command: Set-ExecutionPolicy…
Conor
  • 25,279
  • 3
  • 14
  • 4
2522
votes
54 answers

How do I import an SQL file using the command line in MySQL?

I have a .sql file with an export from phpMyAdmin. I want to import it into a different server using the command line. I have a Windows Server 2008 R2 installation. I placed the .sql file on the C drive, and I tried this command database_name <…
Jaylen
  • 36,481
  • 37
  • 117
  • 208
2519
votes
42 answers

Compare two dates with JavaScript

Can someone suggest a way to compare the values of two dates greater than, less than, and not in the past using JavaScript? The values will be coming from text boxes.
Alex
  • 36,645
  • 21
  • 44
  • 41
2519
votes
38 answers

How to make a div 100% height of the browser window

I have a layout with two columns - a left div and a right div. The right div has a grey background-color, and I need it to expand vertically depending on the height of the user's browser window. Right now the background-color ends at the last piece…
mike
  • 25,247
  • 3
  • 15
  • 4
2509
votes
50 answers

Validate decimal numbers in JavaScript - IsNumeric()

What's the cleanest, most effective way to validate decimal numbers in JavaScript? Bonus points for: Clarity. Solution should be clean and simple. Cross-platform. Test cases: 01. IsNumeric('-1') => true 02. IsNumeric('-1.5') => true 03.…
Michael Haren
  • 101,522
  • 39
  • 162
  • 203
2504
votes
16 answers

How do I get a substring of a string in Python?

I want to get a new string from the third character to the end of the string, e.g. myString[2:end]. If omitting the second part means 'till the end', and if you omit the first part, does it start from the start?
Joan Venge
  • 292,935
  • 205
  • 455
  • 667
2503
votes
53 answers

How to upgrade all Python packages with pip

Is it possible to upgrade all Python packages at one time with pip? Note: that there is a feature request for this on the official issue tracker.
thedjpetersen
  • 25,769
  • 4
  • 24
  • 27
2497
votes
15 answers

What is the best (and safest) way to merge a Git branch into master?

A new branch from master is created, we call it test. There are several developers who either commit to master or create other branches and later merge into master. Let's say work on test is taking several days and you want to continuously keep test…
moe
  • 27,706
  • 3
  • 18
  • 16
2494
votes
55 answers

Deep cloning objects

I want to do something like: MyObject myObj = GetMyObj(); // Create and fill a new object MyObject newObj = myObj.Clone(); And then make changes to the new object that are not reflected in the original object. I don't often need this functionality,…
NakedBrunch
  • 47,255
  • 13
  • 71
  • 97
2486
votes
40 answers

Find (and kill) process locking port 3000 on Mac

How do I find (and kill) processes that listen to/use my TCP ports? I'm on macOS. Sometimes, after a crash or some bug, my Rails app is locking port 3000. I can't find it using ps -ef... When running rails server I get Address already in use -…
oma
  • 34,068
  • 11
  • 68
  • 96
2484
votes
34 answers

How can I determine if a variable is 'undefined' or 'null'?

How do I determine if variable is undefined or null? My code is as follows: var EmpName = $("div#esd-names div#name").attr('class'); if(EmpName == 'undefined'){ // DO SOMETHING };
But if I do…
sadmicrowave
  • 37,748
  • 34
  • 105
  • 178
2482
votes
31 answers

Do a "git export" (like "svn export")?

I've been wondering whether there is a good "git export" solution that creates a copy of a tree without the .git repository directory. There are at least three methods I know of: git clone followed by removing the .git repository directory. git…
Greg Hewgill
  • 890,778
  • 177
  • 1,125
  • 1,260
2480
votes
18 answers

How do I sort a list of dictionaries by a value of the dictionary?

How do I sort a list of dictionaries by a specific key's value? Given: [{'name': 'Homer', 'age': 39}, {'name': 'Bart', 'age': 10}] When sorted by name, it should become: [{'name': 'Bart', 'age': 10}, {'name': 'Homer', 'age': 39}]
masi
  • 118
  • 3
  • 5
  • 9
2468
votes
23 answers

How to make a great R reproducible example

When discussing performance with colleagues, teaching, sending a bug report or searching for guidance on mailing lists and here on Stack Overflow, a reproducible example is often asked and always helpful. What are your tips for creating an excellent…
Andrie
  • 170,733
  • 42
  • 434
  • 486