In Drupal 6, it was easy to insert a block into a template with the following code:
$block = module_invoke(\'views\', \'block\', \'view\', \'block_name\');
print
There's module called insert_block for those which want to insert block "Drupal way" (not to program anything, just enable the module). Here's how to set it up.
NOTE: I know this question is about "programmatically inserting a block into a template or node" but Google sends people here even their are looking for non-programmer solution like me.