Building a LAMP development environment on Snow Leopard

How to install Apache, PHP, MySQL, MongoDB and a whole bunch of other useful packages on Mac OS X 10.6

You already have a copy of Apache and PHP and that's good enough for our purposes, but you're going to need a few things that don't come bundled with your Mac. For that you need to...

Set up a LAMP stack on OS X after the jump.

The established standard with Git is for commit messages to have a first line that is 50 characters or less and then add two newlines, and then explain the commit throughly.

This may seem crazy short, but you’ll find that forcing yourself to summarise the commit encourages you to be atomic and concise. If you can’t summarise it in 50-80 characters, you probably are trying to commit two commits as one.

A great rule of thumb from the Homebrew Formula Cookbook.

Resolved: That Thunderbird 3 is fairly awesome.

Given that:

  1. The newly released Thunderbird 3 uses the much-speedier rendering engine from Firefox 3.5, and includes all-around IMAP speedup,

  2. Also, given that--as part of the Firefox 3.5 changes--Thunderbird 3 stopped looking like a ghetto hack when running on OS X,

  3. Also, given that Thunderbird 3 has simplified the account setup process,

  4. Also, given that Thunderbird 3 adds many Gmail-like features, such as the ability to "Archive" email,

  5. Also, given that Thunderbird 3 solves many of the folder-related hardships encountered in Thunderbird 2,

  6. Also, given that Thunderbird 3 now supports tabbed email browsing,

Be it hereby resolved: that Thunderbird 3 is fairly awesome.

Download it. Install it. Love it.

If, like me, you hose Apache on your Ubuntu LTS server when you finally get around to upgrading libssl, and PHP stops working...

You'll be needing this:

apt-get --reinstall install apache2 php5-mysql \
libapache2-mod-php5 mysql-server

(You're welcome)

Preparing a string for use in a PHP regular expression.

This blog post is just for me, so I can look it up later... I suppose you can borrow it if you find it useful :)

Using dynamic strings inside a regex can be annoying, especially if you can't guarantee that the strings are actually sane. Including a URL in a regular expression is downright obnoxious, since URLs and regular expressions share most of the same special characters, but they mean entirely different things. I threw this function together to make strings regexable. Enjoy.

Function

/**
 * Prepare a string for use in a regular expression.
 * 
 * @author Justin Hileman {@link http://justinhileman.com}
 * @access public
 * @param string $str
 * @return string
 */
function preg_real_escape_string($str) {
    $replace = array('\\' => '\\\\', '^' => '\^', '.' => '\.',
        '$' => '\$', '|' => '\|', '(' => '\(', ')' => '\)',
        '[' => '\[', ']' => '\]', '*' => '\*', '+' => '\+',
        '?' => '\?', '{' => '\{', '}' => '\}', ',' => '\,');
    return strtr($str, $replace);
}

Yeah, the name is a bit weird. This function is an analog to mysql_real_escape_string(), so it seemed fitting.

Usage

// basic usage (this is actually exactly the case I wrote this function for).
$regex = '/^' . preg_real_escape_string($name) . '/i';
$nameless = preg_replace($regex, '', $something_starting_with_name);
 
// trying to find a URL via regex can be especially obnoxious.
$regex = '/' . preg_real_escape_string($my_url) . '/';
$some_text = preg_replace($regex, '<a href="$1">$1</a>', $some_text);

My year in cities, 2009

I'm doing Kotke's cities thing. Here's my list for 2009:

  • Atlanta, Georgia1
  • Austin, Texas
  • Boston, Massachusettes
  • Denver, Colorado2
  • Los Angeles, California
  • Monteverde, Costa Rica
  • New Haven, Connecticut
  • New York, New York
  • Philadelphia, Pennsylvania
  • Portland, Oregon
  • Prosser, Washington
  • Provo, Utah
  • Puntarenas, Costa Rica
  • San Francisco, California
  • Washington DC
  • Wenatchee, Washington
  • Wilton, Connecticut

I spent one or more nights in every city on this list. Thanks to JetBlue's All You Can Jet pass for facilitating several of those trips :)


  1. Under duress. Thank you, Delta. 

  2. Also under duress, this time courtesy of United Airlines.