Skip to content

Instantly share code, notes, and snippets.

@halcwb
halcwb / Agent.fsx
Last active August 14, 2025 12:48
A more safe and functional approach to create and use MailboxProcessor as Agent
open System
open System.Threading
open System.Threading.Tasks
/// <summary>
/// Represents an asynchronous agent that processes messages of type 'T.
/// This is a wrapper around FSharp's MailboxProcessor, providing a unified API for agent-based concurrency.
/// </summary>
type Agent<'T>(body: Agent<'T> -> Async<unit>) as self =
@halcwb
halcwb / MaiboxProcerssor.fsx
Created July 11, 2025 19:03
Demo MailboxProcesser
type DoseRule = {
Id: string
Name: string
Description: string
Dosage: string
}
@halcwb
halcwb / DataRetrieval.fsx
Created May 30, 2025 17:03
Data storage and retrieval using block compression
// AtriumDB Domain Model - Physiological Data Storage and Retrieval System
open System
// Core Value Types
type DeviceId = DeviceId of string
type PatientId = PatientId of string
type BedspaceId = BedspaceId of string
type SignalType = SignalType of string
type Timestamp = Timestamp of int64 // millisecond precision
@halcwb
halcwb / GHIssueExtractor.fsx
Created February 14, 2025 05:40 — forked from houstonhaynes/GHIssueExtractor.fsx
An F# script to extract open GitHub issues from a repo as Markdown
#r "nuget: Octokit"
open Octokit
open System
open System.IO
open System.Text.RegularExpressions
// Configuration
type Config = {
Token: string
RepoUrl: string
@halcwb
halcwb / FunctionTooling.fsx
Created September 26, 2024 18:06
Using AI function tooling
#r "nuget: IcedTasks"
#r "nuget: Microsoft.SemanticKernel, 1.21.1"
#r "nuget: FSharp.Control.TaskSeq, 0.4.0"
open IcedTasks
open Microsoft.SemanticKernel
open System
open System.ComponentModel
@halcwb
halcwb / Ollama.fsx
Last active March 7, 2024 09:29
Experimenting with Ollama
#r "nuget: Newtonsoft.Json"
/// Utility methods to use ollama
/// https://github.com/ollama/ollama/blob/main/docs/api.md#generate-a-chat-completion
module Ollama =
open System
@halcwb
halcwb / CalcPELOD2Score.vb
Created September 4, 2023 07:09
Calculate the PELOD-2 score
Sub Main
End Sub
' Define other methods and classes here
Public Function CalcPELOD2Score(intGCS As Integer, strPupil As String, dblLactate As Double, intMAP As Integer,
intMos As Integer, dblCreat As Double, intPaO2 As Integer, intFiO2 As Integer,
intPaCO2 As Integer, blnVent As Boolean, intWBC As Integer, intPlatelets As Integer) As Integer
Dim intScore As Integer = 0
@halcwb
halcwb / CalcPedSOFAScore.vb
Created September 4, 2023 07:07
Calculate the Pediatric SOFA score
Sub Main
End Sub
' This function, CalculatePedSOFAScore, calculates the Pediatric Sequential Organ Failure Assessment (pSOFA) score for a child based on various physiological parameters.
' The pSOFA score is used to assess the extent of organ dysfunction in critically ill patients.
'
' The function takes several parameters including the age of the child in months, partial pressure of oxygen to fraction of inspired oxygen (PaO2/FiO2),
' saturation of peripheral oxygen to fraction of inspired oxygen (SpO2/FiO2), platelet count, bilirubin, mean arterial pressure (MAP),
' rates of infusion of various vasoactive drugs (Dopamine, Dobutamine, Epinephrine, Norepinephrine), Glasgow Coma Scale (GCS), and Creatinine.
@halcwb
halcwb / CalculateSOFAScore.vb
Created September 4, 2023 07:06
Calculate the SOFA score
Sub Main
Dim SOFAScore As Integer
SOFAScore = CalculateSOFAScore(350, 120, 14, 1.5, 75, 0, 0, 0.1, 0.1, 2.5, 600, True)
Console.WriteLine("SOFA Score: " & SOFAScore)
End Sub
' A function that calculates a SOFA score (Sequential Organ Failure Assessment)
' This function calculates the SOFA (Sequential Organ Failure Assessment) score based on various parameters.
' The SOFA score is used to assess the extent of a person's organ function or rate of failure in the ICU (Intensive Care Unit).
@halcwb
halcwb / CalculateSOFAScore.vb
Created September 4, 2023 07:06
Calculate the SOFA score
Sub Main
Dim SOFAScore As Integer
SOFAScore = CalculateSOFAScore(350, 120, 14, 1.5, 75, 0, 0, 0.1, 0.1, 2.5, 600, True)
Console.WriteLine("SOFA Score: " & SOFAScore)
End Sub
' A function that calculates a SOFA score (Sequential Organ Failure Assessment)
' This function calculates the SOFA (Sequential Organ Failure Assessment) score based on various parameters.
' The SOFA score is used to assess the extent of a person's organ function or rate of failure in the ICU (Intensive Care Unit).