How To Install PHP GMP on Mac OSX 10.3.7

I wanted do some number crunching with the GNU MP Libarary on my Macbook, but it wasn't available by default.

Installation was pretty simple though.

1) Run php --version to check what version of PHP you have.

2) Download that version of PHP somewhere on your system.

3) phpize & compile it

# cd php-5.3.15/ext/gmp
# phpize
# ./configure
# make
# make install

4) Add the following to your php.ini

New Lines to Paragraph Tags (nl2p)

Problem: Emails from your site go out in a good looking HTML format, but some of the content you want to inject in those emails are plain text while others are already formatted with HTML. The email content of the plain text emails which are only plain text now appear as one big block of text with no line breaks.

Let's look at this problem specifically in the context of a Drupal website.

All the emails such as welcome, password recover, etc... are plain text by default. Now you want to add a nice email template utilizing a module like mimemail.

Tags: 

MySQL: Restore a DB From the Command Line

This is a pretty basic tip today, but I noticed someone going through awkward measures to re-import a database over an existing database the other day. I thought I'd just make a note of how you can restore a db in a couple commands.

Scenerio: You have a development environment setup and you want to restore a fresh copy of the production MySQL database.

- The database on the development system is named: "mydb"

- You are using the command line in a directory that has the sql file you want to install: "mydb.sql"

Tags: 

Installing Drush without PEAR

Here's an easy way to install drush without PEAR.

Note, replace the wget argument with a current version of drush. http://drupal.org/project/drush

# cd /usr/local/share/
# wget http://ftp.drupal.org/files/projects/drush-x.x-x.x.tar.gz
# tar -zxvf drush-7.x-5.7.tar.gz 
# rm tar -zxvf drush-7.x-5.7.tar.gz
# chmod a+x drush/drush
# ln -s /usr/local/share/drush/drush /usr/local/bin/drush

When you want to update drush, simply replace the drush directory in /usr/local/share.

CyberSource is Extremely Developer Friendly!

I recently worked on a project that required payment profile management/purchasing and refund functionality for an ecommerce site.

CyberSource was the gateway I was to work with. I wasn't quite sure what to expect going into it, but I have ended up with a very high respect for the company and their support staff.

The documentation is thorough, but somewhat fragmented. I got most of the information I needed from the docs, but I was left scratching my head a few times when I could not find the details I needed.

NVM (Node Version Manager)

I was trying to get a Tilestream server running tonight and I ran into a problem. It wanted an older version of node.

After a little looking around on how to run multiple versions of node on my system, I came across Node Version Manager (nvm)

You can install different versions of node, and then activate them as a specific version is needed.

Drupal 7 Ubercart - Programmatically Capture Pre-Authorized Payments from Authorize.net

I'm working with Drupal 7, Ubercart, and the Authorize.net payment gateway.

The goal here is to pre-authorize the payment at check-out, and capture the payment once the items have been shipped. I'm using order status to trigger when that happens, but I wanted to just show an example of how to capture that pre-authorized transaction.

    Important notes:

How to Read Line Number x of a Large File with Awk

The Situation: You have a 600 GB database dump that produces an error on line 7500 when you attempt to import it.

This size is generally too large to work with in vi. Emacs will generally handle large files like this OK, but maybe it isn't available or your emacs fu isn't quite there.

You can easily achieve the solution with Awk, which is usually available by default on most Linux systems.

awk NR==7500 mysql-dump-file.sql

Tags: 

Bash: Command Line Shortcuts

Here's a few shortcuts that may increase your productivity in the command line.

Navigate around the current command

ctrl+a -- Go to the beginning of the line.
ctrl+e -- Go to the end of the line.
ctrl+w -- Delete last word.
ctrl+k -- Delete everything after the cursor.
esc+f -- Move cursor forward one word.
esc+b -- Move cursor back one word.

Recall the last command with !!

Tags: