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:
[<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 |
Full source for JSON Transformer: https://gist.github.com/mrange/7c39333de480a8de5c812a1f6ba70173
Full source for XML Transformer: https://gist.github.com/mrange/552cb0b474b517b706333cebb64f44aa
A popular approach in Functional Languages to create parsers is to use parser combinators.
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 |
Hello software developers,
Please check your code to ensure you're not making one of the following mistakes related to cryptography.
- Writing your own home-grown cryptography primitives (For example: Mifare Classic)
- Exception: For the sake of learning, but don't deploy it in production.
- Using a fast hash function (e.g. MD5, SHA256) for storing passwords. Use bcrypt instead.
- Not using a cryptographically secure random number generator
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 |
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
You need DNVM as a starting point. DNVM enables you to acquire a (or multiple) .NET Execution Environment (DNX).