Help understanding this schematic : Why is the diode there (AT89C2051 Programmer)?
As some form of protection to prevent A0 from getting roasted with 12V? I think it might be the case, but I don't understand how it works to prevent that.


This is the answer.  Here's how it works:

When A1 is high, 12V is supplied to the reset pin via the optocoupler.  The reset pin is now at +12V, which would presumably damage whatever is connected to A0 without some sort of protection.  

The diode is configured such that it will conduct when its anode (the pin connected between the two resistors) is greater than 5V.  So when A1 is high, and reset is at 12V, that diode will begin to conduct, and clamps the voltage at its anode to 5V plus the forward voltage of the diode--call it 0.7V, so the anode is at 5.7V.  R2 limits the amount of current that can flow through the diode, which prevents overloading the 12V supply and blowing up the diode.  since it's 1k, and it will have 12-5.7=6.3V across it, it will have about 6.3 mA flowing through the diode and the resistor.  

From the schematic at the github project you linked, A0 is connected to an arduino, and microcontrollers, like most ICs, are not rated to have any of their IOs at a higher voltage than that of their supply.  Usually there are diodes from each pin to the positive and negative rails built into the IC for the suppression of ESD.  If an IO pin is brought above the supply voltage, these diodes will conduct, and with sufficient, sustained current, the IC may be damaged.  That's why it's important that the Arduino is not directly exposed to the 12V on the reset pin.  Since D1 clamps to something like 5.7V, this could be enough that an ESD diode in the Arduino would begin to conduct, so R3 limits the amount of current that can be driven through the diode, and ensures that D1 does all of the clamping.