Simple as this.
<?php require_once('app/Mage.php'); //Path to Magento umask(0); Mage::app(); // Run you code here ?>