Skip to content

Instantly share code, notes, and snippets.

@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).

[<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 / boyer_moore.fsx
Created September 29, 2015 16:42
Boyer Moore Search Algorithm
// Boyer Moore String Search Algorithm
open System
open System.Collections
/// Returns the index of the given character in the English alphabet counting from 0
let alphabet_index (ch:char) =
let chlow = Char.ToLower( ch)
let charnum = Convert.ToInt32 chlow
charnum - 97 // 'a' is ASCII character 97
@cloudRoutine
cloudRoutine / ReactiveExample.fs
Last active September 22, 2015 08:32
Using FSharp.Control.Reactive to recognize keyboard input
#r "PresentationCore"
#r "PresentationFramework"
#r "WindowsBase"
#r "System.Xaml"
#I "../../packages/FSharp.Control.Reactive.2.3.1/lib/net40/"
#I "../../packages/Rx-Linq.2.2.5/lib/net45"
#I "../../packages/Rx-Core.2.2.5/lib/net45"
#I "../../packages/Rx-Interfaces.2.2.5/lib/net45"
#I "../../packages/Rx-PlatformServices.2.2.5/lib/net45"
#I "../../packages/Rx-Providers.2.2.5/lib/net45"
<?xml version="1.0" encoding="utf-8"?>
<Settings>
<Shortcuts>&lt;?xml version="1.0" encoding="utf-16"?&gt;
&lt;ArrayOfKeyShortcut xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"&gt;
&lt;KeyShortcut&gt;
&lt;Value&gt;EqualsPlus&lt;/Value&gt;
&lt;Alignment&gt;(^|[\w\s])(?&amp;lt;x&amp;gt;=)&lt;/Alignment&gt;
&lt;AlignFromCaret&gt;false&lt;/AlignFromCaret&gt;
&lt;UseRegex&gt;true&lt;/UseRegex&gt;
&lt;AddSpace&gt;true&lt;/AddSpace&gt;
@cloudRoutine
cloudRoutine / unity3d.gitignore
Created August 3, 2015 08:16
Unity3d gitignore
#=====================
# Unity Project Files
#=====================
/[Ll]ibrary/
/[Tt]emp/
/[Oo]bj/
/[Bb]uild/
*.userprefs
@cloudRoutine
cloudRoutine / morphisms.fs
Created December 24, 2014 08:10
Morphisms
module Morphisms =
/// Hylomorphism that composes an unfold into a fold
/// folding an unfold
// ( fold o unfold )(x) = fold (unfold(x))
let hylomorphism
(ufstepfn:#seq<'b>->'b->#seq<'b>)(ufacc:#seq<'b>)(pred:'a->bool)(mapElm:'a->'b) (inc:'a->'a)
(fstepfn:'c->'b->'c) (foldAcc :'c) : 'a -> 'c =
(Folds.unfold ufstepfn ufacc pred mapElm inc ) >> (Folds.foldl fstepfn foldAcc )
@cloudRoutine
cloudRoutine / 01querylistboxhelpers.fs
Last active August 29, 2015 14:12
Polymorphic WPF GUI Controls with F#
namespace ViewModels
open System.Windows
open System.Windows.Controls
open System.Windows.Documents
open System.Windows.Media
open GUIControls.Extensions
open GUIControls.Patterns
open System.Windows.Interactivity
@cloudRoutine
cloudRoutine / gridcontroller.cs
Created December 24, 2014 06:12
Grid Controller - Unity Editor Extensions
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using UnityEngine;
using UnityEditor;
using HexMap;
using ExtensionMethods;