Skip to content

Instantly share code, notes, and snippets.

@mavnn
mavnn / InstallThings.fsx
Created November 28, 2013 16:15
Install NuGet stuff from code with sensible control of options.
(* Get the files in the right places relative to the script by running:
path\to\NuGet.exe install NuGetPlus.Core -ExcludeVersion -Prerelease
*)
#r "FSharp.Core"
#r "Microsoft.Build"
#r "Microsoft.Build.Framework"
#r "System.Xml"
#r "System.Xml.Linq"
@mavnn
mavnn / build.fsx
Created November 24, 2013 20:34
Sample build.fsx for a vim project - compile, and if it compiles then run the exe and capture the output back into vim.
open System.Diagnostics
let code =
[
"src/Board.fs"
"src/WordSearch.fs"
]
let refs = []
@mavnn
mavnn / riemannlogs.fs
Created November 7, 2013 11:28
Pipe logs to Riemann
module RiemannStore =
open System
open System.Configuration
open Riemann
let client = new Client(riemannServer, riemannPort)
let state entry =
match entry.Level with
let ones =
seq {
while true do
yield 1
}
// seq [1; 1; 1; 1; ...]
@mavnn
mavnn / part1.fs
Created October 14, 2013 09:55
Introducing F# Syntax
// Let's send an email!
@mavnn
mavnn / csharp.cs
Created September 24, 2013 13:17
C# and F# comparisons of NuGet ProjectSystem implementations. F# code is from https://github.com/mavnn/NuGetPlus/blob/master/NuGetPlus.Core/ProjectSystem.fs C# code is from http://nuget.codeplex.com/SourceControl/latest#src/CommandLine/Common/MSBuildProjectSystem.cs They aren't identical in functionality, but they're pretty similar and implement…
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.Versioning;
using Microsoft.Build.Evaluation;
namespace NuGet.Common
{
@mavnn
mavnn / Test.fs
Created August 8, 2013 13:20
Add a dll directory from which to DllImport native code.
open System
open System.Runtime.InteropServices
open System.ComponentModel
[<DllImport("kernel32")>]
extern int AddDllDirectory(string NewDirectory)
[<EntryPoint>]
let main argv =
let result = AddDllDirectory("c:\\")
module DevEd.FsCheck
open System.Xml
open System.Xml.Linq
let AddEnhancement (xDoc : XDocument) (input : string) =
xDoc.Root.Add(XElement(XName.Get "Enhancement", input))
xDoc
#r "System.Xml.Linq"
#r "tools\FAKE\FakeLib.dll"
open System.IO
open System.Xml
open System.Xml.Linq
open System.Xml.XPath
open Fake
// You'll want to replace these values...
let nugetId = "my.package.id"
@mavnn
mavnn / XmlGen.fs
Last active September 2, 2016 17:03
Really naive xml generator for FsCheck.
open FsCheck
type XmlTree =
| NodeName of string
| Container of string * List<XmlTree>
let nodeNames = ["myNode";"myOtherNode";"someDifferentNode"]
let tree =
let rec tree' s =