mac

APC on OS-X: PHP Fatal error: Unknown: apc_fcntl_unlock failed

APC 3.1.9 has a nasty bug, causing a frustrating error: "PHP Fatal error: Unknown: apc_fcntl_unlock failed: in Unknown on line 0" to appear when installed with PECL on Mac OS-X (and reportedly on a variety of Linux platforms).

There's an easy fix.

Command-Line Javascript (CLI) On Mac OS-X

With the increasing popularity of server-side Javascript, you may want to have Javascript everywhere. You can use Javascript outside of a browser, on any platform. There are many choices: you can install Mozilla SpiderMonkey, Google V8 or Mozilla Rhino. If you are like me and use Mac OS-X as your development machine, however, you have hit a jackpot: OS-X Leopard and later come with Javascript CLI pre-installed. The CLI uses JavascriptCore by Apple, the same engine used in the Safari browser, and many other places all over OS-X.

This is how you can enable JSC:

$ sudo ln -s /System/Library/Frameworks/JavaScriptCore.framework/Versions/Current/Resources/jsc /bin/jsc

Once you do that, you can run the jsc interactive shell or write javascript shell executables by putting:

#!/bin/jsc

at the top of a shell script. JSC Wiki lists some extra commands you can use in your CLI scripts.

Alternative JS CLIs

If you install Homebrew, "the missing package-manager for OS X" (generally a great idea for a developer), installing Google v8 or Mozzila Spidermonkey or Rhino becomes trivially easy:

$ brew install v8
$ brew install spidermonkey
$ brew install rhino

For Rhino, you need to make sure you have Java installed on your Mac. If you do that, JS executables will correspondingly be located in:

/usr/local/Cellar/v8/HEAD/bin/v8
/usr/local/Cellar/spidermonkey/1.8.5/bin/js
/usr/local/Cellar/rhino/1.7R3/bin/rhino

Typically, brew will also create convenience symlinks:

/usr/local/bin/v8
/usr/local/bin/js
/usr/local/bin/rhino

Installing GoogleCL On a Mac

GoogleCL is a command-line client to Google services that was released recently. It should appeal to Web geeks, many of whom, in my non-scientific observation, are Mac users.

GoogleCL documentation suggest you use MacPorts to install it on Mac.

Now, I have to admit - it really pisses me off when people talk about installing simple Unix utilities on Mac using MacPorts (or Fink or that new kid on the block called HomeBrew). People, Mac OS-X 10.5 and up is a POSIX Unix system! If you have Dev Tools installed, and Terminal does not scare you, you should not need a crappy thing like MacPorts to install a simple unix utility like Git, SVN or GoogleCL. If you can not install them as you would install on most Unix systems, MacPorts will probably fail you too, so no need to pile garbage on your shiny Mac.

If you don't have DevTools installed on your Mac, stop calling yourself a Mac geek until you go to http://developer.apple.com/, download and install Dev Tools.

The pre-requisites to GoogleCL are Python 2.5+ and Gdata Python Client Library. OS-X versions 10.5 and 10.6 have proper Python version pre-installed. Installaltion of the rest is as easy as:

mkdir ~/src
cd ~/src
curl -O http://gdata-python-client.googlecode.com/files/gdata-2.0.10.tar.gz
tar
xzvf gdata-2.0.10.tar.gz
cd gdata-2.0.10
sudo python setup.py install

curl -O http://googlecl.googlecode.com/files/googlecl-0.9.5.tar.gz
tar
xzvf googlecl-0.9.5.tar.gz
cd googlecl-0.9.5
sudo python setup.py install

Prevent Terminal from timing-out SSH on Mac.

If you use Terminal application on Mac OS-X to connect over SSH, you have most probably been annoyed by closed connections. Following is a quick recipe to prevent timeouts:

Open Terminal

> sudo vi /etc/ssh_config

Edit the file to make lines 20-21 look like:
Host *
    ServerAliveInterval 5

Save file and restart Terminal. Your connections won't time-out nearly as frequently.

How to Enable Local SMTP (Postfix) on OS-X Leopard

OS-X Leopard comes pre-installed with a Postfix version. No need to install it via darwin ports or other such mess (actually uninstall it if you have previously manually installed it via ports or something similar). Postfix just needs to be enabled and following sequence of several easy steps explains how to do it:

 sudo vi /System/Library/LaunchDaemons/org.postfix.master.plist

