Skip to content

Instantly share code, notes, and snippets.

View NickDarvey's full-sized avatar

Nick Darvey NickDarvey

  • Melbourne, Australia
View GitHub Profile

Keybase proof

I hereby claim:

  • I am nickdarvey on github.
  • I am nickdarvey (https://keybase.io/nickdarvey) on keybase.
  • I have a public key ASDKWwfb6jrQ5IhbjgxGAumWL7pim6c2OfV7IlYDVYzVLAo

To claim this, I am signing this object:

@NickDarvey
NickDarvey / Program.cs
Last active November 4, 2016 06:25
DataContract deserialization of Set<T>
using System;
using System.Diagnostics;
using System.IO;
using System.Runtime.Serialization;
using static LanguageExt.Prelude;
class Program
{
static void Main(string[] args)
{
@NickDarvey
NickDarvey / NameValueCollectionToLookup.cs
Last active June 12, 2017 15:17
NameValueCollection to IEnumerable, ILookup
// https://stackoverflow.com/questions/391023/make-namevaluecollection-accessible-to-linq-query
using System;
using System.Collections.Specialized;
using System.Linq;
namespace System.Collections.Specialized
{
public static class Extensions
{
@NickDarvey
NickDarvey / FoldingOperations.cs
Created August 15, 2017 11:57
I don't think I'm doing this right.
using System;
using System.Threading.Tasks;
using LanguageExt;
using static LanguageExt.Prelude;
namespace Operations.Test
{
public delegate Task<Either<Error, Option<T>>> Operation<T>(T source);
public class Error : Record<Error>
using System;
using System.Collections.Generic;
using System.Linq.Expressions;
using System.Reflection;
using System.Xml;
using System.Xml.Schema;
using System.Xml.Serialization;
namespace Thingy
{
public static Verifier Combine(params Verifier[] verifiers) =>
expression =>
{
var current = Init;
foreach (var verify in verifiers)
{
var next = verify(expression);
current = next.Apply(current.Apply(KeepRight));
}
return current;
@NickDarvey
NickDarvey / Directory.Build.props
Last active April 24, 2020 07:29
MSBuild targets for publishing all Azure Function projects in a repo
<Project>
<PropertyGroup>
<StagingDir Condition="'$(StagingDir)' != ''">$([MSBuild]::NormalizeDirectory('$(StagingDir)'))</StagingDir>
<StagingDir Condition="'$(StagingDir)' == ''">$([MSBuild]::NormalizeDirectory($(SolutionDir), 'staging'))</StagingDir>
<ArtifactsDir Condition="'$(ArtifactsDir)' != ''">$([MSBuild]::NormalizeDirectory($(ArtifactsDir)))</ArtifactsDir>
<ArtifactsDir Condition="'$(ArtifactsDir)' == ''">$([MSBuild]::NormalizeDirectory($(SolutionDir), 'artifacts'))</ArtifactsDir>
</PropertyGroup>
</Project>
@NickDarvey
NickDarvey / template.json
Last active October 30, 2021 08:20
Deploy an Azure Web App with a bound App Service Managed Certificate (TLS/SSL) in one ARM template
{
"$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
},
"variables": {
"environmentName": "[resourceGroup().name]",
"location": "[resourceGroup().location]",
"solutionName": "example",
"solutionDomain": "on.example.com",
@NickDarvey
NickDarvey / ReactiveLazyComponent.fs
Created May 25, 2020 01:46
Bolero (and Blazor and Elmish) and Rx.NET lazy component
open Bolero
open Elmish
open System.Reactive.Disposables
open System.Reactive.Subjects
type ReactiveLazyComponent<'model, 'event, 'msg>() =
inherit Bolero.ElmishComponent<'model, 'msg>()
let subject = new Subject<'event>()
let observer = subject :> IObserver<_>
let observable = subject :> IObservable<_>
@NickDarvey
NickDarvey / PointedList.fs
Last active August 21, 2020 06:45
PointedList: a list with a focus element
/// A list with a focus element.
/// Inspired by https://stackoverflow.com/a/38970195/1259408
/// Based on https://github.com/jeffwheeler/pointedlist/blob/master/Data/List/PointedList.hs
type PointedList<'a> =
private PointedList of
LeftsRev : 'a list
* Focus : 'a
* Rights : 'a list
with