Tuesday, October 30, 2012

MONODROID Camera preview as openGL texture

I've been pulling my hair out trying to get a simple camera preview on an android phone with an OpenGL sprite on top. This seems possible if you do it in eclipse using Java but my chosen platform, Monodroid and C# seems to have problems.

Later versions of the Android SDK seem to have this feature also but let's not forget that there are still a huge proportion of 2.3 phones out there that could be supported if only this was a simple feature.

Well, I brute-forced one that runs on OpenGL on a 2.3.3 phone.

#1 I created a camera preview listener and the associated classes to provide a nice .net event when the new camera frame arrived:


    public class CameraListener : Java.Lang.Object, Camera.IPreviewCallback
    {
        public event PreviewFrameHandler PreviewFrame;
        public void OnPreviewFrame(byte[] data, Camera camera)
        {
            if (PreviewFrame != null)
            {
                PreviewFrame(this, new PreviewFrameEventArgs(data, camera));
            }
        }
    }

    public delegate void PreviewFrameHandler(object sender, PreviewFrameEventArgs e);

    public class PreviewFrameEventArgs : EventArgs
    {
        byte[] _data;
        Camera _camera;

        public byte[] Data { get { return _data; } }

        public Camera Camera { get { return _camera; } }

        public PreviewFrameEventArgs(byte[] data, Camera camera)
        {
            _data = data;
            _camera = camera;
        }
    }

#2 Using MonoGame I created a basic app

    public class Game1 : Microsoft.Xna.Framework.Game
    {
        Camera _camera;
        CameraListener _listener = new CameraListener();

        GraphicsDeviceManager graphics;
        SpriteBatch spriteBatch;
        SpriteFont font;

        Texture2D _cameraBG;
        short[] _frameData = null;

        public Game1()
        {
            graphics = new GraphicsDeviceManager(this);

            Content.RootDirectory = "Content";

            graphics.IsFullScreen = true;
            graphics.PreferredBackBufferWidth = 800;
            graphics.PreferredBackBufferHeight = 480;
            graphics.SupportedOrientations = DisplayOrientation.LandscapeLeft | DisplayOrientation.LandscapeRight;

            _listener.PreviewFrame += new PreviewFrameHandler(_listener_PreviewFrame);
        }

        unsafe void _listener_PreviewFrame(object sender, PreviewFrameEventArgs e)
        {
            lock (this)
            {
                fixed (short* fd = &_frameData[0])
                {
                    fixed (byte* yuv = &e.Data[0])
                    {
                        YUV2RGB.convertYUV420_NV21toRGB5551(yuv, fd,
                                                            _cameraBG.Width, _cameraBG.Height);
                    }
                }
                _cameraBG.SetData(_frameData);
            }
        }

        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            // TODO: Add your initialization logic here

            base.Initialize();

           
            _camera = Camera.Open();
            Camera.Parameters parameters = _camera.GetParameters();
            IList<Camera.Size> sizes = parameters.SupportedPreviewSizes;

            _cameraBG = new Texture2D(graphics.GraphicsDevice, sizes[9].Width, sizes[9].Height, false, SurfaceFormat.Bgra5551);
            _frameData=new short[sizes[9].Width*sizes[9].Height];
            parameters.SetPreviewSize(sizes[9].Width, sizes[9].Height);
            _camera.SetParameters(parameters);
           
            _camera.SetPreviewCallback(_listener);
            _camera.StartPreview();
        }

        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);

            // TODO: use this.Content to load your game content here
            font = Content.Load<SpriteFont>("spriteFont1");
        }

        /// <summary>
        /// Allows the game to run logic such as updating the world,
        /// checking for collisions, gathering input, and playing audio.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Update(GameTime gameTime)
        {
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
            {
                Exit();
            }

            // TODO: Add your update logic here

            base.Update(gameTime);
        }

        int c = 0;

        /// <summary>
        /// This is called when the game should draw itself.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Draw(GameTime gameTime)
        {
            graphics.GraphicsDevice.Clear(Color.CornflowerBlue);


            spriteBatch.Begin();
            spriteBatch.Draw(_cameraBG, new Rectangle(0,0,graphics.GraphicsDevice.Viewport.Width, graphics.GraphicsDevice.Viewport.Height), Color.White);
            spriteBatch.DrawString(font, "Hello from MonoGame!", new Vector2(c++, 16), Color.White);
            spriteBatch.End();
            if (c > 350)
                c = 0;
            base.Draw(gameTime);
        }

#3 Using info gleaned from Wikipedia I put together a YUV to RGB translator NOTE the use of unsafe code. Sorry but that's the way it has to be. 

    public static class YUV2RGB
    {
        unsafe public static void convertYUV420_NV21toRGB4444(byte* yuvIn, short* rgbOut , int width, int height)
        {
            int size = width * height;
            int offset = size;
            int u, v, y1, y2, y3, y4;

            for (int i = 0, k = 0; i < size; i += 2, k += 2)
            {
                y1 = yuvIn[i];
                y2 = yuvIn[i + 1];
                y3 = yuvIn[width + i];
                y4 = yuvIn[width + i + 1];

                u = yuvIn[offset + k];
                v = yuvIn[offset + k + 1];
                u = u - 128;
                v = v - 128;

                convertYUVtoRGB4444(y1, u, v, rgbOut, i);
                convertYUVtoRGB4444(y2, u, v, rgbOut, (i + 1));
                convertYUVtoRGB4444(y3, u, v, rgbOut, (width + i));
                convertYUVtoRGB4444(y4, u, v, rgbOut, (width + i + 1));

                if (i != 0 && (i + 2) % width == 0)
                    i += width;
            }
        }

        unsafe private static void convertYUVtoRGB4444(int y, int u, int v, short* rgbOut, int index)
        {
            int r = y + (int)1.402f * v;
            int g = y - (int)(0.344f * u + 0.714f * v);
            int b = y + (int)1.772f * u;
            r = r > 255 ? 255 : r < 0 ? 0 : r;
            g = g > 255 ? 255 : g < 0 ? 0 : g;
            b = b > 255 ? 255 : b < 0 ? 0 : b;      

            rgbOut[index] = (short)(0xf000 | ((r&0xf0)<<8) | ((g&0x00f0)<<4) | b>>4);
        }

        unsafe public static void convertYUV420_NV21toRGB5551(byte* yuvIn, Int16* rgbOut, int width, int height)
        {
            int size = width * height;
            int offset = size;
            int u, v, y1, y2, y3, y4;

            for (int i = 0, k = 0; i < size; i += 2, k += 2)
            {
                y1 = yuvIn[i];
                y2 = yuvIn[i + 1];
                y3 = yuvIn[width + i];
                y4 = yuvIn[width + i + 1];

                u = yuvIn[offset + k];
                v = yuvIn[offset + k + 1];
                u = u - 128;
                v = v - 128;

                convertYUVtoRGB5551(y1, u, v, rgbOut, i);
                convertYUVtoRGB5551(y2, u, v, rgbOut, (i + 1));
                convertYUVtoRGB5551(y3, u, v, rgbOut, (width + i));
                convertYUVtoRGB5551(y4, u, v, rgbOut, (width + i + 1));

                if (i != 0 && (i + 2) % width == 0)
                    i += width;
            }
        }

        unsafe private static void convertYUVtoRGB5551(int y, int u, int v, Int16* rgbOut, int index)
        {
            int r = y + (int)1.402f * v;
            int g = y - (int)(0.344f * u + 0.714f * v);
            int b = y + (int)1.772f * u;
            r = r > 255 ? 255 : r < 0 ? 0 : r;
            g = g > 255 ? 255 : g < 0 ? 0 : g;
            b = b > 255 ? 255 : b < 0 ? 0 : b;      
            rgbOut[index]=(short)(((b&0xf8) << 8) |
                          ((g&0xf8) << 3) |
                          ((r >> 2) & 0x3e |
                          1)
                          );
        }
    }

