Magento get configurable product from simple product

If you need to get the configurable product from a simple one, you can do this

$simpleProductId = 666;
$parentIds = Mage::getResourceSingleton('catalog/product_type_configurable')
                  ->getParentIdsByChild($simpleProductId);
$configurableProduct = Mage::getModel('catalog/product')->load($parentIds[0]);
echo $configurableProduct->getId();