PHP fopen write to single line

<?php
$text = "Here is my new line.";
$newline = "$text\n"
$filename = $_SERVER['DOCUMENT_ROOT'] . "/myfile.php";
if (!($fp = fopen($filename, 'a'))) {
  print 'Cannot open file';
} else {
  if(fwrite($fp, "$newline")){
    print "line written<br />\n";
  } else {
    print "problem writing line\n";
  }
  if(fclose($fp)){
    print 'file closed';
  } else {
    print 'problem closing file';
  }
}
?>

MySQL backup and restore

#backup
DATEVAR=`date +%Y-%m-%d--%H-%M-%S`;
mysqldump -u[username] -p[password] [database_name] > backup_$DATEVAR.sql;
 
#restore
mysql -u[username] -p[password] [database_name] < backup_$DATEVAR.sql;
 
## In one command, dump the remote into local ##
ssh -C username@mysite.com mysqldump -u[remote user] -p[remote pass] [remote db] | mysql -u[local user] -p[local pass] [local db]

Drupal path alias from nid

<?php
// get the alias for any node:
$path = drupal_get_path_alias("node/".$nid);
// or get the alias for current page
$path = drupal_get_path_alias();
 
// get the full path
$full_path = $GLOBALS['base_url'] . $GLOBALS['base_path'] . $path;
?>

Global Redirect

Takes care of many small SEO related tasks related to URIs.

One of the main features:"Once enabled, an alias provides a nice clean URL for a path on a site. However Drupal does not remove the old path (eg node/1234). The problem is that you now have two URLs representing the same content. This is dangerous territory for duplicate pages which can get you

Page Title

Basically, this module lets you control the <title> element. From the project page:

"The word "title" is a bit overloaded. Every piece of content in Drupal has a title, and so does every page. The page title is the one found in the HTML head inside the tag. It is also used on SERPs (Search Engine Result Pages) and can greatly enhance your websites SEO (Search Engine Optimization).

This module gives you granular control over

Pathauto

"The Pathauto module automatically generates URL/path aliases for various kinds of content (nodes, taxonomy terms, users) without requiring the user to manually specify the path alias. This allows you to have URL aliases like /category/my-node-title instead of /node/123. The aliases are based upon a "pattern" system that uses tokens which the administrator can change."

Token

Gives replacement tokens. This module is used by so many other modules, you are sure to use it and learn it if you haven't already.