------------------------------------------------------
There you go.. Check out section #2 where the preview frame event handler converts the data and copies it into the texture. This texture can then be used as a background texture on your game.

My lack of thanks goes out to the people on StackOverflow whose unhelpful responses to my pleas were the inspiration for "Do it yer frikkin self Bob"

Please feel free to enjoy the code in any way that pleases you.

Hey, if you find it useful +1 it please.



Beginning of the end for X86

The first PC I bought back in 1986 had a 16 bit Intel processor. I replaced it with one that could run the full Intel 8080 and 8086 instruction set and used it to compile and debug code for Sinclair Spectrum machines that used Zilog Z80 processors that ran a superset of the 8080 instruction set.

Later, AMD began to create devices that ran the same instruction set as the Intel processors and the war of shorter cycle times, more compact instruction decoders and pipelining began in earnest.

Later still, Apple gave up the PowerPC chips in favour of Intel and the latest generation of MAC was born that you could actually install Windows on if you felt so inclined.

Today AMD have announced that they will be making processors based on the ARM chip designs that have been steadily chuntering along in the background making more and more inroads into the devices all around us. The first ARM machine I ever saw was an Acorn Archimedes owned by my friend Bruce Mardle (Yes, he of Carmageddon fame) and I was very impressed at the time with the power of the RISC architecture. It clearly blew away my PC in benchmarks that Bruce ran. I was a little jealous of that but realised that the PC was a more flexible platform for commercial work.

Today however, I have an iPad, an iPhone, several Android phones a vanilla Tablet thing, the usual complement of Mac and PC devices and I am once again utterly stunned by the ARM's capabilities. My most recent aquisition, an LG E400 phone running Android 2.3.3 (I want the compatibility not the flash) is quite capable of running openGL software at 25-30 frames per second.

AMD's announcement shows that the RISC design that has endured all the changes of the last, damn, nearly thirty years! and is still coming out favourably on speed but particularly power consumption and cycles-per-watt calculations that shows it as a winner. Microsoft have seen the writing on the wall and have versions of Windows that run nicely on ARM designs. It seems now that the next generations of server farms will also be powered by ARM designs.

If I had a hat I'd take it off to the enduring and speedy little RISC processor. Bruce, you were right all along.

Friday, October 26, 2012

MonoGame on Android ROCKS!!!

Damn! Ten minutes and I have a test running on my LG phone.

Its SMOOOOOOOTH!


Thursday, October 25, 2012

Yesterday..

Page views:

New Zealand 213
United States 99
Australia 85
United Kingdom 81
Russia 46
Italy 23
France 22
Germany 16
Sweden 11
India 7

 I wish someone in New-Zealand would give me a job. I obviously speak to that audience..
How about I do a stand-up tour or something. Come on people, work with me here...

What possible use is this?

Looking at the stats for this blog I notice with some considerable concern that a trend has developed over the last few months.

A large proportion of the daily traffic comes from links from a porn page. WTF?

I am utterly at a loss to understand how that gels from any point of view. I can't get my head around the possibility that someone actually thinks: "Hmmm, I'll have a little wank and then go see what Bob has to say today..."

The idea is just too disturbing by halves.

Tuesday, October 23, 2012

Apple patents ruled invalid

Further to my moan of the other day, Apple have just had some of their patents relating to scrolling overturned as not having enough novelty.

While I have nothing against Apple as a company, I have a huge problem with the increasing, almost inconsequential ease with which patents are granted and the use of patents as a way for large companies to make money by suing another.

Patenting the position of a scroll control or the colour of a button is utterly ridiculous. If the colour was one not in the spectrum than that would be novel. Otherwise SHUT UP!

Patenting gene sequences decoded from people is ridiculous. If the gene sequence is one constructed from scratch to do a job, that's programming and should be patented. Otherwise SHUT UP!


The age of the troll.

Looking at a forum I frequent I find that so many people seem to sit around waiting to be fed! Not food I may hasten to add but free information. Please solve all my problems. Please spend all your time and write me this application.  
When they get it they suck up whatever pleases them with no thanks and anything that displeases them gets a tirade of trollish negativity or interminable moaning. Thankfully, most of the morons find it too difficult to string a coherent sentence together that doesn't have LOL in every paragraph or a manically dancing GIF "smiley" that excuses their feeble attempts to communicate in words alone. Beavis and Butthead seem erudite and charming in comparison.

Never a gimp around when you need one.

The GIMP windows installers on sourceforge are giving a 500 internal server error.

Tuesday, October 16, 2012

More patent idiocy

Patent examiners are so overloaded and so many patents are applied for that there is no way to make a proper investigation into whether the claim is valid or not. This has been increasingly true in the past few years and, as a result, the number of frivolous patents that are granted is becoming ridiculous.

An article today in New Scientist tells of a patent that has been granted to a company regarding DRM on 3D printers. Well DUH! This is something that has been discussed time and time again since the beginning of the open-source hardware movement that produced the first 3D printers. To grant a patent on something that has been discussed in such detail and with such controversy for at least five years is like someone allowing a patent on glasses to hold water that can be held to the lips while one drinks!

The entire patent system is fundamentally broken and the grant of a patent confers too many rights for companies toe sue each other. Once again, this does absolutely nothing useful except employ more damned lawyers!

28 gigabytes of wasted space

all takenup by fragmentation of my virtual hard disk.

Thanks to Mark Loiseau for the fix...

If anyone asks, tell them a little bird told you.

http://blog.markloiseau.com/2010/04/virtualbox-compact-a-vdi-in-ubuntu/

Monday, October 15, 2012

Tax

There has been much discussion in the media about tax and tax dodgers of late. I find the whole thing interesting and about as accessible as a well greased pig.

On the one hand we have the governments, usually run by the well heeled elites, that sing loudly about taxation being important and about catching tax dodgers. This appeases the masses who think that stuff is being done on their behalf. However, the imposition of tax usually applies to the poorer working man and not to the rich elites themselves. A case in point being lowly Portugal which is currently suffering the highest tax rates on ordinary people in Europe, ostensibly to pay for bail-outs caused by the banking crisis. The banking crisis on the other hand has been demonstrably caused by the rich elites who run the banks and their infernal greed. Primarily, the banks, not just in the U.S.A but worldwide, engaged in a policy of lending to people who had no possibility of paying back the loans and, i'm certain, that that was part of the strategy. The banks reasoned that by lending to people who could not pay, a proportion of the money would be paid by the purchaser, then, at the failure of the loan, the bank would own the property less the sum that the purchaser managed to pay out before the loan failed. A handy way of amassing property based wealth no?

The cynicism of the banks has been even greater because a certain few began to offer a sort of insurance policy that would enable some to profit enormously from the actuality of that failure. The Credit Default Swop or CDS was an incredibly tortuous system of "financial product" that enabled a supposedly disinterested third party to insure the loans taken out by someone else. The trick was that the payout came when the loan failed and the "instrument" was not designed to advantage either the giver nor the receiver of the loan but the third party. These CDS deals had a price and they themselves were traded according to how little you could pay to get the best advantage over the loans most likely to fail. This is exactly like a man who owns a casino saying to another man who owns a casino "Well, we both have rigged games, We know that and I will come to your casino and bet on the roulette wheel. You make sure that your rigged game pays out and I'll pay you a percentage". Then this casino owner goes to someone else and says "I know where there is a rigged roulette wheel. Pay me a percentage of your winnings and I'll give you the formula for winning" Effectively he double-dips.

CDS deals however double, triple and even more dipped and were instrumental in the fall of the banks that failed and kicked off the crisis.

