Creating an iTunes Dropbox on a Mac

By · Published · apple, applescript, appletv, howto, mac, osx


I recently added a Mac mini to my setup at home, that I'm using to drive my in-home "video on demand" system. With many of the TV's in the house on AppleTVs, any TV in the house can watch any movie in the library at any time. I put the mini (headless) in the closet, along with the Drobo and a printer.

But, the new Mac mini lacks an optical drive. So, how to continue ripping the DVDs I already own?

The solution, it turns out, is to continue doing the actual work on my iMac when it comes to ripping, filtering the files through iDentify and MetaX. But I don't want to have to go to screen sharing on the Mini and add a file to iTunes. I want that to happen automatically. That's where Automator - one of the most underrated pieces of software that comes with every Mac - comes in.

With Automator, you can attach an action to a folder, so that that action will be performed whenever anything is added to that folder. So here's what I did to get files from a folder into iTunes:

  1. Create a folder somewhere on your system. I put mine in my user directory.

  2. Open Automator.

  3. From the dialog box, select "Folder Action."

  4. At the top, where it says "Folder Action receives files and folders added to," select "Other" and select your new folder.

  5. Search for an action called "Set Var of Value". Drag that action over to the right.

  6. From "Variable" select "New Variable." Call it "Source"

  7. Search for an action called "Import Files into iTunes". Drag that action over to the right underneath the variable action. Be sure to select "Library" from the empty dropdown.

  8. Search for an action called "Get Var of Value". Drag that action over to the right underneath the iTunes action.

  9. Be sure the selected variable is "Source".

  10. Search for an action called "Move Finder Items to Trash". Drag that action over to the right.

  11. Search for an action called "Run AppleScript." Drag that action over to the right.

  12. In the AppleScript action, paste this:

on run {input, parameters}
    tell application "Finder" to empty trash
    return input
end run
  1. Save the action. You're done.

On Apple and Maps

By · Published · apple

Unless you've been living under an Internet rock, you know that Apple released a new version of iOS, featuring a much heralded new mapping application. This application replaces the old Google Maps application. You also probably know that it has been roundly criticized and mocked.

Now, before anyone accuses me of blatant fanboyism (although, without a doubt, I am an Apple fanboy), the new Maps application sucks. It's a step backwards from the previous one, lacks some of the features the previous one had, and is generally disappointing. I especially don't like how it didn't degrade gracefully on the iPhone 4 (no voice turn-by-turn, and, for some strange reason, it seems unable to count down the distance to the next turn). In general, it clearly isn't ready for primetime, Apple over-advertised it, and I think Apple could have done better.

But, other than being disappointing, the new Apple Maps application has no real impact on me because I never used the old one. It sucked also, and I think people are forgetting just how badly the old one was allowed to languish without significant updates. The Google-based Maps app in iOS 5 was essentially unchanged from the one that was released 4 years earlier.

Here are some things that were wrong with the "old" Google-based Maps app as of iOS 5:

  • No voice turn-by-turn directions.

  • Had to manually advance while driving when doing directions.

  • Searching sucked: you had to spell things exactly right or it wouldn't find them.

  • For some reason, it thought I lived in Madison, Wisconsin all the time.

If you live in anywhere but a large city, it was essentially useless for navigation. You could maybe find an address, if you knew exactly what you were looking for, but you couldn't safely get there in a car. In short, I long ago abandoned the built-in mapping application for better services available in the App Store.

I've been using the free Mapquest app for the last couple of years, and it's worked great. It's gotten better with each iteration, to the point where it's pretty much my sole navigation app now. My process flow as usually been search for an address in Safari (or get it from another app like Yelp or Urban Spoon) and paste it into Mapquest, or search in Mapquest (usually with a little better luck than the built-in Maps app). Bam. Reliable turn-by-turn voice navigation that actually works on my iPhone 4. Pair that with the new Bluetooth stereo I put in my truck, and it works like butter. If it would just do night colors, it would be damn near perfect.

