Sunday 23 September 2012

Small scale wheat growing big effects

This year we've grown wheat on the allotment.  Its part of the Garden Organic member's experimental trials programme, but its not something we've done before.  In fact we've only ever grown one grain before - quiona - which grew OK but was a pain to harvest, thresh and winnow, especially as it looked pretty similar to some of the related weeds growing on the plot.  Quiona is something that we only use very, very occasionally, so after the hassle it didn't seem worth bothering with again.  Wheat on the other hand is a major part of our day to day diet, so growing a bit ourselves sounded jolly interesting.

Our trial plot is pretty tiny - about 1m wide by 2m long.  According to the GO instructions this should get us enough wheat for two loaves of bread.  What GO are interested in is how well the wheat grew and how we process and use it - they want to know if domestic scale grain growing is something that more gardeners might be interested in.

Our patch grew OK despite the manky summer we've had this year.  It needed the odd weeding but didn't need much else - certainly no watering with the amount of rain we've had!  We ended up with a nice sheaf of golden wheat sitting in the corner of my workshop to dry out a couple of weeks ago.

Now I've been slightly incapacitated recently (a long and rather unpleasant story I won't go into here) so it came to pass that yesterday I was on enforced light duties (or "rest" as my other half and the doctors had insisted).  It was nice a sunny so I managed to persuade She Who Must Be Obeyed that I wouldn't explode or fall apart if allowed to sit in the sun down in the door way of my workshop and slowly thresh the wheat by hand.

What I ended up doing was removing the ears by hand a stalk or two at a time: not at all the process I'd originally intended (I was planning on putting them on a sheet and then jumping up and down to release the grains and chaff, but I doubt m'lady would have considered that "rest" and neither would my body probably).  Massively time consuming, and indeed I've got a third still to do, but it was rather pleasant sitting in the warm late summer sun dealing with our harvest, listening to the wireless (a workshop has to come with a hand-me-down wireless!) and time to think.

Fiddling with the ears I began to realize the amount of effort that goes into the flour and breads that we all take for granted in the modern world.  Its something I "knew" already, but this was making it real.  Even though I bake my own bread, I buy in the flour, yeast, salt and sugar and usually leave the actual process to the bread machine sitting on the corner of my kitchen counter.  Yet here I was getting close and personal with part of the process of getting that flour from something we scattered on the ground some months before.  Obviously farm scale wheat growers and millers don't have folk hand shacking the ears, but just think of the energy use that is going into the process instead: the fuel for the combine harvesters, the transport to the mill, the power operating the milling machines and then the storage and transport to the end user.  All hidden away from most people by a brown loaf in a plastic bag on a supermarket shelf.

Now whilst I'm only going to get a loaf or two out of our little two square metre patch of wheat, I'm beginning to feel that there's a greater value in growing such a small amount.  It provides an education and a reconnection, another part of the food web laid bare.  It might not be the crop to grow on your plot if you're after maximum production, but it could well be a great use of a little space in school and community gardens where folk could once again experience the full "pot to plate" experience of growing, processing and cooking.  Its a talking point and the start of discussions and ideas.

We should be thankful for our daily bread, and doing this experiment has reawakened that for me.  And if the experiment does nothing else, that's a good result for me.

Saturday 1 September 2012

LibraryThing, Android and a cool ZXing barcode feature

I use LibraryThing to manage my personal book collection.  Its a handy way of tracking what books I've bought and what I've leant out to folk.  What I really want though is to be able to check LibraryThing quickly and easily whilst I'm schmoozing the shelves in the local second hand book shops, mostly so that I don't accidentally buy another copy of a book I've already got (again!).

Luckily I've usually got an Android phone sitting in my pocket, which has a camera (two actually) and the handy ZXing barcode scanning app installed.  I've played with the barcode scanner using Perl under SL4A and was able to capture ISBN barcodes and check them against a list I held on the phone.    However the script was rather basic and getting my collection data out of LibraryThing would be a bit of a pain, as the SL4A version of Perl has neither a copy of the LWP web access module, nor a (working) version of CPAN with which to install it.  It does have IO::Socket so I started along that track to build a pure Perl client from the ground up - a bit long winded but doable.  Writing a decent UI in Perl using the Android API exposed by SL4A would be a bit of a pain though.

However last night I got distracted rereading the online version of a book I'd read in paper form when I first got my Android phone: the excellent  Building Android Apps with HTML, CSS, and JavaScript by Jonathan Stark.  This describes how you can optimise web pages to the Android platform using HTML 5 and JavaScript and, more importantly, then use those pages as the basis for a native app.  So this morning I sat down and had a bit of a tinker.

Its surprisingly easy to knock together something that looks fairly respectable quite quickly, especially as you can crib from Jonathan's existing code frame work.  Within an hour or so I'd got a simple web page using JQTouch running that allowed me to fetch my LibraryThing collection (using their JSON Books API), list the works on that I've got in my collection (including pulling cover art from LibraryThing where available) and check if a book is in my list by manually entering its ISBN.  Jonathan explained in the book how you can use localStorage and the HTML 5 database features to provide stand alone storage on the phone, and the JQTouch provides exciting UI animations, etc, whilst allowing the use of the JQuery compatible(ish) Zepos library to handle the AJAX/JSONP stuff.

So that's the heavy lifting done for talking to LibraryThing: now how do I get barcode scanning to work?  Turns out after some researching there's several options (probably even more than this if I really put my mind to it - for example the hardcore Java coders would probably add hacking up their own version of ZXing to the list):

  1. I could turn the HTML/JavaScript/CSS into a native Android app using PhoneGap.  This has several advantages: you can access the barcode scanner directly using a PhoneGap extension, you won't need a network connection whilst scanning if you've already downloaded a local copy of your LibraryThing collections and you'll end up with an .apk archive that folk can easily download and can be put on the Android marketplace (or Google Play or whatever its called this week).
  2. I could go back to the SL4A Perl script and use the HTML/Javascript/CSS as a front end (or replicate it using the SL4A UI calls) and then call the barcode scanner Intent from there.  Bit messy and it wouldn't be terribly easy to give to other people.
  3. Stick with the web delivered application and make use of a cool feature of ZXing that I've only just come across today: ZXing intercepts links in web pages that have a target of zxing.appspot.com/scan, and either fires up the barcode scanner or asks the user if they'd like to install it to use.  Assuming the barcode scanner is installed and working, you can then scan a barcode which can then gets sent to a URL of your choice.  This does mean that there's a need for a server side application to collect the scanned data, but I'm wondering if I can work round that using some sort of local URL to the phone. More playing needed really - at the moment I've just tested the system by pointing ZXing at the LibraryThing works URL once it has captured a barcode and that seems to work fine.  Apparently there's a similar URL that you can using on iOS devices that have ZXing installed (but I've not got one of those so can't try it myself).
  4. Forget the whole thing once I'd realised that the standard ZXing barcode scanner app has the ability to have a custom search URL defined which can be set to "http://www.librarything.com/isbn/%s".  Then clicking on the custom search button once a barcode has been recognised will whisk you off to LibraryThing, which (at least for me) automatically logs me in thanks to stored cookies.  This works fine, though the downside is that you need a live network connection obviously.
In case anyone is interested I've popped the "ALT" web application online if you fancy playing with it.  Even if I don't go down the route of turning that into a native app using PhoneGap, its been interesting to see how far CSS hackery lets you tart up web pages for mobile devices - useful skillz to tuck away for the future no doubt.