Meanwhile, the well heeled elites who run the banks, are pillars of society and who, because of their good reputations stand for office in the increasingly right-leaning governments of Europe have figured out a way of getting the poor people, who aspired to own property and were sold loans they couldn't afford, to pay for the loans they couldn't afford by taxing them so that the elites can bail out the banks again. Does anyone see irony in this?

Now, back to the subject of this post. Well heeled elites say that they will catch tax dodgers by exposing tax havens and increasing revenues. However, it seems to be carefully arranged that the swarthy oligarchs and johnny-come-lately's are the targets of the real tax gathering system. Meanwhile, the people in power pass laws that enable them to dodge taxation in a perfectly legal way. Millionaires pay a few percent of tax, often less than half of what the man in the street pays. Many millionaires pay none at-all. Most of those are in government somewhere or another.

One wonders how long it will be before people understand what has been done to them and a bit of a revolution starts. Off with their heads?

Sunday, October 14, 2012

Debugging on Android (Part 2)

Well, I take back everything I said about the Android debugging experience. All my pain and all my delays were due to the utterly crap quality of the Alcatel 991 phone that I had been trying to use to debug my game.

Working on the LG-E400 is a different prospect entirely. Debugging works smoothly, I can stop, inspect, change and go again in a few moments.

I guess that blowing up that useless phone was a good thing. If it ever comes back repaired I will give it away to someone I despise.


Partial classes in MonoDroid

While developing some applications recently I have been reminded that C# partial classes are a brilliant way of saving you the stress of navigating a file that contains implementations for many different things.

Many Android view classes can implement interfaces that soon make the file large and difficult to navigate. A few partial class declarations to separate out the variables and implementations associated with each of the interfaces makes the code navigation so much simpler.

Great example candidates being implementation of geolocation features or other sensor inputs.

Of course, this applies to all code that you may write in C# but as my focus is on Android development today it seems to be worth a mention.

Saturday, October 13, 2012

Going native?

While I think I'm a reasonably good C# programmer and my .Net skills are second to few I wonder right at this second whether its worth flogging that horse with regard to certain applications that I might write. Notably, I'm wondering about the possibility of jumping the C# ship and using Java-pure for developing on Android phones.

Hell, the syntax of Java isn't scary, I've done a limited amount of Java development before. I might be old but I like a challenge now and again and frankly the bloat incurred by Mono in the Android app space seems to be a bit over the top.

I can't imagine why for example, my app needs to be SEVEN megabytes for two activities that basically use Google Maps anyway??

I intend to play around with it to see what the deal is. Watch this space for news?

How hard do you have to work for three bucks?

My applications on Google Play are free but, more as a test of how to do it than anything else, I integrated AdMob into the app. Today, after about two weeks of availability of the version that has AdMob installed, I have a report that the app has earned the princely sum of three dollars in click revenue.

This is with about 2000 total ad requests. CPM is about 1.50.

Now in France there is a thing called SMIC which is the basic minimum wage that you're paid if you have a job like licking toilets clean or, say, a nurse in a cardiac hospital. The SMIC is about 1300 euros per month so to get that level of income I would have to be making somewhere in the region of 3304 page requests per hour. I have calculated that as requests per hour over 24 hours because we all know that the ad machine never sleeps.

Sadly, I cannot live on the SMIC. I need an absolute mnimum of three times that just to maintain head above water and do all my shopping at LIDL. To keep a metaphorical wolf from Bob's door I need 10,000 page impressions per hour, 24 hours a day and a CPM of at-least 1.5.

That means I need to write about 150 apps. Better get busy! Oh, if anyone uses my app, CLICK THE BLOODY ADS!

Differences in Android phones.

I just blew up one lousy Android phone and replaced it with a little LG-E400. To test one of my apps I downloaded the Camper Companion (I do a US version, RV Assistant) from the Play store.

The app loaded fast. registered on the network and got the GPS fix almost instantly and the display of points on my Google map client was vastly improved over the Alcatel phone that I have been using for development.

This phone, the LG, has an 800 MHz processor and a graphics accelerator but still runs Android 2.3. When I'm rich and famous (again) I'll get myself one of the kick-ass powerhouse phones from Samsung and see how that performs.

Friday, October 12, 2012

Just killed an Alcatel phone..

Well, interestingly, leading on from my post of a few days ago, the Alcatel 991 phone that I was using to test my new Android based game died a death. I hasten to add that it died all of its own accord and not through the auspices of your's truly.

I had used the phone on and off for maps and i discovered this morning that the compass would only point south! I downloaded the most excellent AndroSensor app to see what the thing was doing and lo, i did see that the magnetometer was showing ten times the signal in the Z direction as the other two and that this did not move if I reoriented the phone. I attributed this to a dry joint on the board as it has all the signatory features.

Later, the phone screen went dark and the vibrating alarm. (One is reluctant to use the word "Vibrator") set itself permanently on and vibrated the battery to oblivion. Sadly for the ladies who read this blog, the thing only lasted about one minute and thirty seconds.

I took it back to ElectroDepot from whence it came and the fascist bastards there said they would send it back and get it fixed rather than refund my money for the POS.

I Grumpily went round to a different store and bought a cheap LG-E400 phone which is small but seems to be more powerful and with a better network connection that the Alcatel. Seriously. that is THE LAST EVER time I buy another Alcatel phone. I had an Alcatel mobile that died suspiciously, I have had many Alcatel house phones that have also died for no reason and now this crap Android phone too.

Back to the code!

Saturday, October 06, 2012

Smartphone?

I bought my first iPhone in 2008. I was late to the party with an iPhone 3G, not enough of an apple fanboy to want to snap up the version 1. The first application I obtained for the phone was Stitcher. This because I wanted to be able to listen to the select few scientific and tech podcasts that I enjoyed plus of course, Car Talk and the Friday Night Comedy show from Aunty Beeb. I have listened to literally thousands of hours of podcasts using Stitcher and the application has mostly been the primary use of my iPhone. In the four years that I've owned an Apple phone, I have never been inspired to throw it against a wall and smash it into a million bits.

Recently I bought an Alcatel 991Android phone. Ok, I'm a cheapskate but the idea was to use it for my few small personal projects and app ideas so I couldn't justify forking over a fortune for what I admit is definitely a secondary bit of kit. I've used it with success to test my own app and I am now writing a game. Simply because I had stuffed the sim-card from my iPhone 4S into the Alcatel so I could use Google Maps outside, I decided to put Stitcher on the phone too, just so I could grab whichever phone had the network connection at the time and scoot out to town or to see the kids.

The Android phone suffers from menus even more deeply nested and annoying than the iPhone. I have been using it as a tether on and off too. These have been minor annoyances and forgivable as different rather than plain egregious. The clincher for me came about fifteen minutes into a recent car journey with my son. There is a signal black-spot on the lee of a hill not far from my house. The iPhone will always have downloaded enough of the podcast to continue playing audio while we go through that bit. The Android didn't. Not only that, the app skipped and jumped, rewound and played in an endless loop of waa waa waa waa waa waa for about five minutes such that I almost stopped the car in order to throw the Alcatel on the floor and jump all over it smashing it into a million bits. Later, my best and most loved app decided to rewind to the beginning of Science Friday over and over so that I eventually pulled the battery out of the phone and drove in silence.

I LOVE my Apple phone. I LOVE my Macbook Air. I LOVE my iPad. I LOVE my little Mac Mini. Everything works smoothly apart from the very occasional crash. It all "gells".

I really like my Windows phone. I feel comfortable working with Microsoft's Visual Studio and frameworks. I don't _love_ it but its work, it gets the job done, I'm happy. I don't _love_ my Kobalt socket set but they undo nuts when I need them to.

