Categories
Uncategorized

Thanks, John

A wonderful bouquet of flowers.

John Siracusa: Right now, I’m looking forward to my first summer in many years that won’t be dominated by stolen daytime minutes and long, sleepless nights in front of a screen with a noisy air conditioner blowing behind me. I’m content to have reviewed 10.0 through 10.10. Someone else can pick up the baton for the next 15 years.”

Here’s to the next 15 years, may they be fruitful.

Categories
Life Movies

Rob’s 2015 Summer Blockbuster Must See List

Man, this kind of snuck up on me. Time to put together my Summer Movie Must See List.

Avengers: Age of Ultron May 1
Maggie May 8
Mad Max: Fury Road May 15
Tomorrowland May 22
Poltergeist May 22
San Andreas May 29
The Stranger June 12
Jurassic World June 12
Big Game June 26
Terminator Genisys July 1
Minions July 10
Ant-Man July 17
Dark Was the Night July 24
Southpaw July 31
Mission: Impossible Rogue Nation July 31
Fantastic Four August 7
Pan August 27

Unlike last years list, this one is short. The mini list for me includes: Avengers: Age of Ultron, Maggie, Mad Max: Fury Road, Jurassic World, Terminator Genisys, Southpaw, Pan.

Prior years 2014, 2013, 2012, 2011, 2010 and 2009.

UPDATED 05/15/2015: Added The Stranger.
UPDATED 05/18/2015: Added Dark Was the Night.

Categories
Development iOS Mac

Swift, REST, and JSON

I’m fond of a site called The Pastry Box Project. It’s a collection of thoughts and stories by a bunch of great writers, but that’s not why I mention it. I mention it because I noticed they had a nice, simple, REST API. Nifty!

PastryKit

Since I really enjoy writing code that communicates with services, and I needed a little project to learn some Swift, I thought I’d write a couple classes, I call PastryKit, that implement the Pastry Box REST API in Swift.

PastryKit is just two classes:

  1. PastryKit – Allows you to communicate with the Pastry Box REST API.
  2. Pastry – This is an entry returned by a call to PastryKit.

You can read more about The Pastry Box API on their site.

private func showPastryBaker() {
     var pastryKit = PastryKit();
     pastryKit.thoughtsByBaker("mike-monteiro", completionHandler:{(pasteries, error) in
          if (nil != error) { println(error) }
          if (nil != pasteries) { println(pasteries) }
     });
}

The Heavy Lifting

Most of the “heavy lifting” is performed in one place in PastryKit.swift in the private getWithIngredient function. It makes use of NSURLSession, which was introduced in iOS 7. Go find that function if you’d like to see how to do an HTTP GET in Swift. This is a simple case, it doesn’t require any authentication, or messing around with headers, and it only does GET’s. Doing a POST, PATCH or DELETE would, of course, require some changes, but you get the idea.

    /// getWithIngredient - worker method that does all gets
    private func getWithIngredient(ingredient: String?, completionHandler: (([Pastry]!, NSError!) -> Void)?) {
        let url = ((ingredient) != nil) ? NSURL(string: PastryBoxUrl + ingredient!) : NSURL(string: PastryBoxUrl)
        let request = NSURLRequest(URL: url!)
        let configuration = NSURLSessionConfiguration.defaultSessionConfiguration()
        let session = NSURLSession(configuration: configuration, delegate: self, delegateQueue: nil)
        let task : NSURLSessionDataTask = session.dataTaskWithRequest(request, completionHandler:{(data, response, error) in
            if (error == nil) {
                var conversionError: NSError?
                var ingredientsArray: NSArray = NSJSONSerialization.JSONObjectWithData(data, options:NSJSONReadingOptions.AllowFragments, error:&conversionError) as NSArray
                if (conversionError == nil) {
                    var pasteries = Pastry.pastryArrayFromNSArray(ingredientsArray)
                    if (completionHandler != nil) {
                        completionHandler!(pasteries, nil)
                    }
                }
                else {
                    println(conversionError)
                    if (completionHandler != nil) {
                        completionHandler!(nil, conversionError)
                    }
                }
            }
            else {
                println(error)
                if (completionHandler != nil) {
                    completionHandler!(nil, error)
                }
            }
        });
        
        task.resume()
    }

Go Get It!

The code is available on GitHub if you have need to get stuff from The Pastry Box Project in your Swift or Objective-C app.

Enjoy!

Categories
Life

That’s Life

Medium [“Broken Men And Their Broken System” by Chris Kluwe]: “But why, if the powers that be know that every player is going to transition out of the league at some point; if they know that the odds are against those players, and that almost all of them will end up a tragedy instead of a triumph; why, then, haven’t these multibillion-dollar leagues created and promoted universal support systems to help all players transition from their old lives to their new ones? Why is there no required series of steps upon exiting the game?”

While I was reading this article I caught myself shaking my head, thinking shame on the NFL. Then I caught myself. No doubt the NFL should do something more to teach these guys how to prepare for retirement, but the rest of us Everyday Joe’s have to deal with this too. Nobody takes us through a program designed to prepare us for our eventual retirement. I can’t imagine how tough it must be like to earn millions of dollars over the span of a few years. I wish I had that opportunity. Maybe it’s good to struggle your entire life, then you don’t end up having to deal with this problem.

As for my retirement plans? Easy, it will be a pine box.