Archive for the ‘mac’ Category.

Third Time’s The Charm on Mac RAM — I Hope

Being at the end of a UPS route is hard. Tuesday morning I saw from the UPS website that my third set of RAM from Crucial was “out for delivery” from the local hub. What this means is that it’s on a truck, heading for my house. Unfortunately, we’re at the tail-end of said route, and I have yet to receive a UPS delivery before 4:00 PM. We were going to be leaving around 5:00 and since UPS is a “drop and run” courier, if it got there after we left, it would have been sitting on the porch for several hours until we got home. Fortunately, it arrived about 4:45. So it got inside the house, but wouldn’t get inside the Mac until later.

When I got home Tuesday night, I installed the RAM. So far, it’s working perfectly. Of course, the first set worked perfectly for a week or so, so I’ll have to just keep an eye on it. Thus, once again, my Activity Monitor looks like this

Mac Pro RAM Woes

You may remember how excited I was about a month ago when I got the 2GB RAM upgrade from Crucial for my Mac Pro. Well, about two weeks ago I happened to notice in Activity Monitor that I only had 3GB of RAM. That wasn’t right; I had 4GB. I started testing, and discovered a problem with the RAM. System Profiler was reporting 6 512MB sticks of RAM, instead of 4 512MB and 2 1GB sticks. I tried moving the sticks around to various banks, but never got it to see more than 3GB. Also, there are four LED’s on each of the risers that correspond to the four RAM banks. When you boot the system, these lights come on for about 2 seconds, then go out. There was one Crucial stick whose LED stayed on. No matter which bank I put that stick in, its light stayed on.

Saddened by this, I called Crucial. I spent just a few minutes on the phone with them before they agreed that there was clearly a problem, and that they would replace them. They have excellent customer and technical support. I shipped the two sticks back to them and waited.

Two days ago UPS arrived with my replacement sticks. I shut down my Mac and put the two new sticks in banks 3 and 4 of riser A, leaving the 512MB sticks in banks 1 and 2 of risers A and B, and booted. I logged-in, brought up Activity Monitor, only to see 3GB reported. System Profiler says 6 512MB sticks, just like before. The new RAM is doing exactly what the first set of RAM did. I tried every combination of placement of the sticks I could think of, including removing ALL the Apple RAM, and just putting the Crucial sticks into banks 1 and 2 of riser A. In that case, the Mac only saw 1G of RAM.

So it was back to Crucial tech support. They agreed it sounded like a bad stick (again) and are going to replace them again. I just shipped back the two latest sticks, and am once again waiting on a shipment from Crucial. I hope this one works. If it doesn’t, I’m just going to pony up the 2x extra and buy direct from Apple.

The Crucial guy said it was “hard to believe” that I got two bad sticks in a row, and I agree. But what else could it be? If I only had two banks for RAM in the computer, then you could blame it on the computer itself. But I’ve got eight banks to play with, and have tried them all. I don’t think it’s a problem with the Mac itself. I could be wrong, but I don’t think so.

My Mac Pro Goes Boogety Boogety-er

I said before that my Mac Pro was fast. But lately it’s been bogging down a bit when I have lots of apps open. Especially if I am using Parallels.

But UPS just arrived with a little shipment from Crucial: another 2GB of RAM. O, glorious day! Notice the screenshot of my activity meter:

AppleScript and iTerm: Sweet!

I use iTerm for all my command-line needs. I really like it, especially the tabbed interface. I typically have two to three terminals open for my local box, plus two to three for various systems in the company rack. iTerm has a nice bookmark feature that lets you save commands (like ssh me@foo) to open these various windows, but it’s not exactly what I want. The reason for this is that I either have to leave the bookmark drawer open all the time, or I have to click to open it, then double-click the bookmark I want to launch, then close the bookmark drawer. And that’s a real drag for me, because I’m not really a mouse guy.

So yesterday I started thinking that it had to be possible to do this using AppleScript, and indeed it is. My solution is not optimal, as I had to use two files, but it’s close to optimal. It’s approaching optimal. Here’s the AppleScript file, which is called it.scpt:

 		    1 on run argv 		    2     tell application "iTerm" 		    3             activate 		    4  		    5             tell the first terminal 		    6                     launch session (item 1 of argv) 		    7             end tell 		    8     end tell 		    9 end run 	