I almost, almost smashed my Android phone to smithereens within fifteen minutes of using it seriously for the first time. I had to send back two crap Android tablets before I got a good one. I wonder how that experience would have affected me if I had suffered it when I was adopting the technology?

Friday, October 05, 2012

France in the doldrums

A story on the BBC news site today served to confirm some thoughts that both my wife and I have had for a while now. France seems to be slipping down into abject misery and a general feeling of malaise.

I will qualify what I say by declaring that I am very much a fan of France. I've lived her for sixteen out of the last twenty years. I speak the language fairly well for a "rosbif" and I see France as a safe and secure place for my children to live. A requirement that is close to my heart as I have more children than most people.

Recently however I have begun to notice that France ain't what it used to be. Cities are beset by beggars, both from France and other countries. I know of whole clans of girls who run a lucrative begging business out of St Denis in northern Paris. They leap on the train full of beans, laughing and giggling in the morning and by the time they reach the city they get off the train as limping shambling wrecks with doleful eyes and ever outstretched palms. They often take children with them who sit motionless all day long like people in a persistent vegetitive state, the really good ones drool a bit and allow flies to settle on their cheeks without flinching.

Not only has the underbelly of French society begun to suffer but the business world has too. As a consultant engineer I used to get abundant work and a good salary in France. Recently however, government edicts regarding working practices has all but killed off the consulting business and punitive social charges in the form of "forfaits" or fees-one-must-pay regardless of actual profit serve to prevent the ordinary person from forming their own companies. Examples of this include a requirement for a company director to pay a minimum social security charge, regardless of whether they draw a salary or whether the company shows a profit. This can mean make or break for small companies in the first few years. Schemes to "encourage" small businesses such as the "auto-entrepreneur" or one-man-show type business actually find the businessman charged a fixed percentage of turnover. This means that the company is forced to charge high prices in order to pay the social charges and then the business is less competitive. It also means that a company that doesn't make considerably more than the 12% charged is automatically in deficit and killed off by losses that have to be paid by the aspiring business man. A loophole often used is to start a business using grants, make sure it fails and then have a relative "take over" the failing business a year or two later, getting a grant for the takeover in order to revive the failing business. This obviously puts more pressure on the social system and the cycle continues.

The very worst aspect of France is the paperwork and officialdom. Both individuals and companies are forced to make multiple declarations of essentially the same data. The burden of paperwork requires vast numbers of "fonctionnaires" or civil servants who do nothing to reduce the burden because it keeps them in cushy lifetime jobs.They produce nothing and are a drain on society which keeps the costs up and social charges artificially higher.

I love France. I find it sad to be having the same thoughts about it that I had about the UK in the 1990's. It needs a clean sweep to get rid of useless burdensome paperwork, reduce the load paid by society on people who produce nothing. They must increase computerisation and unify data so that endless "declarations" go away and information from employers and individuals suffice to provide all that is required.

Sunday, September 30, 2012

AdMob, a painless experience

I have a couple of android apps in the Play store at the moment. I am offering them for free because they are essentially something I wrote for myself and a way of testing the process of generating apps and managing the full life-cycle without having to do it on someone-else's code. I went through three iterations very quickly, with a first draft that had working features but a few niggly problems. A second draft that got rid of the errors thanks to Google's superb crash reporting scheme that helped me identify real bugs very quickly and trace them down to the line of code where the failure occurred. Finally, as an experiment I decided to add advertising support to the system with a view to using it in later applications.

AdMob was easy to set up, easy to integrate and has begun generating a (very) modest revenue even though the applications only went up with AdMob on board this afternoon.

My iPhone version of the app is almost complete, I sidetracked to complete the Ad support for the original and so now its full steam ahead for the iPhone version in a few days. All I need to do is re-instate my Apple developer status which I allowed to lapse a few months ago.

After this app, I will be full steam ahead for the Windows Phone version but I see that as more of a one-day job because I know pretty much all I need to about the platform and so there will be no discovery phase for me on that one.

All in all a very smooth experience!


Saturday, September 29, 2012

Its templates all over again!


Many years ago I worked in the world of C++ developer tools and had the job of creating libraries that some other poor sod had to buy, understand and use. Through many years of doing this, I came to a few conclusions about how reusable architectures should be created and the sort of programming techniques that should be used.

Sort of in the middle of my time as a tools developer, ATL, which, if you don't know it, is a system based upon the principles of C++ templates that essentially rely on massive amounts of multiply inherited classes. Its a very "clever" way of programming to be sure but is incredibly hard to read and trying to follow program flow within a templated class is a nightmare.

I think that Anders Hjelsberg actually had recurring nightmares about C++ templates and so invented C# which is singly inherited apart from interfaces and is generally straightforward to work with and eminently readable.

One of my colleagues was a template guru. Lovely fellow, very productive and wrote nice tools but having a style of programming that just made me wince every time I read through his code. It was so esoteric and overly templatised that the whole lot of it just became a blur. The customers had a hard job understanding it too.

So, years pass and Anders decides to add some nice little language features to C#. Features that start off with generics and go on to anonymous methods, lambdas and so-on.

Today I've been programming an Android application in C# using Monodroid from Xamarin and I suddenly realised that my classes only have one method. All the event handling, asynchronous calls, and even marshalling back to the UI thread is done with lambda expressions. I am horrifically reminded of templates just simply because trying to follow the program flow through an activity that uses reverse-geocoding via Google's map APIs, progress bar indication on the phone screen and reporting to a web-service of user actions puts me in mind of the code complexity of C++ templates.

I have become my own worst nightmare!

AXML got a designer!

A while back i reported an issue to Xamarin regarding the failure of the axml (android form markup) designer. I updated this morning and lo-there was a designer in Visual Studio!

I don't know why but I find axml particularly annoying to work with when hand coding. Maybe its my familiarity with WPF that has bred contempt for it. Anyhoo, a new design time tool for Android apps is a good thing.

Friday, September 28, 2012

Apple screws up. Microsoft too, Whats up?

The recent debacle of Apple's mapping software probably has poor Steve Jobs spinning in his grave. It's exactly the type of utter balls-up that he hated and would have taken the time to deal with personally before that crap went out the door. The post Jobs era looks to be shaping up as "more of the same" corporate incompetence with lack-lustre CEOs and uninspiring products.

Likewise the failure of Windows 8 to capture the imaginations of developers and the hopelessly ivory tower approach of Steve Ballmer leaves Microsoft in the gutter again.

Where has all the passion gone from the computer business? What has happened to people with the balls to stick their necks out for a principle and to make products that inspire some sort of emotion in the user? 

I've been a professional developer for all of my thirty plus year career and I can see today that despite the incredible opportunities for technology that would make your head spin right off your shoulders, greed, desire for a status-quo and lawyer driven crapware has become the norm.

Oh for the days of Steve and Bill!

Thursday, September 27, 2012

Monodevelop and DefaultKeyBindings

Frustratingly, MonoDevelop has a custom key binding scheme such that if you come from the Windows world and expect your End and Home keys to work in the time honoured tradition you're out of luck.

I just spent a few hours scratching my head over the problem because I habitually press the end key to go to the end of a line and on a Mac it goes to the end of the document. It is possible to remap this behaviour using the DefaultKeyBindings.dict file however, MonoDevelop overrides this too and defeats all your chosen bindings once again.

So, if you want to be able to use the key bindings on Monodevelop on a Mac but retain the editing style that Visual Studio / Windows developers are used to, and why not because if you're using MonoDevelop on a Mac it's because you're used to C# development but want to write MonoTouch, then you must go to the preferences section of the MonoDevelop application and add your own preferences for those keys.

Tuesday, September 25, 2012

API changes. Someone needs a kick in the pants.

