My nintendo WFC friend code!

287839
004114

Posted in games | Leave a comment

adduser script for Mac OS X / Mac OS X Server

http://www.dreness.com/bits/tech/adduser.html (syntax colored)
http://www.dreness.com/bits/tech/adduser (raw)

Posted in OS X, OS X Server, scripts | Leave a comment

vacation notes

I recently went to PA for a family gathering; mom came up from FL, my brother came out from Seattle, and all the people who live out that way. Impossible to get *everybody*, but we did ok.

Flew out on a Friday, way early… flight left at like 6:20 or something. Connection through Dallas, on to Philly. Mom and AJ arrived many hours later, so I took a shuttle to within a few minutes of my Aunt Marian’s place, then she scooped me up. The party was at their new (very sweet) house (with a bigass barn / stables), which they had only started living in the day before…. so things were a little hectic for them… moving is always crazy. There was lots of food, outdoor activity, a birthday celebration, and several rounds of chess. My cousin Kyle is into it (and seemed pretty decent for an 8 year old), so we played a bunch on their swanky chess set, which caused a couple others to get in on the action as well.

Pictures!

Sunday we went over to a cousin’s place for an afternoon, also fun times, got to hang out a bit more with their kids whom I hadn’t met before Friday (and others; a total of 4 ‘new’ second cousins).

On Monday, myself, my mom and grandparents headed back to their place in Slippery Rock, PA. It’s about a 7 hour drive or so, not too bad, but only two days after the flights to get out here, so I was getting a little antsy toward the end.

The place in Slippery Rock is about the same as I remember it being since I started going up there at like age 5 or something… though it does now have certain modern conveniences such as wireless internet access (granddad is way into it, grandmom is quick to change the subject :). One difference is that this time, for various reasons, a bunch of our (me, AJ, mom, Bob) stuff was in storage under a lean-to behind granddad’s shed. Mom wanted to get that all sorted, so we drug it all out. It was all packed in cardboard boxes, and they were stored outside – though I must note that granddad took every possible precaution to keep them well stored, including digging a ditch around the entire top half of the shed to keep the ground dry. Some of them were still kinda nasty, though, and some groundhog had some fun in there, but overall, only a small amount of stuff was lost or otherwise funktified beyond repair.

One thing I definitely nabbed was my trombone (I played it all through middle / high school); got it all cleaned and whatnot. I played for a short while outside, and my chops are predictably shot. I could build ’em back, but there’s not much motivation unless I start hanging with people who need horns, heh. Also grabbed a few old t-shirts, some CDs, and a couple other very small odds and ends.

It was two days of work getting it all sorted… there was a garage sale pile, a free library donation pile, a keep pile, a garbage pile, and of course the burn pile. Around the half-way point, I heard some sort of music box – just a single tone – from a box that mom was working on, and immediately stopped what I was doing and just stood there, somewhat involuntarily. She started to say what it was, but I already knew it was my first little wind-up music box toy. This probably sounds kinda cheesy, but I was (still am) amazed at how the sound of it affects me, it’s pretty surreal… definitely an intense emotional swell of some sort. Every nuance is familiar.

We also spent some time looking through some old photos… like really old. The grandparents know most of the history; a rather startling amount of it, I thought. Anyway, they’d go though the photos and just weave the story to go along with the pictures. I was thinking how much more valuable that is than just pictures alone… We started plotting ways to capture it all, but it’ll have to wait for next time.

My third day there was also the last; they brought me to the Pittsburg airport to fly out a bit after 7 in the evening. The flights back kinda sucked… we were delayed over an hour getting out, which brought my Chicago connection window down to about 8 minutes. I arrived with a few minutes to spare (rather out of breath) only to find that the connection was also delayed. The second flight seemed comically and then infuriatingly long, and I realized that my expectations had been set by the trip out, which had two more equal legs. After all the recent travel, I was really going nuts on this airplane – plus it was late, and I was worn out and sunburned.

Anyhow, great times were had, and we’ll probably do it again next year!

Posted in bit bucket | Tagged , | 2 Comments