Now, if I lived in a big city, I can understand being upset with the new app. Lacking walking or biking directions and public transit directions seems a curious oversight considering how many of Apple's iPhone customers live in those environments. I can't really understand why Apple would leave that data out unless they simply could not get it, and I hope they address that soon for all the people that do rely on it.

But, for me, the new Maps app sucks just as much as the old one did, and I will not use it just as much as I didn't use the previous one. So, for me, nothing has changed.

Just, more than anything though, I'm disappointed in Apple, for two reasons. One, that they couldn't get this right, and two, that they released it in spite of what they had to know were serious problems with it, all while heralding it as one if iOS 6's killer features. Especially in light of news that they still had a year on their Google maps contract, I would rather they have spent that year fine tuning it rather than release something that clearly wasn't ready for primetime.


Merging M4V files on a Mac ... with chapters!

By · Published · apple, appletv, howto, php, mac, osx

As I've mentioned a couple of times before, one of my projects right now is ripping all the DVDs I own so that I can watch them on my AppleTV (or any AppleTV in the house).

Well, one of the problems I've run into a couple of times is longer movies that are distributed on two discs. This is usually movies like the Lord of the Rings Extended Edition or The Ten Commandments. Really, they're one movie, but are distributed as two separate movies because of the restrictions of physical media.

Well, digital media imposes no such restrictions on us, so why have two separate movies listed on the AppleTV? So after much trial and error, I finally discovered a way to get everything play nicely together. Unfortunately, this is not an easy problem to solve and even involved me writing a small script that could merge chapter files together because every single method I could find would eliminate chapter markers.

So here, in abbreviated form, is the process for merging m4v files together and preserving chapter markers.

Note: This tutorial assumes some level of technical proficiency. This is not a point-and-click process (yet :P) and requires the use of multiple tools and the shell.

Tools you'll need:

  1. Handbrake or whatever tool you're using for ripping your legally obtained DVDs.

  2. MetaX and/or iDentify

  3. Subler

  4. remux

  5. Quicktime, which is now built into Mac OS X.

  6. chaptermerge, a script I wrote that merges chapter files together.