Some years ago I worked in the heady world of developer tools and learned the hard way that changes to an API that other people rely on must be carried out in a careful way. Failure to do so will result in people's code being broken or them being forced to do a lot of work and people being pissed at your product doesn't do sales any good.

Unfortunately, the newbie programmer cubs at Apple don't understand this. They obviously see API changes being a way of sweeping out old mistakes and replacing those ideas with the new-hotness of their own.

I despair of so-called "architects" who have no concept of how to maintain and develop code. Too many cub-programmers solve problems at the keyboard, that is to say that they type stuff in rather than draw a flowchart or "design" a coherent API. As a result, interfaces get changed, API's don't have consistent parameter usage, API's don't get consistent naming and so on.

Cubs are cute, they run around doing cute cub things and they are all fuzzy and lovely. However, when it comes down to the business of being a bear, the cub has a shitload of growing up to do and a lot of scars to obtain before they can be big and badass when they need to be. Hey Apple. Don't leave cubs in charge!

Saturday, September 22, 2012

Android -> IOS

Ok, rolling up my sleeves today with the idea of transferring my recently released Android App to IOS.

For me, this will be the proof of concept that creating multi-platform apps from similar base code works. How much discovery and head-scratching will I have to do to make the very simple droid app run on an IOS platform. Moreover, can I use similar techniques on that app to the ones used in the Android world?

The clock is ticking!

Low Maturity

Once again the ridiculous effects of a world run by lawyers conspires to make an innocent thing into a sordid one.

When creating an Android app, one is forced to declare a rating of "Low Maturity" if the app uses the GPS. Never mind that the app might be used solely to inform you of your own position, the implication is that use of a GPS automatically suggests use for sexual predation of some sort. Of course, when masturbating, most people like to know exactly where they are by using a couple of billion dollars worth of orbital atomic clocks to verify the position using Einstinian relativity calculations. I know I do!

Friday, September 21, 2012

C++ and C# programmers are too smart!

It seems that way anyway. I was browsing around today and discovered that Visual Basic projects in Visual Studio 2010 have the option of importing an XML document and inferring a schema using a wizard.

Of course, we C++ and C# programmers are "Real programmers" who, unafraid of the command-line interface and of the complexities of the XSD.EXE parameters are quite capable of shelling out and generating our schemas by hand. Ha! I say. What happens when the lowly VB programmers want to generate a set of classes for their schema??

MWAHAHAHAHA! We should hold all the schemas to ransom and MAKE THEM PAY FOR THE DESERIALIZATION CODE LIKE THE WUSSIES THEY ARE!!


Freeware at what cost. Part 2

You may know my stance on freeware. I'm not generally in favour of it because it degrades the intrinsic value of the programmers art. Freeware can have many purposes though. There is the purpose of pride in having created a great solution to a problem coupled with the altruistic notion that one doesn't need remuneration for  some work. There is the purpose of camaraderie, wishing to provide something interesting to like-minded people and there is the purpose of commercial exploitation when a freeware is in fact generating something that might be even more valuable than money, such as for example, trust.

The last time I offered any freeware it was in the early 1990s. I became incredibly impressed with the game Myst by Robyn and Rand Miller. It was everything I wanted in a game. Rich, challenging, enthralling and with a visual impact that brought fantasy landscapes to life, albeit in 256 colours, in a way that enabled the dullard graphics of the day to make the experience as immersive as it could be. Myst inspired me to write a wireframe scene editor that output 3D images via the Polyray and Persistence Of Vision ray-tracers that were also freeware at the time. My editor, called WinModeller was a C++ editor for shapes that had some nice features and that I wanted to use to make educational content along the lines of Myst. In the end, I got a job working for someone else and nothing came of it. Eventually, someone bought the code from me for 25,000 dollars but then didn't do anything with it because times seemed to have moved on I suppose.

Today I am offering some freeware again. I have my android apps which are on Play under the name of BPApps and I will probably create more for iPhone and Windows Phone platforms. I had not intended to choose a free model for these packages and had originally decided to make them freemium with a small payment to unlock full functionality but, really, looking at the market place and the software already available I didn't feel that I could truly justify even a meager demand for money. I may go to an ad-based monetization of later applications but these ones, which I really wrote for my own use, can be shared with like minded people and will, I hope, engender trust in my brand. Of course I wouln't be churlish enough to flatly refuse a donation or two for the code but that's at the discretion of the user. The app works well for me so I'm cool with that.

Interestingly however I do have a different angle. In developing the code for Android machines I've come up with a way of making that code very much easier for porting to other platforms. I hinted at this in March of this year when I spoke at the Software Passion conference about creating multi-platform applications. I have a nice method for doing this now and I will be releasing some tools later that I hope will generate a little revenue.

So, is free really free? Who can say. As I get older I tend to think not. Does not-free imply paying money? Nope, definitely not. Facebook is free but the currency of Facebook is in the data generated by it's users and the spinoff sales of stuff other than the Facebook social app itself.


All is vanity

I am fifty two years old and have a lot of, well, not gray, but more like white hair. I went out with a couple of friends the other day, both of them a bit older than me. Their hair is not gray, their hair was dark for one or a sort of ginger for the other. I suddenly realised that these sixty year old dudes coloured their hair! Not even a wisp of gray was to be seen on the men and especially not on the women.

I suppose that I had not seriously thought of colouring my hair in the same way that I wouldn't wear a backwards baseball cap or allow the waistline of my jeans to show a large expanse of arse, well, not intentionally anyway. Besides, my underpants, not that you're interested are not classy or make the right, if any, sort of statement.

My vanity is sort of opposite. My Grandfather, William Anderson was born in 1906 and became a granddad because of me when he was fifty four years old. At that time his hair was gray and later turned a snowy white. White enough to make a polar bear jealous in fact. My granddad was a man who was constantly interested in something, even up to just before his untimely death at the age of one hundred and two years. Granddad gave me my sense of curiosity and a desire not to waste my time. Granddad gave me Charles Dickens, Robert Lois Stevenson, Jules Verne, George Orwell. Granddad  showed me what trigonometry was for when I had berated a math teacher for being a boring twit. Granddad showed me how to ride a bicycle when my dad was working and my mother didn't care. Granddad told me that all the important things in my life would happen by complete accident which I remembered when a girl I really really fancied fell over, I helped her up and she held my hand all the way home.

I could never dye my hair or cover up the shocking gray and soon to be white that I will inevitably carry until the day I die because to do so would be to insult the genetic code of one of the greatest men on earth. My white hair is a badge of honour for me. Thanks Granddad!

Thursday, September 20, 2012

Android app crashes

I just got my first two independent Android apps up online and was pleased to see the error reporting service that appears in the developer console. My app crashed on someone's phone, I got an error report, fixed the problem and issued a release immediately.

If you're interested in my apps which enable camper-van or RV owners to find tank-emptying points, check out BPApps on Google Play.


Friday, September 14, 2012

I've told you a million times!

To enunciate "I've told you" a million times would take eleven and a half days if you did it non stop...

For really pedantic parents that tell their children a billion times not to do something, that would take about thirty one thousand years.

Donations gratefully received

Can some kind soul get me an iPhone 5?

Mono Android html asset localization

While on the subject of localization, I have created some activities of my app as static web-pages. These pages can be stored as an Android asset and loaded at runtime. This provides an easy option for creating complex layouts without the hassle of doing it all in that horribly tortuous axml format.

A static web page can be saved in the Assets directory and reconstituted using Assets.Open(...). This can present problems however because assets are not localizable in the same way that strings are. Rather than duplicating the HTML in the strings.xml files and localizing each on individually, I created a barebones file with replaceable chunks that are themselves localized.

An HTML file could contain:

<html>
<head>
<title>{TITLETEXT}</title>

here be scripts and good stuff...

</head>
<body>

{BODYTEXT1}

Here be boilerplate...

{BODYTEXT2}

</body>
</html>

Obviously the html would need to be complex enough that you wouldn't want or be able to duplicate the whole thing. A good excuse is that maintaining the same page info in one place is better than maintaining it in every localized resource file.

So, to load my HTML in I use:


            var wv = (WebView)FindViewById(Resource.Id.registerwebview);
            var sr = new StreamReader(Assets.Open("reg1.htm"));
            string barebones = sr.ReadToEnd();
            barebones = barebones.Replace("{TITLETEXT}", Resources.GetString(Resource.String.registertitle));
            barebones = barebones.Replace("{HEADERTEXT}", Resources.GetString(Resource.String.registertitle));
            barebones = barebones.Replace("{BODYTEXT}", Resources.GetString(Resource.String.registerblurb));
            wv.LoadDataWithBaseURL("file:///android_asset/",barebones, "text/html", "utf-8", "");


Et voila.. a localized HTML page that looks great, contains images also pulled in from assets, scripts, links and JQuery interactions with the backend...


Six impossible things before brunch...

This week in scientific news there have been reports of a mathematical proof to the ABC conjecture, apparently junk DNA isn't, scientists have taken a picture of molecular bonds, high-temperature superconductivity has been induced with the aid of scotch tape, a neural implant in a monkey's brain has restored decision making capability and the Higgs Boson data has passed peer review.

Developments such as these were traditionally few and far between but the rate of advancement today is reaching a truly phenomenal pace. Almost every day, a breakthrough in some esoteric scientific discipline that has far-reaching consequences for green energy, medical science, electronics and computing or some other high-profile area of study is brought forth upon the world. What we know already is being applied to discover what we need to know that the rate of actually learning the principle or truth vastly outstrips our meager capacity to use it in a practical way.

Today, a woman with a spinal injury that would have rendered her immobile for life is walking around, albeit with the aid of a robotic exoskeleton. What would that have done for Christopher Reeve? Self driving cars collaborate to show each other what's around the corner that they cannot actually detect on their own. Thought-directed helicopters, games and wheelchairs are not even newsworthy any more. Microsoft has patented a "holodeck".

I wonder what tomorrow's breakfast will bring?

Tuesday, September 11, 2012

Mono Android App Localization (part 2)

The process of app localization in any platform is exacting. Many programmers who don't have the discipline to do the job from the very beginning run into problems when the application has some strings localized and some in hard-coded characters that were put in hastily.

Android applications have a great localization scheme but some disadvantages. Here are some tips that I have learned while creating a multi-platform application. I am using MonoDroid and MonoTouch for my development

#1 Localization strings must be kept organized. Ensure that you organize the strings by activity and label the sections with <!-- XML style comments -->

#2 Do not rely on the [Activity(Label = "MyActivity")] attributes. Remove them all and explicitly set the label for the root layout element in the layout files using localized strings.


Sunday, September 09, 2012

Android Emulator battery charge indicator.

Dear Google,
I think there's a bug in the Android SDK Emulator battery charge indicator. When running the emulator on my Macbook Air, the emulator charge indicator shows charging all the time, even when the computer is running on battery power.

This presents several problems. Firstly, if the emulator takes even more power to charge itself when the computer is already running on battery power, the extra drain will reduce battery life even more. I suggest making the emulator run on its own virtual batteries when the main computer is running on its own batteries. Secondly, the process of virtualizing electrons for use in the virtual batteries obviously takes a lot of energy so this should only be done when power is applied. Lastly, and this is the really big problem. If I don't need an emulator any more and I delete it. the virtualized electrons will be erased along with the rest of the data. This will cause a net deficit in the fabric of the universe and my Macbook Air will implode. So far the unibody casting is holding up but it seems to be groaning a little and the R,T,Y,D,F,G,H,C,V and B keys seem to be bending in a bit. Please advise quickly...

Bright spot on Macbook Air screen.

Macbook Air computers have a problem. In certain conditions a bright spot, about an inch across, appears in the center of the screen. Is this due to a problem in the screen backlight controller? Is it a sign that your MacBook Air is malfunctioning? Is it a sign that your screen will soon be dead?

Apple already know about the problem and call it "Irreparable" so? How can you fix this otherwise irreparable problem for very little money? I know and I'll let you know the secret for free!

When you're sitting in the sunshine, with the sun streaming through the Apple logo on the back of the screen, Put a box of Corn Flakes in just the right place to make a shadow!

Thursday, September 06, 2012

IE 9 Dumped in favour of Chrome

For some time I've been suffering from an odd problem with my PC. The desktop provided by Explorer.exe often crashed becoming completely unresponsive to clicks. The computer would also slow to a crawl with web-pages being particularly badly affected when opened in any browser.

I did a little research online and found that Internet Explorer would sometime crash, leaving an instance of itself in the task-manager and never actually closing correctly. The consequence of all this being the aforementioned desktop freeze.

It seems that this problem has been around for a while and existed in Vista and IE8. I am running Windows 7 64 bit edition and IE9. In any case, the symptoms are identical.

I used the control panel's Add-Remove Windows features dialog to remove IE9 completely. Since then, yesterday, my desktop has remained in functioning condition and the low internet speed problems have gone away.

My default browser is now Google Chrome.

Wednesday, September 05, 2012

Should I sue Apple? Should everyone sue Apple?

I broke my iPhone. The glass on the back is utterly smashed because it fell, from a height of less than one meter, onto a tiled floor.

Actually, when you come to think about it, a mobile phone is one of the things in the world most likely to be dropped. It is taken from and replaced into pockets and bags maybe hundreds of times a day. I don't make a hundred phone calls but I do look at mail, send messages, check sites, use maps, scan QR codes etc. etc. all the time.

I had an iPhone 3G which I bought in 2008 and used until recently. My wife smashed her iPhone 4 by dropping it while sitting in an armchair, it fell less than a meter and I had to replace the screen and the back.

Apple, in my opinion, have not made sufficient effort to render their smartphone product robust enough to cope with normal every-day usage. If a car manufacturer built a car that screwed up during normal every day use they would be forced to recall and fix the defective product. I want my phone fixed!

Monday, September 03, 2012

Cathedral or bazaar?

Many years ago I took a position against open source software. Why? well, quite simply, as a pretty much full time freelance programmer since the mid 1980s I've come to have an appreciation of the value of the effort that I put into writing code. My attitude was at the time that open-source software eroded the value of the brainpower that it took to generate an elegant algorithm and do reduced the worth of my own brain as a money-making device.

Now, people say that its very possible to make money from open source. Well, this is true, however not because open-source code is a saleable item but because a lot of it is so poorly usable that consultants make a stack just by being able to troll through and understand poorly documented and esoteric code. If open-source is so fantastic, why then is Linux in all its various forms not viable competition for Windows? A few years ago, PC manufacturers began releasing PC's without an operating system or even with Linux pre-installed. That seems to have fizzled out and now Windows 8 running on ARM chips will absolutely be king of the hill for the next little while.

I will not deny that there is open source software that is great. Unfortunately, a lot of it has been produced by big rich companies specifically to piss-off someone else. There is for example no reason whatsoever for Open-Office except that Larry Ellison wanted to erode the sales of Microsoft Office as much as possible by providing a free alternative that does pretty much exactly the same thing. Later of course he tried to cash in by making Open Office a commercial product, thereby giving the lie to all his previous open-source rhetoric.

Code released on CodePlex is generally not created by altruistic chaps starving in garrets for their art, but as a by-product of the many tracks of development effort that Microsoft starts and deprecates but decides not to waste entirely. People piggy back onto that too.

