Mistreating a Surface Pro 3

My Surface Pro is really coming into its own now. Folks I know who have purchased new ones recently seem to have a very high opinion of them. None of them are complaining of the issues that I had a while back. Perhaps recent firmware updates have sorted out the problems I was having with suspend and resume. 

So for the last few days I've tried something new with my poor device. I've been treating it abominably.  Up until now I've been very careful about starting up and shutting down and docking and undocking. But recently I've given up on that. I've been snapping the machine in and out of the dock and just closing it when I'm done and opening it up again when I want to work.

It seems to work really well. In fact last night I went a bit too far and undocked the machine while Adobe Lightroom was still running and connected to an external drive. That caused Lightroom a few problems as its universe collapsed around it, but the Surface took it all in its stride. 

The one major difference in my approach is that I'm very careful not to interrupt the machine when it is sorting itself out on startup. Previously I'd press the power button, not see anything happen and then press and prod other buttons. I'd also probably press the power button and close the cover and generally do things that confused things. 

I'm much more careful now. If I want it to shut down I just close the cover. When I open the machine I check by touching the Windows button to see if the Surface is trying to wake up. I get a buzz from the haptic feedback motor in the machine if it is doing something and so I just wait for things to appear, which they have done so far.

I hope this post doesn't jinx things, because at the moment the machine is completely living up to the promise it had when I bought it.  

Getting Started with LittleBits

I'm turning into a bit of a fan of littleBits. They are a bit like Lego, but for electronics. They are rather hard to get hold of in the UK at the moment but I reckon they are worth the effort. Each of the "bits" has magnetic couplings on it that let you snap it to other bits and pass electrical signals around between them. It is intentionally very simple and works very well. 

LittleBits started off making simple circuits which have lights and dials and stuff, but based on the success of those kits they've branched out to make lots of other devices.

While I was in the 'states last year I picked up a Korg synthesizer kit. This is awesome. It lets you make the most amazing sounds.  I'm sure there are computer programs you can use to make these kinds of noises, but for me there's nothing like wiring things together and making sounds with them "the hard way". If I was making a space shooter game I'd definitely be using this kit to do all the sound effects. There are even people on the web who have recorded musical pieces using this simple hardware. And some of them are very good. 

Because each of the bits is compatible with all the others you can plug the sound generation components together with other sensors in the kits and make things like touch controlled musical instruments.

I've been playing with the bits for a while now (I've even got them talking to Windows Phone). In the next few weeks I'll be putting out some posts that tell you how.

Failing Properly

There's nothing like writing a program to get you thinking about how to do things properly. My Magic Marker program is one such example. Turns it it is possible to use it incorrectly. If a file is open when you try to save it (because you've got the spreadsheet open in Excel for example) the save is doomed to fail. Above is the message that you see if you try to save in this situation.

private bool saveEverything()
{
    try
    {
       // write the file
        }
    }

    catch (Exception e)
    {
        System.Windows.MessageBox.Show("File error: " + e.Message,
            "Magic Marker");
        return false;
    }

    return true;
}

This the code that makes it happen. It catches files exception and displays it. It then returns false to indicate that the save has failed.

I've also written the program so that it automatically saves the data when you exit it, which seems sensible. It's what most people will expect to happen these days. But if the save fails when you exit you get this message:

This is the best (i.e. least worst) way I can come up with for dealing with this problem. At least it gives the user the chance to go back and fix the problem (for example they might not have entered a valid mark value which is stopping the save from working).

private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
{
    if (!saveEverything())
    {
        if (System.Windows.MessageBox.Show(
        "The file save has failed. Do you really want to exit?", "Magic Marker",
         MessageBoxButton.YesNo) != MessageBoxResult.Yes)
            e.Cancel = true;
    }
}

 

Here's the code that makes it happen. This is the event handler for the WindowClosing event for the application page. It tries to save everything and then, if the save fails, gives the user the option to cancel the exit. I've tried to make the answer options (yes or no) directly match the question. 

