My Macinations

Yet another mac user’s blog

Browsing Posts tagged Leopard

One of the best features of Mac OS X is a feature called ‘Folder Actions’. What this feature allows the power user to do is to watch a folder on the computer and whenever that folder receives a file, folder action kicks in and runs a script of the user’s choosing.

I’ve used this feature for a long, long time. I use it among other things to archive all the files submitted to my main site into a folder tree organized by date. For example a story submitted on April 20th, 2008 will end up in:

/SubmissionArchives/2008/04/20/

I’ve been doing this for years. So long ago that I can’t recall when I started doing it that way; it may have started on Mac OS 9. So needless to say, it’s very useful.

I have few other folder actions set up to do various routine tasks.

But it all came to a halt with my upgrade to Leopard or Mac OS X 10.5.

In Leopard, I couldn’t get folder actions to work with more than one active folder action. If I set up 2 of them, only the second one will work. If I set up three, the third will work and the system will completely ignore the first two. I’ve filed bug reports with Apple, and now at 10.5.2 the problem persists.

This weekend, I’ve had to do something that I rarely do, which is to archive a massive number of files; around 27,000 files at the same time. So what better need for an automated thing other than a massive job?

Well, as it turned out, a massive job is what you don’t want to handle with the current version of Folder Actions.

As soon as I dumped the 27,000 files into the watched folder, my computer (a 2.8 Ghz iMac) slowed down to a crawl. A quick check in the terminal showed that the Folder Actions daemon consuming 100% of one CPU core and the Finder was consuming the remaining 80% of the other core. The funny part is that no files were being moved. After 30 minutes, files started moving at the speed of 1 file every 4 seconds. At that rate, the job would take 30 hours to finish.

But the kicker is that the Finder kept crashing and throwing a dialog about an invalid connection and requiring me to click ‘OK’ in order for it to proceed. So even if I were willing to wait, without constant clicking OK, the job wouldn’t proceed at all.

I worked around the problem by creating a new script that reads the list of files from a flat text file that I created by selecting all the files in the Finder and copying and then pasting into a BBEdit document. So the script reads that text file, line by line and hands the file’s path to the finder and the finder moves it to its destination.

It’s slow, it’s doing about 2 files per second as I write this, so theoretically it should be done in like three hours or so.

I wish I knew more about shell scripting. I’m sure such a job for a good shell scripter would take no time to set up and few minutes at the most to execute. I guess that’s something that I need to add to my arsenal of tools.

And here’s a free tip: In AppleScript’s date function, if you want the number of the month do it like this:

set theMonth to the month of theDate as integer

if you don’t add that ‘as integer’ bit, you always get the name of the month and that bit is not documented anywhere that I could find. I stumbled on it by sheer dumb luck. Page 88 of AppleScript’s language guide gives you this:

month
Access: read/write
Class: constant (page 86)
Specifies the month of the year of a date object, with one of the constants January, February, March, April, May, June, July, August, September, October, November, or December.

But if you you try this:

set theMonth to July as integer

You get 7 back.

Talk about counterintuitive.

Yet another useful feature has been eliminated in Leopard.

The audio controller that the Finder’s column view had for the preview pane when previewing audio files has been eliminated. Why? I don’t know. No logical explanation can come to mind.

Audio ControllerIn Tiger, if you set your window’s view to the column view and point it to a folder that has MP3 files, when you select one of those files, the right-most column shows a controller that allows you to play the audio file, select the point where you want the play head to be and control the playback’s volume. Leopard: NO MORE!

Leopard’s music controllerWhat you get in Leopard is a silly, YouTube-like preview square with a big ‘play’ button in its middle. No volume control and no skipping ahead. You can always hit the space bar to get a big window showing iTunes like display, and you can skip ahead, but you still can’t control the volume.

Somebody should tell Apple’s engineers that an UPGRADE is when you make things better, not worse.

I’ve been using Leopard as my only OS for 4+ days now. Here is a first report on where I’ve encountered the most problems.

Safari:

I spend a lot of time with Safari (can’t use any other browser as my main browser). It’s the only Apple application that I use so extensively. So far I’ve noticed few thing:

  1. It crashes way more than previous versions of Safari. I guess they’re using a code-base almost completely different from the beta 3.0 version that they released for Tiger. The beta Tiger version was almost bulletproof for me. I’ve had unexplained crashes so far at least twice per day. Most of the crashes happened when I started typing in a form.
  2. It seems to be unable to block certain type of popup windows. I have the ‘Block pop up windows’ preference set, and yet I’ve had two or three instances where websites managed to show me some ads in a popup window. Not good.
  3. Visual glitches: A site I visited changed the size of my main Safari window to a really small size and then back to full-screen. After the expansion to full size, the tabs bar got clipped and only a third of its normal hight showed. I couldn’t get it back to normal size without quitting Safari. (side note: I wish Safari had a resize blocking feature like Camino. I just hate it when a stupid website decides that my window size is not adequate for its display and ‘helps’ me by changing the size of my browser window).
  4. Scripting: Apple changed the behavior of some AppleScript commands. The ‘open’ command used to open a new window with the URL, now it opens it in a tab. The kicker is that Safari doesn’t seem to respond to ‘make new window’ command. (I’ve worked around this one by modifying my code to anticipate a new tab instead of a new window and acts accordingly.)
  5. Spontaneous cookie loss: It has happened few times already. I would be surfing and managing my various websites, (most of my websites rely on cookies for log in), and suddenly, I would be logged out. I looked over cookies and most of the cookies weren’t there. They simply vanished. Not all cookies, just some. I have no clue how to track this bug.
  6. Web clippings don’t work: I’ve tested the Web Clip feature and it doesn’t seem to work. When I make a clip of a page, it appears correctly in Dashboard, but whenever I reload the Dashboard, the clip is empty. I tried it with various sites with the same result.

