Thought for the Dazed

I've had to give up that Distance Learning course as I was having trouble seeing the teacher.

Flickr
www.flickr.com
RobMiles' items Go to RobMiles' photostream
Twitter
C# Yellow Book

Search entire site
Monday
Aug062012

Scary Nexus 7

IMG_2542-Edit.jpg

The Nexus is proving quite an impressive piece of hardware. Battery life is shaping up to be very good. I’ve found out how to make the screen brighter (turn on auto-brightness) and got auto-rotate to work (for some reason it is turned off by default). I’ve also found some useful applications, including one that provides access to my Skydrive storage amongst other things. I’ve loaded some films and music onto it and they work very well and look rather good. Then it did something that totally baffled me.

I took the Nexus 7 to work today. Left it in my bag. Didn’t bother connecting it to the campus network. After a while it beeped, so I got it out to take a look. It had received a new email message. Which was rather impressive, bearing in mind it didn’t have a network connection. Then I took a closer look at the WiFi settings. It knew all about the university network, along with a couple of networks at places it had never been to.

Strange.

Eventually I remembered, around a year ago I had a brief fling with a Nook Color, another Android powered tablet. I found the Nook great for reading books (that’s what Barnes and Noble made it for) but a bit slow for anything else. But I did take it to work and connect it to the campus network. And of course I’d registered the device using my Google username. Which means that the Nook had uploaded the WiFi settings to my part of the Google cloud which then made them available to any other Android device that I register.

I’m not sure whether to be impressed or frightened by this. On one hand it is very convenient for me not to have to mess around with SSIDs and passwords. On the other it is a bit scary that Google are holding all my (along with lots of other people’s) network credentials up in their cloud. One of the boxes that I ticked next to a page of licence agreements (does anybody actually read these) probably gave them permission to do this, but I now worry a bit that if I get a security breach on my Google account it also gives people access to my home network, should they choose to register their own device and then stand outside my house, browsing files the other side of my network firewall…

This is a reminder of just how clever and connected modern devices can be, and just how much you have to be aware of the dangers of all this cleverness.

Sunday
Aug052012

Harry Bosch is the man

image

Sometimes you just want a good book to read. Not one that has won awards, just a good narrative and some strong characters. Michael Connelly writes crime novels which are just a great way to pass the time. One of his heroes, Harry Bosch, is a hard bitten and hard boiled detective, just the kind of guy you’d want to investigate your murder (although perhaps you’d be past caring by then). Harry works the mean streets of Los Angeles and has seen a lot of life. There are a number of books which chronicle his ups and downs, you can read them in order or how you like, as each is completely free standing. If courtroom drama is more your style there are also some books staring Mickey Haller, the attorney with a heart of gold and an interesting past. All good reads.

As an exercise, while I was washing the car today I had a go at putting together a Harry Bosch style narrative. There’s actually a serious point here – from a writing point of view it is often useful to have a go at using a particular style – do a blog post from a private eye, or a president, or a poet and see how you get on. Anyhoo, with apologies to Michael Connelly, and a note that his prose is definitely not played for laughs, here’s my attempt at a Harry Bosch story:

The Axe In The Head Affair

Bosch hit the man full in the face as hard as he could. The man went straight down onto the ground, as Bosch knew he would. Bosch stood over him, waiting for the man to get up so he could hit him again. The man looked up at him, with pain in his eyes.

‘Why did you do that Harry?’ he asked

‘This is a murder investigation, not a popularity contest’ Bosch rasped, breathing heavily.

‘But I’m your partner’ the man on the ground managed to say.

‘Listen’, Bosch replied, hoping the voice of experience would get through before anything else bad happened. ‘I get through partners the way some people get through underwear. And I often leave them in pretty much the same state. The sooner you learn that, the better. Next time, remember that it is black with no sugar, not any kind of fancy coffee pourings’. His partner looked at over at the frappachino with chocolate frosting on the top resting on the hood of the squad car and nodded. ‘I just thought you might fancy a change.’ he said, getting to his feet with difficultly.

