Music Question: Apple or Amazon?
I’m in. By in, I mean I have the MacBook Pro (it’s got Unix!), the iPad, the iPod, the iPhone, and the MacMini Server. For documents I still use Microsoft Office like the majority of the rest of the world, but for personal documents increasingly I’m using iWork because of some of nifty features, like autosaving and iCloud.
So, now I want to buy P!nk’s Greatest Hits…So Far!!!. Usually, I purchase my music at Amazon’s MP3 store, or, if I’m really feeling nostalgic, Second Spin; but iCloud presents me with a new opportunity: the idea that if I just buy my music with iTunes I will have access to it wherever I am.
My first concern is space. You see, I’ve ripped about half of my CDs so far and I’m taking up 22GB of space on my iPod with music. As time goes on, I’ll probably reach 45GB in CD music alone. I’m in no danger of hitting my upper limit today, or next year even. My iOS devices (iPod, iPhone, iPad) all have 64 GB of space. I don’t put music on the iPad, preferring to use that device for movies and books, so the space taken up by the different forms of media shouldn’t interfere with one another.
I don’t have a lot of music with iTunes. I bought one album because it was only available there. If I continue to buy MP3s via Amazon, then I will continue to take up more and more space on my iOS devices.
I’m not sure where Moore’s Law will taper off in terms of more and more storage being available in these consumer devices. I doubt this trend will continue for consumer devices because more and more people are moving their storage to the cloud. My theory is that this will lead to fewer folks buying hard drives (whether they be magnetic or flash, it doesn’t matter), thus driving the demand down and the price back up again. With the price up, Apple (or Amazon, or Samsung, or whoever makes your portable music device) will not put as much storage into your portable device. This means that I will hit an upper limit on how many MP3s I can put onto my iOS device in the future. Apple wants me to use iCloud instead, because they see this future coming. More importantly, they are helping that future come.
So, the question is, do I continue to use Amazon’s MP3 store and manually move songs onto and off of my iOS device in the future, or do I just bite the bullet now and move to iTunes altogether? iTunes has the largest collection of music out there and I can always store a few MP3s for those artists and labels that I have to buy on Amazon.
Then there is an issue with preservation. The music on iTunes is (as most of you know) not stored in the MP3 format, but AAC (with various file extensions). As of 2009, it is supposedly DRM free. I opened one of my iTunes songs in VLC player, and it played fine, without asking me for a password like the DRM-full songs do. If this is the case, and AAC players are available in the future, then my concerns about preservation may be unfounded, as I will always be able to play the songs I’ve purchased.
iTunes is big, and with that many customers, I wouldn’t be surprised if AAC stayed around for a long time, so there should be no issue with finding an AAC player if iTunes goes away.
To recap:
| Amazon MP3 Store | Apple’s iTunes | |
| storage space issues | will require more and more storage on my iOS devices | handled by iCloud |
| preservation capability | MP3s are playable on many, many devices | AACs are no longer encumbered by DRM and are playable by a lot of open source software, meaning conversions are possible |
So, there really is no reason I can’t just jump on the iTunes bandwagon and enjoy the benefits of iCloud.
Using launchd to run scheduled jobs
My new server’s predecessor ran Linux. I had a few scheduled jobs, like the ones that back up this blog, its database, and so on. On Linux the tool used for scheduling jobs is cron. Lo and behold, Apple has deprecated cron on their systems in lieu of an Apple-grown tool named launched. Launchd’s job is to replace cron, init, the rc scripts, the file alteration monitor, and a whole host of other normal Unix utilities in favor of one huge behemoth process that starts at boot. I’ve got mixed feelings about this concept, as it goes against the Unix philosophy of “doing one thing and doing it well”, but I chose OSX and have tried to learn their way of doing things.
I found several articles describing how one creates the plist files used by launchd. These XML files contain the information on the process you wish to run, including when to run it, how to run it, and who is allowed to run it. Here I will detail how I used it to merely run a scheduled job every night at midnight.
To start with, I have a simple script that backs up the database on the server:
#!/bin/sh BACKUPDIR=$HOME/Backups/lawrence.littleprojects.org/db REMHOST=lawrence.littleprojects.org OUTPUTFILE=$REMHOST.sql # if we don't have a backup directory, make it if [ ! -e $BACKUPDIR ]; then mkdir -p $BACKUPDIR fi cd $BACKUPDIR # run the remote database dump command ssh $REMHOST "mysqldump --verbose --user=root --password='XXXXXXXXXXXX' --all-databases" > $OUTPUTFILE # if the zipped output file already exists, move it before zipping the new one if [ -f $OUTPUTFILE.bz2 ]; then mv $OUTPUTFILE.bz2 old-$OUTPUTFILE.bz2 fi bzip2 $OUTPUTFILE chown smj:staff $OUTPUTFILE.bz2
This script is creatively entitled backup-database. I want it to run every night so I have an exact copy of this website’s database in case the web server goes down and I have to reinstall everything.
Under cron, I would run crontab -e and then put the following line into the editor that is brought up:
0 * * * * $HOME/bin/backup-database
Apple made this simple step a lot more complicated than, in my opinion, it needed to be; but they gave me a tool that is a lot more powerful that mere cron.
To use launchd, I needed to make a file in the directory /Library/LaunchDaemons named org.littleprojects.backup.lawrence.db.plist that contains the following XML code:
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>Label</key> <string>org.littleprojects.backup.lawrence.db</string> <key>ProgramArguments</key> <array> <string>/Users/smj/bin/backup-database</string> </array> <key>StartCalendarInterval</key> <dict> <key>Hour</key> <integer>0</integer> <key>Minute</key> <integer>0</integer> </dict> </dict> </plist>
I’m a little annoyed at how Apple handled the whole key-value syntax, but I’ll let that be. The file reads as follows: create a job named org.littleprojects.backup.lawrence.db that will run the program /Users/smj/bin/backup-database at the 0th hour and 0th minute of ever day (midnight). I’m not sure if this is any less difficult to read than the cron syntax, but it is more difficult to write to be sure.
Once I created the file, I then needed to load it into launchd, which could be done by running the following commands:
sudo launchctl load org.littleprojects.backup.lawrence.db.plistIf you do this you, do not need to reboot as others claim. This is Unix and reboots should only be necessary for major operating system changes. Rebooting in order to create a scheduled job is not only ridiculous, but time-wasting and leads to error-prone behavior like making many untested scheduled jobs at once in order to save on reboots. I always try to find a way around reboots to avoid error-prone behaviors!
So, I did the same thing for other scripts I wanted to run at certain times. I understand why apple decided to use launchd, I just wish they would have made it easier to configure. Lingon exists in the app store for the express purpose of helping you create these plist XML files, but it will not load them for you and instead recommends you reboot after each edit, which I noted my distaste for above.
In the future I will be exploring how to best use launchd for other purposes, like restarting services, and scheduling scripts to run when other system events occur.
References:
- http://macdevcenter.com/pub/a/mac/2005/11/15/terminal5.html?page=5
- http://www.activecollab.com/forums/topic/4342/
- http://developer.apple.com/library/mac/#documentation/Darwin/Reference/ManPages/man5/launchd.conf.5.html
- http://developer.apple.com/library/mac/#documentation/Darwin/Reference/ManPages/man5/launchd.plist.5.html
- http://developer.apple.com/library/mac/#documentation/Darwin/Reference/ManPages/man8/launchd.8.html
- http://developer.apple.com/library/mac/#documentation/Darwin/Reference/ManPages/man1/launchctl.1.html
Randomly crashing Mac Mini Server running Lion [Solution]
I’d been looking for a home server solution that offered me more disk space, but that ran cool and quieter than my server-closet behemoth. I wanted the server to also be able to execute scripts and scheduled jobs. I researched several options, including the Dell Zino, but none seemed to capture my attention like the Mac Mini Server.
The day it arrived, I set it up and spent hours pouring over Apple’s documentation. I got file sharing, SSH, WebDAV, and other services set up easily, but realized that I had to download Server Admin Tools separately in order to get access to DHCP and DNS. Some admins speculate that this is a separate download to prevent would be admins from accidentally turning on DHCP in a network that already had it. Screen sharing worked flawlessly. I had it using my 46″ television as a monitor, so watching online video and iTunes was awesome!
The next day I went back to my new toy, and… it had locked up. I was not pleased. Murmuring curses and threats of sending the server back didn’t bring the server back from its limbo. This was UNIX! UNIX was not supposed to do this! I felt betrayed by a company I’ve been growing in support for. Why did they do this to me?
I think I’ve solved the problem. Nothing useful was in the logs, but I came across a forum post where someone had suggested that there were bugs [1][2] in Lion’s display drivers that caused some Macs to lock up when returning from sleep.
I went into System Preferences, then chose Energy Saver. I slid the slider next to Display Sleep all the way to the right, choosing Never. I have not had a lockup since.
I can’t recommend this for everyone, because they don’t have a display that is either off, or using another input, like my TV, but it might work in a pinch if you don’t mind manually turning your display off. Also, I’m a little surprised that it’s affecting my brand new Mac Mini Server, because the articles I’ve found refer to older Macs.
Update: This may have been fixed by the 10.7.1 patch. I haven’t tested it yet.
Review: Safari 2 Go (for iPad)
A friend excitedly told me about Safari 2 Go (S2G) for iPad. Having an interest in the technical books Safari offers, I chose to try and download a book right then and there, on 3G. S2G refuses to let you log in at all, unless you have wifi.
Later, on my wifi network, I started the download of a book. It took 10 minutes. I’ve noticed that books in the Amazon Kindle app and iBooks generally take about 5 minutes to download, over 3G. I was quite disappointed with the Safari download speed.
Also, the first attempt was unsuccessful, for the iPad’s desire to sleep during inactivity had forced me to “babysit” the iPad, occasionally touching it to ensure that S2G didn’t terminate the download. Other iPad apps are able to override this inactivity setting so they can finish their downloads without issue, even finishing the download while the user is running other apps (you know, that whole multitasking thing that’s sweeping the nation).
Once I did get the book to download, the resulting product wasn’t fully available.
Some of the pages in the resulting book vanish when you try to read them. They’re quite the tease. It might be related to a watermark that vanishes after a picture is loaded. If you do a quick print screen you might be able to capture the missing page.
All in all, it’s not a pleasant experience.
The Safari web site works fine, but I was looking forward to the offline storage for when I didn’t have or want to use an internet connection.
At the moment S2G sucks. What the hell were they thinking releasing it like this?
Update (2011/06/08): The updates haven’t helped, crashing often and appearing to fix none of these issues. In fact, the latest version doesn’t even load, presenting the user with a black screen and no functionality.
Rebirth of a web site
I just spent time giving birth to an Old Dominion University Computer Science web site at http://www.cs.odu.edu/~sjone. It’s just one page now, with some course information, and some links back to this site. I know, not very interesting. Under the covers, though, is a testbed for the Semantic Web. So far, I’ve got Dublin Core and Friend of a Friend (FOAF) implemented for that one page. In the future, I intend to bring the lessons learned there over to this site. Eventually, the two will begin to look more alike in both style and function.
Perhaps Web Science and Digital Libraries is really my thing. I spend an awful lot of time blogging about my own web sites.
Validation of the Creative Commons Markup
I also discovered that the Creative Commons license markup wouldn’t validate with the W3C validator. This was because my page was initially specified as XHTML, but the Creative Commons license link contains additional RDF metadata used by search engines and other software. A blog post suggested just removing the metadata, but I didn’t want to do that because I knew that metadata had been placed there by Creative Commons for a reason. That metadata is part of the RDFa standard, which is a way of embedding metadata into normal HTML and XHMTL.
It turns out that once you put that Creative Commons markup into your XHTML, it becomes XHTML + RDFa, which is a completely different document type. I felt good that I’d figured this out, and changed the page to use this instead.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML+RDFa 1.0//EN" "http://www.w3.org/MarkUp/DTD/xhtml-rdfa-1.dtd">
Now it validates fine as XHTML + RDFa.
Nifty floating image trick
You may wonder how I got the image to stay on the left and in the same spot, even though the visitor can scroll the page. It is based on the following CSS, shamelessly stolen from the W3C themselves.
body { background-image: url(http://www.cs.odu.edu/~sjone/images/oducs-lpx.png); background-repeat: no-repeat; background-position: top left; background-attachment: fixed; /* more CSS here */ }
That’s it. It’s quite elegant, and I spent more time making the image with Inkscape than I did actually writing the CSS to tell it to stay put.
Useful Links
I discovered the following useful sources for bringing that site to life:
- FOAF Vocabulary Specification
- W3Schools CSS Tutorial
- Learn CSS Positioning in Ten Steps
- RDFa Primer
- RDFa in XHTML: Syntax and Processing
- The W3C CSS Validation Service
- W3Schools HTML 4.01/XHTML 1.0 Reference
- The W3C Markup Validation Service
- Expressing Dublin Core in HTML/XHTML meta and link elements

