iTunes Store tips

  1. Define a shortcut for Power Search. System Preferences > Keyboard & Mouse > Shortcuts > iTunes > Search… I set mine to Cmd -F (odd that that doesn't focus on the search field, by default)

  2. Wishlists. Just create a playlist and drag stuff from the store to it. Only works with individual tracks, sadly

  3. Don't forget to de-authorize computer before formatting the HD. It's OK if you restore from a complete backup (including the stuff under /Volumes).

  4. Use the Browse command (Cmd-B)


|
AppleScripting Keynote 3
And in particular the add chart command. At first it seems like a really cool thing - easily create beautiful charts out of virtually any source. I was excited to try this with some Webalizer output. Looks like you have two options - the Automator Action or Script Editor

The action produces a chart right off the bat, but the input is weird:

Input: (Anything) Two dimensional array of chart labels and data.


What is that? After trying every possible permutation of what I thought an AS 2D array would look like (some of which even compiled!) with different kinds of input sources (AS, text) I finally gave up the Automator Action option.

Using script editor seemed promising at first, but a simple add chart with all the properties produced nothing. Finally managed to find this really nice example, but it only worked with Pages. Digging in the action's bundle revealed that you're supposed to tell the slide to add the chart. OK, time to put this new-found knowledge to work:
tell application "Keynote"
set theData to {{1, 2, 3}, {4, 5, 6}}
set theSlide to (slide 1) of first slideshow
tell theSlide
add chart row names {"Dec", "Jan"} column names {"Machines", "Visits", "Hits"} ¬
data theData type "vertical_bar_3d" group by "column"
end tell
end tell

Pasted Graphic 2

Tadaa! Sweet. Now all that remains is to add the webalizer parsing code...

|
servermgrd bus error
This happened after a failed attempt to add a signed cert from a CA - servermgrd just crashed. Trying to disable all SSL (/Library/Preferences/com.apple.servermgrd.plist) had no effect. Starting in debug mode just said this:
# servermgrd -d
2007-01-28 23:39:04.717 servermgrd[20540] *** _NSAutoreleaseNoPool(): Object 0x306030 of class NSCFData autoreleased with no pool in place - just leaking
2007-01-28 23:39:04.717 servermgrd[20540] *** _NSAutoreleaseNoPool(): Object 0x306420 of class NSCFData autoreleased with no pool in place - just leaking
2007-01-28 23:39:04.733 servermgrd[20540] Entering initialize
2007-01-28 23:39:05.600 servermgrd[20540] Starting idle processing
Bus error

Well, it turns out that the stuff about memory leaking is "normal". Here's the output of the same command on a totally unrelated, perfectly in-order Tiger server:
# servermgrd -d
2007-01-28 23:52:46.348 servermgrd[21665] *** _NSAutoreleaseNoPool(): Object 0x306020 of class NSCFData autoreleased with no pool in place - just leaking
2007-01-28 23:52:46.348 servermgrd[21665] *** _NSAutoreleaseNoPool(): Object 0x306410 of class NSCFData autoreleased with no pool in place - just leaking
2007-01-28 23:52:46.349 servermgrd[21665] Entering initialize

It's the Bus error that I'm worried about. Most of ktrace servermgrd -d and kdump -f ktrace.out is incomprehensible and so is pretty much /Library/Logs/CrashReporter/servermgrd.crash.log

Checking the last lines of kdump (kdump -f ktrace.out | tail -n 20) did mention /Library/Keychains/System.keychain, just shortly before the crash. A find -ctime 2 confirms that System.keychain was modified just around that fateful moment when this problem started. For the heck of it, I decided to move the old keychain aside, and create a new one:
# mv System.keychain System.keychain.old
# security create-keychain /Library/Keychains/System.keychain

Sure enough, servermgrd was open for business again:
server:/Library/Keychains root# servermgrd -d       
2007-01-29 00:20:48.654 servermgrd[20712] *** _NSAutoreleaseNoPool(): Object 0x306030 of class NSCFData autoreleased with no pool in place - just leaking
2007-01-29 00:20:48.655 servermgrd[20712] *** _NSAutoreleaseNoPool(): Object 0x306420 of class NSCFData autoreleased with no pool in place - just leaking
2007-01-29 00:20:48.655 servermgrd[20712] Entering initialize
2007-01-29 00:20:48.946 servermgrd[20712] Starting idle processing
2007-01-29 00:20:51.534 servermgrd[20712] Done with idle processing

I was actually able to salvage the certs and private keys from the damaged keychain file like thus:
# security export -k /Library/Keychains/System.keychain.old -t all -o ./all.pem

and then import them back into the fresh keychain:
# security import ./all.pem -P -k /Library/Keychains/System.keychain   
2 keys imported.
3 certificates imported.

The bad news is that although Server Admin works again, I'm unable to use the Certificate Manager. Any attempt to either add or import a cert gets replied by a dull "The selected certificate could not be retrieved. Going back to the list." Oh well, just another good reason to get more comfortable with the CLI - it's not as fragile... By the way, If you change SSL certs in httpd conf files, it seems it's better to stop and start the server, not restart (otherwise the old cert is still used).

Just for the record, the cert and key in /etc/servermgrd are disposable. If you delete them, they will be re-created by servermgrd on the next launch. Oh, and there's also certadmin, but it did absolutely nothing for me.
|
An interesting quote

If the Mac was so great, why did it lose? Cost, again. Microsoft concentrated on the software business and unleashed a swarm of cheap component suppliers on Apple hardware. It did not help, either that suits took over during a critical period. (And it hasn't lost yet. If Apple were to grow the iPod into a cell phone with a web browser, Microsoft would be in big trouble.)


Excerpt taken from Paul Graham's excellent Hackers & Painters, published in 2004.
|
Building universal binaries
So far I've had the best success with defining the following before configure:
> export LDFLAGS="-Wl,-syslibroot,/Developer/SDKs/MacOSX10.4u.sdk -arch ppc -arch i386"
> export CFLAGS="-isysroot /Developer/SDKs/MacOSX10.4u.sdk -arch i386 -arch ppc"

Sometimes this lead to:
gcc: -E, -S, -save-temps and -M options are not allowed with multiple -arch flags

in which case passing --disable-dependency-tracking to configure seemed to help.
|
last.fm's Taste-o-meter
I'm not a big fan of social networking sites, but last.fm is different. It actually has a point - you can use it to discover new music, keep tabs on your more distant friends, create groups, track events etc. It's useful and actually fun to use.

One thing I think could work better is the Taste-o-meter. It seems it's also the basis of the Neighbours feature. It could be a little smarter - instead of just counting the artists two users have in common, it could compare the relative "rareness" of that particular artist. Everyone listens to Foo Fighters or Tool or DJ Shadow or whatnot but that doesn't mean they actually have anything else in common. This creates the anomaly where someone with 40 000 played tracks is suddenly neighbours with everyone. Now if two people both listen to an obscure Finnish accordion-jazz ensemble, the chances are, they have a lot more in common as well and that they should definitely check out what other tracks they've played.

I thought this idea was pretty cool so I sent it in to last.fm but they never even acknowledged it, so I thought I'd stick it up here instead of just having it vanish into the ether.
|
Postmaster
Giving your (admin) account the "postmaster" alias doesn't actually do anything because /etc/postfix/aliases hardwires postmaster to root and that sends mail to /dev/null. I fixed this by setting the "root" config var in aliases.

In other news, watch out for failed user-specific crontab entries. Sometimes (more than once) running
> crontab -u user -e

will simply hang, creating a tmp.something into /var/cron/tabs. This drives cron mad, eating up all the cycles it can. To fix is to basically pull a:
$ rm -rf /var/cron/tabs/tmp.*
$ killall cron -SIGHUP

|
Emulators over RDC
Always remember to keep the sound option at "Play on remote computer". I tend to leave mine at "Do not play" and then wonder why the S60 emulator will launch and then quit after about 20 seconds.

Pasted Graphic

|
Amavis gone haywire
The problem:
Jan 22 17:57:59 server postfix/qmgr[29037]: warning: mail for [127.0.0.1]:10024 is using up 20000 of 20000 active queue entries
Jan 22 17:57:59 server postfix/qmgr[29037]: warning: you may need to reduce smtp-amavis connect and helo timeouts
Jan 22 17:57:59 server postfix/qmgr[29037]: warning: so that Postfix quickly skips unavailable hosts
Jan 22 17:57:59 server postfix/qmgr[29037]: warning: you may need to increase the main.cf minimal_backoff_time and maximal_backoff_time
Jan 22 17:57:59 server postfix/qmgr[29037]: warning: so that Postfix wastes less time on undeliverable mail
Jan 22 17:57:59 server postfix/qmgr[29037]: warning: you may need to increase the master.cf smtp-amavis process limit
Jan 22 17:57:59 server postfix/qmgr[29037]: warning: please avoid flushing the whole queue when you have
Jan 22 17:57:59 server postfix/qmgr[29037]: warning: lots of deferred mail, that is bad for performance
Jan 22 17:57:59 server postfix/qmgr[29037]: warning: to turn off these warnings specify: qmgr_clog_warn_time = 0


The solution (found from the postsuper manpage):
> mailq | tail +2 | awk  'BEGIN { RS = "" } / spam@host$/ { print $1 }' | tr -d '*!' | postsuper -d -
/ snip /
postsuper: Deleted: 39819 messages


The cause:
I wish I knew...
|
Bruce Is Back!
The Final Cut mascot. It turns out that starting from 5.1 you have to call up the Video Scopes and control-click in the vectorscope. He's alot braver now too. You can actually move the FCP windows around and he'll just sit there. This picture was taken with the Finder as the background:

Pasted Graphic 1

|
As If Nothing Ever Happened
To restore a customised and updated machine so that it looks as if it's never been booted:

Boot to single-user mode
> mount -uw /
> rm -rf /Users/* /var/db/netinfo/local.nidb /var/db/.AppleSetupDone /Library/Preferences/* /Library/Caches/*
> shutdown now

|
Remembering the QTVR Pan Angle
This only works with Safari:
QT_WriteOBJECT_XHTML (
'myVRmovie.mov', 800, 600, '',
'controller', 'true',
'id', 'myvrmovie',
'cache', 'true',
'pan', getAngle ());

... where getAngle() just uses a cookie:
function getAngle ()
{
return document.cookie.split ('=')[1];
}

... which is set with setAngle () like thus:
function setAngle ()
{
document.cookie = 'angle=' + Math.floor (document.myvrmovie.GetPanAngle ());
}

Finally, the hotspots are wired to go through this function:
function openPage (url)
{
setAngle ();
window.location (url);
}

|
Creating Empty Files of Any Size
This is again one of those cool things that you could never do with OS 9 or older:
> dd count=`echo $((1024*1024/512*sizeinmegs))` if=/dev/zero of=myfile.zeros

Perfect for testing drives, networks or file transfer apps.
Update:
man mkfile

|
A Good Year
Speaking of MacWorld and Apple history, here's a "blast from the past" I found while going through some old stuff:

mw-small
That was a pretty good year! And it'll be 10 years this year since Jobs came back, btw.

|
Revitilizing Camino's Flashblock
I noticed the little FlashBlock checkbox in CaminoTools wasn't actually doing anything. It's supposed to disable all flash content until you click on it. Turns out this is achieved with simple CSS and here's how you enable it:
> cd ~/Library/Application\ Support/Camino/chrome
> cat > ./flashblock.css << EOF
/* Prevent flash animations from playing until you click on them. */
object[classid$=":D27CDB6E-AE6D-11cf-96B8-444553540000"],
object[codebase*="swflash.cab"],
object[type="application/x-shockwave-flash"],
embed[type="application/x-shockwave-flash"]
{ -moz-binding: url("http://www.cs.hmc.edu/~jruderma/clickToView.xml#ctv"); }
EOF

and then just include that css file in your userContent.css:
> echo "@import url(flashblock.css);" >> ./userContent.css

I think this is a pretty useful thing to do to Camino since many Flash objects seem to slow it down to a crawl.
|
Smartphone Market Share
I'm really excited about the iPhone. Finally a mobile device that looks great, tackles some serious UI problems with fresh ideas and sports a "real" operating system, made by the same house as the HW to boot (although the specs on that one are still nowhere to be found). They could've dropped the camera to maybe squeeze some extra batter life out of it, but nevermind. Got me excited about mobile app development again! A couple of things I didn't quite get:

Pasted Graphic 2


The mobile phone market - 952 million units. Yeah, but how many of those were actually smartphones? Hard to find any exact evidence, but Symbian reports shipping 37 mil units in 2006 and they're almost 73 % of the whole smartphone market. In other words, smartphones sell waaay less than digital cameras. Frankly, I'm quite surprised they'd let this kind of bug slip into the Keynote.

CalDAV support. One of the biggest reasons why companies buy expensive Nokia Communicators with even more expensive Exchange servers is they provide an end-to-end "cross platform" (mobile + desktop) solution. OK, you can make Exchange email work over IMAP, but what about collaborative services, ie calendards? Apple will be putting CalDAV support into Leopard server, but to this day thre's not a single CalDAV client for mobiles out there. Would've been nice if he'd touch on this subject, or at least showed a glimpse of the client running. Especially since 3'rd party software will apparently not be supported on the iPhone.

Good show otherwise. Apple TV looks really cool too. Thinking of buying one just for the sake of trying to make it work without iTunes (although I'm sure someone will have had it figured out by the end of this week).

One things's for sure - WWDC's gonna be awesome!

|
Are We Or Aren't We?
Everyone knows this by now. This is nice and I couldn't agree more:

1101061225_400

However, I found the Chrysler ad they run before this story on time.com to be a little umm... conflicting?

Pasted Graphic 3Pasted Graphic 4

I have a fairly sarcastic sense of humour, but even I don't get it. Are we or aren't we? Would be kind of a downer if they ran that after the story.

|
I Love Akamai (from now on)
Here's a cool 22 minute video showing how Akamai works which I found when researching for my thesis. Impressive would be an understatement. It's a little long, but definitely worth watching if you're into statistics or online content delivery:



There's actually all sorts of goodies on their site. Like this Dashboard Widget that shows you how much music business there's out there or the realtime metrics visualizations. Plus, they look cool too!

Pasted Graphic

|
Giving .doc an Icon
I don't work much with Word files, but when I do, the only major "problem" I have is that if you only have Pages and TextEdit installed, .doc files have a generic-looking white icon. It's easy to fix though:

/Applications/TextEdit.app > Show package contents > Contents > Resources
Duplicate rtf.icns and rename copy to doc.icns
From the Contents folder open Info.plist and into the CFBundleDocumentTypes array append:
<dict>
<key>CFBundleTypeExtensions</key>
<array>
<string>doc</string>
</array>
<key>CFBundleTypeIconFile</key>
<string>doc.icns</string>
<key>CFBundleTypeName</key>
<string>Microsoft Word Document</string>
<key>CFBundleTypeOSTypes</key>
<array>
<string>W8BN</string>
<string>W6BN</string>
</array>
<key>CFBundleTypeRole</key>
<string>Editor</string>
</dict>

Then flush the LaunchServices cache (this will reset all document/app associations so be prepared to be annoyed):
> cd /System/Library/Frameworks/ApplicationServices.framework/Frameworks/LaunchServices.framework/Support
> ./lsregister -kill -r -domain local -domain system -domain user

Pasted Graphic 1

|
ADC Student Membership
There doesn't seem to be much info out there on this subject, so here's my experience. Bought the student membership for 99 EUR, solely for the hardware discount (I'm sure that's the case for most people). The product listing also says you get the current version of OS X and a copy of XCode as well, but they're bundled with the machine anyway.

> priceOfMembership=99
> priceOfHardware=1408
> newPriceOfHardware=1275
> echo 'Total discount: ' $(($priceOfHardware-$newPriceOfHardware-$priceOfMembership)) 'EUR (' $(($newPriceOfHardware/$priceOfHardware*100)) '% )'
Total discount: 34 EUR ( 0 % )


The percentage is 0 because Bash's arithmetic's only deal with integer values (it's actually about 10%), but it may as well be, because you should also factor in the 30 min on the phone. From some online reports, you get the impression that the discount should be around 20 %. Is Apple discriminating it's European customers... again? It's bad enough they don't state the discount percentage in advance.

I'm having a hard time hiding my disappointment. All the hassle of getting the school papers, faxing them in, solving problems (it took more than 2 weeks for my student status to be verified, finally was able to get the student certificate in through email thanks to the helpful people at ADC, kudos to them) and waiting on the phone for 34 EUR? I understand that it's more useful when you buy something really expensive, but you'd think that student members aren't necessarily the ones driving those shiny Mac Pros or even MBP-s. Most of them can't even afford a Mac at all!!!

This was the first time I ever bought an ADC product. May very well be the last as well.
|
Display Sleep
I usually leave my Mac on when I go to bed. This means setting the display sleep to now or the next best thing, 1 minute. The most obvious way to do it is from System Prefs, but I wanted something faster:
> sudo pmset displaysleep 1

is great, but requires root prvileges (due to some of the other things you can do with it) so it's out for any kind of automation/scripting purpose.

Enter Apple Remote Desktop. Among other niceties, ARD includes a CLI utility called systemsetup that you can use to set various system preferences, like so:
> /System/Library/CoreServices/RemoteManagement/ARDAgent.app/Contents/Support/systemsetup -setdisplaysleep 30

Nice. Time to wrap this into something Mac-like and give it a keyboard shortcut:
property ARDPath : "/System/Library/CoreServices/RemoteManagement/ARDAgent.app/Contents/Support/systemsetup"

set currSleep to do shell script ARDPath & " -getdisplaysleep"

if (currSleep) does not end with "1 minutes" then
set newSleep to 1
else
set newSleep to 30
end if

do shell script ARDPath & " -setdisplaysleep " & newSleep

Throw that into ~/Library/Scripts and give it a fitting shortcut in System Prefs/Keyboard & Mouse.
|
Audio Transcoding with Automator
Got a bunch of FLAC files that I wanted to add to the iTunes library. Options: a) install the FLAC component and hope it works b) decode them with flac, import wavs to iTunes, delete the wavs or c) do point b), but with a click of a button:

Pasted Graphic

Pretty nice. I only wish QuickTime Player had such a nice Automator Library...

|