A lemon


July 2021

Dactyl-Manuform WIP
Dactyl-Manuform WIP2021/07/01

Uploading QMK firmware to ProMicro

Because finding the command was a pain:

cd "\Program Files (x86)\Arduino\hardware\tools\avr\bin" rem Don't forget to watch Device Manager to see which COM port is being used mode com5: BAUD=1200 parity=N data=8 stop=1 avrdude -C ..\etc\avrdude.conf -v -p atmega32u4 -c avr109 -P com5 -b 57600 -D -U flash:w:dactyl-custom-20210701.hex
Things I shouldn't be doing every week - 2021/07/01


June 2021


Mounting Hyper-V gateway shares in Ubuntu

Because I keep forgetting what the command is:

sudo mount -t cifs -w -o username=user,uid=1000,gid=1000 //_gateway/folder ./incoming
Things I only do once a year - 2021/06/25


May 2021

Current layout
Current layout2021/05/22

QMK firmware fun

Just some notes because I do this infrequently enough that I keep forgetting what to do.

The JSON keymap from QMK Configurator can be converted to keymap.c using the below command in QMK console. Just remember that you might have custom code left from your previous compile, so don't overwrite it!

qmk json2c filename.json > keymap.c

Edit the .c file and remember to check config.h and rules.mk. These are all in:


Then run qmk compile, and move the resulting .hex file into the Arduino folder:

copy "C:\Users\Swift\qmk_firmware\handwired_dactyl_manuform_5x6_mrmisterswift.hex" "C:\Program Files (x86)\Arduino\hardware\tools\avr\bin\dactyl-custom-20210522.hex"

Now comes the run part. If you're too lazy to solder the reset buttons, and can't access the RESET key, you'll need to close the RST pin (3rd from the top on the right side, if you're holding the micro USB pointing up) to one of the GND pins (3 or 4 on the left side). Do this with Device Manager open, so you can see which COM port it shows up as. Then, prep the following .bat file:

mode com5: BAUD=1200 parity=N data=8 stop=1 avrdude -C ..\etc\avrdude.conf -v -p atmega32u4 -c avr109 -P com5 -b 57600 -D -U flash:w:dactyl-custom-20210522.hex

Get the commandline ready with the prompt ready to go, then tap the pins together again with jumper cable, and press Enter on the other keyboard you have plugged in.

As for the actual config itself, some peculiarities:

Layer Tap-Toggle, i.e. TT(n), must have KC_TRANS on the target layer. If you are on the origin layer, it will toggle the destination layer to on. The origin layer is still enabled, but any key on the target layer that is not KC_TRANS overrides it. To go back, instead of dedicating a key to TO(0), just double tap the TT() key on your origin layer to return permenantly, or hold it to temporarily have the destination layer disabled and your access to the origin layer restored.

ACTION_TAP_DANCE_DOUBLE doesn't seem to work with TO(n) (maybe I used MO by mistake?), use ACTION_TAP_DANCE_LAYER_MOVE instead. For functions, use ACTION_TAP_DANCE_FN, because _DOUBLE won't pick up your custom keycode.

Macros for Alt+0183 style functions need to use the numpad numbers, not the number row ones. Which means:

// SEND_STRING(SS_LCTL("0183")); register_code(KC_LALT); tap_code(KC_P0); tap_code(KC_P1); tap_code(KC_P8); tap_code(KC_P3); unregister_code(KC_LALT);

Lastly, LT(layer, kc) only activates the layer momentarily when held. Use the tap dance above for a permanent switch.

Dactyl Manuform Master Race, checking in - 2021/05/22


September 2020

PowerBI report
PowerBI report2020/09/16
Get field changes from API
Get field changes from API2020/09/16
Collapse adjacent non-changes
Collapse adjacent non-changes2020/09/16

Visualising changes in columns of a SharePoint document library

I discovered that I could query the version history and related column changes for any file in SharePoint via the api:

https://<subdomain>.sharepoint.com/sites/<site>/ _api_web/lists/GetByTitle('<listName>)/items(<itemID>)/versions

There's a bit of XML table expanding, but it seems everything is there. Unfortunately I have yet to figure out how to do these in bulk.

Once we have a list of every state of the column at a specific point in time, we can change it to a list of state changes by time period, as shown in the 3rd image. So the first table we get would be the nodes, and the table we need to create is one of all the edges between the nodes.

There's a bit of struggling with the permissions in PowerBI with the data privacy firewall, as we're pulling the itemIDs off from the SharePoint, then querying the individual version history for each item in a separate query. I couldn't figure out how to solve this properly, so I disabled the warning.

