Skip to content

Instantly share code, notes, and snippets.

@vietnt
vietnt / example.fs
Last active December 29, 2020 21:54
unsafe in f#
[<Struct;StructLayout(LayoutKind.Explicit, Pack=1,Size=32)>]
type Bucket =
struct
[<FieldOffset(0)>]val mutable Free : int64
[<FieldOffset(8)>]val mutable FreeCount: int
[<FieldOffset(12)>]val mutable Used: int
[<FieldOffset(16)>]val mutable Size: int
[<FieldOffset(20)>]val mutable Full: bool
end
@mrange
mrange / optimizing_performance.md
Last active November 1, 2016 21:03
Optimizing a simple problem in F# and C++

Optimizing a simple problem

I was introduced to a simple optimization problem by one of my interns last week. He was about to participate in a friendly competition where they were asked to find a performant solution to the problem:

The problem

@mrange
mrange / json_transform.md
Last active January 23, 2017 06:53
Monadic JSON Transformers in F#
@sliekens
sliekens / target.xml
Created January 25, 2016 08:28
A list of all <Target /> tags that ship with MSBuild / Visual Studio
C:\Program Files (x86)\MSBuild\12.0\Bin\Microsoft.Common.CurrentVersion.targets
<Target Name="_CheckForInvalidConfigurationAndPlatform"></Target>
<Target Name="Build" Condition=" '$(_InvalidConfigurationWarning)' != 'true' " DependsOnTargets="$(BuildDependsOn)" Returns="$(TargetPath)" />
<Target Name="BeforeBuild" />
<Target Name="AfterBuild" />
<Target Name="CoreBuild" DependsOnTargets="$(CoreBuildDependsOn)"></Target>
<Target Name="Rebuild" Condition=" '$(_InvalidConfigurationWarning)' != 'true' " DependsOnTargets="$(RebuildDependsOn)" Returns="$(TargetPath)" />
<Target Name="BeforeRebuild" />
<Target Name="AfterRebuild" />
<Target Name="BuildGenerateSources" DependsOnTargets="BuildGenerateSourcesTraverse;$(BuildGenerateSourcesAction)" />
// Install-Package -ProviderName nuget SharpDX -Destination $pwd\packages
#r "packages/SharpDX.2.6.3/Bin/DirectX11-Signed-net40/SharpDX.dll"
#r "packages/SharpDX.2.6.3/Bin/DirectX11-Signed-net40/SharpDX.D3DCompiler.dll"
#r "packages/SharpDX.2.6.3/Bin/DirectX11-Signed-net40/SharpDX.DXGI.dll"
#r "packages/SharpDX.2.6.3/Bin/DirectX11-Signed-net40/SharpDX.Direct3D11.dll"
open System
open System.Collections.Generic
open System.Diagnostics
@paragonie-scott
paragonie-scott / crypto-wrong-answers.md
Last active April 21, 2024 23:48
An Open Letter to Developers Everywhere (About Cryptography)
@7sharp9
7sharp9 / parser.fs
Last active November 19, 2015 18:18
toml fparsec
open System
open System.Globalization
open FParsec
type Token =
| KeyGroup of string list
| KeyValue of string * obj
let (<||>) p1 p2 = attempt (p1 |>> box) <|> attempt (p2 |>> box)
let spc = many (anyOf [' '; '\t'])
[<System.Runtime.CompilerServices.Extension>]
type ExtensionMethods() =
[<System.Runtime.CompilerServices.Extension>]
static member inline GetOption< ^a,'k,'v when 'a : (member TryGetValue : 'k * ('v byref) -> bool)>(this : ^a, key : 'k) =
let mutable v = Unchecked.defaultof<'v>
let scc = ( ^a : (member TryGetValue : 'k * ('v byref) -> bool) this, key, &v)
if scc then
Some v
else
None
@cloudRoutine
cloudRoutine / fs-coreclr-build.md
Last active October 18, 2015 20:59
Build the Visual F# Compiler and Tools for .Net CoreCLR ( On Windows )

Make things easy for yourself and start by running posh as admin

If you already have dnvm installed remember to run update-self if you haven't recently

Clone and checkout the coreclr branch of Kevin Ransom's Fork of the Visual F# Compiler and Tools

Installing DNVM

You need DNVM as a starting point. DNVM enables you to acquire a (or multiple) .NET Execution Environment (DNX).