Monday 26 December 2022

Replacing a disk on FreeNAS

The documentation for the older FreeNAS server is slowly disappearing from the Internet. Thank you to the blog post on this link for instructions on how to rebuild a FreeNAS RAID.

If you have a degraded RAID 1 array in FreeNAS you may need to replace the disk and trigger the rebuild on your NAS device. Thankfully it is really easy to repair broken raid in FreeNAS.

If you go to disk > software raid and click on tools you can send commands and if you send the status command you will see that your RAID 1 is marked degraded.


You can also see which disk is still running so that you know which disk to remove, the next step is to forget the broken disk. All you need to do is use the forget command.


Once you have done this you can insert your new disk into the array and the rebuild should start automatically, it may take some time to rebuild a RAID 1 array.


A few hours later you will have fixed a degraded RAID 1 array which you can once again confirm by running the status or list command in the freenas GUI. The FreeNAS RAID is pretty user friendly in this regard since you can remove and add disks easily and have a raid rebuild running in a matter of seconds. 

Wednesday 23 November 2022

Running multiple identities on GitHub on Windows

 

You can run multiple identities on GitHub, by putting a copy of the two files

id_ed25519 and id_ed25519.pub 

in the 

C:\Users\<username>\.ssh 

directory.

It is worth creating two subfolders

C:\Users\<username>\.ssh\user1 and

C:\Users\<username>\.ssh\user2

to keep the original copies of the keys and copy them into the parent folder as required.

If you try and clone a GitHub repo under the wrong user, than isn't permissioned, then you will get the error:

Cloning into 'myrepo'...

remote: Repository not found.

fatal: repository 'https://github.com/myteam/myrepo.git/' not found



Friday 14 October 2022

ZoomIt shortcuts

Ctrl+1 Zoom

Ctrl+5 Record

e delete all


pens

r red

b blue

g green

o orange

y yellow

p pink


shift line

ctrl rectangle

elipse tab

shift+ctrl arrow

w white

b black


ctrl+c copy

ctrl+s save




Friday 30 September 2022

Docker & Kubernetes cheat sheet

Attach to a running container

docker exec -i -t <container> /bin/bash

Test network connectivity

apt update
apt install net-tools
apt install curl
curl -kv

Read logs on failed startup


Networking tools

docker run --rm -it praqma/network-multitool bash

Wednesday 28 September 2022

3D Printer tips for the Longer LK4

Tree supports are the best kind of support. Select "Touching Buildplate" to avoid having them join the print.

Support structure: Tree

Support placement: Touching Buildplate


Thursday 1 September 2022

READPAST SQL hint

 We had a batch process that retrieved 1,000s of rows from SQL Server, processed them and updated them.

Multiple readers were operating in parallel. We found that throughput hit some limitations because of the number of locked rows.


READPAST is a good SQL hint that will ignore locked rows when returning a resultset. If the rows are locked, they are excluded.

This allows a processor to read unlocked rows and process them. Once the locked rows are released they can be processed if applicable.

Using NOLOCK and READPAST table hints in SQL Server | TechRepublic

Friday 26 August 2022

SSH to Freenas

If you SSH to freenas, it errors:

Unable to negotiate with <ipaddress> port 22: no matching host key type found. Their offer: ssh-dss

Solution:

 ssh -oHostKeyAlgorithms=+ssh-dss freenas

Saturday 28 May 2022

Setting a background colour to transparent in GIMP

 Sometimes you have an image with antialising against a background colour, such as white.


If you paste it over a coloured box you get this:


To make the background colour transparent, use Gimp's Color to Alpha (Layer > Transparency > Color to Alpha).


It will remove the background.

Allowing you to paste it in the box:





Saturday 30 April 2022

Correlation ID vs Causation ID

causation or correlation id? - EventStoreDB - Event Store Discuss Forum

From Greg Young:

The are both really simple patterns I have never quite understood why

they end up so misunderstood.

Let's say every message has 3 ids. 1 is its id. Another is correlation
the last it causation.

The rules are quite simple. If you are responding to a message, you
copy its correlation id as your correlation id, its message id is your
causation id.

This allows you to see an entire conversation (correlation id) or to
see what causes what (causation id).

Wednesday 6 April 2022

Client hangs connecting to the Cosmos DB emulator running as a Linux container

 I had created a docker-compose file for building a full environment which included a Cosmos DB emulator. However I found the client code - running locally on Visual Studio could not connect to the emulator. It would hang indefinitely (even with HTTP request timeouts overriden in the Client Factory).

I ran the emulator as a local service (not containerised) and this worked, indicating a problem specific to the container.

I found the error was the missing environment variable

AZURE_COSMOS_EMULATOR_IP_ADDRESS_OVERRIDE

This is required otherwise the emulator returns an IP address the client cannot connect to.

My docker-compose file now included the following variables:

environment:
      - AZURE_COSMOS_EMULATOR_PARTITION_COUNT=3
      - AZURE_COSMOS_EMULATOR_ENABLE_DATA_PERSISTENCE=true
      - AZURE_COSMOS_EMULATOR_IP_ADDRESS_OVERRIDE=${COSMOS_ADDRESS_OVERRIDE:?IPAddress}



Thursday 31 March 2022

Project Templates

SmartHomeFunctions -  Azure Functions that run a GitHub workflow to publish to Azure


Monday 14 March 2022

GitHub actions deployed failing Function

I had provisioned an App Service Plan and Linux Consumption Function using terraform.

Then connected Visual Studio to perform CI/CD with Github actions.

However when it completed it deployed a Function App with no functions.

When the timer ran it also said:



I ended up creating a new one from scratch using Visual Studio to see what was going wrong.

The first thing I noticed was that the failing Function App had a "Deployment Credentials" blade whereas the working one didn't.

This made me suspect that the App Service Plan was different.

Indeed, I then compared the working one to the terraform definition that provisioned the broken one.

Immediately it was obvious that there were substantial differences, including:


The App Service Plan must be set to "FunctionApp", not "Linux".

Setting the Function app kind and os_type probably help too.


Summary

So, the old rules apply for building terraform files. Actually build a working resource first using the Wizards and Visual Studio, then create a Terraform file, import the resource, plan it, and compare the differences until there are none. Then you know you have a working Terraform file.

Sunday 13 March 2022

Useful kuso queries

Get the latest row for each of the Azure Functions

requests 

| summarize arg_max(timestamp, name) by name, success

| project timestamp, name, success


Friday 4 March 2022

Git shortcuts

Git

Added to C:\Program Files\Git\usr\bin

With the folder added to the path environment variable

ga.bat

@git add %1

gd.bat

@git difftool %1

gs.bat

@git status %1

Set default branch

git config --global init.defaultBranch main

Terraform

C:\Program Files (x86)\terraform\tf.bat

@terraform %1 %2 %3 %4 %5






Create SSH key in Windows

 To create a SSH key for Windows:

 ssh-keygen -t ed25519 -C "xxx@email.com"