Killing your favourite children

boats.png

Ages ago I went to a creative writing seminar. It was really interesting. One of the points that they made was that sometimes when writing you have to “kill your favourite child”. What they meant was that you might have a lovely chunk of prose that you are very proud of, but it just don’t quite fit into the context of the piece you are writing. There are two things you can do. Spend ages trying to make your wonderful words fit and fail. Or just get rid of them and move on.

I was reminded of this today when I was writing Chapter 9 of Begin to Code with JavaScript. I’m talking about software objects and I’d written a lovely piece of code that used a schema to create objects and properties on the fly. You can do this kind of thing in JavaScript and its awesome. However, I couldn’t make the example fit into the rest of the chapter. I spent far too long trying to create a solid context, wrote a few pages and then stood back from the piece, took a long hard look at it and then threw the whole thing away. What is left is much better, and of course I’ve not completely discarded the stuff. I never throw anything away.

Sometimes you have to ditch something that you really like because of your loyalty to the final result.

Hull Rocks

Walkway.jpg

They were having a discussion on Radio Humberside this morning about the future of Hull. They asked me to contribute some thoughts. I made some notes (most of which I never used). So I thought I’d pop them on the blog. The question posed was something like: “As a person who has lived in Hull for a while, what do you think of the state of the city and potential for the future?”. These are my answers in bullet point form:

  • There are amazing things going on at the Fruit Market . I’ve been involved with c4di for ages and their building is now fully occupied with people making stuff and doing things. With more coming.

  • We’ve got super fast fibre networking, something which other places have just started to realise might be a good thing.

  • We also have a city wide LoRa network which is free for anyone to use for connected product development and a couple of local companies, KCOM and Connexin, who can provide you with a paid network service you can use to commercialise your solution.

  • Humber Street is awesome. The new pedestrian bridge will make a huge difference to access to the area.

  • We must give give local students a trajectory that encourages them to say in Hull when they graduate. As I said this morning, “It’s cheap and nice”, a killer combo. Students tend to be quite conservative about where they go in their local area. We need to encourage them to take a look at the lovely places we have where you could build a good life..

  • Hull Makerspace is a great development which lets anyone from the community explore technology.

It’s a crying shame that this nasty virus has come along just as we were getting up speed with all this, I really hope that progress is not knocked too far off beam by it.

Indoor thunder with Norns

norns shower.png

I’m slowly getting my head around the Norns device that I built on my birthday. It works by running Lua scripts that talk to SuperCollider engines to make sounds. There’s also a sound sampler and sllcer and you interact with it via your browser. It’s great fun, but at the moment I’m using it to make the sound of rainfall thanks to the lovely Shower app. I’m trying to get my head around how such a short piece of code can produce something that sounds quite realistic. And very relaxing.

Adventures in function names: saveItem or storeItem?

lego functions.png

I’m writing Begin to Code with JavaScript at the moment and I was struck with how the choice of function names can be confusing. I’ve made the point that a good way to come up with a function name is to make them out of a verb and a noun. So storeItem sounds like a good name for a function. Store the item. What could be simpler?

Unfortunately this has the potential to be confusing. It’s because the word store can be a verb (do the storing) or a noun (a store that contains things). So storeItem might mean an item from the store. My strong advice is to try and pick unambiguous verbs, which is why I much prefer saveItem.

Perhaps I’m overthinking this (it has been known) but I’ve been surprised how many times I’ve picked confusing names for things based on distinctions like these. One of the great things about modern development is the ease with which you can rename identifiers, so if you do decide that the name you first came up with is confusing you can change it.

New Begin to Code with JavaScript Podcasts Available

Do you want to learn JavaScript the fun and painless way? Then go forward 200 years into the future when they can plug something straight into your head. For now though, you could do worse than investigate the Begin to Code with JavaScript podcasts for my new book I’ve just uploaded. They are packed with jokes, music, song, dance and misleading product descriptions.

You can get a draft of the book for free and watch screencasts where I code things live that nearly always work. Search Apple Podcasts for “begin to code with JavaScript” or listen fresh from the web at https://www.robmiles.com/jspodcast

Low Power Raspberry Pi in MagPi Magazine

magpie.png

I was digitally leafing through the latest copy of MagPi magazine when I had a sense of déjà-vu. They’ve included my HackSpace magazine article about creating Low Power clock controlled Raspberry Pi.

Quite chuffed. I’ve always fancied being in that magazine and now I am. Without even trying.

Authors note: I hope you are all really impressed by me typing “ déjà-vu” correctly. It was surprisingly hard to do.

You must read "Hello World" by Hannah Fry

If computers, big data, artificial intelligence and self-driving cars confuse you, you should read Hello World by Hannah Fry. Hannah is a proper scientist with a wonderful writing style and she makes the technology easy to understand. She also isn’t afraid to muse on the dark side of all this shiny stuff.

There is no assumed computer knowledge, everything is clearly explained and put into context and subjects are introduced with engaging real-life stories. Everything is also properly referenced so that you can follow up on things that you find especially interesting. Excellent stuff.

Teenage Engineering OP-Z as a Windows 10 sound source

