Nov 23

Get PHP working on Leopard (Mac OS X)

Tag: mac, phpadmin @ 7:48 pm

After I upgraded to Leopard from 10.4.x, my PHP processes stopped working.  The new OS overwrote some configuration files.  Check out this post on how to get things working again.


Jun 22

Textmate as the ultimate editor

Tag: latex, mac, os x, php, stataadmin @ 4:10 pm

With dozens of “bundles” that allow for application-specific editing, the Mac text editor TextMate is a great tool for the researcher. I posted four screenshots below for Stata, LaTeX, Matlab and PHP. The most powerful is PHP as there is a default bundle that lets you run the script directly from the file. With a little work (install TeX on your Mac), you can easily compile and view your LaTeX files. The quick command(e.g. “begin + “tab”) make editing a breeze. What I like most is the syntax highlighting that it brings to editing .m and .do files.  Moreover, you can create “projects” that let you easily handle multiple files.

Textmate with Stata

Textmate and Stata

Textmate with LaTeX

Textmate and Latex

Textmate with PHP

Textmate and PHP

Textmate with Matlab

Textmate and Matlab


Jun 03

Subtracting time from dates in PHP

Tag: code, phpadmin @ 2:48 pm

We want to subtract 6 months off of a set of dates. Let the date to be modified be defined in the variable $date. To get the timestamp of 6 months prior to this date we run

$unix_timestamp = strtotime("- 6 months", strtotime($date));

Then, to convert the date back into a human-readable format:

$new_date = date('y-m-d', $unix_timestamp);

and $new_date is ‘yyyy-mm-dd.’