Applying Authorisation Rules to a Folder of Razor Components/Blazor Pages

A screenshot of a Blazor app designed to test/demonstrate different approaches to applying authorisation rules to razor components

There’s a lot of flexibility in how you can use authorisation rules in Razor components*, but a frustration of this approach is that it seems like you have to slap @attribute [Authorize(Policy = "PolicyName")] at the top or every page with no clear way of applying a given policy to a whole folder of .razor files. After much research and testing, I’ve found how to go about it!

Continue reading “Applying Authorisation Rules to a Folder of Razor Components/Blazor Pages”

UI Flashes after Migrating Blazor Projects To .NET 6

A table with the title of "Vegetables". There are three columns (Id, Product and Quantity) and 3 rows of example data.

The Problem

I’ve noticed an issue recently after upgrading a few Blazor projects from .NET 5 to .NET 6 where the UI flashes after every call to StateHasChanged. Something like this:

A table with the title of "Vegetables". There are three columns (Id, Product and Quantity) and 3 rows of example data. The Id field disappears and reappears once a second causing the table to visibily shift back and forth
Flash. Flash. Flash. Flash…

Yeah, that’s not annoying at all. Unfortunately it was happening in quite a few different places and was pretty darn noticeable, so it looked like I was going to have to dive in and figure out what exactly was causing this to go wrong (despite working perfectly in .NET 5)!

Continue reading “UI Flashes after Migrating Blazor Projects To .NET 6”

SoundFloored: Open Source Soundboard Pedal (Part 4 – Final Implementation)

The top of the SoundFloored pedal. It is held together by various cross-head bolts and has six footswitches embedded in the top, with four along the close long edge and two along the far long edge (with a screen embedded in the lid between them)

This is the fourth and final post in a series about designing and creating SoundFloored, an open source soundboard pedal! Check out the other posts in the series:


So SoundFloored is now working just like I wanted it to with buttons and a screen, but the current build isn’t exactly what I would call robust. As such, the final part of the build involves moving what I’ve built so far into a more permanent home, one that can withstand the rigours of live performance and is far more practical to move around.

Building the Box

Design

Based on some preliminary research on the minimum usable distance between footswitches, I decided to keep them 7cm apart from each other to ensure good clearance. I also thought to leave a 3.5cm gap between the switches and the edge of the pedal since I didn’t need as large of a gap but still wanted the numbers to map out in a simple way.

Since there were going to be four footswitches across the length of the pedal, it would need to be 28cm long (3 x 7cm for the gaps between each switch, plus 2 x 3.5cm for the gaps between the outer switches and the edge). Similar maths for the two footswitches going across the width of the pedal gives us 14cm (7cm for the gap plus 2 x 3.5cm for the edges).

I wanted to find something with these dimensions (or near enough) that I could use to house everything, so I started by looking at “project boxes” (plastic boxes designed for maker projects like this). Unfortunately, the largest project box I could easily order was barely half the size that I needed and I wasn’t interested in putting in a custom order to create one. The only option left at this point was to build something myself!

I figured that wood would be the best material for this project; although not the traditional material for a pedal, I could make it pretty much whatever size I wanted, it’s readily available, cheap and I already have some basic experience in woodworking.

At this point even though I had the dimensions I wanted to get a better perspective of how big the pedal was going to be before I started building anything. Mediocre arts and crafts to the rescue!

Continue reading “SoundFloored: Open Source Soundboard Pedal (Part 4 – Final Implementation)”

SoundFloored: Open Source Soundboard Pedal (Part 3 – Breadboard Implementation)

A Raspberry Pi connected to a breadboard with various wires. The breadboard has a screen on it that says "Memes" on the first row and "RS: STOP" on the second

This is the third post in a series about designing and creating SoundFloored, an open source soundboard pedal! Check out the other posts in the series:


So this project has really been gaining some steam! I’ve figured out the design and managed to get a software implementation with two separate interfaces. Now though, I’m entering uncharted territory; the world of hardware electronics.

Now I say uncharted territory, but I’d be remiss if I didn’t mention that I’ve previously watched a Pluralsight course called something like “Introduction to Electronics” or “Electronics Fundamentals”, although it’s also worth mentioning that I remember approximately 5% of the content. Actually, one of the few things I did remember was how a breadboard works, which is a place to start at least!

Preparation

So although I’ve owned a number of Raspberry Pis over the years and have a lot of HATs/pHATs to go with them, I’ve never ventured far enough into the hardware electronics side of things to have bought any components. As such, I ordered a pretty generic looking “Electronics Fun Kit” that had pretty much everything I might need for this project; a breadboard, wires (especially wires that I could use to connect the Pi directly to the breadboard), buttons, LEDs, resistors etc. I’m sure there are higher quality components out there, but since this is all for prototyping I decided that in this case cheap and cheerful was what I was looking for.

An ELEGOO Electronics Fun Kit, which is comprised of a cardboard box and various electronics components such as wires, buttons, capacitors, resistors etc.
Continue reading “SoundFloored: Open Source Soundboard Pedal (Part 3 – Breadboard Implementation)”

SoundFloored: Open Source Soundboard Pedal (Part 2 – Software Implementation)

A diagram of the SoundFloored Architecture. There is one long red box at the bottom with the text "PyGame" inside. Above that is a single green box that says "SoundFloored Logic", with three seperate side-by-side blue boxes above it that say "Raspberry Pi", "Gui" and "Keyboard" respectively.

This is the second post in a series about designing and creating SoundFloored, an open source soundboard pedal! Check out the other posts in the series:


So now that I’ve prepared what I can, it’s now the step that can often derail the whole project: implementation.

For context the “Plan” section of this post was written before I started writing any code and “Implementation” was written shortly after I’d put the first version together.

Plan

I know, I know, I’ve already done the planning in the first part, “when are you actually going to start writing code“?

Well, except for tiny projects (usually single file, one-off scripts) I like to spend some time considering how the different parts will interact. The reasoning is that as soon as you start working with multiple modules and classes you’ve really got to consider how the parts will hang together, including what should “own” which parts of the logic, what the different interfaces should be and how the code should be laid out.

Continue reading “SoundFloored: Open Source Soundboard Pedal (Part 2 – Software Implementation)”

SoundFloored: Open Source Soundboard Pedal (Part 1 – Planning)

This is the first post in a series about designing and creating SoundFloored, an open source soundboard pedal! Check out the other posts in the series:


So I’m a guitarist in a band (shout-out to #DemocracyManifest). Not a particularly good guitarist, but nonetheless it’s a whole lot of fun and a great excuse to hang out with some friends for our weekly practice.

One of the issues that we have is that there are only three of us in the band; a guitarist, a bassist and a drummer. This is the dream when it comes to planning practices, but we’ve always had trouble with feeling our sound is “full” enough since a lot of the songs we cover have way more instruments and numerous subtle elements like small synth riffs, choir aahs and audio clips that we can’t really replicate in any appreciable way while trying to also play our instruments.

So “hey” I thought, “let’s try to over-engineer build something that can”!

Continue reading “SoundFloored: Open Source Soundboard Pedal (Part 1 – Planning)”