Embed Drupal node form anywhere
Simple 1 line of code to embed a Drupal node form anywhere in your site although I would recommend doing it the Drupal way which is creating a custom module for this.
print drupal_render(node_add('NODE_TYPE'));Where NODE_TYPE is your content type (machine name).
If the code above returns an error that says the function node_add() is undefined, add the following code before it.
Display Drupal menu local task tab according to node content type
By default every node should have the menu tab (MENU LOCAL TASK) of View and Edit.
If your module wants to add its own tab but only restricted to content type of "foo", then use the following code snippet.
XYZ below is your page callback for the new custom tab. Basically it calls another function to validate user's permission but we manipulate it to check the node type (via access callback).
Themer-friendly menu link CSS classes for Drupal theme
What this code does is to give themers an easier way to style individual menu items in Drupal. For example, if you have a menu item title "Company Profile" and you want this link to be red colour, the following code (to be placed inside template.php file of your theme) will provide menu CSS class of <li class="... menu-company-profile">
Style your Drupal theme according to day or night time
Here's a simple snippet to allow you to style your theme differently for day or night time. Place the following code into your theme's template.php file.
Display Drupal block anywhere
Ever wanted to show a Drupal block anywhere in your theme? Use the following code snippet, take note that you will need the module of the block and its delta.
// Load the block region based on module and delta key.
$_your_block = _block_get_renderable_array(_block_render_blocks(array(block_load('MODULE', 'DELTA'))));
// Now we display it.
print render($_your_block);
Add CSS classes to body tag based on your Drupal path
Add custom CSS classes to <body> tag of your theme.
/**
* Implements template_preprocess_html().
*/
function YOUR_THEME_preprocess_html(&$vars) {
$path = 'your-drupal-page';
if (drupal_match_path($_GET['q'], $path) || drupal_match_path(drupal_get_path_alias($_GET['q']), $path)) {
$vars['classes_array'][] = 'page-my-css-class';
}
}The $path can be more than one path, separated with newline "\n".
Add close button to Drupal status messages
Add close button "x" to status messages for better user experience and usability.

Place the following JavaScript to your theme.
Use CDN jQuery for your Drupal theme
Simple code to use jQuery from Google CDN. Change the version "1.7.1" to your preferred version.
You can also switch to use Microsoft CDN, or other sources by changing the jQuery path below.
Hide Drupal 7 generator meta tag
Use this code in your theme's template.php file if you want to obfuscate your visitors from easily knowing your site is powered by Drupal. It will replace the existing meta tag in <head> section:
Style Drupal node according to Teaser or Full page view
Allows you to theme nodes according to the view mode. This code provides more template suggestion for you to style.
If you have for example content type "computer", you may copy node.tpl.php in your theme to node--computer.tpl.php or more specifically node--computer-teaser.tpl.php or node--computer-page.tpl.php