Thursday, January 31, 2013

GalleryPlugin

I've updated the GalleryPlugin to the Cordova 2.2.0 API but I've realized that I've never really talked about it. The GalleryPlugin is used when you need to add or remove a file from the Gallery or Music apps. Typical use cases include downloading an image from the internet and wanting it to show up in the Android Gallery app or conversely you delete a file and you don't want the dreaded black rectangle to be left in the Gallery app.


First lets take a look at what the gallery.js file. It's written using the cordova.define template but it still adds itself into window.plugins for those of you using the old style plugins:

Then will move on to the Java code. I've trimmed down code only to show the execute method for brevity.

In order to use this plugin you'll need to include the gallery.js in your HTML as a script tag:

and add a line to res/xml/config.xml to tell the JavaScript side where to find your Java class:

Now you should be able to add and remove images from the gallery. Here is some sample code to get you going:

Sunday, January 27, 2013

Books I've Read This Week

Captain Vorpatril's Alliance by Lois McMaster Bujold is the latest novel in the Vorkosigan  Saga but the twist is this time Miles Vorkosigan barely shows up in the book at all. Instead we are focusing on Miles' cousin Captain Ivan Vorpatril. Ivan rarely enjoys the spotlight and he prefers a desk job that highlight his organizational skills but when Imperial Security Officer needs Ivan's help he is duty bound to repsond. It doesn't hurt that there is a beautiful off worlder to woo. But what Ivan doesn't know is that her family issues make his look small by comparison.

Once again Bujold delivers some great characters and a rousing funny story. The best part about this saga is that the books are pretty much stand alone and can be read in any order.
Pirate Cinema by Cory Doctorow is the type of sci-fi book I really love. He uses the medium of a book set in our very near future to shine a light upon some of the political decisions going on today. In this case the advent of those 3 strike (or similar) laws where families can get booted off the internet if they are caught illegally downloading. Doctorow lays out a number of unintended consequences that can arise when a family is denied internet access.

In the book Trent McCauley gets his family booted off the net. So in typical teenager thinking he decides to run off to the city, London in this case. There he falls in with squatters  dumpster divers and makers of all sorts. Hilarity and predictably railing against the government ensues.

PhoneGap Plugin Updates to BarcodeScanner and AppPreferences

I've updated the BarcodeScanner and AppPreferences to use the Apache Cordova 2.2.0 API's. That means no more deprecation notices in the Java code and the JavaScript code uses the cordova.require method. However, I'm still slapping the objects into window.plugins so you shouldn't need to change any of your JavaScript code after upgrading.

The BarcodeScanner code has also been updated to use the ZXing 2.1 library. If all goes well there I will contact Ryan over at PhoneGap Build to pick up my changes.

Next up will be the GalleryPlugin. The only thing holding it up is that I want to add a remove method to go along with the add.

Monday, January 21, 2013

PhoneGap Plugin Updates

In the past few days I've spent some time upgrading my plugins so they work in PhoneGap/Cordova 2.2.0 or greater without requiring the users to make any changes. I've done the FtpClient and VideoPlayer. Basically I'm removing any deprecation warnings by moving from the org.apache.cordova.api.Plugin class to the org.apache.cordova.api.CordovaPlugin class. Also, I've been moving to the cordova.require way of defining a plugin on the JavaScript side while retaining the old window.plugins object for people who've written their code to use this object.

I'm currently running a poll to see which of my plugins should get upgraded next so go please vote for your favourite:


I'll start picking them off as I have time this week.

Sunday, January 20, 2013

Books I've Read This Week

Kill Decision by Daniel Suarez is not a continuation of his previous two books, Daemon and Freedom. This is a stand alone novel with no connection to the previous two books. I just want to make that clear that if you are looking for more from the Daemon universe you aren't going to get it here.

What you are going to get is an engaging and sometimes thought provoking novel in which autonomous drones are killing people all over the world. After a few scenes of the awesome power of the drones we are introduced two our protagonists. A military organization who's mission is to figure out who is behind the drone strikes and a myrmecologist who's ant behaviour algorithms may be being used to give the drones a type of intelligence.

The cons of this book are that it is short and I found that the story itself was no where near as interesting as the questions it posed. I found myself spending more time thinking about whether or not drones should ever be used without a human intelligence overseeing the entire operation. As a software developer I realize how easy it is for bugs to crop up in the system.
The Dreaming Void by Peter F Hamilton is a sprawling science fiction epic set in the year 3589. In the far future humanity has discovered a void which takes on a very religious context. One man Inigo discovers he is able to dream about the humans who live inside the void in a type of paradise. Over one hundred years after Inigo's disappearance a second dreamer has emerged. This signals the followers of the dream to begin preparing for a pilgrimage into the void. A pilgrimage that some think may cause the void to expand and destroy millions of worlds.

