Most Popular

1500 questions
1154
votes
20 answers

Can a local variable's memory be accessed outside its scope?

I have the following code. #include int * foo() { int a = 5; return &a; } int main() { int* p = foo(); std::cout << *p; *p = 8; std::cout << *p; } And the code is just running with no runtime exceptions! The…
Avi Shukron
  • 6,088
  • 8
  • 50
  • 84
1153
votes
28 answers

Getting error: Peer authentication failed for user "postgres", when trying to get pgsql working with rails

I'm getting the error: FATAL: Peer authentication failed for user "postgres" when I try to make postgres work with Rails. Here's my pg_hba.conf, my database.yml, and a dump of the full trace. I changed authentication to md5 in pg_hba and tried…
orderof1
  • 11,831
  • 4
  • 18
  • 18
1152
votes
9 answers

List all environment variables from the command line

Is it possible to list all environment variables from a Windows' command prompt? Something equivalent to PowerShell's gci env: (or ls env: or dir env:).
Nicola Cossu
  • 54,599
  • 15
  • 92
  • 98
1152
votes
41 answers

Another Git process seems to be running in this repository

I'm trying to learn how to use Git and have created a small project with an HTML, CSS, and JavaScript file. I made a branch from my basically empty project and then made some changes to my code. I tried staging the changes, but I get the following…
Matt Corby
  • 11,984
  • 3
  • 12
  • 19
1152
votes
9 answers

How to iterate over arguments in a Bash script

I have a complex command that I'd like to make a shell/bash script of. I can write it in terms of $1 easily: foo $1 args -o $1.ext I want to be able to pass multiple input names to the script. What's the right way to do it? And, of course, I…
Thelema
  • 14,257
  • 6
  • 27
  • 35
1151
votes
13 answers

What is the difference between
and

What is the difference between
and
in HTML? Aren't we defining sections in both cases?
Simplicity
  • 47,404
  • 98
  • 256
  • 385
1151
votes
9 answers

jQuery how to find an element based on a data-attribute value?

I've got the following scenario: var el = 'li'; and there are 5
  • 's on the page each with a data-slide=number attribute (number being 1,2,3,4,5 respectively). I now need to find the currently active slide number which is mapped to var current =…
  • Jannis
    • 17,025
    • 18
    • 62
    • 75
    1151
    votes
    8 answers

    What is the difference between String.slice and String.substring?

    Does anyone know what the difference is between these two methods? String.prototype.slice String.prototype.substring
    tmim
    • 12,091
    • 4
    • 18
    • 12
    1151
    votes
    20 answers

    How to parse XML and get instances of a particular node attribute?

    I have many rows in XML and I'm trying to get instances of a particular node attribute. How do I access the values of the attribute foobar? In this example, I want…
    randombits
    • 47,058
    • 76
    • 251
    • 433
    1150
    votes
    40 answers

    How to make links in a TextView clickable

    I have the following TextView defined:
    Richard
    • 28,691
    • 8
    • 33
    • 34
    1150
    votes
    23 answers

    What's the difference between OpenID and OAuth?

    I'm really trying to understand the difference between OpenID and OAuth? Maybe they're two totally separate things?
    Micah
    • 111,873
    • 86
    • 233
    • 325
    1149
    votes
    20 answers

    How to set environment variables in Python?

    I need to set some environment variables in the Python script and I want all the other scripts that are called from Python to see the environment variables' set. If I do, os.environ["DEBUSSY"] = 1 it complains saying that 1 has to be a string. I…
    prahallada
    • 11,741
    • 4
    • 16
    • 6
    1149
    votes
    10 answers

    Is there a regular expression to detect a valid regular expression?

    Is it possible to detect a valid regular expression with another regular expression? If so please give example code below.
    psytek
    • 9,011
    • 3
    • 17
    • 7
    1148
    votes
    38 answers

    How do you auto format code in Visual Studio?

    I know Visual Studio can auto format to make my methods and loops indented properly, but I cannot find the setting.
    user719550
    • 11,507
    • 3
    • 15
    • 7
    1147
    votes
    8 answers

    How to subtract a day from a date?

    I have a Python datetime.datetime object. What is the best way to subtract one day?
    defrex
    • 15,735
    • 7
    • 34
    • 45