My own code released on my site at http://www.bobpowell.net was, for a decade, not entirely an altruistic effort to share my knowledge, I do enjoy doing that but I was very conscious of the fact that my efforts in that regard netted me an MVP award that didn't injure my career one iota, nor did the free access to MSDN Ultimate which is a bit outside of my pocket-depth.

Spooling forward to today then, how has my attitude to open source changed? Well, I am very interested indeed by open-source hardware and resurgence of maker culture that was an important part of my early life. When I started in programming, unless one had a rich mummy and daddy, getting a computer like an Apple II or Commodore PET to program on was not easy. I built my first Z-80 based computer from scratch on hand-soldered boards and with TTL chips that I reclaimed from boards dumped by a nearby PLESSY factory in Cowes Isle of Wight. Today, Arduino and Raspberry PI and other systems are providing a cheap and accessible doorway into a world of electronics and programming that had become progressively more closed and software-commodity based as the years rolled on. Today, you can build your own electronic gizmo again with hardware designs that are easily understood and programmed. I see that as an important form of education in a world that has bred the ultimate dumbass consumer.

My belief is that the role of the professional programmer will diminish over the next ten years as software begins to write itself using genetic algorithms. The process of specifying what is actually required by the software will become declarative and the actual process of creating the code will go away. People will need to find interesting things to do apart from work and it is important not to allow the machine to become its own closed domain. Open source as a work practice may have failed in my eyes but open source as a way to interest people and steer them away from unquestioning consumerism might just be a success.



Thursday, August 30, 2012

3D Printing and the cassette tape.

When I was in my teens, cassette tapes were very popular. You could make your own mixes and carry them about with you. You could share music with friends who couldn't afford to buy. Some people made copies of whole albums to sell on for pocket money. Cassette tapes were cheap and you could buy a C120 tape, take it to bits, cut it up and make four copies of Dark-Side and spool them into equally cheap empty cassettes. This was the beginning of what later became Napster, Bit-torrent and peer-to-peer hell.

3D printing, if you don't know, is the process of laying down layers of material to build up a solid object in slices. Most of the 3D printing systems of today have been created from an open-source hardware perspective where people create the equipment from their own ideas or ask other people who have already built a printer print up parts to build a replica.

The raw materials for printing at the moment are usually some sort of thermo-plastic that can be melted in a nozzle and squirted into place to make the layers. Some experimental setups are using ceramic materials and there is a great deal of interest, especially in professional engineering, in using arc and MIG or TIG welding techniques to build up solid metal objects. For those who have a smelting facility or a little foundry, wax is a great medium for creating the objects which can then be cast in a lost-wax process.

Possessing a 3D printer is one thing, having something to print on it is another. Most hobbyists are also geeky enough to be able to run some sort of computer-aided manufacturing tool but unless you're a top-flight  engineer you won't be printing gas-turbine engine blades or disc-drive parts. However, given a suitable design, and even tough what you can print today is limited to materials like APS plastic there would be a possibility of printing something almost indistinguishable from the same doohickey bought in a shop. Given a bit of investment you could probably print yourself a shoe today. In the not too far distant future, you will probably be able to print yourself the latest Nike trainer, and indeed, it's other-foot partner.

Given that 3D printing is a huge open-source movement today and that commercial printers don't have data standards that can "DRM" a Nike shoe, what's the likelihood that many companies will subscribe to a common format, that printers will become mainstream enough that no one will build their own and that data files will become a commodity?

My own opinion on those subjects are that a single standard is very unlikely, at least in the short term. 3D printers will take hold first as a high-street shop service and then become cheaper home gadgets later. One thing is for sure though, if you have a not-very good lathe, you can use it to build yourself a better lathe...This is to say that the process of bootstrapping a printer from a crummier printer is definitely possible and in a few iterations you could have a very good printer indeed. This means that there will be a burgeoning market for high-quality object files that can print stuff of all sorts. Ultimately of course, you truly will be able to print parts for your own jet engine but that day is a ways off. Until then, the open-source hardware movement will have an opportunity to re-open the old Cathedral and Bazaar debate all over again.




Mobile ain't the word for it!

I have a great big American style camper, what is called an RV or Recreational Vehicle in the US. Anyone in Europe would just say WOW or Blimey! Look at that!!

My RV is an old Gulftream Sunclipper and is incredibly lo-tech. Big solid engineering, no finesse and a SIX LITRE motor. The Sunclipper has a nice roomy bedroom, which, if I must be honest, is actually more comfortable and with better storage space than my own bedroom in the fixed-down house. It has a gas furnace to deliver heated water and hot air for cold nights. It has an air conditioning unit that will suck the heat out of a small star and a self-contained kitchen that will cook just about anything as well as having the usual shower and loo.

Last week, I had a quick job to do down past Saint Nazaire in France so I took the whole family, piled them in the bus and off we went. Chrissy and the kids all hung out at the beach and I went to work for a few days doing tech stuff. Of course, in my line of work it's of huge importance to be well connected so I have converted part of my storage space to a sort of server room. I have a PC which has a 3G dongle, WIFI on board, a printer and other good stuff.

I think I just became a techno-gypsy!



Monday, August 27, 2012

Recaptcha just getting RIDICULOUS

Several times now I have attempted to sign up for various sites and have come to the conclusion that the recaptcha is going too far. It often takes me five or six attempts to get one right and when the web-page resets all its fields if you happen to get the verification code wrong then it becomes enough of a pain not to sign up at all.

These dudes need to throttle back on the zealous obfuscation of the words because people want users to sign up for their sites. Not be frightened away.

The top image is one I stripped from the very first example on their site. Totally unadulterated.

The bottom one is what it looks like to me...


Saturday, August 25, 2012

Neil Armstrong

One of the most important people in the history of the entire race.

A great hero of mine and an inspiration to many.

We can only ever follow his footsteps.

VirtualBox greatly improved running on MacBook Air

You may remember that I bought myself a Macbook Air earlier this year. To run Windows (I do program Windows now and again) I installed a Windows 7 OS on Oracle VirtualBox.

For earlier version of VirtualBox I was unable to allow the MacBook to sleep by leaving it or shutting the lid because the machine would lock up completely, effectively bombing the OSX as well as the virtual box.

I recently updated to the 4.1.8 R78361 version of VirtualBox and I'm happy to report that the problem has gone away. Closing the lid and sleeping the machine no longer has problems for either the base OS or the hosted one.

French language pollution

I just saw an online ad that had a button on it that read "Commencez shopping"

Interesting because "le shopping" is a rather nice mixture of language pollution and faux ami. A faux ami in French is a word that phonetically sounds great but means something else.

Chope, pronounced the same way as "shop" means to catch but in French is more often a euphamism for screwing someone.

Pierre: eh- tu sais- J'ai chopé ma voisine!
Albert: Sans blague? Fuck dude COOL!

Let the chopeing commence!


Climate change a touchy subject but not why you think.

This story from the BBC suggests that only two percent of Canadians deny climate change. Well, according to the World Health Organization, more than two percent of people are clinically insane and probably want to marry their underpants! Go CANADA!!

Disclaimer. I do not deny climate change. Its FRIKKIN AUGUST AND I AM WEARING A SWEATER!

Post Disclaimer. I am NOT Canadian but sometimes I wish I was. Plaid looks GREAT on me!

Post post Disclaimer. I am not insane. In fact I am the only sane person in here!


Thursday, August 23, 2012

Elementary my dear House?

Expert systems for medical applications have been proposed and indeed have shown some measure of success over the years. I remember the principles of these cleverly indexed databases being used as long ago as the 1970s. That's almost equivalent to the Cambrian period in the evolution of the computer.

