Self-discipline (according to zenhabits)

This belongs on a poster:

Have a powerful reason — when things get difficult, “because it sounds nice” or “to look good” aren’t going to cut it.

Start tiny, with a simple but unbreakable promise to yourself to do one small thing every single day.

Watch your urges, and learn not to act on the whim of a moment.

Listen to your self-rationalizations, and don’t believe their lying ways.

Enjoy the habit, or you won’t stay with it longer than a week’s worth of sunrises.

I’ve quoted the whole post because I thought it was important enough to save you the effort of clicking through.

But you should totally be following zenhabits if you’re not already.

PHP with FreeTDS on OS X Mavericks and Yosemite

Need your OS X-hosted PHP code to talk to Microsoft SQL Server? Here’s the guide I couldn’t find when I needed it.

Or you could just download my Mavericks-ready mssql.so and skip to the end.

Update (6 July 2014): A newer mssql.so compiled for PHP 5.4.24 on Mavericks 10.9.4 can be downloaded here.

Update (22 December 2014): A newer mssql.so compiled for PHP 5.5.14 on Yosemite 10.10.1 can be downloaded here.

Update (16 September 2015): A newer mssql.so compiled for PHP 5.5.27 on Yosemite 10.10.5 can be downloaded here.

Prerequisites

  • Xcode with command line tools (these are installed when you first run Xcode, as of the latest version)
  • Latest autoconf source from http://ftp.gnu.org/gnu/autoconf/ (or Homebrew installed)
  • Latest FreeTDS source from http://www.freetds.org/ (or Homebrew installed)
  • Source for the same version of PHP that ships with OS X (5.4.17 on 10.9; run `php -v` from a terminal if unsure)

Build and install autoconf

If you’re a Homebrew user, brew install autoconf is easier than the following.

$ tar zxf autoconf-latest.tar.gz 
$ cd autoconf-2.69
$ ./configure 
$ make
$ sudo make install

Build and install FreeTDS

FreeTDS is on Homebrew too: brew install freetds

Alternatively:

$ tar zxf freetds-stable.tgz
$ cd freetds-0.91
$ ./configure 
$ make
$ sudo make install

Build and install mssql.so

Don’t worry, unlike some of the Internets will tell you, there’s no need to rebuild PHP itself. Nor do you need to write an essay after .configure.

Update (16 September 2015): phpize doesn’t seem to work out-of-the box anymore. If it can’t find the files it needs (you’ll see grep errors), try adding a symbolic link like this: sudo ln -s /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/usr/include/php /usr/include/php

Here goes:

$ tar zxf php-5.4.17.tar.gz
$ cd php-5.4.17/ext/mssql
$ phpize
$ ./configure --with-php-config=/usr/bin/php-config --with-mssql=/usr/local/
$ make
$ sudo cp modules/mssql.so /usr/lib/php/extensions/no-debug-non-zts-20100525/

Finally, add this line to your php.ini (probably in /etc/php.ini):

extension=mssql.so

And restart Apache if necessary.

Done!

Hacking Profile Manager on Mavericks

Dear Fellow OS X Server Geeks,

Just a heads up that I have updated my earlier posts about gaining access to Apple’s Profile Manager PostgreSQL database. The commands therein now work on Mavericks.

If you’ve upgraded from OS X Server 2.0 on Mountain Lion, you’ll have to open up remote access from scratch. Data is retained (flawlessly in my case), but the PostgreSQL instance has been moved and a new database (with a new name) created beside the old one.

Virtual hugs,

Me

Mail.app on Mavericks: now plays nice with Exchange

If you use Mail.app on OS X Mavericks, there’s a good chance you already know this, but if not: Apple have just updated it.

Much has been made of Gmail not working under Mail.app on Mavericks, but for those of us who use it with Exchange, it’s been a similar story (with less rage). I’m happy to report that the latency/timeout/crash problems I was experiencing with Mail.app and Exchange 2010 appear to be resolved with this update.

And there was much rejoicing!