Skip to content

Instantly share code, notes, and snippets.

View mpezzi's full-sized avatar

Michael Pezzi mpezzi

View GitHub Profile
@mpezzi
mpezzi / gist:2221593
Created March 27, 2012 23:51
.htaccess 301 redirect
RewriteCond %{HTTP_HOST} ^example.com [NC]
RewriteRule ^(.*)$ http://example.ca/$1 [L,R=301]
RewriteCond %{HTTP_HOST} ^example.com$ [NC]
RewriteRule ^(.*)$ http://example.ca/$1 [L,R=301]
@mpezzi
mpezzi / gist:1498447
Created December 19, 2011 19:10
PHP Validate Contains Numbers
<?php
/**
* Validates a string containing numbers.
*
* @param $string
* A string to validate if it contains numbers.
* @return
* TRUE or FALSE if it contains numbers.
*/
@mpezzi
mpezzi / .bash_profile
Created November 26, 2011 02:52 — forked from thesven/.bash_profile
Bash Profile OS X
echo "Hello Michael, You are great at turning me on."
### ----------
### PATH SETTINGS
### ----------
PATH=/applications/MacVim/:$PATH
### ----------
### Archive
### ----------
alias tarc="tar -zcf"
@mpezzi
mpezzi / install-lamp.sh
Created October 24, 2011 19:54
Ubuntu 10.04 / LAMP + Drush + Drupal Sandboxes
#! /bin/bash
# Upgrade and install required packages.
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install lamp-server^
sudo apt-get install php5-cli php5-gd php5-curl phpmyadmin
# Configure Apache
sudo sed -ie 's/AllowOverride None/AllowOverride All/g' /etc/apache2/sites-available/default
@mpezzi
mpezzi / gist:1287269
Created October 14, 2011 14:28
PHP Validate Human Name
function valid_human_name($name) {
return preg_match("/^[A-Z][a-zA-Z '&-]*[A-Za-z]$/", $name);
}
@mpezzi
mpezzi / install-aegir-on-ubuntu.sh
Created October 11, 2011 02:23
Install Aegir on Ubuntu 10.04 LTS
#! /bin/bash
#
# Aegir 1.1 install script for Ubuntu 10.4 LTS (Lucid) servers
# (install-aegir-on-ubuntu.sh)
# script on Github: https://raw.github.com/doka/install-aegir-on-ubuntu/lucid/install-aegir-on-ubuntu.sh
#
# run with users with sudo rights
#
# this script assumes:
# - your hostname is: myhost.local (it will be the Aegir admin interface)
@mpezzi
mpezzi / gist:1260706
Created October 4, 2011 01:24
Canadian Provinces
Alberta
British Columbia
Manitoba
New Brunswick
Newfoundland
Northwest Territories
Nova Scotia
Nunavut
Ontario
Prince Edward Island
@mpezzi
mpezzi / gist:1249870
Created September 29, 2011 02:43
Ubuntu: Gitolite Installation
# Creating git user
sudo adduser -system -shell /bin/bash -gecos 'git version control' -group -disabled-password -home /var/git git
# Clone Gitolite
git clone git://github.com/sitaramc/gitolite
cd gitolite
src/gl-system-install
# Run setup as git user.
sudo su
@mpezzi
mpezzi / gist:1244064
Created September 27, 2011 01:40
MySQL Command Line
# Create User
CREATE USER 'user'@'localhost' IDENTIFIED BY 'password';
# Grant Privileges
GRANT ALL PRIVILEGES ON database.* TO 'user'@'localhost' IDENTIFIED BY 'password';
@mpezzi
mpezzi / gist:1171590
Created August 25, 2011 19:30
PHP Validate Postal Code
<?php
/**
* Validate a postal code.
*
* @param $value
* A postal code as string.
* @param $country
* The country postal code format.
* @return