The proces:

  1. Rip both movies from their individual DVDs using Handbrake or whatever other tool you're using. Be sure that you're adding chapter markers.

  2. Load each movie into MetaX and download the chapter names. That's really the only thing you need to add to the file. Save the files with chapter names.

  3. Load each movie into Subler and extract the chapter files. To do this, select the chapter track and select File -> Export.

  4. Now, open the first movie in Quicktime.

  5. Drag the second movie on top of the first one. Quicktime will add the two together.

  6. Save the movie for use on an AppleTV. Get a beer or 6, because this takes awhile.

  7. While the movie is saving, use chaptermerge to merge the chapter files together. See the docs on how it works.

  8. Once the file has finished saving as a Quicktime MOV (it's actually still h.264 inside the file), fire up remux and convert the merged file back into an m4v. Drag the file into remux, set the output to m4v, and save. Should be pretty quick - a matter of minutes.

  9. Load the merged file back into Subler and add the merged chapter track. Drag the chapter file into the Subler window. Save the file.

  10. Load the merged file into a tool such as iDentify or MetaX and add the remaining metadata.

That's it! You now have a merged file with both parts of the movie, accurate chapter markers and full metadata, ready to be copied to iTunes and viewed on your AppleTV.


NBC and the Olympics

By · Published · ramblings, sports

It's always amusing to watch what happens when old media slams head first into a new world.

NBC, the broadcaster holding the rights to Olympic coverage in the United States, seems not to have realized how much the world has changed since Beijing in 2008. Social media is huge now - much more so than it was then - and people routinely have access to a much larger amount of information than we did back then. Whereas most countries saw it, or could at least access it, in realtime, NBC decided to show the Opening Ceremonies on a 3 hour tape delay so they could cash in on the larger primetime audience.

I actually had to turn Twitter off yesterday afternoon because I was already seeing tweets about the Opening Ceremonies from people in other countries and at least one person I know who was actually at the thing.

Now, to their credit, NBC is actually streaming a lot of coverage live on their website and showing highlights for the American audience in primetime. So why not do the same with the Opening Ceremonies? Why not stream it live on the website for those of us who might have wanted to watch it in realtime, then show the tape delayed version later for the larger audience?

Well, someone asked NBC that and this was, no lying, their response:

“They are complex entertainment spectacles that do not translate well online because they require context, which our award-winning production team will provide for the large primetime audiences that gather together to watch them,” the network told the Wall Street Journal.

Right, because we're all bloody mouth-breathing morons who can't figure out what's going on without their precious context.

Is this the same "award winning production team" that didn't know who Tim Berners-Lee was or realize the significance of the computer he was sitting at? Tim Berners-Lee is why I have a job. Tim Berners-Lee is why I'm able to type this right now, and why an economy that generates billions of dollars every year exists. The British thought it important enough to salute him in the Olympic Opening Ceremonies. They didn't even know who he was?

Is this the same "award winning production team" that made cracks about Kim Jong-Il while the North Korean team was walking in the parade of nations? Yes, he was a brutal dictator and his "11 holes in one" story is laughable to say the least. But first of all he's dead now, and second the Olympic Opening ceremonies are not an appropriate time or place to be cracking jokes about other countries'  deceased leaders. I wonder if the BBC called Mitt Romney (who was sitting in the audience) "the American Borat" or made cracks about the French president?

Is this the same "award winning production team" that never mentioned that Kenneth Branaugh was playing the role of Isambard Kingdom Brunel, perhaps the greatest engineer that ever lived?

Here's a clue, NBC: anyone with two brain cells could figure out what was going on, and your "award winning production team" was annoying. Not to mention the advertising EVERY FIVE MINUTES during the parade of nations got really, really old.


A Year With Drobo: My Review of the Drobo FS

By · Published · reviews, drobo, mac, osx

About a year ago, I picked up a Drobo FS. It was something I had been wanting to do for awhile to support my ever growing data needs. In particular, I had three problems I was aiming to solve:

  1. Data security. In addition to the obvious suspects of photos and home movies, I have a lot of old files and documents I've been hanging onto for  years now. Papers I wrote in high school and college, some of the first computer code I wrote, etc. How I've managed to preserve some of this over the years is a miracle in itself - a lot of it was recovered a few years back when I picked up a 3.5" floppy disk drive and started going through boxes of floppies in my attic. But now that I have it all in one central place, I'd like to secure it.

  2. Media library. My wife and I own a lot of DVDs, and they take up a lot of space. They're also not very portable. A while back I started the process of ripping all my DVDs into iTunes so that they could feed to any TV in the house with an AppleTV, essentially creating our own private video on demand system. This was rapidly outpacing the available space.

  3. Central backup location. I wanted a place where all the Macs in the house could backup to via Time Machine.

After doing a great deal of research, I decided on the Drobo FS. In addition to being able to do all of the above, it had some other nice features that I liked:

  • Thin provisioned, meaning you can hot-swap drives in and out while the device is running and not have downtime while it rebuilds the array.

  • Also thanks to thin provisioning, your drives (theoretically, I'll get to this in a bit) don't need to be the same size or from the same manufacturer.

  • Data protection that purports to examine the health of a drive and move data around to give it the best change of preservation.

Now, to be sure, you're trusting a black box. If Drobo fails, there is almost no cheap way to recover that data as they use non-standard, proprietary technology to accomplish all their voodoo magic. Nonetheless, in this case, it was a tradeoff I was willing to make.

So after a year of ownership, how does Drobo stand up in fulfilling these promises? Well, there's a lot of stories here but, overall, it does well with a few caveats I've learned along the way.

When I first ordered the Drobo, at the same time I placed an order for 3 identical Seagate 2TB drives. I got them installed and got the array up and operational, and got all my data from various places moved over to the Drobo. The first thing I noticed while copying data over to the Drobo was that it was slow. Very slow. Transfer speeds to the Drobo across my gigabit network were in the ~10 megabit range. Upping the frame size to jumbo (9000) improved that a little but it was still very slow. Not a deal-breaker, as you're rarely moving that much data around, but it was something I noticed.

Then, the real problems started.

The Drobo would just randomly vanish from Finder. No reason, just one moment it wouldn't be there and you couldn't even connect to it via IP address, although you could still ping it. I opened a support ticket with Data Robotics, who took me through a troubleshooting procedure that involved directly connecting the Drobo to my Mac via Ethernet. Of course it would work fine when we did that, so I figured it was a problem with my network. But even creating the shortest possible path between my iMac and the Drobo yielded the same results.

I opened another ticket, and we went through the same procedure again. This time, however, we let it sit longer. Sure enough, about 30 seconds after it booted and appeared in Finder, it disappeared from Finder and from their Dashboard tool. I was able to SSH to it and see that the filesystem was now mounted in read-only mode. But we were able to get some diagnostic log files off of it. The tech looked them over and said that the drives were failing. And sure enough, the next day, Drobo reported one of the drives had died and that it was moving data around to protect things.

Now, in my entire life, I've had 2 hard drive failures, with one occurring just a couple years ago. So I popped online and ordered another drive (this time, a Western Digital Enterprise 2TB drive). Popped it in the Drobo and it seemed happy, although still slow and occasionally vanishing from finder. Then, about a month later, I'm out working in the yard and boom, get an email on my iPhone about a second drive failure in the Drobo. So I order another Western Digital 2TB drive and put it in. The whole time, by the way, Drobo remains on and accessible. Pretty cool actually. And replacing a drive is pretty easy - you just pop the old one out and put the new one in, without even shutting down. Drobo then goes into a "protection" mode where it shuffles data around onto the new drive.

But, with 2 of the 3 Seagate drives I bought failing within 6 months, I decided it probably wasn't wise to continue to trust that last one since it was probably from the same batch. So I replaced that one as well. That was about seven months ago, which brings us to today.

Between the better drives and several firmware and software upgrades from Data Robotics in the interim, Drobo is now virtually rock solid and (knock on wood) I haven't had any further problems. It no longer randomly disappears from Finder or the Drobo Dashboard and, in a very Apple way, it just works. And I also want to say that, throughout the troubleshooting process, the Data Robotics guys were great to work with and wanted to see the problem solved.

So overall, after a year and some growing pains, I'm pretty happy with it and wouldn't hesitate to recommend the Drobo FS with the following caveats:

  1. Use quality drives. Don't buy the cheap drives and definitely avoid Seagate drives as the Drobo seems to hate those. When I upgraded to the WD drives, I bought the server-level Enterprise drives. Those have been rock solid. My guess is that Drobo is pretty hard on drives, with lots of reads, writes and seeks.

  2. Use the same size and manufacturer. Now, one of Drobo's big selling points is that you can use different size drives and all that. This is one of those cases where what you can do and what you should do are two different things. You can use any size and manufacturer, but I've had better success and performance when all my drives are from the same manufacturer and are the same size.

  3. Be sure your firmware and software are up to date.  Kinda goes without saying, but the firmware upgrades for the Drobo have really helped with it's stability.

  4. If you start having problems with your Drobo like I had above, get ready for a drive failure.


Restoring a Mac from a Time Machine backup on a Drobo (or other network storage)

By · Published · apple, drobo, mac, osx

Been having some problems with my iMac upstairs. I'm pretty sure the hard drive is failing (again), although hopefully it's just bad sectors. But, with hard drive prices currently still in the stratosphere, I decided to try one more last trick to see if I can save myself some money. That is, the old Windows trick: fdisk, format, reinstall. Or, well, the Mac Equivalent - Disk Utility, reinstall.

About a year ago, a bought a Drobo. I've been meaning to write a review of the Drobo and maybe now I will (the short of it is, I had some growing pains with it, but now that I've figured out its quirks, it seems to work well). One of the reasons I bought the Drobo as to use a shared Time Machine backup store for all the Macs in the house.

So, I thought, in addition to trying to save my Mac, now would be a great time to test my fancy Time Machine backup system. And, unfortunately, since Time Machine really isn't meant to work with unsupported network volumes, it does require some gymnastics to get it to work. Even worse, it isn't a very well documented procedure. But, ultimately, I was able to figure it out; I'll post what I did hoping that maybe it will save someone some time and headache.

  1. First step is to format and reinstall as you normally would. If you are on/installing Lion, you may be presented with an option to reinstall from a backup as part of the install process. Don't do this. Reinstall Lion as if you were performing a fresh install.

  2. When the installation is complete and you get to the Lion post-install setup screens, you will (eventually) reach a screen asking you to create a user account. Create your original user account (same username) as in your backup.

  3. Once you're out of setup, go to System Preferences, then Users. Create a new administrative level user (I called mine "foo"). Be sure this is an admin-level user.

  4. Log out and log into the account you just created.

  5. Turn on unsupported Time Machine volumes. Open up a Terminal window and enter:

defaults write com.apple.systempreferences TMShowUnsupportedNetworkVolumes 1
  1. Now, open up a finder window and navigate to your Drobo or other device and to whatever network share you have your Time Machine backups stored on. Mount it.

  2. Now, inside the share, mount the .sparsebundle that is your restore image (it should be the machine name). If you open it, you should be able to see a folder called "Backups.backupdb" in it.

  3. Next, fire up the Migration Assistant.

  4. Select "From another Mac, PC, Time Machine backup, or other disk." Hit continue.

  5. Select "From a Time Machine backup or other disk." Hit continue.

  6. It may take a second, but, eventually, you should see a drive image and the name of your old hard drive (usually "Macintosh HD") appear. Click continue.

  7. It may take awhile for it to parse the image. My backup image was about 350gb, and it took about 20 minutes to parse out all the information. Select what you do or don't want and click continue.

  8. You should be presented with a dialog stating that a username on the system is the same as one in the backup. Select "Replace..." Click continue.

  9. Wait. It will take awhile. It took about 5 hours for me to do a complete restore from a backup on the Drobo to my iMac.

And that's it. Once it finished and you reboot, your Mac should be just as it was during the last backup.


Mac Developers: Clean Up Your Output!

By · Published · apple, objective-c, xcode

Over the weekend, I was having some hard drive issues. While I think I fixed the issues, I've been keeping a close eye on my console (Console.app) to look for any hints that the issues are more major than those that can be repaired by Disk Utility.

However, while watching my console, I noticed something: there are a LOT of spammy Mac apps out there!

Most Mac/Objective-C developers are aware of the NSLog() function, which, while in an Xcode environment, outputs data to the Xcode console. It's usually one of the first things a new developer learns about and it's very useful for debugging. What many developers may not realize is that NSLog() continues to output data to the system logs even when the app is not being run from within Xcode. As a result, the console fills up with messages that don't mean a whole lot to people looking at the console.

Now, I don't want to come across as saying you should never use NSLog() outside of Xcode. There are times when outputting debug data to the console is fine. But some of the things I see are people echoing objects into the log or short text strings that are obviously method names. These aren't helpful to people looking at the console and, arguably, aren't helpful to a developer once an app is in the wild. Once your app is in the wild, data in the logs should indicate error conditions in your app.

NSLog() is fine for debugging in Xcode, but you should be careful to remove them when you're done. A good question I ask myself before leaving an NSLog() in place is, "if a user filed a support request with this data, would it help me fix their problem?" Most of the time, the answer is no.

So before releasing an app, do a quick search in your project for all uses of NSLog() and evaluate whether they are really needed.


Don't be a PHP / JavaScript / Java / Ruby developer - Be a Software Developer

By · Published · ramblings, business

Among the many sites I follow for programming discussion is /r/PHP on reddit. While most of the discussion is more user-based than I would like - things like frameworks, use of PHP-based software packages and the like are usually discussed more often than actual programming - there are occasionally a few gems worth chiming in on. But it never fails that, at least once a week, I see the headline "How do I become a PHP developer," or "What do I need to know to be a PHP developer?"

My answer is simple: don't. Just stop.

Don't be a "PHP Developer." Don't be a "Java Developer." Don't be a "Ruby Developer." In fact, don't be any kind of developer that depends solely on a single language.

Languages come and go. Ten years ago I would bet the majority of web programming was still done in Perl. Fifteen years ago the web was still widely misunderstood and Java was promising that we would only have to write code once to run on any computer. Twenty years ago you found C, FORTRAN and COBOL on mainframes.

Every few years a new language comes around and everybody moves to it. Sometimes they stay around, and sometimes they don't. C has been around for many years and is just as valid now as it was twenty years ago. Even if you're programming in C++ or Objective-C (both of whose roots go back further than you probably realize), you still need to understand the fundamentals of the C language. Will we still be using Clojure in 20 years? How about Coffeescript? Who knows. Maybe. Maybe not.

My point is, don't chain yourself to a single language. If you do that, you will be forever behind the curve.

A good developer should be able to work independent of his/her tools, should be always willing to learn new and exciting things, and should be able to apply lessons learned in past development independent of the language they are working in. A good developer should be able to come up to speed quickly on a new language. And while it is true that every developer will probably always have a preferred language and a language they're best at, we as developers should always place the craft of software development ahead of specialization in a single language, and we should be willing to use the best tool for the job independent of our linguistic preferences.

While PHP is my primary language (and what pays the bills), I am not a PHP developer. I am a software developer who works in PHP among many other languages. It should always be the goal of every developer to remain at the forefront of our craft. That means not chaining ourselves to PHP, Ruby, JavaScript, Java, Scala, Python, or any other language.


Disabling Text Zoom in Netbeans

By · Published · apple, ramblings

A couple of days ago, I upgraded to the most recent version of Netbeans - 7.1.1. I had been running a 7.1-DEV nightly from back in 2011 and just hadn't bothered to upgrade yet. The first thing I noticed is that this version of Netbeans introduced a "feature" that allows you to zoom in or out of text. This is accomplished by, on the Mac, holding down the Command key and scrolling on the trackpad.

The problem with this is that it is very easy to trigger accidentally - to the point where I was doing it multiple times a day. Even more irritating, there was no indication as to what the zoom level was or easy way to revert to normal view. If you trigger it accidentally, you just have to kinda zoom back out until you find a setting somewhat similar to the rest of your tabs.

Fortunately, someone on the nbusers mailing list mentioned how to solve this problem, so I want to post it here in case anyone else gets as lost and frustrated as I was.

  1. Open the preferences page. On the Mac, you would go Netbeans Menu -> Preferences.

  2. Go to Keymaps.

  3. Search for "zoom".

  4. Remove the bindings for "Zoom Text In" and "Zoom Text Out." Double click on the Shortcut and hit backspace twice.


New Personal Blog

By · Published ·

While this blog will still have my occasional musings about life in dot-com and software development, there's a lot of other stuff I'd like to talk about that really doesn't fit under that label. Carpentry? Home improvement? Relationships? I need a place to put a lot of that stuff. Well, me and my wife will be (re-)launching a new blog documenting our life. So if you're interested in us at a more personal level, feel free to check out the new blog.

www.robandsarah.org