Next is a regular shell script, called it that calls it.scpt:

 		    1 #!/bin/bash 		    2  		    3 if [[ $# == 0 ]] 		    4 then     		    5     echo "Usage: it " 		    6     exit 		    7 fi 		    8  		    9 osascript ~/bin/it.scpt $* 	

You can see that the shell script checks to see if you’ve specified a bookmark name to launch. If you haven’t, it tells you how to run it. Once it’s established that you have specified a name, it calls the AppleScript file it.scpt, which I’ve placed in ~/bin for convenience. (Both files are in ~/bin on my system.) The AppleScript tells the currently-running iTerm to activate (probably not needed) and then tells it to launch the requested bookmark in a new tab. I don’t need to worry about the case where iTerm isn’t running, because I would execute this script from within iTerm. If you specify a non-existent bookmark, it just opens a new shell on your local system, which is OK, I guess.

So, to run it, I would type something like

it web1

to open the bookmark called “web1.” And that’s what I wanted.

I was a bit surprised that I was unable to just have one file. I should have been able to put a she-bang line in it.scpt and have it work. In other words, I should have been able to have

 		    1 #!/usr/bin/osascript 	

and then the rest of the script, but I got an error when I tried that.

If anyone knows an easier way to do this, please let me know.

04/11/2007 14:20 Update: A reader sent in how you can combine the two scripts into one, using osascript’s -e switch. I knew about this switch, which let’s you specify the program on the command line, but I’ve seen so many horrible (ab)uses of the same option in Perl that I didn’t even try it. What I didn’t know was that you can have embedded line feeds inside the quotes, so you can still have a nicely formatted script. Here’s the new and improved, single-file version of it:

 		    1 #!/bin/bash 		    2  		    3 if [[ $# == 0 ]] ; then 		    4     echo "Usage: $0 " >&2 		    5     exit 1 		    6 fi 		    7  		    8 osascript -e 'on run argv 		    9     tell application "iTerm" 		   10             activate 		   11  		   12             tell the first terminal 		   13                     launch session (item 1 of argv) 		   14             end tell 		   15     end tell 		   16 end run' $@ 	

04/12/2007 11:46 Update: This tip got posted over at MacOSXHints.com and has gotten some comments. Based on those comments, below is the latest version, which includes the ability to get a list of available bookmarks to launch by typing it list. Here it is:

 		    1 #!/bin/bash 		    2  		    3 if [[ "$#" = "0" ]]; then 		    4     echo "Usage: 'it bookmarkname' or 'it list'" && exit 1 		    5 elif [[ "$1" = "list" ]]; then 		    6     defaults read ~/Library/Preferences/iTerm|grep Name 		|grep -v NSColorPicker|awk '{$1="";$2=""; print $0}'|tr -d ';' 		    7 else  		    8 osascript <<ENDSCRIPT 		    9 on run argv 		   10   tell application "iTerm" 		   11     activate 		   12     tell the current terminal 		   13       launch session "$1" 		   14     end tell 		   15   end tell 		   16 end run 		   17 ENDSCRIPT 		   18 fi 	

My Mac Pro Goes Boogety Boogety

I have a Mac Pro. It goes fast. A full dump of my production MySQL database is about 481 MB. To load that into one of my development machines (dual 1.4MHz 64-bit AMD’s) takes about 40 minutes.

On my Mac Pro, it takes 7.5 minutes.

iTunes Script Menu on Context-Menu?

Does anyone know if it’s possible to duplicate the iTunes Scripts menu in the context-menu? IOW, I want to right-click on a track and have a submenu on that context-menu called “Scripts” and all my installed scripts would be there. It doesn’t have to be called “Scripts” but you get the idea.

The reason this is important is that I have two monitors. I leave iTunes running on the second monitor which works perfectly 99 2/3% of the time. But since OSX has only a single menubar for all applications, and since that menubar only lives on the primary monitor, when I want to do something in iTunes, the menubar is actually on the other monitor. This makes using scripts from the main Scripts menu a pain. Thus my desire to context-ify the Scripts menu.

Is this possible? Anyone?

03/15/2007 17:53:23 Update: I did come up with something that works pretty well, though it’s quite different from what I asked for. The script I was really wanting to easily run sets the last played date on the currently-playing track to the current date and time, increments its play count and then skips to the next track. This is something I’ve been wanting for a long time, so that songs that Party Shuffle hits me with that I don’t like will be buried for all time. Anyway, the script works, but I wanted an easier way to get to it. What I really wanted was a global hotkey that would invoke the script, no matter if iTunes was up front of not. What I did was opened the script in the AppleScript editor, and then saved it as an application. Once I had the app, I added it to the dock. Now, whenever I click on it, it does what it’s supposed to do, then exists. It works pretty well.

