Making Shadows in CSS

crazy adventurefunland.png

You can get some quite nice effects in CSS to make 3D text. Above you can see a heading for one of the exercises in the Begin to Code with JavaScript book (get the draft chapters here). It was simple to set up as a style:

.menuHeading {
font-size: 4em;
font-family: Impact, Haettenschweiler, 'Arial Narrow Bold', sans-serif;
color: red;
text-shadow: 3px 3px 0 blue, 10px 10px 10px darkblue;
}

A shadow is specified by three values and a colour. The first two values give the X and Y offset of the shadow and the third controls how diffuse the shadow is. You can add multiple shadows to a single style, which is how I got the sharp blue shadow and then the blurred deep blue shadow behind that.

Quite fun.

Rob's Podcasting Tips

podcasts.png

I’m still not sure why I decided to make podcasts by reading out all the first drafts of Begin to Code with JavaScript. But I must admit that I’ve learned a lot by trying to do it. Here’s what I’ve learned so far:

  • Don’t read from a script. Unless you are very (and I mean very) good it will sound like you are reading. If you listen to my earlier efforts you can tell that I’m reading words what I wrote. In later podcasts I’m using my words as a starting point for what I’m going to say which sounds a lot more natural. By all means have some notes, but don’t write down exactly what you are going to say.

  • Have something for your hands to fiddle with while you talk. My mind tends to be able to run faster than my mouth (which is surprising) so I have something to fiddle with to keep bits of my brain busy that would otherwise run ahead and make me trip over my words.

  • Don’t have a squeaky chair (or indeed anything else).

  • Make sure you stay a constant distance from the microphone. I do this by using a headset mic, I’ve always had real problems using desktop microphones. Other tricks include putting your elbows on the desk to stop yourself from rocking backwards and forwards.

  • Don’t sweat the fluffs. If you make a mistake don’t go back and edit, just make a joke of it and carry on. I can guarantee that the second time you try to retake something you think you got wrong the first time, you will be a lot more nervous and inclined to get it wrong again….

  • Find a style that you like and grow into it. I’ve noticed that my podcasts are getting better (at least I think this is the case) because I’m now more relaxed and at home with what I’m doing. I seem to be establishing a relationship with a listener even though I know that at the time (and probably afterwards) there is nobody there.

  • Force yourself to listen to yourself. I don’t like doing this, but I do try to make constructive notes to myself to try and make the next podcast better.

  • Try to enjoy it. I quite like doing podcasts and that for me is a good enough reason for doing them (although you can regard this as a form of public speaking and therefore very, very useful to get good at). It doesn’t really matter if nobody listens, just by trying to do this you are adding value to yourself.

You can find my podcasting efforts here. I’d love to hear what you think of them.

Netgames is great for, er, network games

netgames.png

This site is a hidden gem. For a while I was concerned about telling everyone about it on the blog in case everyone started using it and it got too busy.

Then I got real.

It is network gaming as it should be. Zero effort to create games, no crashes, no grinding of busy icons. It just works and the game implementations are spot on. And there are versions of some of our favourite games.

We tried Avalon and Codenames and they worked really well. All players need is a phone each (although it works fine via web browser on a PC too). And it is free, although they’ll take donations for a very worth cause.

Netgames.io

Make good food with Simply Cook

simplycook2.png

Pretty much all I know about cooking can be summed up in this blog post from a while back. But number one daughter put us on to Simply Cook, which is livened up our mealtimes no end. You get sent sauces and whatnot to add to your ingredients, plus a well-explained recipe to follow. And the results so far have been excellent. We’ve had three of the four dishes above, just the Cuban Mojo to go.

We’ve set it up to get enough for four meals a month so we can have a new meal once a week or so. We can try out new ones or go back to favourites. We particularly enjoyed the Bokkeumbap. I never thought I’d like sliced cabbage that much….

Free Sound on Sound Magazine

sound on sound.png

I’ve been messing around with audio since I bought my first pair of headphones from Woolworths. Recently I’ve started reading sound magazines to try and brush up my knowledge a bit. Sound on Sound Magazine has been very useful for this. Lots of technical stuff, good coverage of gadgets and some nice content on the finer points of making nice sounding things. Unfortunately I’ve not been able to get to the shops to buy the latest issues, but now they have started putting their magazines online for free. Well worth a look.

Riches Beyond the Dreams of Avarice

turnips.png

I’m really enjoying playing Animal Crossing. It provides a good chunk of escapism every day. And last week this happened. If you know the game, you’ll understand how exciting this was. If you don’t, the game lets you buy turnips and do a little speculating with them. I’d bought my turnips at a 94 bells, so this price had me turning a tidy profit. In fact the price was so attractive that I had folks turning up to sell their turnips too.

Great fun.

Listen to "The Global Ventilator Race"

global ventilator race.png

“The Great Ventilator Race” is a most excellent podcast about worldwide attempts to respond to the Covid 19 pandemic by making ventilators that will keep people breathing while their lungs recover from the virus.

You can find it on your podcast provider, and it is also here.

It’s a well told tale of hubris and a whole bunch of people finding out that some things are just hard to make and that people who have been making them for a while might have something of an inside track. I found it fascinating that large companies and very clever people were all falling foul of the same mistakes that I used to tell Imagine Cup teams off for making all those years ago. Lots of folks had plunged into making something before taking the trouble to find out if it was useful, deployable or even needed by the target audience.

