Skip to content

Instantly share code, notes, and snippets.

let buildTrigrams (s : string) =
s
|> Seq.windowed 3
|> Seq.map (fun s -> System.String s)
|> Seq.toArray
//buildTrigrams "ABCDEFGHIJK"
let hitPercent (s : string) (tg : string array) =
let matchCount =
void Main()
{
var result =
from g in AllGames()
let _ = Sort(g.Goals)
select new { Team1 = g.Team1, Team2 = g.Team2, Goals = g.Goals };
result.Dump();
}
// Define other methods and classes here
#if INTERACTIVE
#r "System.Net.Http"
#endif
module MimeTip
open System.IO
open System.Net.Http
open System.Runtime.InteropServices
@toburger
toburger / Pretzel.SassTransformer.fsx
Created October 9, 2014 10:00
Simple pretzel extension to transform SASS files into CSS
#r "System.ComponentModel.Composition"
#if INTERACTIVE
#r "../Pretzel.exe"
#r "LibSass.x86.dll"
#r "libsassnet.dll"
#endif
open System.ComponentModel.Composition
open Pretzel.Logic.Extensibility
open Pretzel.Logic.Templating.Context
@toburger
toburger / functional_unity3d.fsx
Last active August 29, 2015 14:07
An experiment if Unity3D and (kind of) idiomatic F# can play nicely together.
#r @"C:\Users\TBurger\Downloads\UnityEngine.dll"
open UnityEngine
module Unity =
[<AutoOpen>]
module Log =
let inline uprintfn fmt =
Printf.kprintf Debug.Log fmt
#r "System.Speech"
open System.Speech.Synthesis
let synt = new SpeechSynthesizer()
// synt.Rate <- 5 // schneller mochn!
let say s = synt.Speak(s: string)
[1 .. 100]
|> List.map (fun n ->
match n%3, n%5 with
@toburger
toburger / reflector.fsx
Last active August 29, 2015 14:25
Cool new F# 4.0 feature
module Reflection =
open Microsoft.FSharp.Quotations
open Microsoft.FSharp.Quotations.Patterns
open System.Reflection
let private (|Name|) (info: MemberInfo) = info.Name
let private (|PropertyName|_|) = function
| PropertyGet (_, Name name, _) -> Some name
| _ -> None
@toburger
toburger / file.php
Last active September 28, 2015 10:09
PHP: Computes the difference of two arrays by value, not by key (like array_diff_ukey)
<?php
function diff($array1, $array2, $compare_func) {
return array_diff_ukey($array1, $array2, function($key1, $key2) use ($array1, $array2, $compare_func) {
if (!isset($array1[$key1])) return 1;
if (!isset($array2[$key2])) return -1;
return $compare_func($array1[$key1], $array2[$key2]);
});
}
using Contrib.Navigation.Models;
using Orchard;
using Orchard.ContentManagement;
using Orchard.Logging;
using Orchard.Roles.Models;
using Orchard.Roles.Services;
using Orchard.Security;
using Orchard.Security.Permissions;
using Orchard.UI.Admin;
using Orchard.UI.Navigation;
@toburger
toburger / EnumerableExtensions.cs
Created October 1, 2012 09:09
Enumerable Extension Method to Distinct or Union IEnumerable(s) by a property without the need to create an IEqualityComparer<T> implementation.
static class EnumerableExtensions
{
public static IEnumerable<T> Distinct<T, TProperty>(
this IEnumerable<T> source,
Expression<Func<T, TProperty>> propertyExpression)
{
return source.Distinct(
new PropertyExpressionComparer<T, TProperty>(propertyExpression));
}