Graham's Blog

Categories:

Recursive wget to download via FTP

wget -r ftp://username:password@domain.com/directory/*

Recursively delete .svn directories

find . -iname '.svn' -print0 | xargs -0 rm -rf

Bash PS1 var

PS1="\[$(tput bold)\]\[\e[34m\]\u@\H \[\e[32m\]\w\[\e[0m\]\n\[$(tput sgr0)\][\[\e[31m\]\!\[\e[0m\]] $ "

FTP Put Syntax

-bash-3.2$ ftp 
ftp> open 
(to) domain.com
Connected to domain.com (67.199.146.247).
220---------- Welcome to Pure-FTPd [TLS] ----------
220-You are user number 5 of 50 allowed.
220-Local time is now 12:29. Server port: 21.
220-This is a private system - No anonymous login
220-IPv6 connections are also welcome on this server.
220 You will be disconnected after 15 minutes of inactivity.
Name (domain:projects): username
331 User username OK. Password required
Password:
230-User username has group access to:  username
230 OK. Current restricted directory is /

Create / Extract .tar.gz files

To create a tar.gz archive from a given folder you can use the following command

tar -zcvf tar-archive-name.tar.gz source-folder-name

This will compress the contents of source-folder-name to a tar.gz archive named tar-archive-name.tar.gz

To extract a tar.gz compressed archive you can use the following command

tar -zxvf tar-archive-name.tar.gz

to compress a directory with saved permissions:

tar -pczf archive.tar.gz folder

MySQL Import / Export

mysql -u user -ppass table < dump.sql
mysqldump -u user -ppass table > dump.sql

drupal_add_js function

$module_path = drupal_get_path('module', 'custom');
drupal_add_js($module_path.'/javascript.js', 'theme');

add to template.php

Include JavaScript Libraries via Google JS API

<script type="text/javascript" src="http://www.google.com/jsapi"></script>
<script type="text/javascript">google.load("prototype", "1.6.0.3");</script>

Validate email address function

function Validate_Email_Address_Format($email_address) {