Well worth a listen.

ArduinoJson is awesome

arduinojson.png

I’ve probably raved about this before. But, in case you missed it, here it is again. Arduino Json is awesome. Awesome, awesome. I’m using OpenWeatherMap to get some weather data into my ESP32 program. It arrives as a Json formatted string that I need to convert into values to use in my program. With ArduinoJson I can just pop their include file in the same folder as my application and away I go. No messing around installing libraries and wondering if they are the right ones. The decoder stays right with your code.

They’ve made it incredibly to create the code that you need to unpick your data. You just have to take the Json you want to work with and paste it into their web page. Then it comes up with the C++ code for you to drop into your solution to decode and encode the Json stream. Wonderful.

OpenWeatherMap is a good source of free weather data

I’m writing something that will let you use a Furby toy as a weather station. For that I need a source of weather information. I found OpenWeatherMap and stopped looking. Their free tier gives me all I need and the service is so easy to use, even from a lowly ESP32. If you want to make your embedded applications weather aware I reckon this is a great place to go.

Mysterium is Great Fun

Mysterium.png

We’re playing a lot of online games at the moment. One of them is Mysterium. It’s a very good implementation of the board game, which is a bit like Cluedo, but with clues. One player, the ghost of the unfortunate murder victim. has the task of picking pictorial clues that match the suspected people, place and weapon. Each of the pictures that the ghost can pick has a set of elements that may, or may not, match the particular scenario assigned to each player. It builds up to a nice reveal at the end, and the artwork and presentation is suitably gothic. Worth spending a few hours with I reckon.

Getting your car serviced in the midst of a pandemic

I’m not sure why I was so keen to have the car serviced and tested. It’s not as if I’m going to be needing it much. Just put it down to my mildly compulsive nature. Anyhoo, we took the car down to the garage this morning. We got there nice and early because there was hardly any rush hour traffic. The dealer was very prepared with one way signs on the floor, Perspex dividers on the counters and plenty of hand gel.

The whole thing passed off very smoothly and I now have a shiny car that should be good for a couple more years. Now I just need somewhere to go and permission to go there.

Begin to Code with JavaScript Recording Fun

I quite enjoy recording the Begin to Code with podcasts. Although I’m far from sure how many people enjoy listening to them. I started the project to see if it was possible to produce useful programming teaching content that could be deployed as a podcast. If you’ve listened, I’d love to hear what you think. If you’ve not had a go, I’d love you to have a listen (the link is on the right hand side) and then let me know what you think.

I’m going to keep doing them whatever happens. But I’d be really interested in some feedback as to how they can be more useful.

Using Multiple Inheritance for Good

Multiple inheritance sounds like a good thing. After all, why would you not want to inherit a bunch of stuff? But some programmers don’t like it. They say it makes things confusing, they say that a class made from multiple parents will be neither one thing nor the other. And mostly I think they are right. However, when the alternative is something even more confusing, I can be persuaded to think of multiple inheritance as a good thing.

My problem was that I wanted to make a driver class to control a Furby toy over Bluetooth BLE from an ESP32. The ESP32 has a bunch of Bluetooth libraries and they work fine, but they expose their callbacks the form of class instances that contain overridden versions of the class callback methods. Ugh.

Wow. That sounded cool didn’t it. But did it make sense? Probably not. Here’s the thing in bullet points:

  • When a program connects to something over Bluetooth BLE it needs a way that the Bluetooth BLE library can tell it things. In other words, if the BLE library receives a message from the Furby it needs to be able to deliver this to the program.

  • One way to do this would be to pass the Bluetooth BLE library a reference to a function for the library to call when the message arrives. I like this method, lots of other things use it. However, the BLE library doesn’t. For some reason it likes to be given a C++ class instance.

  • A class is an object that can contain methods (lumps of program code a name). If I pass the Bluetooth BLE driver a reference to the object the driver can then call the methods in it.

  • The Bluetooth BLE library provides templates in the form of abstract classes (classes with method names but no implementation) which I can override with my own methods in new message passing classes that I base on the abstract parents. I then pass references to instances of these message passing classes into the Bluetooth BLE driver so that it can call the methods in them and tell my program things. But this is a right pain, because if I want these methods to interact with the data in my program (which I do) I have to make these objects aware of their context. Which is a mess.

I hope that’s cleared that up. Anyhoo, rather than implement lots of message passing classes and then pass references around between them (ugh), or make everything static so that everything can see everything (double ugh) I simply make my Furby adapter class inherit from all the abstract BLE library message classes and then drop the overridden methods from these classes right into my driver class. Because the methods are now inside my driver they can use all elements inside the driver and it just works. So, a good use for multiple inheritance. Yay!

Unfortunately, the Bluetooth BLE driver writers have thrown in some function references too, which means that I need some static members in my driver class, but I’m in a happy place at the moment.

One of the things that occurred to me as I was writing the code was how much effort I would have had to put in to avoid using multiple inheritance. When you are programming it is important to remember that the final outcome should be a program that solves the problem. Worrying to much about the “right” way to do that can sometimes send you backwards if you are not careful.