03/19/2007 11:13:23 Update: I now have an even better solution. I installed QuickSilver which allows you to map just about anything to global hotkeys. I replaced iMote, which I had been using to give me global iTunes hotkeys, with the functionality in QuickSilver, but I also got more. I was able to map Opt-Cmd-PgDn to my “Skip and Update Play Count” script, which executes within iTunes itself. This is much faster than launching the program I mentioned in the update from Thursday. I’m still digging into QuickSilver, but even if it didn’t do anything else, I’m happy with it.

First Mac “Exploit” from MOAB — Yawn…

Yesterday was the start of the Month of Apple Bugs, and I have to say it was a big snooze. The “exploit” supposedly allows a malicious QuickTime “movie” file to run arbitrary code on your Mac. Sounds scary, doesn’t it? Yep. The only problem is you have to really work at it to get the exploit to actually do anything. Supposedly, following this link will demonstrate the exploit and will speak the oh-so-classy message “Happy new year shit bag” using the Mac’s speech synthesizer. Unfortunately, I couldn’t get the exploit to work.

I tried following the link with Firefox and two versions of Safari. In all three cases I got a page with some garbled text on it, but nothing exciting. It’s always funny when someone reveals a supposed “exploit” and includes instructions for “if it doesn’t work for you, then try this.” And that’s what we have here. They have included a Ruby program to generate a file that is just like what you can download, and after running it, you should then “open pwnage.qtl”. I did this, and while QuickTime did open and crash, I didn’t hear the message. To be fair, and to ensure that I didn’t just miss hearing the message, I changed what the “exploit” should try to do. Instead of speaking the message, I changed it to open a terminal window, using “/Applications/Utilities/Terminal.app/Contents/MacOS/Terminal”. Guess what happened. Nothing.

All of this tells me this “exploit” is nothing more than a Mac-hater trying to make people think that Mac’s are “just as vulnerable” as crappy Windows machines.

Let’s see if the rest of the month is as scary and exploitable as yesterday was…

Pasteboard Op Hosed My Mac

Today, during lunch, I continued to work through Aaron Hillegass’s book, Cocoa Programming for Mac OS X. I was finishing up the chapter on using the Pasteboard for cut & paste, and my sample app was working as it should. And on my shiny Mac Pro, it ran very fast, indeed.

Then I got to the “Challenge” section… The challenge was to have the app copy its data to the pasteboard in both text and PDF formats. I got this working in about 5 minutes; no sweat.

Then I got creative… In the “For the More Curious: Lazy Copying” section, he explained how to have an application tell the pasteboard that it could provide data in various formats, just like usual, but to only put the data on the pasteboard when specifically asked by another app. I thought to myself, “Self, you should implement that with the text + PDF copying you’ve already got working.” And so I did. I got the code written in just a few minutes, referring to the API docs for various help. I ran my app, and copied the data. So far, so good. Then I went into the Preview app, selected File>New From Clipboard… and that’s when things started going South. I got the spinning beach-ball on Preview, and never a window opening. I toggled back over to my app, and it, too, was spinning. I killed Preview and my app, but trying to restart my app resulted in the window showing up, but the spinning beach-ball, and nothing else.

At this point, I figured I had hosed something, so I killed off Xcode and tried to restart it. Same thing as with the others: menubar + spinning beach-ball. Now, I figured a reboot was going to be required. And so it was, but actually rebooting proved to be a problem. I started killing off all my apps and while some would actually quit, some wouldn’t. I tried killing them from Activity Monitor, which worked on some, but not others. I then went to the Apple menu and selected Restart… which eventually timed out trying to kill the running apps. I tried again, but it still wouldn’t restart. I killed some more apps, and tried restarting again, but no dice. I finally killed the power to the box and turned it back on.

If anyone is interested, here are the relevant pieces of code that were involved in this fiasco.

