Peter Naur's classic 1985 essay "Programming as Theory Building" argues that a program is not its source code. A program is a shared mental construct (he uses the word theory) that lives in the minds of the people who work on it. If you lose the people, you lose the program. The code is merely a written representation of the program, and it's lossy, so you can't reconstruct
- Get .NET SDK with
sudo apt install dotnet9(ordotnet-sdk-9.0),brew install dotnetfor macOS - Get FSharpPacker tool with
dotnet tool install -g --allow-roll-forward FSharpPacker - Make an F# interactive script file (e.g. copy the
phash.fsxbelow) - Compile it with
fspack {your-script.fsx} -f net9.0 -o {destination} --aot
(in this example:fspack phash.fsx -f net9.0 -o . --aot), note that it will take some time to do so for the first time - .NET needs to fetch IL AOT Compiler from Nuget - Profit! You have compiled an F# script to a native binary
- (Optional) If you add fspk.fish, the process is simplified to
fspk {my-script}.fsx!
Note 1: if you are not using macOS or FreeBSD, give https://github.com/ieviev/fflat a try which can produce even smaller binaries
This file contains hidden or 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
| // Comment about https://mastodon.social/@brandewinder@hachyderm.io/113064780292323247 | |
| // https://brandewinder.com/2024/09/01/should-i-use-simd-vectors/ | |
| using System.Numerics; | |
| using System.Runtime.InteropServices; | |
| using System.Runtime.Intrinsics; | |
| public class VectorProcessor | |
| { | |
| public static float Take2(float[] left, float[] right) | |
| { |
This file contains hidden or 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
| <!DOCTYPE html> | |
| <html> | |
| <head> | |
| <title>Interactive 3D Globe</title> | |
| <script src="https://cdnjs.cloudflare.com/ajax/libs/d3/7.8.5/d3.min.js"></script> | |
| <script src="https://cdnjs.cloudflare.com/ajax/libs/topojson/3.0.2/topojson.min.js"></script> | |
| <style> | |
| body { | |
| margin: 0; | |
| background: #000; |
This file contains hidden or 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 Example | |
| open Fable.Core | |
| open Fable.Core.JsInterop | |
| open Msal | |
| open Configuration | |
| open Account | |
| open System.Collections.Generic | |
| module private Internal = |
This file contains hidden or 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 Demo.HashRings | |
| open System | |
| open System.Collections.Generic | |
| /// Range is a tuple describing (s,e] - where `s` is start | |
| /// (exclusive) index, while `e` is end (inclusive) index. | |
| type Range = ValueTuple<int,int> | |
| [<RequireQualifiedAccess>] |
This file contains hidden or 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
| open System | |
| type Interval = | |
| | PerfectUnison | |
| | MinorSecond | |
| | MajorSecond | |
| | MinorThird | AugmentedSecond // Enharmonically the same in 12TET | |
| | MajorThird | |
| | PerfectFourth | |
| | DiminishedFifth | AugmentedFourth // Enharmonically the same in 12TET |
- Install Homebrew from https://brew.sh
$ brew install podman
This file contains hidden or 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
| using System; | |
| using System.Threading.Tasks; | |
| namespace System.Collections.Concurrent | |
| { | |
| public static class ConcurrentDictionaryExtensions | |
| { | |
| /// <summary> | |
| /// Provides an alternative to <see cref="ConcurrentDictionary{TKey, TValue}.GetOrAdd(TKey, Func{TKey, TValue})"/> that disposes values that implement <see cref="IDisposable"/>. | |
| /// </summary> |
This file contains hidden or 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
| // http://www.fssnip.net/ma/title/Alternate-version-of-Private-DU-constructor | |
| module Email = | |
| type EmailAddress = | |
| private | |
| | ValidEmail of string | |
| | InvalidEmail of string | |
| let ofString = function | |
| | "validEmail" -> ValidEmail "validEmail" | |
| | invalid -> InvalidEmail invalid |
NewerOlder