controling brushless motor esc with external souce

Typically, ESCs need to be armed. That involves waiting for it to beep, and then sending signals (write(something)) from 0 to 180, to discover where the ESC begins and ends responding. How have you armed/calibrated your ESC?