Friday, August 30, 2013

Books I've Read This Week

It's an all graphic novel catch up week. Back with sci-fi and fantasy books next week.

Mind The Gap Volume 2: Wish You Were Here story by Jim McCann and art by Rodin Esquejo is the continuation of the "murder mystery" from volume one. Unlike some other books or shows in this volume we start to get answers from all of the questions that were originally raised. But like any good story the answers just open up some new questions. This is just a great series and more people should be buying it.

Batwoman Vol. 2: To Drown the World is a book I was apprehensive about buying. I've really loved JH Williams III art but in this volume he's not contributing to the art duties. Instead we get Amy Reeder (who I love) for a short period of time before she left the book under the ominous creative differences label. Then Trevor McCarthy picks up the rest of the issues. The art is good but not as amazing as when JHW3 handles the layouts.

The story is a confusing mess. JHW3 and Haden Blackman you are not Alan Moore so while I applaud your attempt at telling a cohesive narrative from six different point of view characters while jumping back and forth the timeline I can't really say you did a good job as the whole thing is confusing as hell.

Apparently the next volume is set to guest star Wonder Woman and supposedly it is better but I'm not sure I'll shell out the bucks to pick it up in hard cover.

Saga Volume 2 story by Bryan K Vaughn and art by Fiona Staples. Okay, here's my elevator pitch, Romeo and Juliet in Space! Wait you need more details, okay then. In volume 2 of this space epic we get more background on how Marko and Alana fell in love and decided to run away from the conflict between their two species. We also get more Price Robot IV, more Izabel the ghost baby sitter, more The Will, more Slave Girl, and the repercussions of Marko's parents visit. Plus, Marko's ex Gwendolyn gets involved.

Oh and more of the break out star, Lying Cat...


Best. Cat. Ever.

This is really some great writing and phenomenal art make this book a standout. One of the best things about it is Staples really lets her imagination go wild when drawing the aliens. Think the Star Wars Mos Eisley cantina scene amped up to 11.

Sweet Tooth Vol. 6: Wild Game by Jeff Lemire who is everywhere in DC right now. You could make a case that he is there second most important writer next to Geoff Johns, but I digress. The final volume of Sweet Tooth has our band of humans and hybrids travelling north to Alaska in order to find out where Sweet Tooth originally came from, the initial cause of the disease and maybe even a cure?

Lemire is on fire here tugging out our heart strings and eliciting a strong emotional response as we see the ultimate fates of characters we've been following for years. I strongly recommend this whole series to anyone. 

Friday, August 23, 2013

Books I've Read This Week

The Blade Itself, Before They are Hanged and Last Argument Of Kings are all part of the First Law trilogy by Joe Abercrombie. Previously I'd read a couple of stand along novels set in the same universe but I finally had a chance to jump into this trilogy and I was not disappointed.

This is a fantastic grim and gritty fantasy series. There are a lot of memorable characters in these books including a couple of my favourites the northern beserker Logan Ninefingers and Inquisitor Glotka. None of the characters that you encounter in these novels are purely altruistic or purely evil.

The first book starts off with the Magus Bayaz putting together a group of adventurers to go off on a quest including Logan Ninefingers, the vain fencer Jezal dan Luthar among others. While this sounds like a typical fantasy setup Abercrombie eschews the normal traps of epic fantasy.

The three books are a long read but well worth it especially if you like you fantasy novels to be more like George R R Martin instead of J R R Tolkien.

Sunday, August 18, 2013

Books I've Read This Week

The Ocean At The End Of The Lane has been described as one of Neil Gaiman's most accessible books to readers new to the fantasy genre. In this story we follow a middle age man who returns home to attend a funeral and finds himself drawn to the farm at the end of the lane. Once there he unlocks memories he hasn't thought of for forty years. Memories where he and a childhood friend stumbled onto something otherworldly.

