Most Popular

1500 questions
2829
votes
23 answers

Determine installed PowerShell version

How can I determine what version of PowerShell is installed on a computer, and indeed if it is installed at all?
Tangiest
  • 43,737
  • 24
  • 82
  • 113
2827
votes
17 answers

What's the difference between dependencies, devDependencies, and peerDependencies in NPM package.json file?

This documentation answers my question very poorly. I didn't understand those explanations. Can someone say in simpler words? Maybe with examples if it's hard to choose simple words? Also added peerDependencies, which is closely related and might…
Vitalii Korsakov
  • 45,737
  • 20
  • 72
  • 90
2823
votes
17 answers

How to mkdir only if a directory does not already exist?

I am writing a shell script to run under the KornShell (ksh) on AIX. I would like to use the mkdir command to create a directory. But the directory may already exist, in which case I do not want to do anything. So I want to either test to see that…
Spike Williams
  • 35,795
  • 13
  • 48
  • 60
2820
votes
11 answers

How can I remove a key from a Python dictionary?

I want to remove a key from a dictionary if it is present. I currently use this code: if key in my_dict: del my_dict[key] Without the if statement, the code will raise KeyError if the key is not present. How can I handle this more simply? See…
Tony
  • 36,591
  • 10
  • 48
  • 83
2815
votes
14 answers

How do I make Git ignore file mode (chmod) changes?

I have a project in which I have to change the mode of files with chmod to 777 while developing, but which should not change in the main repo. Git picks up on chmod -R 777 . and marks all files as changed. Is there a way to make Git ignore mode…
Ro Marcus Westin
  • 28,490
  • 4
  • 18
  • 11
2803
votes
21 answers

Ignore files that have already been committed to a Git repository

I have an already initialized Git repository that I added a .gitignore file to. How can I refresh the file index so the files I want ignored get ignored?
trobrock
  • 46,549
  • 11
  • 40
  • 46
2795
votes
33 answers

Open a URL in a new tab (and not a new window)

I'm trying to open a URL in a new tab, as opposed to a popup window. I've seen related questions where the responses would look something like: window.open(url,'_blank'); window.open(url); But none of them worked for me, the browser still tried to…
Mark
  • 39,169
  • 11
  • 42
  • 48
2795
votes
7 answers

Flash CS4 refuses to let go

I have a Flash project, and it has many source files. I have a fairly heavily-used class, call it Jenine. I recently (and, perhaps, callously) relocated Jenine from one namespace to another. I thought we were ready - I thought it was time. The new…
Ender
  • 27,153
  • 7
  • 30
  • 34
2781
votes
26 answers

Is there an equivalent of 'which' on the Windows command line?

As I sometimes have path problems, where one of my own cmd scripts is hidden (shadowed) by another program (earlier on the path), I would like to be able to find the full path to a program on the Windows command line, given just its name. Is there…
namin
  • 37,139
  • 8
  • 58
  • 74
2776
votes
34 answers

Homebrew install specific version of formula?

How do I install a specific version of a formula in homebrew? For example, postgresql-8.4.4 instead of the latest 9.0.
Gravis
  • 30,149
  • 5
  • 23
  • 20
2775
votes
31 answers

How do I get a YouTube video thumbnail from the YouTube API?

If I have a YouTube video URL, is there any way to use PHP and cURL to get the associated thumbnail from the YouTube API?
CodeOverload
  • 47,274
  • 54
  • 131
  • 219
2773
votes
27 answers

How can I prevent SQL injection in PHP?

If user input is inserted without modification into an SQL query, then the application becomes vulnerable to SQL injection, like in the following example: $unsafe_variable = $_POST['user_input']; mysql_query("INSERT INTO `table` (`column`) VALUES…
Andrew G. Johnson
  • 26,603
  • 30
  • 91
  • 135
2773
votes
50 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
  • 27,759
  • 3
  • 15
  • 4
2770
votes
27 answers

Copying files from Docker container to host

I'm thinking of using Docker to build my dependencies on a Continuous Integration (CI) server, so that I don't have to install all the runtimes and libraries on the agents themselves. To achieve this I would need to copy the build artifacts that…
user2668128
  • 39,482
  • 8
  • 27
  • 34
2766
votes
29 answers

Do I cast the result of malloc?

In this question, someone suggested in a comment that I should not cast the result of malloc. i.e., I should do this: int *sieve = malloc(sizeof(*sieve) * length); rather than: int *sieve = (int *) malloc(sizeof(*sieve) * length); Why would this…
Patrick McDonald
  • 64,141
  • 14
  • 108
  • 120