Friday, June 29, 2012

Books I've Read This Week

JavaScript Patterns by Stoyan Stefanov is the kind of book you need to take your JavaScript knowledge to the next level. It is an excellently written book that takes you through a tour of a multitude of patterns in JavaScript code. I particularly like the chapter on JavaScript inheritance which is a topic I only partially understood. After reading this book I feel like I have a much better handle on things.

Zen And The Art Of Motorcycle Maintenance by Robert Pirsig is a book where I went, who the, what the, how? Quite possibly I was not in the correct frame of mind for reading this book as while I enjoyed the parts about philosophy I could have done without the cut aways to their road trip and his annoying son. I don't know maybe I'd like this book more if I read it a second time but I don't see that happening.

Friday, June 22, 2012

Books I've Read This Week

Redshirts by John Scalzi examines the sci-fi troupe that originated in Star Trek the original series where on away missions Kirk, Spock and Bones always escaped unscathed but whoever the poor ensign that accompanied the big three always ended up dead. For those of you not familiar with ST:TOS ensigns wore the red shirts and that is where this novel gets it's name.

In the novel Ensign Andrew Dahl has been assigned to the starship Intrepid. Once on-board Dahl quickly realizes there is a redshirt problem and sets his mind towards discovering the root cause of the problem. This leads to some hilarious and mind bending examination of science fiction writing in general.

I greatly enjoyed the first three quarters of this book but once Scalzi got into the second and third coda's I kinda lost interest. It's not that the coda's weren't written well it is just that they moved on from the comedy of the first part of the book into more melancholy. All and all an enjoyable read.

I initially started picking up Batwoman when DC relaunched their entire line. The book is visually stunning so I decided to pick it up in hardcover once it was collected. My copy of Batwoman Vol. 1: Hydrology arrived this week and I immediately devoured it. JH Williams III is an amazing draftsman he continues his standout work from Batwoman: Elegy. The two page panel layouts are amazing and there is no way that it can be properly enjoyed on a tablet, you really need to have a hard copy in your hands.

On this collection writing duties are handled by Williams and Haden Blackman who are replacing Greg Rucka who's left DC altogether. I can't say I enjoyed the writing as much in this collection as I did in Elegy but I will definitely pick up the next collection based on art alone. Williams is taking a break from the art but a few issues will be handled by Amy Reeder and Trevor McCarthy after a split between Williams and Reeder on the books direction.

Anyway, pick up the book on art alone. Hopefully the quality remains just as high for the next collection. Fingers crossed!

Monday, June 18, 2012

Updated Speaking Engagements

I got some really positive feedback for my Adding Speech Recognition to Your Android Applications presentation that I did at AnDevCon III. I'm incorporating that feedback and I'm going to be giving the talk a couple of more times over the next two months:
In addition I'm going to be at PhoneGap Day talking about my side project Corinthian. Basically, Corinthian monkey patches a bunch of stuff that should work in the Android WebView and adds some extra UI elements as well.
If you are going to be in or around those cities on those dates ping me on twitter and we'll see if we can arrange a meet up.

Friday, June 8, 2012

Books I've Read This Week

I decided to read Horns by Joe Hill since I'm a huge fan of his graphic novel series Locke & Key that he writes with Gabriel Rodriguez on art duties. While Locke & Key is a horror/suspense book it did not adequately prepare me for how disturbed I would be by Horns. I mean, I liked the book and everything but it did creep me out. I enjoy suspense novels but there was just something extra here that gave me the heebie jeebies.

In the novel we follow the journey of Ig Perrish a year after he was rightly/wrongly accused of brutally murdering his long time girlfriend. The Ig of a year ago was a saint as we discover through flashbacks but now he is literally becoming the devil complete with horns growing out of his head.

Let's just say that this novel is full of "bad things happen to good people" which makes it painful to read at times but ultimately satisfying. 

Wednesday, June 6, 2012

PhoneGap Android Application Preferences Plugin

So I'm working on a side app that I get to touch about once a month for about 15 minutes and one of the things I ran into is that I need a way to store user preferences. Well I realized that I could build my own HTML page and store the data in localStorage but I wouldn't learn anything new that way. In the end I decided to do a plugin that would allow PhoneGap developers to use Android Application Preferences and I modelled it after the existing iOS plugin by originally by Tue Topholm (Randy McMillian ported it to the updated Plugin API on iOS).

First if you are unsure about how application preferences are setup on Android go read this tutorial and then come back I'll wait. Oh great, your back. Let's crack on with things.


Okay, so the application preferences plugin will provide you with four methods that you can use to interact with the native Android preferences.

get(key, success, fail)

If the key exists in the preferences it will be returned as the single parameter of the success callback that you provide. If the key does not exist the failure callback will be executed with an error object with error.code set to 0 which means no property.

    window.plugins.applicationPreferences.get(key, function(value) {
        console.log("The value is = " + value);
    }, function(error) {

set(key, value, success, fail)

If the key exists in the preferences then value will be saved and your the success callback will be executed. If the key does not exist the failure callback will be executed with an error object with error.code set to 0 which again means no property.

    window.plugins.applicationPreferences.set(key, value, function(value) {
        console.log("set correctly");
    }, function(error) {

load(success, fail)

Calling load will have the native side loop through all the preferences creating a JSON object that will be returned as the single parameter of your success callback.

    window.plugins.applicationPreferences.load(function(value) {
        console.log("The object is = " + JSON.stringify(value));
    }, function(error) {

show(activity, success, fail)

Calling show passing in the class name of your PreferenceActivity class will cause the native Android GUI to be shown so your user can interact with the preferences. If the class name you pass in doesn't exists your failure callback will be called with an error object with error.code set to 1 which means no preferences activity."com.simonmacdonald.prefs.QuickPrefsActivity");

which brings up a GUI that looks like this:


Installation of the Plugin follows along the common steps:

  1. Add the script tag to your html:
    <script type="text/javascript" charset="utf-8" src="applicationPreferences.js"/>
  2. Copy the Java code into your project to the src/com/simonmacdonald/prefs folder.
  3. Create a preferences file named res/xml/preferences.xml following the Android specification.  
  4. Finally you'll need to create a class that extends PreferenceActivity in order to be able to view/modify the preferences using the native GUI. Refer back to the tutorial I mentioned for more details. 
That's about it. Give the plugin a try if you need to store native preferences and let me know what you think.

Oh, and I'm pretty sure that Darren McEntee has already included this plugin in his Live Football on TV app which means this plugin is already in the wild.


Friday, June 1, 2012

Books I've Read this Week

Okay, it's been a long time since I've done one of these. You take a couple of week break while on vacation and then the next thing you it is 2 months later.

The Night Circus by Erin Morgenstern is a rocking good story which conjures up remembrances of Ray Bradbury stories I'd previously read. The novel centres around a contest between two young magicians named Celia and Marco. It is a very imaginative little romp as the two magicians compete against each other while falling in love.
A Discovery of Witches by Deborah Harkness was not what I was looking for after reading The Night Circus. It is another supernatural love story but it is not handled as deftly as The Night Circus and reading the two books back to back definitely cast A Discovery of Witches in a poor light. Seriously though, what do women see in vampires? When did they start becoming boyfriend/husband material? They are the undead people!