Friday, September 2, 2016

Welcome to the revolution(s)

The following is a rough transcript of my toastmasters speech 7: "Do your research"




The Luddites were a protest group that primarily operated between 1811 and 1816.  They were primarily workers in the garment industry.  They started riots and destroyed machinery.  These days, the name Luddite is applied to anyone who struggles with or opposes new technology.  However, the original Luddites however weren't so much opposed to technology as  to it's effects.  In particular they feared the loss of work from automation and the replacements of skilled labour with unskilled.

The Luddites were correct in their fears.  The industrial revolution eventually resulted in better working conditions, better wages and an improved standard of living standard.  However it took a long time to get there. On the way, it resulted in widespread pain and unemployment.

Mr chairman, fellow toastmasters and guests, welcome to the revolutions.

I am not actually going to talk about the first industrial revolution, the one we learned about in school.
Nor am I going to talk about the second one, exemplified by Henry Ford’s introduction of the assembly line
The third revolution was the digital revolution.  Most of us have lived through it.  But I am not going to talk about it

I am going to talk about the one happening right now, the fourth industrial revolution.

  • What is it?
  • What is the impact?
  • What can be done?

What is it? 

There area number of technologies making up IR4 such as

  • AI
  • Robotics
  • Automation
  • genetic engineering/biotechnology
  • Nano technology

Most of these are autonomous, things that happen without human intervention.

Individually any of these would have a large impact.  together, it is a perfect storm of change.

Let me give you a few examples:
Every major car manufacturer is working on self-driving cars.  Tesla has one out now.  Uber is trialling self driving cars in Pittsburgh this month.

Major truck manufacturers such as Mercedes Benz and Volvo are working on self driving trucks.  The intention is that a local driver will drive the truck to a motorway, the truck will drive cross country to near it’s destination and then a second driver will handle driving the last few kilometres to the final destination.  Long haul truckers will become short haul truckers

IBM have been working on an AI called Watson.  A few years ago it won the American game show Jeopardy, beating out previous champions.
Now it is being used in medicine, as a laywer and in other fields such as teaching

Amazon is my poster child for IR4.  They started out as a website bypassing physical stores to reduce prices.  They have giant warehouses heavily using robots and autonomous delivery cart.  Now they are working on using drones to deliver directly to purchasers.

What is the impact?

There is going to be a big impact.  Many job categories will disappear or become much smaller.

  • Oxford: %47-81% of jobs under threat in 20 years
  • McKinsey Quarterly: Almost half of current job activities can be automated.
  • World Economic Forum: Predicts loss of 5m jobs in the next 5 years
  • The International Labour Organisation 137 Million SE Asian Workers Could Lose Their Jobs in the Next 20 Years

Most of the 137m SE Asians work in the garment industry, the industry that gave us the original luddites.

“Foxconn replaces 60,000 factory workers with robots”
Foxconn is the company that makes iPhones.  They employ 480,000 people.  Well they used to, now they employ about 420,000.  These are people that make $5 per day, and it is still cheaper to use robots.

If you think China is too far away to care about, Watties is right next door.  They have been replacing workers with robots for the past 20 years

This graph shows the change in income across the world from 88-2008.  The poor are on the left, the rich on the right.
The area around 50-60% is mostly China and India.  New Zealand and other rich countries are mostly from 75% - 100%.

This graph is both good news and bad news.
Good news.  If you are rich, well you got even richer.
If you are poor, then it’s also good news.  Offshoring and globalisation have made many of the poorer countries much better off.
But for those of us in the room, we mostly fall in the 80-95% range.  And we haven’t seen much growth in our incomes.

IR4 may (and we don’t really know) make the dip even wider, as the rich keep getting richer but the drop in employment reducing incomes for the rest.

What can be done? 

  • Shorter working hours
Before the 1st IR, the average working week was about 70 hours.  Now it’s more like 40.  If half of the jobs disappear then perhaps we will only need a 20 hour week.  The French have already started moving in this direction.
  • Universal Basic Income
The UBI is a payment made to every adult in a jurisdiction with very few eligibility criteria.  It provides enough money for people to live without working and replaces most government benefits.  It’s much like National Superannuation if it had a starting date age of 18.
This is been trialled in many areas around the world.
  • Education 
Education will be key, but it will be lifelong education as employment requirements change.
  • Adapt 
In the long term, the 1st industrial revolution was a good thing.  It reduced working hours, lowered the cost, and raised the standard, of living .  However there was a lot of pain along the way.  We can expect this again, the trick will be to navigate the 20-50 years till we get there.



Friday, September 11, 2015

Using the Visual Studio Android emulator inside VMWare