The only thing I'm not completely happy with is that it is possible for a programmer to use my saveEverything method and ignore the situation where the method doesn't work properly (you don't have to use the result of a method call).

Ideally saveEverything should rethrow the exception or not catch it and rely on the caller to deal with the problem. However, in this case I'm happy to keep things comparatively simple. 

Spell Checking in XAML applications

When I was writing my Magic Marker application I wanted to make my notes input box spell checked. Turns out that this is really, really easy. This is the XAML for the notes texbox. 

<TextBox Name="NotesTextBox" Width="500" Height="315" AcceptsReturn="True" ScrollViewer.CanContentScroll="True" TextWrapping="Wrap" SpellCheck.IsEnabled="True"></TextBox>

I just had to add the one extra property (that I've highlighted above) and it works a treat. 

VISR Virtual Reality from Hull

Visr is a Hull based product development aiming to bring a bit of "other worldliness" into your life. It takes the idea popularised by Google's "cardboard" project and moves it on a notch or two, with the aim of making a properly durable personal virtual reality device powered by your phone. 

It arrives ready built, so you just have to drop your smartphone into the end and set out to explore the new worlds that developers in Hull are working away to create. It looks very interesting, perhaps we should have a "Visr games" section at the next Three Thing Game. 

I've signed up (always one for a new gadget me). You can find the project on Kickstarter here.

json2csharp is magic

Json (JavaScriptObjectNotation) is a really popular way to pass information around on the internets. Lots of services will serve up lumps of json for your programs to munch on. It works very well with JavaScript (which is not surprising) but in the strongly typed world of C# (a great place to be in my opinion) it is a bit of a pain, because C# likes to have proper classes to back up the contents of the Json strings. 

That's where the wonderful json2scharp web page comes in. Grab the chunk of json that you get back from the service (in this case I pulled it straight out of the string in my app while debugging with Visual Studio) and paste it into the window at json2csharp.com and it will spit out all the class definitions that you need.

You can then paste these into your source code and hey-presto, you have all the types that you need to read and work with the json formatted data you just received.

Wonderful stuff.

Robs Magic Marker

In December last year we spent a happy four days marking first year coursework. I'd printed out a marking sheet for each student and we sat down with each one and went through their programs filling in the marks. At the end I had around 200 forms that had been filled in during the marking, the next step is to enter these into the assessment system.

This seems like the hard way to do it, and it is. But it is the only way that I can check to make sure that all the grades from the different makers line up and that every student gets appropriate feedback.

Imagine my joy when I discovered that when I created the assignment on the university assessment system I'd accidentally selected the "anonymous marking" option. This means that the submissions on the system are, ahem, anonymous, not in an alphabetic list like the one that I'd carefully created. And there's no way that I can "de-anonymise" them. So now I have to sort all my paper sheets into numeric order and then run the risk that I'd get things mixed up.

Fortunately I'm a programmer and so I reckoned I could fix this. Turns out that "anonymous" means "indexed by student number", which is something I can easily obtain for each student. And the submission system has a "bulk download" option so I can bring down all the submissions and then fiddle with them on my computer.

I've ended up with a little program that does all the heavy lifting for me. It gets all the entries, matches names with numbers, lets me enter comments and generates the marking spreadsheet ready for upload into the system.

It took me a morning to create (which is around the time that it would have taken me to sort the paper copies) and I can use it with the assignments from now on.  Sometimes you do get progress from your mistakes.....

Update: A sharp eyed reader has spotted that my cunning technique makes a bit of a mockery of "anonymous marking" as it turns out I was able to map the submissions onto the students with just a bit of C#. That's true, and any member of staff who wanted to could find out the author of a so-called "anonymous" work. However, we don't use this technique to prevent this kind of bad thing. Instead we use it to prevent "unconscious bias".

I was not a fan of anonymity when it was introduced, I saw it as a criticism that implied I might be inclined to victimize particular students if I knew who they were. However, it is not like that at all. If I know Fred, and I'm marking Fred's work, then I'm going to bring to the process all my knowledge of what Fred is like. If the mark I come up with is a bit low, but I happen to think that Fred is quite good, I might inflate it to compensate for this. This is unfair. Fred should get the mark the work is worth.

If all I see is the student number when I'm marking it is much less likely that I'll know  that it is Fred who did the work, and the mark I come up with will be impartial. 

In this case we mark the work in front of the student and so the question of anonymity does not arise. The student is in a position to discuss the mark that they have been awarded to make sure that justice is done, and so I don't see a fairness problem in this situation. But I'd never use it to break "proper" anonymity as this actually makes my job more difficult. When I'm marking exam scripts I much prefer not to know who wrote them, this makes it easier to just focus on what is in front of me. 

The Quest for a Tidy Desk

One of my more sensible resolutions is to have a tidy desk where possible. I tried this before and it worked well, until some kind of task based entropy kicked in and things got all untidy again. But today I started with my "making things" desk and it is now a lot more tidy, as you can see above. . 

The idea is to have enough storage space so that I can get something out, work on it and then put it away before moving onto the next task. We'll just have to see how this goes. When I get my office desk tidy (which is presently such a mess that I'm too ashamed to post a picture) then I'll be able to say that I've cracked this one. 

Exploding Robots

So I fancied having a go at building one of these Sainsmart balancing robots. But I wasn't sure how hard they would be to build. So I hatched a cunning plot. Get one for each for myself and number one son as Christmas presents and then, once he had built his and got it working, carefully copy it. 

The plan was working very well until a wire came off my robot and rather than providing a nice friendly 5 volts to the robot controller it delivered a much more unpleasant 11.3 volts. This did not end well. The voltage surge took out the Arduino board, the radio receiver and the gyroscope. Around ten pounds worth of damage. Wah. 

The good news is that the spares arrived today and my robot is now back on his wheels, lurching around the kitchen under sort of remote control. Getting the robot to balance was a bit of a challenge, my top tip is to just use the values given at the end of this video

I'm looking forward to adding a few more features.  Ideally I'd like to make him self tuning, or at least be able to tune the PID loop using the remote control rather than the fiddly trimmers that are supplied.

The kit is good value, the components are good quality and you get a lot of them. This would serve as the basis of a lot of interesting projects. 

Roundabout is Crazy-Wonderful

The Roundabout game is completely crackers. You play the role of Georgio Manos, 'arguably the world's most famous revolving chauffeur'. Your job is to drive a bunch of wacky characters around the town of roundabout using a constantly rotating limousine.

The game is a fantastic example of how an interesting movement mechanic (timing the moves of your spinning car around obstacles including, er, roundabouts) has been used as the basis of a weird but wonderful narrative built around the strange folk who want to be taken for a ride. 

The whole affair, from the knowing dodginess of the acting to the crackers story, is a delight. You'll play through it in an afternoon (at least that is what number one son did) but there are missions aplenty once you've finished.  You can find it here.

Greeting Card Conundrums

card.jpg

So I'm tidying up at home today (it does happen) and I come across a box of Christmas cards that I bought last year and never sent. Oh well. 

Last year I got everything wrong. I bought a whole bunch of cards and then didn't get around to writing them. Then I noticed that some folks around the place were not writing cards this year, but instead donating to charity and sending round an email . So I thought I'd do the same.

Then the Oxfam web site crashed half way through my transaction and I wasn't sure whether I'd donated or not. By the time I got a bank statement that confirmed the money had moved it was too late to send any messages around. So I looked like I'd not even tried.

So this year I did things properly. Cards were written and delivered around the department (I was especially proud of how I wrote them in the order of the offices in the corridor so I could deliver them in one pass) and I've also made a donation. I had just enough cards too. (or so I thought until I found this extra box). 

Amiibos United

My retirement plan. Probably.

My retirement plan. Probably.

I blame Adam for this. During the build up to our Super Smash Bros Christmas Bash he was waxing lyrical about the amiibo models and the way that some of them are quite collectible as Nintendo (who cut their business teeth selling trading cards) have stopped making them already. The one I really wanted was the villager, along with the Wii Fit trainer. I got the pink one because I thought it looked cute. 

Now I get to agonize over whether or not to take them out of their boxes....

Christmas Quadcopters

As well as racing camels, we also found some time to do some quadcopter flying on Christmas Day. Number one son had built a new one (I think one of his hobbies is building flying machines) that had a POV (point of view) camera and we took it out for a quick fly.

The wind was a bit strong but we managed to get a bit flying action. I'd taken along my much more sensitive Parrot drone and I felt a tiny built guilty when, having watched number one son battle horizontal gusts of blustery wind, I decided not to fly mine. 

I did take some pictures though.

In flight

In flight

Point of View View.

Point of View View.

Christmas Camel Racing

camel up.PNG

Hope you had a great Christmas. Ours was lovely. And we spent some time playing Camel Up, the best camel racing game I've ever played. (and I've played one or two).

You get to place bets on the leader at each stage and also on the the ultimate race result. The balance is very finely wrought and leaders can switch position in the blink of an eye, so you have to be somewhat strategic in where you put your money. 

My opinion of the game is in no way influenced by the fact that by some inspired bets I managed to win the first time we played (I came last in the second game).

Great fun for up to five players.

Christmas Eve Bokeh

Christmas Eve Fun Fact: Bokeh is the term used by photographers to describe the quality of the out of focus parts of a picture. Turns out that the designers of a lens pay nearly as much attention to the blurry performance of a lens as they do to how sharp the in-focus parts are.

By playing around with the aperture value  (the size of the hole through which the light arrives at the camera) you can get some quite nice bokeh effects. Try using your camera settings to make this hole as large as possible by using an f-stop value (the unit that cameras use) as small as you can. Great fun with Christmas tree decorations.