πŸŽ™ Dithering: 13 Sept 22 - Discord AI

Enjoyed the discussion on Midjourney and AI images, but it was the final two minutes on the UIs of Slack and Discord that I found to be the most interesting part of this episode.

Sunny day today. Might need to bring out the hat once again.

Really tired this morning. Work up last night due to a production incident. Must say that nothing goes out to prod quicker than a 3 AM change you hope will just shut the damn PagerDuty alerts up.

Letting Queries Actually Be Queries In Dynamo-Browse

I spent some more time working on dynamo-browse over the weekend (I have to now that I’ve got a user-base πŸ˜„).

No real changes to scripting yet. It’s still only me that’s using it at the moment, and I’m hoping to keep it this way until I’m happy enough with the API. I think we getting close though. I haven’t made the changes discussed in the previous post about including the builtin plugin object. I’m thinking that instead of a builtin object, I’ll use another module instead, maybe something like the following:

const ext = require("audax:ext");

ext.registerCommand("thing", () => console.log("Do the thing"));

The idea is that the ext module will provide access to the extension points that the script can implement, such as registering new commands, etc.

At this stage, I’m not sure if I want to add the concept of namespaces to the ext module name. Could help in making it explicit that the user is accessing the hooks of “this” extension, as opposed to others. It may leave some room for some nice abilities, like provide a way to send messages to other extensions:

// com.example.showTables
// This extension will handle events which will prompt to show tables. 
const ext = require("audax:ext/this");

ext.on("show-tables", () => {
    ui.showTablePrompt();
});

// com.example.useShowTables
// This extension will use the "show-tables" message "com.example.showTables"
const showTables = require("audax:ext/com.example.showTables");

showTables.post("show-tables");

Then again, this might be unnecessary given that the JavaScript module facilities are there.

Anyway, what I actually did was start work on making queries actually run as queries against the DynamoDB table. In the released version, running a query (i.e. pressing ? and entering a query expression) will actually perform a table scan. Nothing against scans: they do what they need to do. But hardly the quickest way to get rows from DynamoDB if you know the partition and sort key.

So that’s what I’m working on now. Running a query of the form pk = "something" and sk = "else" where pk and sk are the partition and sort keys of the table will now call the dynamodb.Query API. This also works with the “begins with” operator: pk = "something" and sk ^= "prefix". Since sk is the sort key, this will be executed as part of a query to DynamoDB.

This also works if you were to swap the keys around, as in sk = "else" and pk = "something". Surprisingly the Go SDK that I’m using does not support allow expressions like this: you must have the partition key before the sort key if you’re using KeyAnd. This touches on one of the design goals I have for queries: the user shouldn’t need to care how the expression actually produces the result. If it can do so by running an actual query against the table, then it will; if not, it will do a scan. Generally, the user shouldn’t care either way: just get me the results in the most efficient way you can think of!

That said, it might be necessary for the user to control this to an extent, such as requiring the use of a scan if the planner would normally go for a query. I may add some control to this in the expression language to support this. But these should be, as a rule, very rarely used.

Anyway, that’s the biggest change that’s happening. There is something else regarding expressions that I’m in the process of working on now. I’ll touch on that in another blog post.

I miss working on monoliths. Micro-services are just so painful to test. So many moving parts you need to get working before you can even start.

Then you’ve got serverless stuff. Go to test those, and wow, you’ll wish you were testing micro-services. 😟

Saw someone at work use Numi to show some maths so I’m giving it a try. Only just started using it but I already like it. Feels very similar to Tot and Boop: a small MacOS utility that fits nicely in that middle-ground between Calculator and a spreadsheet.

Screenshot of Numi

Absolutely incredible seeing how far AI image creation has come. I know this was years in the making, but with all the recent launches, it feels like the change has happen over mere months. Will need to give it a try.

At least one photo will be taken at this event (well technically the setup of the event).

Sign that says 'Photo and video will be taken at this event'