The class is called BigLetterView, and it’s a subclass of NSView. The first method to see is copy:

 	- (IBAction) copy: (id) sender 	{ 	    NSPasteboard *pasteboard = [NSPasteboard generalPasteboard]; 	    [self declarePasteboardTypes: pasteboard];  	    NSLog(@"Backing up data"); 	    [self backupDataForCopy]; 	    NSLog("@Backed up data");  	    // [self writeStringToPasteboard: pasteboard]; 	    // [self writePdfToPasteboard: pasteboard]; 	} 	

Next is the method called from copy: that makes a copy of the data so that if the current values changes, a paste from another app will get the data as they were when the copy was invoked.

 	- (void) backupDataForCopy 	{ 	    backupString = [string copy]; 	    backupPdf = [self generatePdf]; 	} 	

Moving right along, we come to the method that is invoked when another app tries to paste our data from the pasteboard.

 	- (void) pasteboard: (NSPasteboard *) pasteboard provideDataForType: (NSString *) type 	{ 	    NSLog(@"Pasteboard requesting data of type: %@", type);  	    if ([type isEqual: NSStringPboardType]) 	    { 	        [self writeStringToPasteboard: pasteboard]; 	    } else if ([type isEqual: NSPDFPboardType]) 	    { 	        [self writePdfToPasteboard: pasteboard]; 	    } else 	    { 	        NSBeep(); 	    } 	} 	

And, finally, the two methods that write the data to the pasteboard when asked

 	- (void) writePdfToPasteboard: (NSPasteboard *) pasteboard 	{ 	    // NSData *data = [self generatePdf];     	    // [pasteboard setData: data forType: NSPDFPboardType]; 	    [pasteboard setData: backupPdf forType: NSPDFPboardType]; 	}  	- (void) writeStringToPasteboard: (NSPasteboard *) pasteboard 	{ 	    // copy data to the pasteboard 	    [pasteboard setString: backupString forType: NSStringPboardType]; 	    // [pasteboard setString: string forType: NSStringPboardType]; 	} 	

The problem seems to be in pasteboard:provideDataForType:, though I can’t see what it is. When I hit Cmd-C, the copy works OK. When I switch to Preview and select File>New From Pasteboard is when everything locks up. What looks to be happening is that the pasteboard service (pbs) is getting hosed, and it’s considered a “critical service” by the OS (I read that in some OSX docs), so if it’s dead/dying other apps who try to contact it are locking up. Makes sense. I tried restarting pbs, but that didn’t seem to make a difference.

So, has anyone else fought with this situation? If so

  • Do you see a problem with the code snippets above?
  • How can you recover from hosing pbs?
  • Any other suggestions?

Wow, That’s Quite a CPU You Have There…

I noticed that when I moved over to the new, shiny Mac Pro that I hadn’t brought over all my digital photos. I’m glad I realized this before whacking the hard drive in the old Windows machine… Anyway, I brought over 2Gb of photos and started importing them into iPhoto. Shortly after it started, I noticed my iconified activity monitor showing activity on all four cores of the CPUs, so I opened it and saw a very large number for CPU percentage for iPhoto. I assume it’s some sort of sum of cpu utilization across the cores, but it looks pretty funny, however they compute it.

Mac Firmware Upgrade Scare

I just got really scared. I noticed that Apple had release a new firmware update for the Mac Pro that said it fixed a bunch of stuff. I followed the directions to install it and all seemed to be going well. I got the progress meter that I saw the last time I updated the firmware, then it restarted, with the (really loud) system “bong”. It initialized one of my monitors with a gray screen and then… nothing. It didn’t go any further. I let it stay like that for a good 10 minutes, not wanting to interrupt anything in progress, but still nothing. Nervousness set in.

Then I remembered something I saw earlier about a firmware restoration CD from Apple. Fortunately I also have an iBook, because in order to create a CD from the download, you have to have a Mac. I made the CD, then followed the directions to use it. Only problem was that it didn’t work. I turned the box off. Then held down the power button until the light flashed rapidly, but the S.O.S. blinkenlichten that were promised in the directions never blinked. Which meant the CD tray never opened, which meant I couldn’t put the restoration CD in to do anything with it. Panic set in.

Then I happened to notice that when it was trying to boot, it did initialize my iPod. I thought maybe, for some strange reason, it doesn’t like/want the iPod plugged in on the reboot. I unplugged the iPod, shutdown the Pro and powered it up again and this time… it worked. After logging in, the firmware updater let me know that my firmware was now the latest version and that all was well. I don’t know why it balked with the iPod plugged in, but I’ll try to remember that next time.

And just now, as I was writing this, I went back and looked at the directions again. And what did I see?

Some USB and FireWire devices may prevent firmware updates from installing correctly. If you are having trouble installing an update try disconnecting non-essential devices and use only an Apple branded keyboard, mouse and monitor.

I guess it really does pay to read the directions all the way to the end before starting something like this. I could have saved myself some serious worrying…

I’m sure I’ll be able to laugh about this at some point, but not yet. If it hadn’t come back up, I would have had to drive half-way to the other side of Atlanta to the nearest Apple store, which would not have made me happy.

One Week After The New Mac’s Arrival

I’ve had my shiny, new Mac Pro for just over one week now and all I can say is “Whoa,” in a very Joey Lawrence sort of way. This thing is the fastest machine I’ve ever owned, and the closest to top-of-the-line I’ve ever been. Granted, I paid a premium for it, but it sho’ is nice.

Eclipse, which on my 1.4GHz AMD box took 45 to 80 seconds to startup, starts in 10 seconds. Yes, that’s 10 seconds. From clicking on the icon to ready-to-accept-user-input, in 10 seconds. And with 2GB of RAM, I can run iTunes, Eclipse, SQuirrelL SQL, SmartCVS, Adium, NeoOffice, TextMate, iTerm, JBoss, two instances of Firefox and Parallels Desktop (running WindowsXP), all at the same time, all without breaking a sweat. It’s a very sweet machine. Oh yeah, the other day I had Serenity playing on one monitor while I was working on the other.

When I decided to get this computer, there was only one Windows app that I was really going to miss, and that was SQLYog. I do most of my SQL work in SQuirreL, but SQLYog has this neat utility to compare the structure of two databases and generate DDL to alter one to look like the other. It’s very handy, and I was going to miss it. Then I noticed that the CodeWeavers folks have made CrossOver available for the Mac. I tried it, got SQLYog running and went ahead and bought a license. I’ve used CrossOver on Linux, and it’s a nice product. My only complaint is that it wants to open dialogs centered across both my monitors, so they end up being split across both monitors, but that’s a small problem, really. I’m just happy I can still run SQLYog.

Anyway, I’m very happy with my machine. I don’t miss Windows at all.

New Mac. Ordered.

Well, I did it. I finally took the plunge. Last night I ordered a Mac Pro, direct from Apple. It has two dual-core 2.66Ghz processors, 2GB of RAM, 250GB of hard drive, USB ports out the wazoo and an NVIDIA GeForce 7300 GT video card that supports dual monitors out of the box. The only difference between what I ordered and the “recommended” configuration is that I doubled the RAM. Consequently my estimated ship date goes from 24 hours to 2 - 4 days. I did upgrade the shipping, so I should have it by Halloween. But that’s 6 days from now. That’s a very long time to wait, knowing that something so lucious is on its way…

I’ve been using a home-brew 1.4Ghz Athlon PC, that I built 5 years ago, and it’s just been getting more and more problematic lately. Last week I spent a whole day re-installing Windows XP and all my software, because it had just gotten too unstable. After the rebuild, it was only marginally better. So I decided a new machine was in order. But what to buy? I had already decided some time ago that I wanted my next computer to be a Mac, but I could get another PC for far less. But did I want to sink any more money into PC-land, when I really wanted to live in Mac-ville? After considering for quite some time, and consulting with my wife, we decided that it made sense to go ahead and get what I really wanted.

Oh, the next 6 days are going be long…

I Got a Mac!

On Tuesday of this week, I traded my no-longer-used Dell Axim PDA for an iBook G4. I owned a Mac Toaster Model back in 1988, but that was a completely different beast. Even though this new Mac is a few years old, and only 800Mhz, it’s amazingly snappy. I have a desktop machine with an Athlon 1.4Ghz chip running XP, and this little Mac feels faster than that. Maybe it’s just because it’s different, but it really does feel that way. I’m very happy with it so far. I have installed a ton of software and have gotten it configured just so. I have my full Java development environment setup (Eclipse, Ant, SmartCVS and SQuirrelSQL) and I can build my company’s software, which is very cool.

Tonight I had a little spare time and started looking into Cocoa development. I knew that the Mac used Objective-C as it’s main development language, but I had never before had the desire to probe Objective-C. As I started looking into it, what do I find? Smalltalk-style calling semantics. I was shocked. I never knew that Obj-C had essentially grafted Smalltalk-style message passing onto the C language. What a surprise. This may end up being quite a bit of fun!

I’m currently just looking online, but I will very shortly want a dead tree to delve further into Cocoa. Any recommendations?