Concat two arrays in C#

		public static T[] Concat<T>( this T[] array1, T[] array2 ) {
			var result = new T[ array1.LongLength + array2.LongLength ];
			array1.CopyTo( result, 0 );
			array2.CopyTo( result, array1.LongLength );

			return result;
		}

Some useful C# Swap methods

public static class SwapExt
{
	[MethodImpl(MethodImplOptions.AggressiveInlining)]
	public static void Swap<T>(ref T? left, ref T? right) => (left, right) = (right, left);

	[Pure]
	[MethodImpl(MethodImplOptions.AggressiveInlining)]
	public static (T? right, T? left) Swap<T>(this T? left, T? right) => (right, left);

	[Pure]
	[MethodImpl(MethodImplOptions.AggressiveInlining)]
	public static (T? right, T? left) Swap<T>((T? left, T? right) tuple) => (tuple.right, tuple.left);
}

Pay close attention to which method you think is being used. (The refs versus the tuples.)

C# null coalescing operator, ??

C# has a nice ?? operator that can be chained.
In a statement, it will return the first non-null value or null if none are found to not be null.

For example, if you had the code:

string? value1 = null;
string? value2 = nameof(value2);
string? result = value1 != null ? value1 : value2;

The last line could be simplified down to:

string result = value1 ?? value2;

As far as I know, there is no limit on how many ?? can be chained!

Dream of Peace

I had a dream… A dream last night.
I saw the world in a different light.
A place to live without despair.
Where men can breathe a clearer air.

A joy like this, I’ve never known.
It filled my heart and filled my soul.

And the dream of peace lives on..
And the dream of peace lives on!

Protiguous, 2021
Note: This song may be from my childhood, but I have been unable to find it again.

Scale of Intelligence Levels

  1. God-like – Able to change inputs and outputs
  2. Intuitive – Able to predict a sequence of outputs with missing inputs.
  3. Intelligent – Able to recognize the pattern of inputs even with missing inputs.
  4. Sentient – Able to recognize a sequence of inputs.
  5. Algorithmic – Able to activate the correct outputs in the correct sequence for a given input in the correct sequence.
  6. Logical – Able to activate the correct outputs for a given input.
  7. Moron – Unable to activate the correct outputs in the correct sequence for a given input.
  8. Idiot – Unable to activate the correct outputs for a given input.
  9. Alive – Able to respond to inputs.
  10. Lifeforms – Able to modify the inputs and create outputs.
  11. Exists – Has inputs and outputs.
  12. Nonexistent – Has zero inputs and outputs.

Examples:

  1. God-like – God, Q, etc..
  2. Intuitive – Any smart woman, mothers, grandmas..
  3. Intelligent – Any above average human.
  4. Sentient – Common household pets: dogs, cats, etc..
  5. Algorithmic – Computers, smartphones, etc..
  6. Logical – calculators? complex machines?
  7. Moron – G.W.B.
  8. Idiot – D.J.T.
  9. Alive – animals, insects
  10. Lifeforms – bacteria, viruses
  11. Exists – I dunno.. sand, rocks maybe? Heheh.
  12. Nonexistent – Nothing unreal exists, according to Spock.

Just some things I was thinking about one day.
Decided to post it to get any constructive feedback.
FYI, this scale is not fully fleshed out or set in stone.
Also, some things can belong to multiple descriptions. 🙂

From my old blog, http://ai-brain.blogspot.com/2012/12/scale-of-intelligence-levels.html

Fix for the message “Windows is still setting up the class configuration for this device”.

So, the Hyper-V Manager stopped allowing me to open the settings on any virtual machine. It would just stay on “loading…”; the cancel button worked but the properties just would not show up.

So, I uninstalled and reinstalled all Hyper-V settings under the Control Panel “Turn Windows features on or off”. No change. The Hyper-V settings still would not load.

So, I checked the device manager. There was a yellow flag alert under one of the WiFi adapters with the message, “Windows is still setting up the class configuration for this device.”.

Okay? Sounds like the network subsystem for Windows got borked. <insert high-tech-sounding cause here>

Tried a disable/enable. No change.

So, I did a network reset. “Settings”, “Networks”, “Status”, scroll down to “Network Reset”.

Rebooted. Everything in Hyper-V works now.. You’d think there would be a more robust system for a feature many people use, right?

How to save some Emergency Drive Space for SQL Server

Running out of disk space on a SQL Server server is something that you should never allow to happen, but it can happen.

If you need to be the emergency Fireman putting out the fire, here is a way to “reserve” some drive space ahead of time. It is literally an 8GB “dummy” file that you can delete at any time without worry – nothing is using the file. Just SHIFT+DELETE it so it doesn’t fill up the Recycle Bin.

fsutil.exe file createnew "Emergency Disk Space (safe to delete).$$$" 8589934592

This will create an 8GB temporary file in the current folder. Adjust the size to suit your future needs.

When you need to reclaim the disk space, simply select the file and shift+delete (no need to send it to the Recycle Bin).

Here’s the gist if you don’t feel like copy & pasting.