Skip to content

Instantly share code, notes, and snippets.

View daveyostcom's full-sized avatar

Dave Yost daveyostcom

View GitHub Profile
@daveyostcom
daveyostcom / SemaphoreSlim_WaitAsync.fs
Last active November 4, 2023 19:56
SemaphoreSlim WaitAsync with CancellationToken
open System.Threading
open System.Threading.Tasks
let semaphoreWaitAsync semaphore cancellationToken = task {
printfn "Semaphore wait begin."
let ss = (semaphore: SemaphoreSlim)
let ct = (cancellationToken : CancellationToken)
try
do! ss.WaitAsync(ct) // This doesn’t work. OperationCanceledException is not caught.
@daveyostcom
daveyostcom / ReadMe.md
Last active September 17, 2023 23:34
Parse a Roman Numeral in F#
package shop.examples;
import javafx.application.Application;
import javafx.beans.Observable;
import javafx.scene.Cursor;
import javafx.scene.Scene;
import javafx.scene.input.KeyEvent;
import javafx.scene.input.MouseEvent;
import javafx.scene.layout.Pane;
import javafx.stage.Stage;
@daveyostcom
daveyostcom / PartialFunctionApplicationVsCurrying.swift
Last active March 17, 2020 23:32
partial function application vs currying
// Consider the heavily-aligned source code as a kind of exploded view to aid understanding.
// C# version: https://gist.github.com/daveyostcom/307aedf294042d0aba596cda9cc480ea
// Swift version: https://gist.github.com/daveyostcom/21cc630c3431026db73abd7606a59414
// Inspired by https://codeblog.jonskeet.uk/2012/01/30/currying-vs-partial-function-application/
class PartialFunctionApplicationVsCurrying {
func main() {
@daveyostcom
daveyostcom / PartialFunctionApplicationVsCurrying.cs
Last active March 17, 2020 23:41
partial function application vs currying – exploded view
using System;
namespace PartialFunctionApplicationVsCurrying {
// Consider this heavily-aligned source code as a kind of exploded view to aid understanding.
// Func<> documentation https://docs.microsoft.com/en-us/dotnet/api/system.func-4
// C# version: https://gist.github.com/daveyostcom/307aedf294042d0aba596cda9cc480ea
// Swift version: https://gist.github.com/daveyostcom/21cc630c3431026db73abd7606a59414
// Inspired by https://codeblog.jonskeet.uk/2012/01/30/currying-vs-partial-function-application/
@daveyostcom
daveyostcom / swift-4.1-Codable-JSON.swift
Created February 12, 2018 00:42
Example code in Swift 4.1 for JSON using the Codable protocol
#!/usr/bin/swift
// swift-4.1-Codable-JSON.swift
//
// Example code in Swift 4.1 for JSON using the Codable protocol
import Foundation
let encoder = JSONEncoder()
let decoder = JSONDecoder()