Archive for July, 2009

PHP Date Issue strtotime() vs. date()

I ran into the following date issue in PHP: adding one month to July 31, 2009 yields August 31, 2009; but, adding 2 months to July 31, 2009 yields October 1, 2009. Tell me how that makes sense.

The real question at hand here is how long is a month?  I would tend to say that simply adding 1 to the month column would suffice, but if you are actually working with epoch times, it isn’t that simple.  The number of seconds to add varies based on what month it is.

Sample Code

echo date("Y-m-d"); //Now:  2009-07-31
echo date("Y-m-d",strtotime("+1 months")); //One month from now:  2009-08-31
echo date("Y-m-d",strtotime("+2 months")); //Two months from now:  2009-10-01
echo date("Y-m-d",strtotime("February 28th + 2 months")); //Two months from February 28th:  2009-04-28

Growl from PHP

I just found this nifty PHP class for sending growl notifications from sitecrafting.com.  Very nifty.  Here’s some sample code to get it going:

// Setup
$growl = new Growl();
$growl->setAddress('127.0.0.1');
$growl->addNotification("Test");
$growl->register();
 
// Send Notification
$growl->notify("Test", "Test Alert", "The body of the test alert!");

SQL Server Error 3154

I ran accross the SQL Server error 3154. In SQL Server 2008, it says “Restore Failed for Server ‘ServerName\InstanceName’” Additional Information: “System.Data.SQLClient.SqlError: The backup set holds a backup of a database other than the existing ‘dbname’ database. (Microsoft.SqlServer.Smo)”

Solution:

Use WITH REPLACE.  This can be found in the GUI tool or done in T-SQL as follows:

RESTORE DATABASE dbname
FROM DISK = 'C:\dbname.bak'
WITH REPLACE

Soocial Highrise Sync

There were two main reasons I went with Highrise for CRM.  First, because of its simplicity, and second because of its ability to sync with Soocial.  This functionality is advertised on their website yet when you go to actually do the sync, Soocial states that 37 Signals has requested they disable synchronization.

Why?

A little investigation points the finger at Soocial.  There were bugs in their implementation that resulted in the deletion and recreation of contacts, removing relations and detaching deals and cases from the contacts.

It looks like I’ll be writing my own implementation eventually using the Highrise API and the Google Apps API.

Time Machine Backup to a Network Drive

I just set up Time Machine to backup to a network drive.  It was surprisingly easy to do.  As simple as creating a disk image in disk utility and telling time machine where to find it.  I followed this tutorial.

The part that got me was naming the image.  I missed that part and didn’t put my MAC address as the name:  ComputerName_MACAddress.sparesebundle

Now I just have to get ghost to do the same thing for my Vista machine.