Thursday, January 19, 2012

Kodak, a case of the Xerox's

When Bill Gates was a young programmer he worked for Steve Jobs and Apple. This was when Apple had begun work on the Macintosh and the first commercially available GUI.
Apple didn't however invent the Windows, Icons, Mouse and Pointer WIMP system. Xerox did at their PARC facility in Palo Alto where a young Steve Jobs was mooching around seeing what the big boys were doing.

The truth was that the bosses at Xerox didn't think much of WIMPS and thought it was a stupid gimmick. Certainly no good for real computers so they basically let Jobs walk out with the ideas for free. Later, after Microsoft had developed Windows 1.0 Jobs let fly at Gates, accusing him of robbing ideas from Apple whereupon the shrewd Gates replied along the lines of: "We both went into our neighbor's house to rob him. You got the television and I got the stereo"

Kodak were one of the first companies to develop digital imaging. The bosses of the company however were confident in the fact that film emulsions would always be higher resolutions and richer color than digital sensors could produce. Oh how wrong they were and how much that lack of foresight cost them.

There must be a moral to this story somewhere. Perhaps it is that no boss should ever let go of his options when it comes to an interesting but seemingly unpromising technology.

ASP.NET button mouseover image change in javascript

The story so far: I wanted to do something very simple. I have a web-site that needs multi language capabilities so, I store all my site text in a database and pull it out using the country code of the client browser. This means for example that I could have a button with "About" in English and "A Propos" in French. I also wanted a mouseover effect for my buttons to provide a little bit of visual feedback so I created button background slices with appropriate blank backgrounds with the intention of updating the button text in the manner mentioned above.


Well. An ASP.Net image button does the mouseover just fine but not the text. It can't have text. With a little bit of cajoling one can make the ASP.net Button control have a background so that one can indeed update the text. The problem was that there seems to be no way in the world to make the mouseover behaviour work with the Button control. Not using Framework 4.0 anyways.


Microsoft recently modified the way attribute encoding is done in Framework 4.0. This means that if you if you put something like:

onmouseover="alert('boo!')

The 4.0 framework however encodes this as:

onmouseover="alert(&#39boo!&#39)"

I have no clue why but if you start the web project as framework 4.0 and use javascript inline, the server falls over at the encoded apostrophes. If however you switch to framework 3.5 and then back to 4.0 again, something magic happens and the javascript sees the &#39 as an apostrophe.

In order to make my ASP.Net Button control with image background mouseover behaviour work correctly, here's what I did:

#1 Switch the project to framework 3.5 then back to Framework 4.0 
#2 Declare your button:
<asp:Button ID="AboutButton"

Style="background-image:url('images/aboutoff1.jpg'); text-align:left; background-color:Transparent; cursor:hand; background-repeat:no-repeat; background-position:left; font-family:Verdana, Sans-Serif; font-size:28pt; font-weight:bolder;"

Runat="server"

Height="53px"

BorderStyle="None"

Text="About"

Width="352px"

#3 declare your mouseover behaviour in javascript
onmouseover="document.getElementById('ctl00_AboutButton').style.backgroundImage='url(images/aboutover.jpg)';"
onmouseout="document.getElementById('ctl00_AboutButton').style.backgroundImage='url(images/aboutoff.jpg)';"/>

Summary
Traditionally, asp.net controls have been a bit closed but relatively easy to coerce. A bit of wc3 compliant Javascript helps out enormously when the ASP control of choice needs a tweak. Ok, one could roll up one's sleeves and write an ASP.net custom control and render the HTML yourself with no problem but it so much easier to mix and match ASP and javascript.

Sunday, January 15, 2012

Star Trek X-Prize

Well, it had to happen. Strangely I was just expounding the possibilities of such a device to my wife, Chrissy, just a few days ago. Qualcom and the X-Prize organisation have put up a ten-million dollar prize for the team who succeeds in creating a "Medical Tricorder" similar to the type used by Doctor Leonard McCoy in the original Star Trek series.

The device should weigh no more than 2.2 kilos so bulkier than that of the good doctor, should be able to scan and analyse a patients vital signs and to diagnose fifteen conditions over a short period of use.

My own view is that this sort of device is well within reach without a vast amount of research. Given that modern smartphones sport multi-processor CPU's, huge memory, internet connectivity and are already packed with peripherals I see no problem in adding to the range of peripherals available and getting the prize.