It's got a creepy faerie tale vibe, combined with the exploration of youthful memories. It is really worth the read even if it is only a short book weighing in under 200 pages.
One Click: Jeff Bezos and the Rise of Amazon.com by Richard Brandt was a quick read as well. Even though the book was published in 2011 it tends to focus on the earliest years of Amazon. I can't honestly recommend this book as it doesn't tell me anything about Amazon I didn't already hear about from other sources.

Friday, August 9, 2013

Books I've Read This Week

Effective JavaScript: 68 Specific Ways to Harness the Power of JavaScript by David Herman is an excellent book on JavaScript. Chapter 7 on Concurrency is worth the price of the book alone. It is a great way to extend your mastery of JavaScript.
For the Win by Cory Doctorow is a pretty cool book where "gold farmers" across the world try to unionize in order to get fair wages. The gold farmers in India, China, etc. use the internet to get organized and are opposed by not only their local bosses but also the big companies that run the games and are responsible for the game economics. Honestly, the information about how these large economies are run is some of the most interesting stuff in the book.

Friday, August 2, 2013

Books I've Read this Week

Whoops, haven't done one of these in awhile but that doesn't mean I haven't been reading.

Ted Chiang doesn't often write but when he does it's usually a masterpiece. He's a 4 time Nebula award winner to go along with 4 Hugo's. I re-read his collection of short stories Stories of Your Life: and Others for a book club I'm in. Even upon the second reading I was just as drawn into these stories as I was the first time I read the collection. While I'm not a huge lover of short story collections this is one I'd recommend to anyone.
Among Others is a Hugo and Nebula award winner by Jo Walton. In it there is a semi-autobiographical journey of a young woman who has just defeated a dark fairy queen and is living with the consequences or maybe she's just nuts. You'd really have to read it to decide. It has a very "what happened after Sam and Frodo dropped the ring off in Mordor" vibe to it. Not a typical fantasy novel but a really enjoyable one all the same.

Thursday, July 25, 2013

PhoneGap Day US 2013 Recap

Why, weren't you there? Seriously, what's stopped you? This conference is so great and so cheap that if you are anywhere near Portland, Oregon you need to go. Even if you aren't near Portland you need to convince your boss to send you to the conference.

What's the number one reason to attend PhoneGap Day? Timing, no wait the community. The community really comes out for this conference. I can't think of another conference I've attended where you can meet so many committers. If you were there you could have met all those people you see fixing bugs on JIRA and checking code into GIT.

Beyond the committers there were lots of folks who are building real applications with PhoneGap and they are there for you to talk with, network and generally pick their brains.

There were a lot of great presentations this year but if I was going to single out three they'd be Andy Trice's PhoneGap+Hardware, Michael Brooks super slick PhoneGap Command Line demo/presentation (I only wish I was that smooth) and finally Lyza Danger Gardner's deck on PhoneGap Self-Defense for Web Devs. That one was jam packed with things web devs should know before diving into PhoneGap.

I was sweating my talk a bit before heading up on stage. I was about to give a speech recognition demo on a stage in front of 250 people. There were so many things that could have gone wrong like the (network, crowd volume) and one thing did. For some reason my MBP would not mirror the displays so either I could see the presentation or the audience could. Luckily, as a former boy scout, I was prepared. I was hosting my presentation on Dropbox so I was able to slide over to Tommy-Carlos Williams laptop to do my demo without holding up the show. Thanks again Tommy!

Sacrificing my laptop to the demo gods seemed to appease them and the rest of my presentation went off pretty well with only one unintentionally funny moment. People seemed to have liked it which I was happy about. You can download a PDF version of the presentation but it plays much better as a live demo.

All of these presentation videos will be available soon. In fact when mine is up I'll be posting it here. As well I'm lagging behind posting my source code but I'm kinda busy with some other commitments I'll talk about on a later date.