‘Now to business’ said Bosh, walking towards the other car. He could tell at once there had been a murder there. The un-natural stillness around the vehicle, the faint, lingering, smell of fresh death, and the axe sticking out of the head of the man in the driver’s seat all pointed to homicide. He paused to open his briefcase and take out a fresh pair of blue crime scene gloves from the bulk pack he carried with him everywhere. “I really must stop wearing these around the house” he thought as he put them on and carefully opened the car door.

Somebody had wanted Harvey Putz to be very dead indeed. Only a small part of the axe blade was still visible, the rest was embedded in his temple. From the angle of the blow Bosh decided that it had been wielded by a left handed female with a club foot. Or perhaps that’s what they wanted him to think, he thought grimly, remembering that this was Los Angeles, where nothing was ever as it seemed, except perhaps the weather, and even that was sometimes changeable.

‘Send the car down to the lab’ he said eventually. ‘Let’s go and see Mrs. Putz and break the bad news to her’ If she didn’t already know he thought to himself grimly.

Mrs. Putz lived in a neighbourhood of fancy cars and even fancier houses. As they drove to her address Bosch looked at the neat suburban lawns, some with children playing in the warm spring sunshine. He wondered what dark secrets each house held, and speculated on the unhappiness that undoubtedly lurked behind each brightly painted door. Mrs. Putz took her time to answer the doorbell. When she did Bosch saw that she had once been truly beautiful. Before the city of Angels did its dirty work and brought her down to its level, before her dreams were crushed and buried by time. And before she painted herself bright blue.

‘Sorry about this’ she said, in lieu of introduction. ‘Smurf convention. How can I help’.

‘I’m afraid I have some bad news’ said Bosch, ‘Your husband has just been murdered’.

‘Have I?’ boomed a male voice from behind the woman. ‘I feel fine at the moment.’

Bosch looked at the address in his notebook. ‘Is this number 82?’ he asked finally.

‘Nope’ said the man, who was also painted the same disturbing shade of blue. ‘They’re next door’.

Bosch apologised and headed back to the car, wondering if he should punch his partner in the face again.

The real Mrs. Putz was much quicker to get to the door. Almost as if she had been expecting them to call by. Bosh told her that her he had some bad news about her husband and she instantly said something that aroused his suspicions. ‘Which one?’ she asked.

That was all it took as far as the investigation was concerned. Time to move things downtown to police headquarters and transfer the conversation an interview room. Bosh used all his experience to get the suspect in the mood to talk. He left her there for half an hour to give her time to stew, gave her a cup of triple strength coffee to loosen her tongue and then turned his chair the other way round when he sat down, like he had seen in the movies.

‘So what do you think happened?’ he asked eventually, trying to get comfortable on the seat.

She wrinkled as much as much of her brow as she could. She was definitely one of the Botox generation. ‘I don’t know’ she said finally. ‘I’ve had a tragic life. My first husband died of eating poisoned mushroom soup and then my second husband died, also from eating poisoned mushroom soup.’

‘Why do you think that your third husband was hit in the head with an axe?’ Bosh asked, moving in for the kill.

‘Well’ she said thoughtfully, ‘For one thing, he wouldn’t eat his soup.’

Bosh sighed, and started on the paperwork. When would people learn that crime doesn’t pay? Unless you write good books about it.

Saturday
Aug042012

Google Nexus 7 Review

image

I think other folks have used the gag about needing three hands to work it, so I won’t

Warren told me that I’d get a Google Nexus 7. I protested. ‘There is no way I need one of those’ I said. But the one Adam had bought looked very nice. And the price is pretty amazing. And I was going to get number one wife a Kindle Touch for her birthday. And the Nexus will do a lot more than just read books. So there you are. We ended up with one each, mainly because I hate the idea of number one wife having better gadgets than me. And I have just been paid.

The device is very nice. Works a treat. Binds tightly to your Google account. Has this Google Now thing that is supposed to tell you all kinds of important stuff about your life. At the moment it is just telling me that it is 18 degrees in Cottingham, which is about right.

You get 15 pounds of credit in the Google Play store with the device. I’ve spent 70 pence on Real Racing, which is on offer at the moment. It runs very well and really shows off the power of the device. I also wanted to download BBC iPlayer (one of the best reasons for owning a device like this) but at the moment it doesn’t work, which is pretty terrible. I think this is because the Nexus is “Flash Free” and iPlayer needs that. Whatever it is, it needs to be sorted out soon. There are some other irritations in applications, some of them assume they are headed for a phone screen, and look wrong. Also, for some reason the default setting of the device is to lock in portrait mode, which is a bit of a pain. Number one wife was upset to find that you can’t get Scrabble for it if you are outside the USA, which is unfortunate.