I would begin with a normal smartphone architecture, add an infra-red camera, an ultrasound that could do scanning using the accelerometers for position referencing. I would interface in an add-on wrist sphygmomanometer (blood pressure doohickey)  via a bluetooth connection, similarly a blood-oxygen clip to go on an earlobe. A super sensitive microphone and a nice DSP for listening to lungs and heartbeat with decent frequency analysis software for listening to heart valve noises, gas analysis and a set of really good macro lenses for looking into eyes that  could even double as a microscope.

Imagine all that in a SIRI style relationship with a back-end system capable of doing differential diagnosis based on the experiences of a nice fat medical database and you're done!

Hey, somebody give me a job running the team and I'll snag the prize for you!

(Seriously!)

Saturday, January 14, 2012

Virtual Box VM portability

I am researching possibilities for my new portable development setup that I will be installing on my new laptop. Experience has shown me that weight and battery life are more important than processor power for laptops I use in demos and presentations so I have ordered a Macbook Air 13" system.

I will be leaving OSX intact on the machine and probably dual-booting Windows 7 too but as an experiment I looked into the issues of using virtual machines copied between the two OS's by copying my Windows 8 Developer Preview VM from the PC to my recently upgraded Mac Mini to see if Virtual Box could indeed run a straight copy on both systems.

I can happily report that it does, however there is a small problem of keyboard interaction inasmuch as the VirtualBox VM running on the Mac doesen't seem to be getting the same scan codes from the keyboard via the Mac as it does via the PC. The VM on the Mac will not respond to the Start key for example and so it can be problematic switching applications in Metro on the Mac based VM.

I'll continue to do more on this as time goes on but if you have any experience in theese matters please feel free to comment here or to send me a friend request on the facebook link seen on this page where we can discuss your experiences in more detail.

Thursday, January 12, 2012

The shame of Apollo

There are ten billion earth-like planets in our galaxy and we haven't even got a moon-base! The US have dropped the ball by doing ultra-safe ultra-expensive space exploration and have lost thirty years of initiative that we could have had to safeguard and enrich our species.

Great Mango video tutorials here:

http://channel9.msdn.com/Series/Mango-Jump-Start/Mango-Jump-Start-01-Building-Windows-Phone-Apps-with-Visual-Studio-2010

Friday, January 06, 2012

Code Year

This is a great idea. Shame its just JavaScript though. This is something I've thought necessary for a long time. Perhaps something more generic would be a useful thing to do as well.

I've been following the progress of the RaspberryPi foundation as you probably know. The UK government was roundly chastised by Sergey Brin for failing to ensure that high school students had programming skills. I've been desperately trying to convince my son to program rather than play games all weekend and I am utterly convinced by the argument of "Program or be programmed"

I might follow it just to see.

Wednesday, January 04, 2012

Its all just ones and zeros

Visual studio 2010 running on Octogig editing an Android app using MonoDroid.

A second instance of Visual Studio editing an Arduino project

A virtual machine running Windows 8 and a new Metro sample in development

MonoDevelop running on the Mac doing the iPhone version of the aforementioned Android App

I never got diversity like this working in a bank!

Tuesday, January 03, 2012

Welcome to 2012! Granular Programming.

First of all, I wish a happy and prosperous new year to all readers. Here's hoping that 2012 will be far less "interesting" than 2011 was. I guess we can only hope?

So, today's topic is "granular programming" which is a term that does exist at the moment but which I believe is the term that is underused in the context of modern software architectures.  For some time now, I have been using a technique which I like to call granular programming in which metadata and declarative programming techniques allow the construction of a working architecture from objects that may not seem to be related to one another at first.

A prime example of this is something that you may be aware of may not use in your day to day work simply because it's built into the .net framework, and has been since day one and that functions very well on its own, most of the time with no intervention whatsoever from you.  I'm speaking of the type converter system that in .net enables conversion of some binary value such as integers or floats to a string of characters suitable for editing in a TextBox and back again from a string of characters to a binary value.  Types in .net are often associated with the type converter specifically designed for them at a very low level.  Often, in the framework code itself, the association of a type converter with some low level type has been made in advance by Microsoft.

When a type converter is needed by the system it will be loaded, used and then discarded automatically in response to a specific need.  In code, we can specify which typeconverter is required using the attribute designed for that purpose.  In WPF, we can specify a static, or dynamic, resource in XAML creates an instance of our "helper class" which is then used by the rest of the code.  A great example of this in WPF would be a value converter.

This type of "on-demand" instantiation of helper classes is something that I use in my own code more and more.  One interesting aspect of this principle if that its possible to create applications that can be reconfigured and extended without recompiling the application itself.

I will come back to this subject in the near future up in the meantime, if you have any ideas or comments about this subject please feel free to voice them here.