This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// https://www.reddit.com/r/ProgrammerHumor/comments/umbmlt/this_is_hurting_my_ego/ | |
[ | |
"8809", 6 | |
"7111", 0 | |
"2172", 0 | |
"6666", 4 | |
"1111", 0 | |
"3213", 0 | |
"7662", 2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type Foo () = | |
do | |
printfn "I'm constructed" | |
member x.Value | |
with get() = 0 | |
and set (v:int) = invalidOp "Hello world!" | |
interface IDisposable with | |
member x.Dispose() = | |
printfn "IDisposed!" | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// from https://gist.github.com/ImaginaryDevelopment/952b3a9afc4f2fa3c4631d43f760748a | |
module GistTemplate.BReusable | |
open System | |
open System.Collections.Generic | |
open System.Diagnostics | |
let inline guardAgainstNull msg (o:obj) = | |
if isNull o then | |
nullArg msg | |
let (|GuardNull|) msg (x:'T) = |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let inline tryParse f x = | |
match f x with | |
| true, v -> Some v | |
| _ -> None | |
// this version does not compile: | |
//let (|Parse|_|) (str: string) : int option = tryParse Int32.TryParse str | |
let inline tryParseInt (x:string) = x |> tryParse Int32.TryParse | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module ResizeArray = | |
let init i f = | |
Seq.init i f | |
|> ResizeArray | |
let (|IsSeq|_|) (t:Type) = | |
t.GetInterfaces() |> Seq.choose(fun t -> | |
if t.IsGenericType && t.GetGenericTypeDefinition() = typedefof<seq<_>> then Some("iseq",t.GenericTypeArguments) else None | |
) | |
|> Seq.tryHead |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let logStep action = | |
let res = action <| printf "%s... " | |
printfn "Complete." | |
res | |
type LoggingBuilder() = | |
member this.Bind(x, f) = | |
logStep x |> f | |
member this.Zero() = ignore | |
member this.Return(x) = x |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
onNotifyAcknowledgedPositions() { | |
const companyState = this.memberState; | |
if (companyState && | |
companyState['BUY'] && companyState['SELL'] && | |
(isFalsy(companyState['BUY'].addedRequests) || companyState['BUY'].addedRequests.length === 0) && | |
(isFalsy(companyState['BUY'].updatedRequests) || companyState['BUY'].updatedRequests.length === 0) && | |
(isFalsy(companyState['BUY'].deletedRequests) || companyState['BUY'].deletedRequests.length === 0) && | |
(isFalsy(companyState['BUY'].addedComments) || companyState['BUY'].addedComments.length === 0) && | |
(isFalsy(companyState['BUY'].deletedComments) || companyState['BUY'].deletedComments.length === 0) && |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// hosts file lock of certain sites, and unlocking, while not interfering with other entries | |
// WIP | |
let winpath = | |
"C:\\windows" | |
// Util.GetPassword("WindowsPath") | |
if not <| Directory.Exists winpath then failwithf "Unable to locate path '%s'" winpath | |
let sites = [ | |
"discord.com" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// adapted from https://github.com/gregoryyoung/m-r/blob/master/SimpleCQRS/CommandHandlers.cs | |
// actual code https://github.com/thinkbeforecoding/m-r/tree/FSharp/FsSimpleCQRS | |
module Commands = | |
//[<Abstract>] | |
type DeactivateInventoryItem = | |
{ | |
InventoryItemId: Guid | |
OriginalVersion: int // version I'm acting on, for checking to make sure my change only fires if the data the change was based on is still unchanged |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This file is part of Silk.NET. | |
// | |
// You may modify and distribute Silk.NET under the terms | |
// of the MIT license. See the LICENSE file for details. | |
module Silk.NET.Maths.Tests.Box2Tests | |
open System | |
open Expecto | |
open FsCheck |