You can rent (but I can see how to buy) movies on the device. You do get a free copy of the latest Transformers movie though. And a Jeffry Archer book. I’m looking forward to loading up the 16G of internal memory with some music and videos of my own. Battery life seems OK, I’ve not run it flat yet but 7 hours seems a reasonable amount. It has WiFi and Bluetooth, but not mobile data. For me this isn’t a problem, as I can us the Lumia as a hotspot if I need to. The 7 inch screen is bright and clear and the software is responsive, even if the UI seems a bit more complex than it needs to be – but then again I am used to Windows Phone on touch devices. There is no video out facility, but given the fairly limited internal space on the device I don’t think you ‘d be using it as a video library really.

All in all, you’d be bonkers to spend any more than the price of a Nexus on a tablet of this kind. The hardware is excellent and there’s no way they can be making much, if any, profit on it. This does of course mean that you are meant to be part of the product, and so you can expect all your actions on the device to be comprehensively mined for selling opportunities. Having said that, you can just use it and it will deliver a very good, and eminently portable tablet experience.

Friday
Aug032012

A Career in Windows Phone Programming

image
I’m not saying you can reach the dizzy heights of accomplishment reflected by a product such as Cheese Lander, but you can try….

Last week I got a tweet “i am electrical engineer and wanna start a career in windows phone programming. any advice ?! “.

I’ve been thinking about this for a while, and this is my advice, for what it is worth.

Get the Free Tools

Head over to http://create.msdn.com/ and grab the Windows Phone SDK. It is a free download and will give you everything you need to get started.

Get a Windows Phone

You can write programs without needing a real device, but for the proper experience you really need some hardware I’m afraid. The good news is that with all the shiny new Nokia devices coming along, lots of people are moving up in the Windows Phone world and so there is a good supply second hand devices at very good prices. As far as I’m aware, all of the older phones can be upgraded to the latest version of the software and so you can perform Windows Phone development on one of the first generation devices. If you can find a second hand Omnia 7 device that would be a good one to start with.

You might have noticed that Windows Phone 8 is just around the corner, and may be thinking about holding off for this. I’m not sure that this would be a good move though. Whatever you do, there is always another version coming along and the skills that you pick up on Windows 7 will transfer over to Windows 8 when the time comes.

Decide whether you are writing games or applications

If you want to write games you can think about using XNA. Unfortunately the future of this platform is a bit more hazy than I’d like, but as a quick way of getting into writing silly games (like Cheese Lander) then it is very hard to beat. If you are getting started and want to write some useful and fun stuff I think I’d go for the Silverlight approach at the moment. This will make it easy to move into the XAML based environments on Windows Metro and Windows Phone 8. It is also getting increasingly viable as a casual gaming platform.

Get the Free Documents

If you have never programmed before you could read my C# Yellow Book. This will give you a good grounding in programming.  You can find out about Windows Phone programming from my Windows Phone Blue Book, which is available from the same place. There is also a ton of free stuff on the http://create.msdn.com/ site that you can use.

Find a Problem to Solve

Coding in a vacuum is very hard. It is much easier to learn how to write a program if you have something specific to achieve. As your background is electronics I’d try to think of a simple problem (for example a resistor colour codes calculator) which you could write a program to solve and then have a go at coding that.

Use the Forums in the Right Way

There are lots of forums out there with people who are more than happy to help. However, they hate it when someone posts a problem like “I’ve got to do X. Where do I start?”. This kind of post sounds like someone is asking the forum to do some work for them. A much better post is something like “I’ve got to do X. Is Y a good approach to do this?” or even better “Why does this code not work?”. This shows that you have thought about the problem and done something before putting it out there. And as soon as you know something, start posting sensible replies to other post questions, so you give back to the system.

Blog what you do

