Skip to content

Instantly share code, notes, and snippets.

Avatar

David Glassborow davidglassborow

View GitHub Profile
@davidglassborow
davidglassborow / HashRings.fs
Created Jan 6, 2023 — forked from Horusiath/HashRings.fs
Hash rings implementations in F#
View HashRings.fs
module Demo.HashRings
open System
open System.Collections.Generic
/// Range is a tuple describing (s,e] - where `s` is start
/// (exclusive) index, while `e` is end (inclusive) index.
type Range = ValueTuple<int,int>
[<RequireQualifiedAccess>]
@davidglassborow
davidglassborow / chords.fsx
Created Dec 23, 2022 — forked from mnebes/chords.fsx
Chord progressions with F#
View chords.fsx
open System
type Interval =
| PerfectUnison
| MinorSecond
| MajorSecond
| MinorThird | AugmentedSecond // Enharmonically the same in 12TET
| MajorThird
| PerfectFourth
| DiminishedFifth | AugmentedFourth // Enharmonically the same in 12TET
@davidglassborow
davidglassborow / Podman as a Docker Desktop replacement.md
Created Dec 23, 2022 — forked from acdha/Podman as a Docker Desktop replacement.md
Instructions for using Podman as a Docker.app replacement on MacOS
View Podman as a Docker Desktop replacement.md

Podman as a Docker Desktop alternative

Prerequisites

  1. Install Homebrew from https://brew.sh

Install Podman

$ brew install podman
View ConcurrentDictionaryExtensions.cs
using System;
using System.Threading.Tasks;
namespace System.Collections.Concurrent
{
public static class ConcurrentDictionaryExtensions
{
/// <summary>
/// Provides an alternative to <see cref="ConcurrentDictionary{TKey, TValue}.GetOrAdd(TKey, Func{TKey, TValue})"/> that disposes values that implement <see cref="IDisposable"/>.
/// </summary>
@davidglassborow
davidglassborow / privateDu.fs
Created Jun 1, 2022
Alternate version of Private DU constructor
View privateDu.fs
// http://www.fssnip.net/ma/title/Alternate-version-of-Private-DU-constructor
module Email =
type EmailAddress =
private
| ValidEmail of string
| InvalidEmail of string
let ofString = function
| "validEmail" -> ValidEmail "validEmail"
| invalid -> InvalidEmail invalid
@davidglassborow
davidglassborow / GenericSqlProxy.cs
Created May 5, 2022
Generic TCP proxy from MS SMO project
View GenericSqlProxy.cs
// https://github.com/microsoft/sql-server-samples/blob/master/samples/features/sql-management-objects/src/GenericSqlProxy.cs
using System;
using System.Data.SqlClient;
using System.Net.Sockets;
using System.Net;
using System.Diagnostics;
using System.Threading;
using System.Threading.Tasks;
@davidglassborow
davidglassborow / tracing-intro-appinsights.md
Created Apr 28, 2022 — forked from ninjarobot/tracing-intro-appinsights.md
Correlated tracing in F# with Application Insights
View tracing-intro-appinsights.md

Tracing with Application Insights

Application logging is ubiquitous and invaluable for troubleshooting. Structured logging enables you to log formatted messages and the data fields separately so that you can see the messages but also filter on the data fields. Tracing takes this a step further, where you can correlate many log entries together as you follow a trace of execution through an application. Traces also include additional information about the execution process, such as the sequence of calls to dependencies and how long any given call may take.

Application Insights lets you see all of this data correlated together in an application. You can search for an error log and then see in the execution flow that the log entry was added right after a failed call to another service. Or you can see that a certain web request is slower than others because it spends a lot of time on many redundant data access calls.

What about OpenTelemetry?

@davidglassborow
davidglassborow / 0_README.md
Created Apr 25, 2022 — forked from mrange/0_README.md
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.

@davidglassborow
davidglassborow / key.md
Created Mar 3, 2022 — forked from shobotch/key.md
Twitter (un)official Consumer Key
View key.md

Twitter Official Consumer Key

Twitter for Android

type:            PIN
Consumer key:    3nVuSoBZnx6U4vzUxf5w
Consumer secret: Bcs59EFbbsdF6Sl9Ng71smgStWEGwXXKSjYvPVt7qys

Twitter for iPhone

type:            PIN

Consumer key: IQKbtAYlXLripLGPWd0HUA

@davidglassborow
davidglassborow / build.proj
Created Nov 24, 2021 — forked from dasMulli/build.proj
Sample CI build definition using MSBuild
View build.proj
<Project>
<ItemGroup>
<Solution Include="*.sln" />
<PublishProject Include="XXX.Mvc\XXX.Mvc.csproj" />
<TestProject Include="**\*.Test*.*proj" Exclude="XXX.Tests.Shared\XXX.Tests.Shared.csproj" />
</ItemGroup>
<Target Name="Build">
<MSBuild Projects="@(Solution)" Targets="Restore" ContinueOnError="ErrorAndStop" UnloadProjectsOnCompletion="true" UseResultsCache="false" />
<MSBuild Projects="@(PublishProject)" Targets="Publish" Properties="Configuration=Release" ContinueOnError="ErrorAndContinue" />