Archive for July, 2009

APN on Rails 0.3.0 Released

Friday, July 31st, 2009

The latest version of Apple Push Notifications on Rails (APN on Rails) has been released. This release brings a few bug fixes, a new migration, and Feedback processing.

Installing/upgrading is easy:

$ sudo gem install apn_on_rails
$ ruby script/generate apn_migrations
$ rake db:migrate

It’s important to always run the migrations generator after each update to get the latest database schema needed for the the gem.

To use the new Feedback integration you have to first make sure that you update the new last_registered_at column when your iPhone application calls home. This column is checked against the timestamp Apple returns with the device token. If the last_registered_at is older than Apple’s date then the device is deleted, otherwise the Feedback is ignored.

To get and process the list of devices from Apple’s Feedback service just run the following Rake task:

$ rake apn:feedback:process

Enjoy!

Almost There… Book Wise.

Monday, July 27th, 2009

I’m now entering the home stretch of writing the Distributed Programming with Ruby book. I’m just a few weeks away, well, technically I’m hours away from finishing the last chapter (Delayed Job) in the official table of contents, however, I’m going to add another chapter and a half. Why? Mostly because I’m a glutton for punishment. That and I want to deliver the best book possible. The extra chapter and a half, not featured in the table of contents below, will be on MapReduce technologies. It’s a really hot topic, and I think it will fit well in the book. What do you think?

Unfortunately, the “Rough Cuts” book on O’Reilly’s Safari site hasn’t been updated in nearly 3 months! I’m not sure why. I keep asking my editor to update it, but it hasn’t happened yet. I’m sure it will soon, especially since the first draft of the entire manuscript will be done in just a few weeks!

UPDATE: Today they updated the “Rough Cuts” with nearly the latest revisions. It’s still missing the chapters on Delayed Job and BackgrounDRb, but it’s closer than it was yesterday.

Anyway, as a public service announcement to you, the readers, I thought I would the table of contents as it stands right now, so you have a better idea of what the book is going to be about. So here it goes:

What do you think? Does it look good? Is this something you’d buy? Let me know. This is your chance to have an influence on a book. If you think something is missing or should be laid out differently, please let me know, it might just make it into the final product.

Ok, enough delaying here, let me get back to writing so I can finish up the Delayed Job chapter.

Apple Push Notifications on Rails

Friday, July 24th, 2009

The other night I submitted a new iPhone application to the Apple Store. The app, which I’ll speak about when, and if it gets approved, uses the new Apple Push Notification service available in iPhone OS 3.0. On the server side I have a Rails application that I am using to send the notifications to Apple. The problem I ran into was how.

Enter the APN on Rails gem. While searching I found one plugin for Rails that mostly worked for me, Sam Soffes’ apple_push_notification plugin. It was a great place to start, but I found that there were things that didn’t suite me. For starters, not having any tests is always a big turn off for me when it comes to any code. I also didn’t like that you didn’t need to save a notification in order to send it. That means you don’t have a record of what was sent and when. I also wanted to have devices stored separately from the notification. Finally, I wanted to be able to easily configure the plugin. Sam’s was using constants that would need to be changed when it hit production.

So, with all that said and done I took Sam’s great work, ripped it apart, and put it back together again, this time in gem form instead of a plugin, and here it is.

There are a few migrations, a few models, and a few Rake tasks, but here is the basic idea of how it works:

To get a better understanding of exactly how it works, and what it does, I highly recommend reading the RDOC.

There are a few things I still would like to add, for example, a controller to do CRUD for devices so iPhones can register with the Rails app. I’d also like to add a task that talks to Apple and finds out which devices are no longer accepting messages so they can be removed.

If you’d like to contribute, please feel free and for the project on GitHub:
http://github.com/markbates/apn_on_rails/tree

Again, a special thanks to Fabien Penso and Sam Soffes for their initial work on this project.

Becoming a Recording, sorry I meant Software, Engineer

Sunday, July 12th, 2009

Recently I was sent a survey from the college I attended, the Liverpool Institute for the Performing Arts. In the survey I was asked a question about what I’ve done in the field of music, that’s what my degree is in, since I’ve graduated. I typed up a rather long winded answer to the question and afterwards I thought it was actually thought it was an interesting commentary on the recording industry. It also shows the path a guy like me takes from being a musician to being a software engineer.

Anyway, I thought I would share this little story with you all. I hope you enjoy it.

About 3 – 4 after graduating I found myself unemployed and decided that I would take that opportunity and try to pursue a career as a recording engineer. I spent two years struggling and working very hard at one of the best studios around and I found that things were just not working out.

I don’t necessarily think it was a problem of my not having the skills needed for the job, but rather it had to do with several other factors. One, because of the state of the recording industry ‘proper’ studios are/were struggling to find work because more and more musicians are doing recording at home on their computers. While their results might not be as ‘high quality’ as those of the studios, the musicians are/were finding that it was good enough to help land them gigs in town.

Because the studio was struggling, and I was the lowest guy on the totem pole, because I was the ‘newest’, I found that I was only getting a few sessions each month, that compared with the ‘top’ engineers who were only getting a week or two worth of work each month.

It was at this point that I sat down and re-evaluated what I wanted most in life. I decided that was really important to me was to have a family and be happy with what I was doing, and to just generally enjoy my life. Realizing that, I had to decide if my current situation was really going to work for me. While I thoroughly enjoyed being a recording engineer, when I got to do it that is, I found the pay ($90 a day – awful!), the hours (usually 12-14 hours), and the lack of sessions to not be a viable way to raise a family.

Once I decided that being a recording engineer wasn’t going to work for me, I needed to find something that would. I thought long and hard about this, as well, and realized that I really enjoyed being a software engineer. It is strangely creative, the pay is very good, and I was damn good at it.