Skip to content

Instantly share code, notes, and snippets.

View johnazariah's full-sized avatar

John Azariah johnazariah

  • Microsoft Corporation
  • Brisbane, Queensland, Australia
  • 22:51 (UTC +10:00)
View GitHub Profile
@johnazariah
johnazariah / LazyAsync.cs
Created April 19, 2020 17:12
Simple LazyAsync
namespace Utility
{
using System;
using System.Runtime.CompilerServices;
using System.Threading.Tasks;
internal sealed class LazyAsync<T>
{
public T Value => valueL.Value;
@johnazariah
johnazariah / LinqExtensions.cs
Last active June 17, 2024 10:53
Maybe Monad in C#
public static partial class LinqExtensions
{
public static Maybe<C> SelectMany<A, B, C>(this Maybe<A> ma, Func<A, Maybe<B>> f, Func<A, B, C> select) => ma.Bind(a => f(a).Map(b => select(a, b)));
}
@johnazariah
johnazariah / Readme.md
Last active July 11, 2018 07:33
Getting Organised with Orleans 2.0 in .NET Core

Getting Organized with Orleans 2.0 on .NET Core

Prerequisites

  • Install .NET Core >= 2.1.3 so you have access to dotnet tool install.
  • Install Fake 5.0 with dotnet tool install fake-cli -g.
  • Install Fake Templates with dotnet new -i "fake-template::*"
@johnazariah
johnazariah / Helpers.Client.cs
Last active July 30, 2018 16:55
Getting Started with Orleans 2.0 on .NET Core
using Microsoft.Extensions.Logging;
using Orleans;
using Orleans.Configuration;
using Orleans.Hosting;
using System;
using System.Threading.Tasks;
namespace Orleans2GettingStarted
{
internal static class ClientDevelopmentHelpers
@johnazariah
johnazariah / free.fs
Created April 3, 2018 22:02
Free Monad with Trampoline Infrastructure and Computation Builder
// F<'a> is any type with member 'map' of type ('a -> 'b) -> F<'a> -> F<'b>
type F<'a> = QIL<'a>
and S<'a> = F<Q<'a>>
and Q<'a> =
private
| Step of Step<'a>
| Bind of IBind<'a>
with
static member lift (k : F<'a>) : Q<'a> = Step (Suspend (fun () -> S<_>.map (Yield >> Step) k))
@johnazariah
johnazariah / Tree.fs
Created December 22, 2017 18:02
Monkeying Around : Fun With Trees
module Tree =
type NodeId = | Id of string
with
member this.unapply = match this with | Id x -> x
[<AutoOpen>]
module internal Node =
[<AbstractClass>]
type NodeBase<'a> () = class
member val internal Children : NodeBase<'a> list = [] with get, set
@johnazariah
johnazariah / .bash_profile
Last active October 13, 2020 17:11
Git Configuration
# generated by Git for Windows
test -f ~/.profile && . ~/.profile
test -f ~/.bashrc && . ~/.bashrc
#from http://stackoverflow.com/questions/33220492/ps1-bash-command-substitution-not-working-on-windows-10
# Reset
Off="\[\e[0m\]" # Text Reset
# Regular Colors
@johnazariah
johnazariah / maybe.fs
Created December 31, 2016 14:01
Maybe Computation Expression Builder
namespace Utility.Monads
[<AutoOpen>]
module MaybeMonad =
type MaybeBuilder() =
member this.Zero() = this.Return ()
member this.Bind(m, f) = Option.bind f m
member this.Return(x) = Some x
member this.ReturnFrom(x) = x
member this.Yield(x) = Some x
using System;
namespace FSM.BankAccount
{
public abstract class BankAccountState
{
public static readonly BankAccountState ZeroBalanceState = new ChoiceTypes.ZeroBalanceState();
public static readonly BankAccountState ActiveState = new ChoiceTypes.ActiveState();
public static readonly BankAccountState OverdrawnState = new ChoiceTypes.OverdrawnState();
public static readonly BankAccountState ClosedState = new ChoiceTypes.ClosedState();
@johnazariah
johnazariah / .bash_profile
Last active August 27, 2020 12:58
Git Aliases
# Git branch in prompt.
parse_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/'
}
export PS1="\u@\h \W\[\033[32m\]\$(parse_git_branch)\[\033[00m\] $ "