If you've found yourself needing to create a custom order with the Commerce API, you've likely come across this article "Creating orders with the Drupal Commerce API" or found your answer from the Commerce Examples module. The solution provided works great, but it doesn't tell you how to assign values to custom fields you've created for line items. Here's how you do it.
The place where I write things down.
If you find yourself needing to manipulate node fields during hook_node_insert or hook_node_update, the best way is to use field_attach_update. Especially, if you need access the node id.
When defining an "access callback" for a menu item in hook_menu, Drupal doesn't provide a callback for restricting access by a user's role. Which seems to be a bit of an oversight. So here's some code run a simple check against the user's role
If you need to include a custom template for a block in your Drupal 7 module, here's how to do it.
The error "Notice: Undefined index: access in _menu_translate()..." shows when Drupal is looking for a access callback that doesn't exist (see _menu_check_access() does not warn when the access callback does not exist).
I came across this error when working with the Entity API and using Model as my base. I had to change the module and entity names, but I forgot one. So the access callback in hook_menu() was looking for the wrong function. But instead of telling me that, Drupal threw that "Undefined index" error.