What gate resistor for IGBT irg4pc50s
You take parameters from datasheet: output current, output voltage, on/off resitance. Then a simple ohms law R=U/I. The MOSFET is a capacitor like, when discharged it will sink the current limited by gate resistor, when discharged also. So let's make one rude example:
Vcc=15V
HCPL-3120 max peak current = 2.5A
Vout=Vcc-4
R=(15-4)V/2.5A= 4.4ohm.  Take a resistor from 4.7 to 10 ohm.