Discovered that I can use a URL shortener to grab a link from my Android phone and open it on my iPad. I guess that means I’m finally up to speed on the awesome ideas of 2007. πŸ˜€

My whimsical side might be developing a little. I’m starting to come round to the wiggly seek bar in Android.

Rail works.

The Australian Republic Question

With the passing of Queen Elisabeth II, the talk of whether Australia should become a republic will probably start making the rounds once more. I don’t consider myself a royalist, and when the last referendum on the issue came around, I voted in favour of becoming a republic. The idea of having the British Royal Family as the head of state of a country halfway around the world seem anachronistic to me, and I was disappointed when the referendum failed.

Since then, my position has been become slightly more nuanced. I still believe in the ideals of becoming a republic β€” in being a country that is more-or-less completely self governing. But after reading this article from Vox.com, I’ve come to see some benefits of having a head of state that is removed from the day-to-day politics of government. Sure, the stability from such a figurehead may not have been wholly constant, but that “lack [of] semblance of legitimacy” that comes from the royals being the head of state does provide some reassurance. One less divisive thing for people to think about when that position changes hands.

So if the referendum was held today, which way would I go? I’d probably still vote “yes”, but it would have a “can we make it such that the office is not in any way marred in the politics of the day?” qualifier attached to it.

Then again, I talking about the terms of a theoretical referendum where the proposed system is more than just replace-the-monarchy-with-a-president. Such concerns regarding the division of power might already be settled within the constitution. I really don’t know: might be worth looking up if the question were to come up again.

Either way, we’ll see which way the winds blow.

Flags at half mast at the school today to mark the passing of Queen Elizabeth II.

Australian and Aboriginal flags at half mast

Those worried about video-centric podcasts ruining the format can allay their fears. The killer feature of podcasts is that you can listen to them without having to pay attention to anything visual. Video may fill a nitch, but I can’t see it taking over the entire format.

I’ve been tinkering around with Pico-8 game development recently. I like how limiting it is. Expectations are not too high, which helps given that I’m hopeless at the non-coding aspects of game design, like artwork.

It’s quite a joy. Reminds me a lot of making games in QBasic back in the day.

And while we’re on the subject of tests: make it easy for me to launch tests quickly from the IDE. Refusing to run a test because a particular environment variable is not set is really annoying, especially when a suitable default value would work 90% of the time.

The unit test I’m working on uses so many mocks it’s infuriatingly difficult to change anything. I wonder if a better approach is to just mock out external dependencies and use the actual services in the test. May not be as unit-ey, but would make it easier to move things around.

Finished version 0.0.3 of Audax Toolset yesterday. The code has been ready since the weekend, but it took me Sunday morning and yesterday (Monday) evening to finish updating the website. All done now.

Now the question is whether to continue working on it, or do something different for a change. There are a few people using Dynamo-Browse at work now, so part of me feels like I should continue building features for it. But I also feel like switching to another project, at least for a little while.

I guess we’ll let any squeaky wheels make the decision for me.

πŸ”— emperror.dev/errors

Drop in replacement for the github.com/pkg/errors package. The original package is archived as there’s a plan to change how Go handles errors. But not all of us are ready to adopt this yet.

Detecting When GetItem On DynamoDB Returns Nothing

I was trying to remember how best to detect when a GetItem call to DynamoDB returns no values. That is, when there’s no item with that key in the table. This is in a project that is using v2 of the Go AWS SDK.

After poking through some old code that did this, it looks like the way to do so is to check that the returned Item field is nil:

out, err := p.client.GetItem(ctx, &dynamodb.GetItemInput{
    Key:       key,
    TableName: tableName,
})
if err != nil {
    // Error getting the item
    return nil, err
} else if out.Item == nil {
    // No item found
    return nil, nil
}

// Do the thing with out.Item

Ok, I can live with this approach. I’m kinda happy that I don’t need to check the error message, since doing so using the Go AWS SDK is a bit of a pain.