IBM have announced now that the computer system known as Watson that beat the best players of Jeopardy last year on U.S televisions is being re-purposed to absorb, index and understand medical texts so that it can bring to bear its vast capacity for sorting out wheat from chaff to the domain of medical diagnosis. The team in charge of Watson, or should this version be named "House"? is currently feeding it as many medical text books, case studies and even individual patient follow-up reports as they can in an effort to have this AI indexing and recognition system winnow out the grains of goodness in medical cases.

Right now, the software that defines Watson runs on a rack of ninety POWER7 processors that each have an eight-core processor running four threads per core to give a total of 2880 parallel processing engines. Jeopardy was a very public publicity stunt and proof of concept that was masterfully managed by IBM to bring the concept of intelligent computers to the masses. After all, the awareness raising exercise that was Deep Blue didn't exactly bring the cause of AI into the home of the common man. Jeopardy however was a bread-and-circuses coup that made anyone who was a fan of this esoteric and long-running game show format very well aware of what a computer could do.

Today, a top of the line smartphone has a four core processor and 32 gigabytes of memory on board. LG have already released a quad-core phone, My money is on the new iPhone and iPad getting a quad-core processor and Moore's law still holds true. This means that in twelve years we can envisage a handheld device as powerful as the Watson system is today. I'd like to propose a new law also. The Kurzweil Compression law that states that time for advancement in technology becomes more compressed as technology itself advances. According to the combined Moore/Kurzweil effect, that twelve years may shrink to ten or fewer.

A human being is as dumb as his lack of access to knowledge. On a conversational level, you or I could chat with and even hold a lively and interesting conversation with a Cro-Magnon person from forty-thousand years ago. Had one of us been brought up in a world as devoid of solid knowledge as they had, we too would be considered primitive and would not know anything about simple math or simple aerodynamics or simple electricity or cooking in an oven or making of cloth and so many other things that make us "civilised" If you took a person from that time and taught them to read, gave them a smartphone and a broadband connection then they too would be capable of confidently discussing aspects of the modern world that they discovered through that medium. In ten<?> years. Any person on the planet will have instant access to any aspect of knowledge that they desire to absorb.

Just like the Cro-Magnon person, there are so many things beyond our mundane experience that even having the concept of an idea or a technology or a novel use for treacle is utterly unthinkable. A case in point is the discovery of Graphene. Andre Geim, the Nobel physics prizewinner had the interesting idea of using Scotch-tape to pull the stratified layers of carbon atoms in graphite apart until he arrived at a single layer of atoms. Blocks of Graphite and Scotch tape have been around for many many years. Why didn't we have Graphene decades ago? Access to the wealth of ideas that inspire people to do things differently based upon what is known to be possible or thought to be impossible is where the Human race excels. There isn't enough room in any one person's brain for all that knowledge but an expert system in your pocket will give everyone a huge boost.







Wednesday, August 22, 2012

Android TextView accented characters

I have a list of addresses for various places in Europe that I am incorporating into a Monodroid application and have had little success in getting TextView to display characters with accents.

I saved the file in UTF-8 and in Visual Studio, the file opens fine and the accented characters display correctly. However, opening the file from assets or from an embedded resource stream and then showing it as text in a TextView was driving me mad because it refused to show accented characters in the final screen.

Here's how I fixed it:

#1 Ensure that the values are saved as UNICODE. Do this by opening the file in Notepad and saving plain text with Unicode encoding. Even though your file looks like its encoded as UTF-8 the Android device won't like it.

#2 Embed this file into the assembly as an EMBEDDED RESOURCE

#3 Load the file using GetManifestResourceStream

#4 use a StreamReader to wrap the resource stream and declare new StreamReader(theStream, Encoding.Unicode);

The standard Android fonts all handle unicode character sets.


Monday, August 20, 2012

Prophecy of Star Trek

Bones held the medical Tricorder up to the patient. "Jim, this is an acute case of postprandial upper abdominal distention. We have to do something now or she may barf!"

Back in the late 1960s the vision of Star Trek with its sliding automatic doors, beamed energy weapons, remote sensing and remote manipulation with "tractor beams" introduced many ideas to the young minds of people who were destined to become engineers, doctors and, yes, astronauts. It seems that almost nothing proposed by the series is too fantastic to actually come up with real-world engineering solution for.

The Magnetic Resonance Imaging scanner for example is a wonder of modern medicine that relies on being able to detect the "ringing" left over in atoms after they get thumped with a magnetic pulse. With MRI we can look into brains and bodies to discover what is going on without touching the patient with anything more than a magnetic field that penetrates skin and bone as if it were air.

Today, a robot car is on Mars, blasting rocks with a laser gun to enable scientists to analyse the elements in those rocks. Today, you have a cellphone that does far more than Captain Kirk's Communicator and that same cell phone would be the envy of Mr Spock's talking computer.

There is even an X-Prize for the first working medical Tricorder that will scan people and diagnose a few illnesses in the same way that Doctor McCoy's Tricorder diagnosed the Horta in "Devil In The Dark"

Science fiction is more correctly known as Speculative Fiction. The Sci Fi image of over-the-top geek fans in costumes belies the fact that many science-fiction authors are themselves scientists and have a pretty good idea of what is actually physically possible in the universe as we understand it. The speculations of Star Trek have been coming true with alarming regularity over the past four decades. There is no real reason why at least some of the more esoteric ideas shouldn't also be realised.

In the Star Trek universe. Money is no object to human advancement. Riches come from knowledge and power comes from an ability to command respect. In "Shore Leave" the objects of desire of the crew were manufactured on the spot without even the mention of price. An antique gun, a World-War II fighter aircraft, some rather comely lady robots and many other luxury items were conjured up with nothing but a few watts of power spent in the process.

Thousands of years ago, brass foundries were the height of technology and the metallurgists who worked them were the kings of commerce and power. So much so that the bronze axe head became currency because they were precious, difficult to produce and sufficiently rare to have an intrinsic value. These objects were useless as axes but were used as currency for a while. When the art of making Bronze became more common and the ways of casting the metal became commonplace too, the bottom dropped out of the bronze axe-head market and they fell out of use. Meanwhile, hordes of axe heads that had been buried, possibly for safe keeping remained forgotten and useless in the ground.

Soon, money will be as useless as the bonze axe-head. Coins and banknotes will be an intriguing memory of times when people exchanged tokens for goods. When goods were laboriously made in factories and shipped all over the world instead of being printed up from a reservoir of atoms that are lying around. The only real cost will be the cost of electrical power and that will all be free anyway, gathered from the sun or made in cheap and inexhaustible fusion reactors here on Earth.

For the moment, money and commerce remains but it will go away. It must because there is no logical reason for it to continue, just as the bronze axe head became simple to replicate in days gone by, so too will the tokens of modern commerce become simple to create in a home based molecular printer. Counterfeiting will become as simple as scanning and printing is today despite the phenominal resources governments put into anti copying measures.

For the moment I'm a computer programmer but I know with confidence that soon, the computers will all program themselves. You, I, and indeed everyone else has to find a different way of doing things. Get busy, the Singularity is coming.


Sunday, August 19, 2012

Watch Julian Assange

http://www.bbc.co.uk/news/uk-19310335

If your government is responsible for torturing and detaining its citizens without trial for speaking out against wrongdoing by the rich and powerful people that are behind almost every law that affects you then you should watch this and support the cause.

Write to your politician and tell them that detainment without trial is illegal and that it must stop. If your politician does now or ever has supported gagging the press or detaining prisoners without trial or has been involved in such wrongdoing forget all the political shenanigans about healthcare plans and taxes. Vote to stop oppression even if it means voting "none of the above".

If you don't, the next time you disagree with something your response may come from a tear-gas grenade or a truncheon. Not from a government THAT WORKS FOR YOU!