Beyond catching up with all of the other PhoneGap committers it was a great conference for meeting folks I internet knew, In Real Life. Besides the afore mentioned Tommy-Carlos Williams who shocked me by not having an Australian accent, he is USA born, I got to meet my co-worker Marcel Kinard for the first time. Both Marcel and I work at IBM where he is managing IBM's contributions to the PhoneGap/Cordova code base. Finally I got to know Jim Cowart of Icenium pretty well over the conference. Jim's done a great write up of the conference himself.

Honestly, I will carry to my grave the memory of the taste of Griddled Bacon Wrapped Date with warm honey from Tora Bravo. Jim, Marcel, Burin and I went there after the first day of the conference and we were all blown away with how good the food was. I guess it is not a secret but Portland is a great city for foodies.

Finally I will leave you with this over the shoulder video of me playing Galaga at Ground Kontrol the amazing barcade (bar + arcade) courtesy of Jim.

Wednesday, July 3, 2013

Backup, Remove and Restore your Contacts using PhoneGap

A couple of people have had questions on how to do this recently so I thought I would do a write up on it. As well, it illustrates how you avoid using loops with asynchronous code. Although for an even better explanation of that topic you'll want to read Item 64: Use Recursion for Asynchronous Loops from David Herman's book, Effective JavaScript. Chapter 7 on Concurrency is worth the purchase price of the book but I digress...

First a warning. Try all the code out on an emulator first. The methods below will completely wipe the contacts from your device so you'll want to make sure the backup step works first before continuing. You've been warned!

Anyway, if you want to backup the contacts on your device to a file you'd use the following process:
  1. Find all the contacts
  2. Request a file system object
  3. Create a FileEntry object
  4. Create a FileWriter
  5. Write the JSON data to file
The code in which to accomplish those tasks is as follows: Once you see the "backup complete" message in the console you'll have a file called "contacts.bak" in the root directory of your file system. For Android users that will probably be /sdcard and for iOS, etc. it would be in the applications sandbox. If you take a look at the file you will see something like this: If you are seeing what looks like your complete contact database in text format then you are ready to proceed.

Next we will delete all the contacts on the device. The steps are:
  1. Find all the contacts
  2. Recurse through the contacts deleting one at a time.
The code looks like:

This might look a little bit weird at first glance but trust me it'll make sense. You'll notice in deleteAllTheContacts the first thing we do is to create a local function called deleteContacts. This is the method that will actually remove the contacts from the device. Then after the definition of deleteContacts we call navigator.contacts.find(). This call will get an array of all the contacts on the device and call it's success function which is deleteContacts.

Now in deleteContacts we do a check to see if the length of the contacts array is zero. If it is zero then we are done, there are no more contacts left to be deleted. If the contact array length is greater than zero we have more work to do. We'll pop the next Contact object off of the contacts array, which reduces the size of the array by one and we'll call the remove method of the Contact object. The success call back for remove method is the deleteContacts method. Keep reading this paragraph until all of your contacts have been deleted. Boom recursion.

But wait, you are wondering how could this possibly work. Your thinking I've got 7 quintillion contacts and there is no way the call stack can support that many recursive calls. Ah, but you are forgetting that asynchronous calls return immediately so they never eat up the call stack. If you tried doing this with a for loop you would blow up the call stack causing your program to crash if you had enough contacts and even if you didn't kill your app how would you know when all of those async calls to remove were complete without doing a lot of JavaScript gymnastics. Just use the recursion approach.

Finally you'll want to be able to restore the contacts you've previously saved to file. I've broken it down into two separate methods to make it easier to read:
  1. Request local file system
  2. Get the FileEntry
  3. Request the File object
  4. Read the data and parse it to JSON
  5. Recurse through all the contacts and save them to the device

This is pretty much just unrolling the two previous steps of backing up and deleting the contacts. If you've gotten this far you should be able to understand what is going on. Although there are two lines I want to draw your attention to:
contactData.id = null;
contactData.rawId = null;
What I'm doing here is removing the unique ID's from the contact. If you skip this step you will signal the API that you are attempting to modify an existing contact and the save will most probably fail. Hopefully this helps a bunch of folks.