Skip to content

Instantly share code, notes, and snippets.

View Microsoft.PowerShell_profile.ps1
# Stored under My Documents\WindowsPowerShell
function global:prompt
{
"╭─ PS $($executionContext.SessionState.Path.CurrentLocation) $('+' * ($nestedPromptLevel))`n╰─$ ";
}
@mrange
mrange / commit-msg
Created Sep 26, 2022
gerrit commit hook
View commit-msg
#!/bin/sh
# From Gerrit Code Review 2.12.3
#
# Part of Gerrit Code Review (https://www.gerritcodereview.com/)
#
# Copyright (C) 2009 The Android Open Source Project
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
View FsDistanceField.fsproj
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<Compile Include="Program.fs" />
</ItemGroup>
@mrange
mrange / 0_readme.md
Last active Sep 21, 2022
Reactor shader inspired by Microsoft Reactor Graphics. For us in windows terminal
View 0_readme.md

Install shader

Note: Doesn't work on latest preview of windows terminal (2022-09-15) but should work on later previews.

  1. Save reactor.hlsl to disk, note the path for later.
  2. Open Windows terminal settings
  3. Open settings as JSON
  4. Add a custom shader to the default profile, see excerpt below.
@mrange
mrange / thindal.hlsl
Created Sep 11, 2022
Thindal Windows Terminal
View thindal.hlsl
#define WINDOWS_TERMINAL
Texture2D shaderTexture;
SamplerState samplerState;
// --------------------
#if defined(WINDOWS_TERMINAL)
cbuffer PixelShaderSettings {
float Time;
float Scale;
@mrange
mrange / 0_README.md
Last active Sep 2, 2022
FsGenAll - Generate all possible values for an F# type
View 0_README.md

FsGenAll - Generate all possible values for an F# type

writing test code I often use FsCheck. However, sometimes I want to generate each possible value for a test model and check the properties for that.

My typical use case is something like this:

  1. Create an ADT that models what I want to test
  2. Generate all possible values of this test model
  3. Generate test data from the test model
  4. Run the function under test that produces a result
@mrange
mrange / 0_the_easy_way.cs
Last active Aug 19, 2022
Examples IEnumerable implementing a fibonacci series
View 0_the_easy_way.cs
// Example on the "easy" way to generate the fibonacci sequence
// https://en.wikipedia.org/wiki/Fibonacci_number
// Take the first 20 fibonacci numbers and print them
// the "easy" way.
foreach(var n in Fibonacci().Take(20))
{
Console.WriteLine(n);
}
View GeneratedDI.cs
namespace CsDI
{
partial record DI
{
IY? _singletonOf_IY;
IZ? _singletonOf_IZ;
public void Get(out IX v)
{
@mrange
mrange / 0_README.md
Last active Aug 10, 2022
Simple physics in F# and WPF
View 0_README.md

Simple physics in F# and WPF

This is an example on how to use WPF and F# to do some simple physics using Verlet Integration.

The program creates a system of particles and constraints. Particles have inertia and is affected by gravity but their motion is also contrained by the constraints.

I tried to annotate the source code to help guide a developer familiar with languages like C#. If you have suggestions for how to improve it please leave a comment below.

How to run

@mrange
mrange / 0_README.md
Last active Jun 29, 2022
Simple physics game in F# and WPF
View 0_README.md

Simple physics game in F# and WPF

This is an example on how to use WPF and F# to do a simple physics game using Verlet Integration.

The program creates a system of particles and constraints. Particles have inertia and is affected by gravity but their motion is also contrained by the constraints.

You control the ship by firing rockets attached to the ship. Use the arrow keys to fire the rockets.

I tried to annotate the source code to help guide a developer familiar with languages like C#. If you have suggestions for how to improve it please leave a comment below.