Skip to content

Instantly share code, notes, and snippets.

View Thorium's full-sized avatar

Tuomas Hietanen Thorium

View GitHub Profile

The Nature of "Now" (as Quantum Measurement)

There are structural parallels between quantum measurement and the experience of "now":

Property Quantum measurement The present moment
Selects one outcome from many Yes Yes
Irreversible Yes (wavefunction collapse) Yes (past becomes fixed)
Creates definite classical reality Yes Yes
The "before" is indeterminate Superposition Open future
@Thorium
Thorium / remarkable_and_md2pdf.fs
Created February 10, 2026 18:17
1) Script for downloading reMarkable PDFs from their cloud service, 2) Script to convert PDFs to Markdown (pdf2md) to be consumed e.g. by agents.
#!/usr/bin/env dotnet fsi
// =============================================================================
// reMarkable Cloud File Downloader and PDF to Markdown (pdf2md) - F# Script
// Based on the PHP ReMarkableAPI by splitbrain/remarkable-api
// This is to download reMarkable cloud files and convert them e.g. for agents to read.
// You'll need to add/use reMarkable device web-script (to get auth token).
// =============================================================================
//
// Usage:
// dotnet fsi remarkable-download.fsx register <one-time-code>
@Thorium
Thorium / a-common.sql
Created October 10, 2025 12:59
A few useful Microsoft SQL Server T-SQL function samples
-- A few useful Microsoft SQL Server T-SQL function samples
@Thorium
Thorium / ollama.fsx
Created October 2, 2025 14:11
Using local LLMs from F#
// Using local LLMs from F#
// Download and install Ollama: https://ollama.com/
// Ollama is a free common host for multiple different LLM-models
// like Google Gemma, OpenApi's GPT-OSS, Deepseek, etc.
#r "nuget:OllamaSharp"
open OllamaSharp
// For better Collections.Generic.IAsyncEnumerable<_> support for F#:
#r "nuget:FSharp.Control.TaskSeq"
open FSharp.Control
@Thorium
Thorium / Client.fsx
Created September 29, 2025 10:45
ModelContextProtocol with FSharp (MCP with F#)
#r "nuget: ModelContextProtocol,0.4.0-preview.1"
open ModelContextProtocol.Client
open ModelContextProtocol.Protocol
open System
open System.Threading.Tasks
module McpClient =
let clientTransport =
StdioClientTransport(
StdioClientTransportOptions(
@Thorium
Thorium / weightedAvg.fs
Created September 15, 2025 08:54
Takes a list of (quantity/amount and price/rate) as decimals, and gives a weighted average
/// Takes a list of (quantity/amount and price/rate) as decimals, and gives a weighted average
let weightedAvg mylist =
let weightedValue = mylist |> List.sumBy(fun (isum,irate) -> isum*irate)
let weightedSum = mylist |> List.sumBy(fun (isum,irate) -> isum)
match weightedSum with
| 0m<GBP> -> 0m
| x -> weightedValue / x
@Thorium
Thorium / farmer-clockpart.fs
Created September 15, 2025 08:44
Creating Azure dashboard clock component with Farmer
// Farmer F# https://compositionalit.github.io/farmer/
// Example of shaping an anonymous-object-as-JSON structure
// for an Azure dashboard using strong typing and minimal code.
// #r "nuget: Farmer"
open Farmer
open Farmer.Builders
/// TimeZone
let timezoneInfo =
@Thorium
Thorium / dev.md
Last active November 4, 2025 06:01

Guidance for .NET systems development

Here is some opinionated guidance maybe to save some part of your valuable lifetime. The following topics focus on: development, architecture and maintainability.

The primary advice after John Skeet: Just solve your issue in the simplest possible way. Limit the boundaries: what are the requirements? Don't try to solve meta-level problems of every software engineer ever. Draft the boundaries even if you're writing a general library: Users can compose multiple small libraries if necessary. Expect your requirement specifications, if any, could be better, that's life.

@Thorium
Thorium / textmagic.fs
Created July 2, 2024 09:46
Send text messages with F# (FSharp)
[<RequireQualifiedAccess>]
module TextMagic
//https://www.textmagic.com/docs/api/send-sms/
// #r "System.Text.Json"
// #r "FSharp.Data"
open System
open System.IO
open System.Net
open System.Text.Json
@Thorium
Thorium / ef-functional.cs
Last active July 1, 2024 09:40
DBContext independend LINQ, the functional way
/// Old post recovered from Feb 2013:
/// https://web.archive.org/web/20130510043355/social.msdn.microsoft.com/Forums/en-US/adodotnetentityframework/thread/bc0bd8f3-0e49-440c-b0bb-8d9adb593934
///
/// This shows how you can:
///
/// - Code from top-down, give high level picture first and then go to details
/// - Define LINQ outside EF-context and still convert it to SQL: Don't hammer the database!
/// - Have small independend classes (/parts)
/// - Have state-less code with no global/class-variables outside entities
/// - Easy to test: a) Integration test with EF-DbContext.