I’m loving my Teenage Engineering OP-Z. Great fun. One of the things I like about it is its versatility. The usb port can be used to make it into a usb MIDI host (so that you can hang other devices off it) or a usb MIDI client (so that it can hang off other hosts) or a sound output (so it can sample sounds sent over USB) or a sound source (so that other devices can grab digital copies of the sounds the OP-Z produces).

The only problem has been that I can’t get the last option to work on my Windows 10 PC. If I want to record stuff I’ve created on the OP-Z I’ve had to send out of the OP-Z headphone socket and then re-digitise it. Which seems a bit silly for a digital device.

Anyhoo, today I was able to try the OP-Z on a non-Windows device and discovered that it worked perfectly. Knowing that something is possible is very useful if you are trying to make it happen, and so I put a bit more effort into making it work. And I managed to do it. Here’s how, if you are having the same problem:

opzsoundfail1.png

After you’ve plugged in the OP-Z, open up Device Manager on your Windows 10 PC by right clicking the Windows icon in the bottom left of your screen and selecting “Device Manager” from the menu that appears. Then open up the Sound, video and game controllers item. You can see that the OP-Z is a speaker (so we can send it sound) but not a microphone (so we can’t listen to it). Wah.

opzsoundfail2.png

No matter. We’ve got this. Type “Control Panel” in the search box on the task bar and hit enter to open the Windows 10 Control Panel.

opzsoundfail3.png

Now type “Troubleshooting” into the search window at the top right of the Control Panel and select the troubleshooting icon from the list that appears.

opzsoundfail3.png

Now click Troubleshoot Audio Recording in the middle of the page.

opzsoundfail4.png

Now click Next.

opzsoundfail5.png

Select “Synthesizer - OPZ from the menu that appears and click Next again.

opzsoundfail6.png

Windows 10 will do something magical that it should have done first time. Close the Troubleshooter and the Control Panel. Go back to your Device Manager and you should now see another input.

opzsoundfail7.png

You now have another input device that you can connect to Audacity or whatever you fancy.

Plumbing hilarity

tapfitting.png

What do you do when faced with a dripping tap? Answer, in my case, is try to fix it. No matter that it wasn’t my tap, the urge to show off my plumbing skills was too hard to resist. So, after a rummage around under the sink I found the isolator for the tap in question and, after a bit of swinging on a spanner managed to pull out the leaky bit.

At this point I was feeling somewhat smug. All we had to do was find a replacement and drop it into the tap. And then someone pointed out that all the water in the house was off.

Oops. Perhaps the isolation valve that I’d turned off did a bit more than I thought. So I put everything back together and turned the isolator back on again. And the water was still off.

Now I was more than a bit worried. My attempt to demonstrate my skills was showing something else entirely Then we discovered that, owing to a supply fault, the water was off in the entire area.

We drove off to the DIY superstore marvelling at the way circumstances collide. How a dripping tap had coincided with a water outage, both events calculated by fate to make me look like an idiot. Then the DIY superstore showed that it was a lot less than super by not having any of the replacement parts in stock. So we took our masks off and headed back.

To find that the water pressure was back to normal and the tap had stopped dripping. At least I’ve learned something, which is that some designs of tap fitting need high water pressure to force them shut. We’ve ordered some spare parts in case the problem comes back again. And I’ve discovered (but not learned just yet) that sometimes fools really do rush in where angels fear to tread…..

Fixing the width of an HTML element

fixed width ice cream sales.png

If you want to make an element input with fixed with labels you can do it by adding this to the style for the element:

.menuLabel {
display:inline-block;
width:12em;
margin: 10px;
}

The width bit sets the width of the label and the inline-block setting for display makes sure that the input field lines up properly. You can use it to make other things line up too.

Happy Birthday with Norns

norns kit.png

It’s my birthday today. Go me. I tend to sort out my own presents. Except for the chocolates of course…

I’ve fancied getting myself a Norns device from Monome for a while because I want to write some code that makes music. However, the Norns, while very pretty, is also very expensive. But now they do a Norns shield kit which you can attach to a Raspberry Pi 3 or 3+ to make the same device only cheaper. And you get to do some soldering.

I ordered a kit on Tuesday from Monome in New York. It arrived today. Amazing. Happy Birthday me. I spent a happy half hour this afternoon soldering it together. I made an image of the operating system on an SD card and fired it up. It worked. Really Happy Birthday Me.

norns.png

So far I’ve managed to make some very trippy sound loops and stuff. You can attach your browser to the device and write Lua scripts to control what it does. You can also write sound generation code using a language called SuperCollider. The Norns also has an audio input so that it can be used as an effects processor. It’s going to be a fun thing to play with.

Furby Article now in HackSpace Magazine

Furby article.png

I’ve been turning out the odd (and I do mean odd) article for HackSpace magazine recently. You can find my description of how to use an ESP32 to control a Furby toy in the latest issue here. I’ve written a little set of helper files that let you connect to a Furby toy, but you can also use the code to talk to any Bluetooth BLE device from your ESP32. You can find the code for the article on GitHub here.

I need to work on my "VR legs"

We’ve been playing some escape room type games with the Oculus Quest and the Rec Room application. They are like real escape rooms, in that a bunch of you have to figure out some puzzles to find your way to the exit. However, you do all this in a virtual environment. We’ve played a few now and the only real problem for me is that they entail lots of moving around which I don’t seem to have the stomach for.

However, if you’re made of sterner stuff they are certainly worth a look.