I’m assuming that you are doing this as a way of getting employment. If this is the case (and even if it isn’t) you should start a blog about your progress. In the blog you can put what you learn (so you don’t forget it) and chart your progress. Potential employers are very impressed by people who are constructive and resilient. A regular blog will be something you can point them at to which will show how you have progressed. Keep the focus on the technology you have learned, and how you have applied it. You never know, you might find other people following what you do and learning from you. Regular blogging is also a great way to build your writing skills, which are also very useful for getting work.

Enjoy it

Learning to program is hard work. The most important thing about success is persistence.  Focus on getting little things to work and then building on them. Don’t have a huge, grand, idea and then get upset with yourself when you can’t realise it. This is the most common reason for people giving up on programming.

If you find yourself getting bogged down or stuck on a problem remember that you can always simplify your solution and just focus on one small part. With a bit of luck you will get a little buzz when you get something to work, and a bigger buzz when someone looks at your program and says “How did you do that?” and that will motivate you to do more. Good luck.

Thursday
Aug022012

MonoGame Demo

screenshot_08022012_142049

Last week I discovered how MonoGame is making it possible to write XNA games for the Windows 8 Metro environment. And I managed to draw a blue screen, which was nice enough, but not much of a basis for a game. So today I thought I’d make a sample project that had all the bits that you need to make your own game, including art assets, using the touch panel, using the accelerometer, drawing text and making sounds.

I’ve made a single, one-stop, demo that does all these things. It also includes the source of the MonoGame code as part of the project. I’ve found this to be quite useful when working out how the XNA implementation works. If you download the zip archive you should have everything you need. Here is how to get started.

Pre-Requisites

You will need three things before you can move any further:

  • Windows 8 Release Preview – this is where you run everything
  • Visual Studio 2012 Release Candidate for Windows 8 – this is where you build your program
  • Visual Studio 2010 for Windows Phone – this is where you create the XNA resources that you want to add to your game

Getting the Files

To get started just download the file from here. This is around 22MB. Before you unzip the file it is a good idea to Unblock it. This will stop Visual Studio from giving you warnings when you open any of the projects. To unblock the file you just have to right click on the file where you have download it, select Properties from the context menu and then click Unblock and then OK as shown in the badly highlighted screenshot below.

image

Then unzip the files. There are quite a lot of them. Once you have completed the download you will have the whole MonoGame framework and my little test project. Open the folder and find the Visual Studio Solution “MonoGame.Framework.Windows8” and open it. Make sure you open it with Visual Studio 2012 Release Candidate. If you double click the solution you will probably start up the wrong version of Visual Studio (I do) which doesn’t end well.

Running the Sample Program

The solution contains a project called Test Project which runs a port of a Windows Phone demo I wrote that lets you draw lines of dots on the screen using your finger. The dots that you draw will also fall down the screen in a way that is controlled by the accelerometer. You can clear the dots by double tapping on the screen, the game will make a “Ding” sound when you do this. The game also writes some text on the screen.

Resources and Fun

The MonoGame XNA part of things works very well, apart from content. At the moment there is no way of getting Visual Studio 2012 to pre-process XNA content for use in a game. We get around this by creating a Visual Studio 2010 XNA project and using it to produce the xmb files that are read by the content manager when the game runs. The content in the sample program came from existing XNA projects that I had around the place. If you are migrating an XNA game onto Metro you can do the same. The tricksy bit is where you put the xmb files for the game to use. I had no success adding them to the Visual Studio project, instead I had to put the xmb files in the specific directory read by the game when it runs.

image

Here you can see the path to the AppX\Content folder where I put the XMB files for the sample game. These include the two textures, the font and the ding sound file. If you want to add more content to your game, just drop your files here and then refer to them in the program as you would in any other resource:

protected override void LoadContent()
{
    // Create a new SpriteBatch, which can be used to draw textures.
    spriteBatch = new SpriteBatch(GraphicsDevice);
demoTexture = Content.Load<Texture2D>("DemoArtwork"); demoRectangle = new Rectangle(0,0,GraphicsDevice.Viewport.Width,
GraphicsDevice.Viewport.Height); smudgeTexture = Content.Load<Texture2D>("Smudge"); font = Content.Load<SpriteFont>("MessageFont"); dingSound = Content.Load<SoundEffect>("ding"); }

You should be able to use my TestProject as the basis of anything that you fancy making.