Folder Actions:

To show my geeky side, one of Leopard’s features that I anticipated the most is the enhancements to the Folder Actions engine. In Tiger, if you had multiple folders with folder actions, those actions don’t run concurrently. They run back to back. So if folder 1 fires its action and it takes a while to complete, folder 2 won’t fire its action until folder 1′s action ends. Leopard’s feature list promised to fix this.

However, not only they didn’t fix it, a bug seems to have broken Folder Actions further. Now, even if I have multiple folders with folder actions set up, only the first active one works. All the other ones don’t work at all. So now I have to choose which folder action I can live without and which ones are too crucial.

One of the ugly new interface “features” of Leopard is its translucent menu bar. In my opinion it’s ugly, distracting and serves absolutely no useful purpose. I have no clue why any sane person at Apple would want to implement it.

There have been many complaints about it on the internet since Leopard reached people’s hands; and unlike the shiny Dock, so far, the menu bar has no workaround to fix the problem and make it opaque.

However, I found a very simple solution after two minutes of looking at this annoying eye sore.

It’s simple. Open your desktop picture in any image editor and fill the top 22 pixels with white. Now because the system caches the desktop image, the change won’t appear until you log out, or simply go to the System Preferences and through the Desktop & Screen Saver panel, select a different picture for your desktop and then select your original white top image again and done. You’ll have a white menu bar without the visual clutter.

Leopard brings one big change to web developers working with Apache, PHP and Mysql on the Mac. Apache 2 comes with Leopard along with PHP 5.

Here is what to do to restore a test environment.

First, you need to enable PHP.

Apache’s .conf file moved from /private/etc/httpd/httpd.conf to /private/etc/apache2/httpd.conf

Open this file with your favorite text editor and uncomment the line:

# LoadModule php5_module libexec/apache2/libphp5.so

You don’t need to add the mime type for php, because it’s already done for you under leopard. The last line in the .conf file is:

Include /private/etc/apache2/other/*.conf

The ‘other’ directory contains a .conf file for php5. That takes care of the mime type and the index.php configuration for php sites.

If you develop multiple sites and you need virtual hosting functionality, scroll down to the end of the .conf file and uncomment the following:

# Include /private/etc/apache2/extra/httpd-vhosts.conf

That’s all the modification that I had to make to to the httpd.conf file.

Next, you’ll need to setup whatever virtual hosts you have in the virtual hosts file /private/etc/apache2/extra/httpd-vhosts.conf

For example, for each line that you set up in your hosts file like so:

beta-site-1.com 127.0.0.1

You need to make an entry in the httpd-vhosts.conf file like so:

<VirtualHost *:80>
   ServerName beta-site-1.com
   ServerAlias www.beta-site-1.com
   ServerAdmin webmaster@beta-site-1.com

   DocumentRoot "/Library/WebServer/beta-site-1"
   ScriptAlias /cgi-bin/ "/Library/WebServer/beta-site-1/cgi-bin"
   <Directory "/Library/WebServer/beta-site-1">
     Options FollowSymLinks MultiViews Includes
     AllowOverride All
     Order allow,deny
     Allow from all
   </Directory>
</VirtualHost>

One good thing is that the ‘upgrade’ install of Leopard does not mess with your hosts file, so whatever virtual domains you may have set up won’t be affected.

If you had Mysql installed previously, good news too, Leopard’s installer won’t touch it. I found mysqld running just like before the upgrade.

One thing changed with Leopard is the socket for Mysql. It moved to /private/tmp, so you may need to configure your php.ini file to point it to the new location.

To do so, open the file ‘/private/etc/php.ini‘, (if no such file exists, then make a copy of ‘/private/etc/php.ini.default‘ naming it ‘php.ini‘) and edit that.

You have two lines to modify:

mysql.default_socket =

becomes:

mysql.default_socket = /private/tmp/mysql.sock

and mysqli.default_socket =

becomes:

mysqli.default_socket = /private/tmp/mysql.sock

of course, from the sharing pref pane, stop the server and restart it and voila!