Posted by admin on May 15, 2010 in Mac OS X
When working on an Xcode project, it’s really easy to end up with a dozen windows open. You did know that you can close all of them and leave just the main project window open, right?
Just option-click in the close “box” (that’s what we used to call it when it was square, is it the “close circle” now?) of any editor window, just not the main project window. Et voilà — all windows closed.
Posted by admin on Apr 23, 2010 in Mac OS X
One of the very useful features of the mysql command line utility is the ability to edit the query you just executed and then execute it again.
Here is a query:
mysql> select now();
| now() |
| 2010-04-23 15:57:02 |
1 row in set (0.00 sec)
I can now edit this by entering the command “edit” at the mysql prompt:
The query is opened in an editor (vi for me) and I can edit and save the new query. When I exit the editor, it does NOT display the query. Instead, it just says “edit” and I must now append a final semi-colon before pressing return to execute the new query:
| The time is: | now() |
| The time is: | 2010-04-23 16:00:14 |
1 row in set (0.00 sec)
Posted by admin on Dec 24, 2009 in Mac OS X
I don’t do this often enough to remember, so I figured I’d write it down. For example, to look for all the places where you include stdio.h in .cpp files below the current directory:
$ grep -r -n --include "*.cpp" '#include <stdio.h>' .
Posted by admin on Dec 4, 2009 in iPod / iPhone
, Mac OS X
I always wondered if NULL got toll-free bridged to nil. I figured that NULL is a pointer value of all zeroes and nil is actually a pointer to a special object. So my hypothesis was they weren’t interchangeable. I was wrong.
// Check to see what happens to a toll-free bridged ptr when it gets set to NULL.
CFStringRef stringRef = NULL;
NSString *str = (NSString *) stringRef;
if (str == nil)
NSLog(@"str is nil");
NSLog(@"str is NOT nil!!!");
NSLog(@"The object value of nil is %@", nil);
NSLog(@"The numeric value of nil is %d", nil);
Yields the following output:
2009-12-04 10:51:58.532 TollFreeBridging[18053:a0f] str is nil
2009-12-04 10:51:58.535 TollFreeBridging[18053:a0f] The object value of nil is (null)
2009-12-04 10:51:58.536 TollFreeBridging[18053:a0f] The numeric value of nil is 0
And then there’s NSNull….
Posted by admin on Nov 25, 2009 in Mac OS X
Typically, tea needs to brew from 4-5 minutes. You’re probably smart enough to figure out the rest of what’s going on here:
$ sleep 240; say "Tea's Done"
Edit 25-Nov-2009: I guess there’s no reason I couldn’t make a MacRuby app out of this, huh?
Posted by admin on Nov 3, 2009 in Mac OS X
In the current Mac OS X / Cocoa project I’m working on, we need to be able to run an installer from code. Naturally, I’ve written tests for this, which work fine on my own machine. However, when I checked in the code, the test would literally hang at the point where it should be executing the “installer” command.
The continuous integration system we’re using is cruisecontrol.rb which is started at boot time by launchd under a non-root user running on a Mac Mini. Consequently, when the test is run that fires up the installer command, it’s doing so as a non-root user.
This no workie.
I’m sure there’s some sort of interesting and obscure way to circumvent this, but the general size of things is that you can’t run the installer command unless you’re using sudo or you’re root. Since running sudo in the above context is kinda obtuse, and since we’re not going to run cc.rb as root, it looks like these particular tests are now out of the automated test suite and into the manual test suite. At least there’s an explanation now!
Posted by admin on Oct 2, 2009 in Mac OS X
On a current project, whenever a menu extra menu was open and an underlying item was updated, the entire menu extra would crash. Upon further review here (note “Main Thread Only Classes”), it appears that it is verboten to update the menu item title from a thread other than the main thread. Check out this git repository for a simple project that used to reproduce the problem and now shows how to set the menu item title properly from a non-main thread.
Posted by admin on Sep 8, 2009 in Mac OS X
I’m not sure why Xcode doesn’t support Print Selection like Terminal (and other) apps do. Anyway, I finally got tired of not having this feature and implemented it myself using a shell script. No step-by-step this time — you should know how to do that by now. Just notice the script’s contents, input/output, etc. This specifically prints the selection two-pages-per-sheet and will display an alert with the command output.
Posted by admin on Jul 1, 2009 in Mac OS X
Well, as much as I coveted one of the new MacBook Pros, I didn’t expect I’d end up with one. Until yesterday when my stalwart 17″ MBP started blank-screening me on sleep and restart. I spent a number of hours trying about everything I could think of and finally gave in and bought a new 15″ MBP — the one released at WWDC this year.
So far, I do miss the resolution of the 17″, and I’m not sure if I’m crazy about the glossy screen or not. Otherwise, the speed is great, and the multi-finger gestures are pretty cool. Now if I could only get Boost to build….
Posted by admin on Jun 15, 2009 in Mac OS X
During a recent presentation about Xcode, when the speaker brought up how to create a “snapshot,” my colleague Chris and I both had the same answer:
$ git commit