I just learned that my friend Michael Bartosh died this weekend. His death was accidental; he fell from a balcony in Tokyo. He was a pretty well known guy in the mac enterprise consulting sphere; definitely one of the very best at his craft, constantly jetting all over the Earth, doing his thing. His last IM status line that I remember was “3 continents in 3 days”.

I first met him 3 or 4 years ago on the Apple certified training circuit; I was just getting started, and he was an old hand. We were at Apple in cupertino, having been invited by the courseware developers to alpha test some new curriculum, provide feedback, and tighten things up for the release. I was surprised to hear that his feedback was pretty harsh at times; not necessarily directed at the courseware, but at Mac OS X Server in general. He was very honest about the shortcomings of the OS, which was kind of a breath of fresh air… many hard-core mac guys tend to gloss over the faults.

We shared an apartment for a week at a time on several occasions in the course of doing the training stuff for Apple. In 2004, he asked me to contribute the firewall chapter for his O’Reilly book; I was and still am proud to be associated with his work. Once I started working at Apple, I’d always try to hook up with him for beers / dinner when he was in town.

It was always good times, as Michael was very much a fun loving guy, and really smart. Lots of great stories. He was one of those people who does everything to the max… worked real hard, played real hard.

Real hard. I don’t know the details of his death, but anyone who knew him decently well knows that he was not afraid to push limits.

This is the first time a friend of mine has died, and it feels weird. I read mailing list posts from him last week, exchanged IMs… now he’s gone. He was 28 years old, same as me.

He’ll be missed.

Posted in bit bucket | 6 Comments

Apache AddType directives for AAC audio

AddType audio/x-m4a m4a
AddType audio/x-m4b m4b

Posted in bit bucket | Leave a comment

Automated backups of Open Directory databases

# Automated backups of Open Directory databases (ldap / kerberos / password server)
# This needs to run as root and should be mode 700 due to embedded password

# Get current date
TODAY=`/bin/date +'%m-%d-%y_%H:%M:%S'`

# Set destination directory  (do not include trailing slash!)
DSTDIR=/path/to/backups

# Set archive password (needed to restore from / unlock the resulting dmg)
PASS="the_foo"

# Feed a heredoc to serveradmin
/usr/sbin/serveradmin command <<EOF
dirserv:backupArchiveParams:archivePassword = $PASS
dirserv:backupArchiveParams:archivePath = $DSTDIR/od_backup_$TODAY
dirserv:command = backupArchive
EOF
Posted in OS X Server, scripts | Leave a comment

Remote Server Setup get stuck?

I was using Server Assistant to do a remote setup of Mac OS X Server, and for some reason Server Assistant hung. When I relaunched it, the target server would not allow me to start over or continue the remote setup, claiming that it was already being remotely configured (clearly it didn’t notice that Server Assistant barfed).

I SSH’d to the server as root / [first 8 chars of serial number] and begun to poke around. Typically, OS X leaves little breadcrumbs in certain areas of the filesystem as state indicators, such as /var/db/.AppleSetupDone which is created after you go finish the setup assistant. However, this file was not there on my target server (and it shouldn’t have been, since I never did actually finish the setup). There was also no ‘setup in progress’ file in /var/db. After running fs_usage -w for a brief minute, I found what I was looking for: /System/Library/ServerSetup/.RemoteSetupInProcess. After nuking this, I was able to start again with the remote setup, and all is well.

Posted in OS X Server | Leave a comment

NSTask trickery for long shell pipelines

I learned a cool trick hack today in the process of trying to help somebody with their cocoa code. Dude was trying to fire an NSTask with some arguments for the current command, and then an additional argument that included the rest of a 3 or 4 stage pipeline. The command in question is /usr/bin/ldapsearch, and he was trying to set the arguments array something like:

arguments = [NSArray arrayWithObjects:
@"-LLL", @"-x", @"-b", @"cn=users,dc=company,dc=com", @"-h", @"dirserver.company.com",
@"cn", @"uid",
@"| /usr/bin/othercommand -with -arguments | /bin/thirdcommand -and -even -more -args",
nil];

