How can I calculate the angle of attack of an airfoil?
The angle of attack is the angle between the wing and the direction of flight. The direction of flight is opposite to the airflow, so the angle of attack is also the angle between the wing and the relative wind.

For a more refined definition (thanks @Peter Kämpf): The flight path direction (the velocity vector in the language of aerodynamicists) should be expressed relative to the air mass, not to the ground (as measured by an inertial system), but that's beyond the topic.



How to compute it? Well, it's like airspeed, we don't. It's just measured using a small windvane:


A380 angle of attack sensor (combined with a Pitot-static), source

In the image above, the black angle of attack sensor is combined with a classic Pitot-static which measures airspeed. On airliners, there are usually several AOA sensors. The one in the picture is located on the FO side, air comes from the right side.

Another simple AOA sensor at the bottom, Captain side:


Source (original source not found)

There is a specific AOA sensor found on GA aircraft, to trigger an alarm when approaching the critical angle of attack: The stall sensor:


Source

This strip located at the wing leading edge has two positions and rock abruptly before the critical angle of attack is reached. It triggers an alarm in the cockpit, so that the pilot can reduce the angle of attack.



A final note: The AOA wasn't displayed to the crew in the cockpit, only the pitch angle was. Newer aircraft now display both. I think it was a recommendation of the BEA after AF447 accident, were the crew couldn't figure out the AOA they were at after a Pitot-static froze.