The benefit this report brings is that we can visualise our existing list of tickets with their workflow status, and track their state, or stage-by-stage movement, of each tickets on a detailed level over a period of time.

While before we could only see the current state of everything (which tickets are currently overdue or complete), now we can see *when* tickets were closed on a day-by-day (or even minute-by-minute) basis.

We could further improve this by using Time-Intelligence to be able to visualise the breakdown of tickets by status at any single point in time.

Mister "Time is but an illusion" Swift - 2020/09/16


September 2020

Agenda-style Adaptive Card
Agenda-style Adaptive Card2020/09/15

Inspired by the 'Agenda' sample Adaptive Card, I decided to make one that showed how far along an entity is in one of our workflows.

The primary key and title on top are pulled from a master data SharePoint list.

The Power Automate Flow then checks if a document set has been created in the paperwork document library, and for each stage it checks if any forms are present, and what their current status is.

Ideally I would have done it in a more programmatic and generalised manner, but I hardcoded it for the sake of simplicity and time (and resilience to failure).

— The Ghost of Lost and Forgotten Corporate Paperwork - 2020/09/15


September 2020

First query
First query2020/09/13
Another query
Another query2020/09/13

Put together yet another over-engineered and convuluted Microsoft Power Automate flow, this time for filing and cataloguing approvals.

tl;dr Outlook, Adaptive Cards, Teams, Sharepoint, Sharepoint Document Sets.

When a user flags an email in a specific folder, it tries to guess a primary key, and asks the user to confirm. It then checks if a document set has already been created for this entity on Sharepoint.

If it has, we save the flagged email and update the metadata accordingly. We also check if a matching form to the approval is present, and update that one as well.

The user can then file the documents on another system we do not control, and once they receive a ticket number, they can update straight from MS Teams.

The reason for this process is to save all the relevant emails and attachments in a centralized, managed location on Sharepoint, with the appropriate metadata for primary keys, status, and normalized form types.

— WTB F# to WDL transpiler - 2020/09/13


August 2020

Create document set
Create document set2020/08/25
Update document set
Update document set2020/08/25

Creating and updating Document Sets via MS Power Automate

Both using 'Send an HTTP request to Sharepoint':

Create: Method: POST Uri: _vti_bin/listdata.svc/<listName> Headers: Accept: application/json;odata=verbose Slug: /sites/<site>/<list%20name>/<documentSetName>|<contentTypeID>
Update: 'Send an HTTP request to Sharepoint' Method: POST Uri: _vti_bin/listdata.svc/<listName>(<documentSetId>) Headers: Accept: application/json;odata=verbose X-HTTP-Method: MERGE If-Match: etag Body: { "Field1" : "value1", "Field2" : "value2", ... "Fieldn" : "valuen" }

Some notes:

listdata.svc prefers (?) names with whitespace removed, while the slug prefers spaces encoded to %20. It also accepts the Id of a file or list item in parenthesis as an index accessor. MERGE will update the existing properties with the changed ones (instead of replacing the existing properties that were not specified with defaults(?)). Don't forget to include the etag of the item to be changed, or it will fail.

Mister "Learning from mistakes" Swift - 2020/08/25


August 2020

Create document set
Create document set2020/08/25

Updating visiblity of fields on Sharepoint's NewForm and EditForm

Connect-PnPOnline -Url https://<domain>.sharepoint.com/sites/<site> -UseWebLogin $list = Get-PnPList -Identity "Form Name" $ctx = Get-PnPContext $field = Get-PnPField -List $list -Identity "Field Name" $field.SetShowInNewForm($false) $field.SetShowInEditForm($false) $field.Update() $ctx.ExecuteQuery()

Some notes:

PowerShell Sharepoint PNP -Identity is okay with names with spaces in it. Sometimes the update/execute fails for certain fields, haven't had the time to figure out why.

Mister "Learning from mistakes" Swift - 2020/08/25


August 2020

Screenshot of Flow 1/6
Screenshot of Flow 1/62020/08/20
Screenshot of Flow 2/6
Screenshot of Flow 2/62020/08/20
Screenshot of Flow 3/6
Screenshot of Flow 3/62020/08/20
Screenshot of Flow 4/6
Screenshot of Flow 4/62020/08/20
Screenshot of Flow 5/6
Screenshot of Flow 5/62020/08/20
Screenshot of Flow 6/6
Screenshot of Flow 6/62020/08/20

Outlook to Sharepoint Document Set with Microsoft Power Automate

Some of our end users were presented with the problem that their current filing system (Plain Old Folders) wasn't scaling well to the modern-day influx of reports and forms, and needed an interim measure until a proper enterprise workflow was implemented.

