Empty road
/They’re putting a new bridge in today over the A63. When I went there was nothing much to see, but they’ve had to close the road, with the result that it is a lot more empty than is usual for a Saturday morning.
Rob Miles on the web. Also available in Real Life (tm)
They’re putting a new bridge in today over the A63. When I went there was nothing much to see, but they’ve had to close the road, with the result that it is a lot more empty than is usual for a Saturday morning.
“Just type in the EID number of your device” said chap at the other end of the support chat. “It’s the 32 digit number that you can get from the About page” he added helpfully.
No worries then.
Maybe it’s my advanced age, but I really hate typing in great big numbers like this. Particularly where the consequences of getting it wrong are that nothing will work. So, I came up with a solution:
Take picture of the About page on your phone and crop out just the digits in the image.
Transfer it to your PC.
Drop into an empty Word document as an image.
Set the image to be behind the text.
Then type the digits on top of the numbers in the image until it looks right (see above).
Then cut the completed text out of the document and paste it into the chat window.
Worked for me.
I thought I’d have a play with my Lego Mindstorms Rubik Cube solver. But the controller is broken. I’ve tried everything. I’ve put in some new batteries, then another set in case the new ones were broken.
I’ve even taken the back off and had a look inside (always guaranteed to fix anything I find). It’s really complicated in there, and beautifully made.
But it doesn’t work.
Oh well. I’ll have to solve the cube myself…
The Addams Family movie is OK. It’s not great. It’s not bad. It’s OK. There are some good bits, there are some predictable bits. The voice acting is very good indeed and the story is nicely played out.
As I was watching it I was struck by the fact that the art direction was good, but I’ve seen better resources and animation in some video games. But then, these days, I guess that video games have bigger budgets than some movies, so it makes sense. If you go expecting an Addams Family movie you’ll not be disappointed, but that’s about as far as it goes.
Here’s a programming tip for you. If you have a bug and you’re not sure why (or even where) it is occurring, spend some time writing comments in the code as you work through what it is supposed to do.
This is a great way to “explain to yourself” what the program does and it might even be useful information in the future. You never know. You can also spend some quality time refactoring the code so that variable and function names properly reflect what they are used for.
I like this approach because you then don’t look back on the time spent debugging as wasted. When you find the mistake that you made you can at least reflect that fixing it made the code better.
Long blog title. But it’s true. You might be surprised to learn quite a bit of my work involves cutting and and pasting. Particularly for screenshots. For a long time my weapon of choice has been the Windows Snipping Tool, which if you read the name quickly sounds a lot more exciting than it is.
Anyhoo, me and the Snipping tool have got along fine over the years and I was worried when I saw a warning message that it was being replaced. I was even more worried when I discovered that the new tool provides no easy way to capture the contents of a particular window on the screen. However, I can relax now. Because the latest Windows 10 upgrade has introduced a fantastic new way to grab, annotate and save parts of the screen. You don’t even need to start a special program. Just hit the three keys SHFT+WINDOWS+S to bring up a snipping menu, grab the thing that you want and then either paste it straight into your target using CTRL+V or open up the image editor to annotate it and save it into a file.
It works a treat. Worth knowing about.
I didn’t intend to get hooked on the Apple ecosystem but here we are. What can I say? The stuff just works.
The latest iPhones are very nice. They have almost caught up with my Lovely Lumia 1520 which I still have. I get it out every now and then, marvel at the design and the UI and then sadly put it back in the drawer.
I’ve just signed up for Apple Arcade. It costs around the same as a packet of cigarettes a month and I can share it with number one wife, who has found a bunch of nice casual games including one that lets you mess around with Jane Austen text.
I really like Assemble with Care, which has a bunch of beautifully built 3D models to play with.
And Speed Demons is great high sped fun. You can use your favourite XBOX or PS4 controller with your iPhone, which seems so wrong but actually works really well.
You can get a free month to see if you like it. If you have an Apple device it is worth playing with.
I was in Ryman’s in Hull today looking for cheap AA batteries (I have lot of robots to feed) and I came across a tiny handheld video game that had been massively reduced in price. Always a sign of quality I find.
However, the promise of 150 games for a tenner was too hard to resist. So I invested in one. Note that I never say “bought”, always “invested in”. Buying something means that the money is gone for ever, whereas an investment has the potential to go up in value over time. Although I think that it is unlikely in this case.
Anyhoo, the game is not bad. The hardware works well and the screen is bright and clear. There are indeed 150 games. I was expecting a bunch of dodgy ports of old 8 bit favourites but the reality is a bit different. It’s rather like someone has locked a programmer in a room and said “You can come out after you’ve written 150 games”. The range of gameplay types is interesting. They are all very casual. None have any instructions and so for me a lot of the fun comes from figuring out just what your are supposed to do. And if you get bored or irritated by one you just move on to another. I’ve had quite a bit of fun with this already and I think I’ve recovered my investment.
You really should read this book. It’s not a happy tale, although there are moments of pure heroism.
It tells the story of the worst nuclear accident the world has ever seen, when a Russian nuclear reactor exploded in April 1986. I can vividly remember seeing news footage of helicopters swarming over the doomed reactor building, along with reports that everything was under control. It was not, and this book tells why and how. The level of detail, and the access to those directly involved, is hugely impressive.
The book serves as a cautionary tale of what can happen if you let economics and political expediency ride roughshod over safety. It has eerie parallels with some recent events. Read it.
A while back I ordered a TTGO camera from Ali Express. It came today and it is lovely. It is similar to the ESP32 webcam that I bought a while back, but it has a PIR sensor and a BME 280 environmental sensor along with a nifty OLED display.
It is supplied with firmware that sets it up as an Access Point. If you connect to it you can view the image and control it from the web page that it serves out. I think it is running the same software as I loaded into the earlier device, but it is nice to have it on the device at the end.
It works extremely well. I’ve printed a little case for it from a design I found on Thingiverse and now I’m looking forward to having a play. They say it can do facial recognition, which is very interesting, and it might be a good device for our Humber Care Tech Challenge entry.
Update: I’ve found a nice blog post here on how to use this device as a fridge alarm. This shows how to put the processor to sleep and trigger wakeup using the PIR sensor.
We went to see the new Shaun the Sheep movie tonight. This builds nicely on the TV show and the earlier film to add an interplanetary element, with a cute alien stranded on the farm. The story bounces along nicely through a whole bunch of lovely set pieces and some excellent voice acting (but no script). Great fun for all ages. Just go and see it.
I got an email over the weekend from Drew about a glaring typo in my downloadable edition of the C# Yellow Book. I was about to respond that I’d fixed the error when I thought I’d better check first. It turned out that I hadn’t.
So I’ve spent this morning going through all the reports of issues with the book and fixing them. Most of them have been typing mistakes but I’ve also made a few changes to make some things easier to understand. I’ve completely reworked the section on thread safety to incorporate a more meaningful example.
Thanks to Liz, Dina, Lilli, Neil, Richard, William, Don, Bram, Mitch, Jaswinder, Javi, Peter, Justin, James, Mike, Ian, Papartis, and Drew who took the trouble to get in touch and help me make the book even better.
You can download it here.
At the DDD last week I was talking to a young lad who had been to my IoT talk and wanted to make a voice controlled device. At the time we talked I was thinking that this is the kind of thing that you would push into the cloud for processing. However, TensorFlow Lite is now a proper part of the Arduino libraries (you can just add it as you would any other device driver - search for Tensor).
One of the examples actually does voice recognition on the device. I’ve not found anyone who has got this working on the ESP32 but it would be wonderful if it was possible.
After Lego on Saturday we continued our Scandinavian themed weekend by going to Ikea on Sunday. There was some method in our madness, in that we went right at the start of the day when it wasn’t supposed to be that busy - although it was still a lot busier than I expected.
We didn’t get out without spending something though, they had a nice line in wireless chargers for a not too bad price.
Saturday finds us in the Lego store in Leeds. The back of the store is filled with dispensers for individual pieces. I’ve never found these very interesting, but today it turns out that they are the only way to get the pieces for the nice little Halloween themed bat and ghost designs they had in store.
So we went round and filled a pot. The cost was 6.99 which compares favourably with the price of a set with a similar number of pieces. And you get to keep the pot. This meant I was able to distract myself during Strictly Come Dancing by building the models and then working out what to do with the rather large number of bits I had left.
I realise that this will probably require the use of more imagination on my part than just buying a kit, but I can see me picking up a pot full of interesting colours and shapes on my occasional visits to the store. It also raises the prospect of buying particular Lego bricks to make custom cases for devices and perhaps even gluing them together.
We had a bunch of folks round this week and spent a while playing the “Bang!” dice game. It’s great fun. The sheriff and the deputies have to kill off the pesky outlaws before the sheriff gets shot, while the renegade just has to be the last man standing.
The dice action is fun and nicely unpredictable, although this can result in you being shot out of the game early on. The way that nobody knows who anybody is at the start of the game is fun, but it can result in deputies taking multiple hits from a sheriff who just wanted to begin the game by going “pew, pew, pew, pew” because he got the dice to do that. Worth getting.
If I was still teaching a programming course (those were the days) I’d be taking a very long, hard, look at Jupyter. It’s a web based active notebook where the pages can contain text, images, programs and outputs from programs. You can write your code into blocks on the page, hit run and see the output. And you do this inside your browser.
I’ve had a go with Python and JavaScript and they just work. You can also use C# as well. It would make it possible to create an interactive text book which contained code and output that readers could play with in the text. You can also use it to create interactive labs in other things too. We’re working on some curriculum for experiments with particle sensors and I’m going to take a look at how we could use Jupyter to do this.
I feel that I must apologise for the blog post yesterday. Readers with long memories will no doubt be feeling short changed by the way that I failed to meet their appetite for new, relevant articles and recycled an old one from 16 years ago.
I’m not the kind of person who fill his blog with old posts from way back. But I am the kind of person who fills his blog with apologies for posting old posts from way back.
Maybe tomorrow I’ll apologise for this post…..
If you think that the current internet is a bit of a time sink, try taking a look at the past one.
I’ve been playing with the wayback machine, which has been carefully salting away copies of my deathless prose for around twenty years or so. I’ve just lost a big chunk time reading stuff I wrote ages ago. But some if it I rather like. Take this one, about debugging and magic that I wrote on 25th September 2003.
Been thinking about debugging (as one does). Debugging is what you do when the program doesn't work. Or works but does the wrong thing (nearly the same problem). The thoughts were prompted by a magic show on telly a few days ago. They showed the 50 best magic tricks (for which the number one was David Copperfield being chopped in half). Debugging a program is a bit like figuring out how a magic trick works. When I watch a magician setting up a trick I always want to jump up and go "No! That padlock is fake. There's an open link in the chain, you're hanging from a wire and that solid case you're going on about has got a trap door at the bottom. Oh, and what's that up your sleeve? And how come your assistant is twins?"
You get the picture... If everything the magician tells you is true, the trick must be impossible. This means that at some point he is telling you whoppers.
Broken programs are just the same. Something somewhere is not how it should be. Some part of the system is lying to you. This means that you debug the same way that you find out from a magician how a trick works; asking "Is the chain real?" etc etc.
Saying "It should work, I dunno why it doesn't" is tantamount to saying that you believe in magic. What you must do therefore is test all the things that you are assuming are true. "I know that this contains the customer number..." Really? How do you know? Did it start off with that number and change? Did the system that delivered the number send something else? Is the range of the numbers what you are expecting? And so on.
The worst thing that can happen is that you can end up convincing yourself that everything is OK. In that case you have what I call a "reality fault". And you start to believe in magic. At this point you have to resort to desperate measures:
First thing you do is walk away from the problem for a couple of hours. Often you will think of the answer; how the trick was performed. If that doesn't work, explain the trick to someone else. Two times out of ten you'll think of the answer during the explanation. One other time out of ten the someone else will tell you how the trick is done, or ask a question which changes how you view the problem: "Do you think he might have a fork lift truck in there somewhere?" or "What if the guy from the audience is in on it?".
Next thing you do is fiddle with the system in stupid ways. This is like asking the magician to perform the same trick, but using an elephant rather than his assistant. You might spot something this time. Send in completely invalid data. Send in lots of it. Send in lots of the same thing. This quite often gets you some behaviour which lets you track down the problem.
Then get the magician to do the trick in slow motion and freeze frame. Step through the code. Put in print statements. At some point you may well spot where your program does something it is not supposed to - and there you are at the solution.
Finally, run the trick backwards. The great advantage that a magician has is he knows how the trick will end. The audience doesn't. You can often figure out how it was done if you start from the result and try to figure out how to end up there. It is the same with debugging. Try to think how it could have ended up with that result.
OK. If you've done all that and it still fails you are in the one time out of a thousand where magic might actually exist. In this case you change the documentation and abracadabra! Your bug is now a feature! Failing that it is probably time to re-write the code.....
Rob Miles is technology author and educator who spent many years as a lecturer in Computer Science at the University of Hull. He is also a Microsoft Developer Technologies MVP. He is into technology, teaching and photography. He is the author of the World Famous C# Yellow Book and almost as handsome as he thinks he is.