So that's the setup. The execution is excellently done. It follows a number of main characters in various parts of the galaxy and I'm yet to determine how their stories relate. Honestly, I can't accurately judge this book until I read the next two in the series.

Thursday, January 17, 2013

Carbonite Backup

Look this is kind of an ad and kind of a public service announcement. If you are not backing up your computer you really need to be doing that. Something will go wrong. Those hard drives don't live forever.

If you are not following the 3-2-1 backup rule then you are either:

a) being and idiot or
b) playing with fire.

Maybe both. What? You don't know what the 3-2-1 backup rule is?

Simply put:

3) You should have three copies of any important file.
2) Those copies should be on two different media types.
1) At least one copy should be off site.

For instance, all of those digital pictures of my daughter growing up are super important to me so I employ the 3-2-1 strategy for all of my picture files. I have copies of the files on the hard drive of my computer, the NAS drive that runs on my network and finally a copy offsite with Carbonite.

Now Carbonite is great tool for doing offsite backups. For $59 a year you get unlimited backup of your computer. The best thing is that it runs as a background task on your computer and you never have to think about it. Don't worry about it sucking up all your bandwidth when you want to get something done as it will throttle itself if it detects you are doing something else.

Right now if you follow my referral link you can get Carbonite and both of us get $20 Amazon.com gift cards. Also, there is a 15 day free trial so you can give it a try without committing any money.

Carbonite is the reason I didn't start freaking out when my NAS died as I knew I had a backup copy in the cloud.

Tuesday, January 15, 2013

Phillip Broughton on Triangulation

I haven't posted on coffee for a bit so when I heard Phillip Broughton on Triangulation I knew I needed to share it with all of you. Mr. Broughton is a nerd of the nth degree. Besides working at Lawrence Livermore National Laboratory he is the man behind Black Blood of the Earth Coffee. BBotEC is a cold brew coffee that is so strong you medically should only drink 100 ml or less a day.

Listen to a great interview with Phillip on Triangulation.

Thursday, January 10, 2013

Books I'm Looking Forward to this Year

io9 pulled together an fantastic list of all the new hotness in science fiction and fantasy that will be release in 2013. Here are the books I'm most interested in reading.


  • The Gun Machine by Warren Ellis
  • A Memory of Light by Robert Jordan and Brandon Sanderson
  • Homeland by Cory Doctorow
  • The Demonologist: A Novel by Andrew Pyper
  • Red Planet Blues by Robert J. Sawyer
  • London Falling by Paul Cornell
  • NOS4A2 by Joe Hill
  • The Human Division by John Scalzi
  • The Shambling Guide to NYC by Mur Lafferty
  • The Ocean at the End of the Lane by Neil Gaiman
  • The Long War by Terry Pratchett & Stephen Baxter
  • Neptune's Brood by Charles Stross
  • Steelheart by Brandon Sanderson
  • The Water Knife by Paolo Bacigalupi
  • The Abominable by Dan Simmons
  • Who Wacked Roger Rabbit? by Gary Wolf


What ones are you most looking forward to reading?

My Speech Rec in the Browser Slides

I was able to do my presentation on speech rec in the browser at last nights Ottawa JS meeting. The slides/code for the talk have been posted up to my Ottawa-JavaScript-SpeechRec github repo. Honestly, it is a pretty light talk but that was its intention as it was going to be an amuse-bouche before heading off on holidays.

In order for you to run the question/answer part of the code you'll need to get a product key from Wolfram Alpha. Then go into index.html and find all instances of <INSERT WOLFRAM ALPHA KEY> and replace them with your api key.

Also, David grabbed a pretty good picture of me contemplating life, the universe and everything in-between right after my talk. I think it is just begging for a funny caption.


Do your worst, or best, internets.

Monday, January 7, 2013

Speaking at January's Ottawa JS, This Time for Real

So I was supposed to give this presentation at Decembers Ottawa JS but well pneumonia had something to say about that. The next meeting will be held this Wednesday January 9th at 6:30pm at the gorgeous Shopify offices. My talk is all about developing speech recognition web apps which of course is me pulling the guts of my Android app, Anna, and making it work in the browser.

It should be a good time so if you can make it out it'd be great to talk with you.