Currently, they receive an email per customer, with up to three separate forms which need to be actioned via different workflows. Currently we were tracking this via Excel, and as you can expect, queries were getting stuck and forgotten about for months on end.

Our current prototype is as follows:

Email is moved to a designated folder in the user's Outlook mailbox. This triggers a Power Automate flow.

First, we store some data from the email into more convenient variables. The subject, the person who sent the email, the date, and so forth. We need to do some minor string manipulation on these to make them print friendly for humans.

Next, we check if the unique key for the customer is placed in the email subject. Ideally I'd use RegEx for this, but there does not seem to be a vanilla regex action or function available. We then take what we think might be the customer key, and search in a Sharepoint list containing all the keys. This both checks if the key is valid, as well as returns us the ID of the customer in the Sharepoint list, which we will need later on.

We then need a name for the document set we are going to create for this specific email. If we have the customer ID, we use that, otherwise we fall back to something like "Received from John Doe at 2020/08/20". We cannot use the customer's name yet as our master data still needs some clean up to disambiguate duplicates.

We then check if we already have a document set with this exact name in the document library. We shouldn't have duplicates, but we check in case somehow the flow gets triggered twice for the same email, or the user completing the form sends it twice by accident. If it does not already exist, we are free to create the document set. Unfortunately there is no built-in action, so we need to use 'Send an HTTP request to Sharepoint' along with some minor listdata.svc REST work.

Once this is complete, we Export the triggering email so that we have access to its' content as a binary variable, then we save it into the document set using 'Upload file to folder (Sharepoint)'. We then use a Control/for-each loop to do the same for each of the attachments whose content-type does not begin with 'image'. If any of these files have already been uploaded, the entire flow will stop and exit with a failed status.

Finally, we use Microsoft Teams to send the user a message informing them that the document set was created, along with a link to access it. I chose this over an email to avoid cluttering their inbox too much. They can now access the forms on Sharepoint, where they can update columns such as Status, Approver, Ticket number, and Date Completed.

All of this can then be queried via Export to Excel, or using PowerQuery to Load Data from Sharepoint List. We have created both a new Excel sheet with a few charts (Number of Forms per status, Number of Forms not completed older than 30 days, Forms awaiting on Approval by person, etc.), as well as integrated the live data from Sharepoint into the old tracking sheet.

Mister "Go with the Flow" Swift - 2020/08/21


August 2020

Visual Studio Code screenshot
Visual Studio Code screenshot2020/08/20
In-memory F# Record
In-memory F# Record2020/08/20
Resulting HTML TABLE
Resulting HTML TABLE2020/08/20

Spotify Playlist Scraper

I haven't been using F# for a month or two now so I decided to do a little one day project to keep the brain gears running.

The goal: extract all my public playlists from Spotify so I can dump them on this microblog. I could have probably achieved the same result using PostMan or some other REST tool, or heaven forbid, copy and pasting it from the pages, but it seemed like a neat little problem to tackle that wasn't completely out of my league.

So, I grabbed my profile URL from Spotify's share button, poked around a bit with the DevTools HTML Inspector. It looked simple enough to grab the song data via either DOM selectors or Regex, so away I went and attempted to open the URL via a HTTP request in F# and bam. 400 Bad Request.

Huh? Odd. I ran it through wget, and sure enough, everything loads fine. It's a public URL, I can open it in an Incognito window without logging in, I can download it via the terminal, what am I missing?

I copied the headers as-is from the Network tab in DevTools, to mixed result. Long story short — I completely neglected the fact that I first need to grab an (anonymous) authentication bearer token, and that the proper way to get the data was not to parse the HTML page, but to just poke the REST API.

I then used a naïve and lazy way of dumping it into an HTML TABLE, and voila, mission completed, but my scalp left severely scratched in confusion.

Mister "Please don't judge my music taste" Swift - 2020/08/20


December 2019

OLED lolcat
OLED lolcat2019/12/06
LED Bar Graph
LED Bar Graph2019/12/07

Raspberry PI and LED Bar Graph

Bought a Raspberry PI with the idea of tinkering around and making a bandwidth meter in the style of the old hi-fi's/stereos.

Got about as far as wiring up one (of two) LED Bar Graphs to a multiplexer, to the PI, and then running some rudimentary copy-and-paste'd Python, before I got bored and ended up using the Raspberry for the more mundane usual network activities of Pi-Hole, mini-DLNA, and a "micro NAS".

Mister "How the hell does solder work?" Swift - 2019/12/07