Skip to content

Instantly share code, notes, and snippets.

View ReedCopsey's full-sized avatar

Reed Copsey, Jr. ReedCopsey

View GitHub Profile
namespace TipCalc
open FSharp.ViewModule
open System
type TipCalcModel() as self =
inherit ViewModelBase()
// Create our backing fields
let subTotal = self.Factory.Backing(<@ self.SubTotal @>, 0.0)
#region
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Cmc.Core.ComponentModel;
using Cmc.Core.Diagnostics;
using Cmc.Installer.Core.Tasks;
#endregion
@ReedCopsey
ReedCopsey / Program.fs
Created August 23, 2014 00:27
Timing on Seq.toArray with ICollection<'T> input
// Learn more about F# at http://fsharp.net
// See the 'F# Tutorial' project for more help.
open System.Diagnostics
[<EntryPoint>]
let main argv =
let sequ = seq [ 1 .. 10000000 ]
let cach = ResizeArray<_>(sequ)
@ReedCopsey
ReedCopsey / RwLock
Last active August 29, 2015 14:15 — forked from JohanLarsson/RwLock
using System;
using System.Threading;
public sealed class RwLock : IDisposable
{
private readonly ReaderWriterLockSlim _innerLock = new ReaderWriterLockSlim();
private bool _disposed = false;
public IDisposable Read()
{
/// <summary>
/// An <see cref="ICommand"/> whose delegates do not take any parameters for <see cref="Execute"/> and <see cref="CanExecute"/>.
/// </summary>
public class ActionCommand : DelegateCommandBase
{
/// <summary>
/// Initializes a new instance of the <see cref="ActionCommand"/> class with the <see cref="Action"/> to invoke on execution.
/// </summary>
/// <param name="executeMethod">The execute method.</param>
/// <param name="useCommandManager">if set to <c>true</c> use the command manager instead of our own event process for CanExecuteChanged Tracking.</param>
@ReedCopsey
ReedCopsey / Manager.fs
Last active December 9, 2015 21:02
FsAdvent Code
type ForestUpdate =
| Add of Tree * Forest
| Decorate of Tree * Forest
type ForestUpdateResult =
| Success of Forest
| Pruned of Forest
| Error of string
module ForestManager =
@ReedCopsey
ReedCopsey / application.fs
Last active December 15, 2016 20:52
FsAdvent 2016 Code
let application =
// Create our forest, wrapped in a mutable with an atomic update function
let forest = new AsyncMutable<_>(Forest.empty)
// Create our 3 functions for the application framework
// Start with the function to create our model (as an ISignal<'a>)
let createModel () : ISignal<_> = forest :> _
// Create a function that updates our state given a message
@ReedCopsey
ReedCopsey / test.cs
Created August 31, 2017 18:37
Linqpad C# Program
void Main()
{
IMsg test = new S2("foo", "bar");
switch (test)
{
// How do I simplify this??? I'd like to "match and deconstruct" as a oneliner if possible
case S1 s1:
{
int foo = s1.Data;
@ReedCopsey
ReedCopsey / app.fs
Last active December 15, 2017 05:56
FsAdvent 2017 Code
let application nav =
// Start pruning "loop" via Executor type
let prune = new Executor<_,_>(pruneHandler)
prune.Start()
// Start our application, and attach the executor so messages dispatch to the application
Framework.application Forest.empty Forest.update forestComponent nav
|> Framework.withDispatcher prune
@ReedCopsey
ReedCopsey / AvaloniaProgram.fs
Last active December 18, 2018 16:37
FsAdvent 2018 Code
[<STAThread>]
[<EntryPoint>]
let main _ =
let app () =
AppBuilder.Configure<App>().UsePlatformDetect().LogToDebug().SetupWithoutStarting().Instance
let nav = Gjallarhorn.Avalonia.Navigation.singleView app MainWindow
let app' = Program.application nav.Navigate
Gjallarhorn.Avalonia.Framework.RunApplication<Forest,unit,ForestMessage> (nav, app')