This won’t work. Not even close, actually. The proper cocoa way to do this would be to create an NSTask for each command, setting each task’s arguments as necessary. You connect the tasks with NSPipe objects, as explained at cocoadevcentral. Obviously this would become somewhat verbose / tedious if you needed a long pipeline.

Of course, the whole idea of calling shell commands in the first place is usually considered ‘icky’ by most real programmers. The ‘better’ way would be to use the appropriate cocoa / carbon API, and there’s one for just about everything. The thing is that some folks (such as myself) are more comfortable in a unix shell than in Xcode; often it is faster to whip out an NSTask than to learn some Cocoa API to get the job done. Performance geeks will rightly assert that using NSTask is much slower, however the speed difference is not even perceptible to a human unless you’re using NSTask in a rapid-fire fashion (a simple “take input, fire NSTask, collect and display results” is quite fast). Now, I’m certain that I’ll read this again in a few years and laugh at myself for being a hack, but I don’t care :)

For right now, if I’m going to hack, I’m going to hack it good. The trick is this: set the NSTask command to /bin/sh, and the arguments as follows: The first argument is set to “-c”, the second argument is the entire shell pipeline, including as many commands and pipes as you need, and the third argument as the requisite ‘nil’. Basically, we’re now simply passing a little mini shell script directly to /bin/sh. This is roughly akin to creating a small shell script on the fly, writing it to the filesystem, and then executing it with NSTask, except this way there’s no need for any file i/o. Another advantage is that you should (note: untested!) be able to take advantage of other shell functions for which there is no direct equivalent in NSTask land; e.g. angle brackets for input / output redirection, etc.

Posted in development | 3 Comments

Modifying nested property list items with PlistBuddy

The /usr/bin/defaults command gives us basic command line access to the Mac OS X preferences system. I say ‘basic’ because it provides no facility for directly operating on any keys / values that are not at the top of the heirarchy. For example:

{8} andre@werk [~] % defaults read com.apple.finder ComputerOptions
{
    ComputerListViewColumnFlags = 1; 
    ComputerSidebarWidth = 121; 
    ComputerToolbarVisible = 0; 
    ComputerUseCustomIconViewOptions = 1; 
    ComputerUseCustomListViewOptions = 1; 
    ComputerViewHeight = 385; 
    ComputerViewStyle = clmv; 
    ComputerWindowBounds = {bottom = 726; left = 1589; right = 2277; top = 341; }; 
}

The ComputerOptions key contains not a string or an integer, but a dict (dictionary). Note that this is different from a ‘top level’ key which is a simple key / value relationship, such as:

{9} andre@werk [~] % defaults read com.apple.finder AppleShowAllFiles
OFF

So, what do you do when you want to change the value of, for example, the ComputerToolbarVisible attribute in the ComputerOptions dict? With /usr/bin/defaults, you’d have to read out the entire dictionary, make the change in some other mutable environment, then load the whole ComputerOptions dict back in as a plist. It works, but there’s an easier way, using a tool that’s already on your system: PlistBuddy. You’ll find this in several apple-supplied installer packages (on my system at work, I have 18 different copies of PlistBuddy scattered throughout various packages / receipts).

Here’s how you’d twiddle the ComputerToolbarVisible attribute with PlistBuddy. Note that this is all one single command.

/Library/Receipts/AdditionalEssentials.pkg/Contents/Resources/PlistBuddy -c \\
"set ComputerOptions:ComputerToolbarVisible 1" \\
~/Library/Preferences/com.apple.finder.plist

and then check the results…

{14} andre@werk [~] % defaults read com.apple.finder ComputerOptions | grep Toolbar        
    ComputerToolbarVisible = 1; 

Execute PlistBuddy with no arguments, and then again with -h for more information.

Posted in OS X | Leave a comment

Managing dual boot Macs

How I learned to stop worrying and image / restore those dastardly windows NTFS partitions:
http://www.bombich.com/mactips/dualboot.html

Posted in OS X | Leave a comment