I do my development in Virtual machines.  It makes it much easier to to back up and transfer my dev environments.  However not everything works inside a virtual machine :(.  Emulator that themselves rely on a virtual machine are problematic.

When Visual Studio 2015 was released, I built a new VM and installed everything.  VS2015 worked fine but the new shiny Android emulator wasn't so happy.

The first error was around Hyper-V.

Visual Studio Emulator for Android
The emulator is unable to verify that the virtual machine is running:
Something happened while starting a virtual machine: 'VS Emulator 5-inch KitKat (4.4) XXHDPI Phone.bob' failed to start. (Virtual machine ID 889F3EA2-7B0E-4873-9180-C765E4293D4E)
The Virtual Machine Management Service failed to start the virtual machine 'VS Emulator 5-inch KitKat (4.4) XXHDPI Phone.bob' because one of the Hyper-V components is not running (Virtual machine ID 889F3EA2-7B0E-4873-9180-C765E4293D4E).

This a fairly common error and once that is easy to fix.

  1. Open the .vmx file in notepad and ad the following lines:
    hypervisor.cpuid.v0 = "FALSE"
    mce.enable = "TRUE"
    vhu.enable = "TRUE"
  2. Run the VM.  Go to "Programs and Features" and ensure that Hyper-V is installed

Running the emulator now gives a completely different error.  Yay, progress.
Visual Studio Emulator for Android
An OpenGL error has occurred:
Failed to create Context 0x3005
The emulator will now shut down.

There are multiple ways to fix this:

Either way works:

Friday, September 20, 2013

Slides - Cross platform programming with .net, xamarin and MvvmCross

The slides from yesterdays presentation "Hot tuna - Cross platform development with .net, Xamarin and MvvmCross" are available from here.

Useful links from the presentation

Stuart Lodge - MvvmCross Author



Video index


Mobile library 

Ninja Coder
Adrian Sudbury – Ninja Coder Author


Ninja Coder

Portable Class Libraries

Wednesday, March 27, 2013

Using with POCO classes

SQLite has become one of the most pervasive embedded databases around.  It's built into Android, iOS and OSX and is a part of many applications.  It has also become the recommended client side database for WinRT applications

The go-to solution for using SQLite in .net is  It’s a simple ORM that comes as one (or two if you want async support) source files.  You can get the full source from github or just the main files from Nuget lets you store nearly any object in the database without needing to descend from a specific type.  However to make it work well, you need to decorate your objects with data attributes denoting primary keys, indexes and so on.

For example:

       public class Valuation
             [PrimaryKey, AutoIncrement]
             public int Id { get; set; }
             public int StockId { get; set; }
             public DateTime Time { get; set; }
             public decimal Price { get; set; }

On startup, you register your class with SQLite as follows:

       var myConnection = new SQLiteConnection ("Stocks.db");
       myConnection.CreateTable<Valuation> ();

This will check to see if the table exists in the database and create or update it if required. 
You can then start using the database in your code.

       var valuations = myConnection.Table<Valuation>().Where(...);

However for my use case (cross platform application with data objects defined in a portable class library and used in WPF, WinRT and MVC applications), the attribute approach didn’t work.  The nice thing about open source though is that you can always change things…

The latest github version of now has an optional argument for CreateTable that allows defining indexes by convention.   

Acceptable values are:
    public enum CreateFlags
        None = 0,
        ImplicitPK = 1,    // create a primary key for field called 'Id'
        ImplicitIndex = 2, // create an index for fields ending in 'Id'  
        AllImplicit = 3,   // do both above

        AutoIncPK = 4      // force PK field to be auto inc

So to define and register a class, we can now use something like the following:

    public class Valuation
        public int Id { get; set; }
        public int StockId { get; set; }
        public DateTime Time { get; set; }
        public decimal Price { get; set; }

And then 

       myConnection.CreateTable<Valuation>(CreateFlags.AllImplicit | CreateFlags.AutoIncPK);

This will create the table, make Id into an auto incrementing primary key and add an index for StockId.  To explicitly add additional indexes, use the CreateIndex methods.  E.g. 

       myConnection.CreateIndex<Valuation>(v => v.Time);

The main advantage of this approach is that it lets you separate storage details of the object from it's definition.  This is great for cases when you don't want to, or can't, use the sqlite attributes in the main class.  

The main disadvantages are that you have now separated storage from definition, and currently there is no way to set the field size.

Sample applications demonstrating both approaches can be found on github.  The sqlite.dll binaries can be downloaded from here.

Thursday, August 4, 2011

Delphi for iOS!

I attended the Rad Studio World Tour today in Auckland. Delphi XE2 has some nice features (x64, OSX, FireMonkey) but the standout for me was the iOS support.

Developing for the iPhone et al is mostly a pain in the proverbial. XCode is somewhat of a mess and Objective C was designed by someone with an unholy fetish for square brackets. The last time I did iPhone dev, I did most of my coding in c++ on Windows and only booted into OSX for deployment and testing on the iPhone.

Embarcadero are looking to fix that with Delphi XE2. You can write and test your code in Delphi on Windows. When you need to try it on iOS, you create a xcode project (1 mouse click, only needed once) and then boot into OSX and open the xcode project there. From xcode you can edit, compile, run and debug your 100% Delphi code. If you have either Windows or OSX in a virtual machine you can flick from one tother as you wish. Yor app can be compiled and run in both Windows and iOS.


It's not all perfect, xcode is still there, OSX is a must and the whole code signing is probably as irritating as before, but it's much better than the objective c alternative. It only works with new apps written using FireMonkey but you will be able to pull in older code.

The iOS app is full native code, with access to hardware such as gps, accelerometer and camera.

Note: Accessing the phone hardware means that your app will no longer run under windows due to either the hardware or the support units not being there. I suspect that this is resolvable with some conditional defines and a bit of hacking.

Much to my supprise I am now excited again; both about delphi programming and about iOS programming.

Saturday, June 11, 2011

Delphi image components, ImageEn has a new home

If you have used image editing and manipulation in delphi, there is a good change you have used or heard of ImageEn components. I have used them in my photo printing program, Pics Print.

The ImageEn component suite has now moved to delphi shareware company Xequte. You can find them at or at If you want to see the components in action, download demos from here.