add following line before the closing </dict> tag:

<key>RunAtLoad</key> <true/> <key>KeepAlive</key> <true/>

Start service with

$ sudo launchctl
launchd% start org.postfix.master

You can also start simply with "sudo postfix start" but the above command will start via launch sequence and test the configuration you edited in the previous step.

Check that SMPT is running:

telnet localhost 25

For more information, see: Mac OS X Manual Page For launchd.plist

Control Your OS-X Keynote Presentation from iPhone

If you are on a Wifi and both your mac and iPhone can access it, you can get free ride with controlling Keynote from your iPhone by using: Keymote, which in part uses Telekinesis iPhoneRemote.

Telekinesis actually uses iPhone Safari and Ajax so you need to point iPhone Safari to a specific address (https://192.168.74.104:5010/ by default). You can bookmark it as iPhone shortcut on iPhone desktop though, for easy launching.

XAMPP Runs As User Nobody on Mac

During my recent macbook pro upgrade, I had a sweet time automatically migrating my entire old macbook to the new one using Migration Assistant. The experience could not have been smoother - all my data and applications were moved without a hitch. Couple apps asked to re-enter serial numbers, but that's all.

However when I tried to start my XAMPP-packaged MySQL today (I usually develop on a Linux box, so do not use local MySQL that often) - it would not start. After some digging around I noticed that permissions on the MySQL data folder in /Applications/xampp/xamppfiles/var were wrong - it was owned by "admin" and MySQL could not write in it. I quickly changed ownership to the mysql user (that was present on my computer), but to my surprise - that did not help. After some more digging, I found that, apparently, XAMPP runs MySQL as "nobody", just like it does Apache. Somewhat uncommon, but oh well.

Following three commands fixed my after-migration problem:

cd /Applications/xampp/xamppfiles/var
sudo chown -R nobody:admin mysql
sudo chmod -R 775 mysql

How To Uninstall Cooliris from Safari on a Mac

Cooliris is one of these new gadgets that sound cool in somebody's blog review, but do not live up to an expectation when actually used. Let alone that it is not nearly as useful as it claims to be, Cooliris has been reported to significantly slow down Safari on Macs. Specifically - when viewing FLASH videos like on YouTube. These fellas must have done something terribly wrong.

In any case, the real sad part is - they don't have any human way of uninstalling it. So here is a quick tutorial of how to remove this weed from your computer and let your Safari breath again:

  • Close Safari
  • Trash the Cooliris Previews folder found in $LIBRARY/InputManagers/)
  • Trash the cooliris' .plugin file found in $LIBRARY/Internet Plugins

Depending on whether you installed Cooliris for just your user or system-wide, substitute $LIBRARY with /Users//Library or /System/Library.

Hope this works for you, too.

Measure Distances on Screen in Mac OS-X

Really nice and useful tool:
http://www.pixelatedsoftware.com/products/pixelstick/

Tools like this one are plenty, but this particular one has a great user-interface. Better than any other free one, I have seen.

Bring SFTP to OS-X: Magnetk ExpanDrive

Today is a great day for Macintosh users! Magnetk has released ExpanDrive - a tool allowing to mount remote servers as local drives over ssh/sftp. Their press-release promises to add more protocols. I am taking a not-so-wild guess here that S3 will be one of the first protocols to get in.

But back to Magnetk. In the past I have used the Windows version of the same tool they had - SftpDrive and have come to love it. It was actually one of the few things I used to miss from Windows. I remember e-mailing them and asking to give us, Mac users something like that, as well. They promptly e-mailed back saying it was in works. And here we are with ExpanDrive! Magnetk is clearly a company that lives up to its promises.

I have been evaluating ExpanDrive for couple hours now and it is AWESOME!. I am gonna try it for a day or two more and am definitely buying it.

P.S. To be completely fair, we have to mention that there is an open-source tool that aims at solving the same problem and it has been around for a while: MacFuse is its name. I have used it.

Well, quite honestly bare-naked MacFuse is not in the same league, at least for now (I suspect ExpanDrive is using MacFuse at least partially if not in its totality). I am always the first to favor an open-source alternative, but quite honestly, if you are serious about your SFTP needs (like: developing a web application on a remote server), ExpanDrive is well worth its modest price.

Syndicate content