Set your hostname on a Mac

October 23, 2014 2:01 PM
sudo scutil --set HostName larryx.local

Async helper function

October 11, 2013 2:30 PM
An "um, duh" moment with nodejs.
function after(times, done) {
return function () {
--times || done();
}
}

Fixing memcached/mcrypt on the mac with Zend Server

May 30, 2013 4:48 PM
Blantantly stolen from: http://www.tyler-cole.com/zend-server-memcached-mcrypt-cli

I was getting some odd errors when I ran PHP CLI and PHPUnit. Take a look at the following example:
php -v
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/local/zend/lib/php_extensions/memcached.so' - dlopen(/usr/local/zend/lib/php_extensions/memcached.so, 9): Library not loaded: /usr/local/libmemcached-0.50z/lib/libmemcached.8.dylib
Referenced from: /usr/local/zend/lib/php_extensions/memcached.so
Reason: image not found in Unknown on line 0
PHP 5.3.9-ZS5.6.0 (cli) (built: Dec 22 2011 12:28:41)
Copyright (c) 1997-2011 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2011 Zend Technologies
with Zend Extension Manager v5.1, Copyright (c) 2003-2010, by Zend Technologies
- with Zend Data Cache v4.0, Copyright (c) 2004-2010, by Zend Technologies [loaded] [licensed] [disabled]
- with Zend Job Queue v4.0, Copyright (c) 2004-2010, by Zend Technologies [loaded] [licensed] [enabled]
- with Zend Utils v1.0, Copyright (c) 2004-2010, by Zend Technologies [loaded] [licensed] [enabled]
- with Zend Optimizer+ v4.1, Copyright (c) 1999-2010, by Zend Technologies [loaded] [licensed] [disabled]
- with Zend Code Tracing v1.0, Copyright (c) 2009-2010, by Zend Technologies [loaded] [licensed] [enabled]
- with Zend Monitor v4.1, Copyright (c) 1999-2010, by Zend Technologies [loaded] [licensed] [disabled]
- with Zend Debugger v5.3, Copyright (c) 1999-2010, by Zend Technologies [loaded] [licensed] [enabled]
- with Zend Page Cache v4.0, Copyright (c) 2004-2010, by Zend Technologies [loaded] [licensed] [disabled]

After much searching around, it seems one of the environment variables was empty:
echo $DYLD_LIBRARY_PATH

Returned nothing. So the solution was simple:
export DYLD_LIBRARY_PATH=/usr/local/zend/lib
echo $DYLD_LIBRARY_PATH
/usr/local/zend/lib

What prompted all this was due to the fact that mcrypt() was installed via php.ini, the CLI was using the right php.ini, and yet mcrypt still failed. Fixing the contents of DYLD_LIBRARY_PATH fixed both issues.

Getting core dumps from PHP on mac

January 25, 2013 5:06 PM
So, you are trying to run something using php (unit tests perhaps?) and you are getting seg faults. Time to dig into those pesky core dumps and get some insight but wait, where are they? Long answer short, they don't exist.

To get them you must do a couple of things. First you need to create /cores and make it writeable by your user. Then you need to enable core dumps. To do so run the following commands in your terminal:
sudo mkdir /cores
sudo chmod 777 /cores
ulimit -c unlimited

Now when you next get a segfault a file called core. will be created in /cores with replaced by the process id of the process that seg faulted. Need to know what to do with that file? This link might help.

Disable TimeMachine local backups

December 18, 2012 2:28 PM
You can disable local snapshots and still use TM.

In Terminal, paste this command:
sudo tmutil disablelocal

To reverse the command
sudo tmutil enablelocal