Skip to content

Instantly share code, notes, and snippets.


Alison Perez amazingant

View GitHub Profile
amazingant / Tabs.fsi
Created January 4, 2016 14:28
Union with a TypeConverter for use as a literal in WPF
View Tabs.fsi
open System.ComponentModel
type Tabs =
| Item
| Hour
| Event
| Search
and TabsConverter() =
amazingant / SourceLink Proxy.fsx
Last active August 29, 2015 14:28
Bad home-made server and basic Suave site for proxying calls for source code off to GitHub; for use with SourceLink
View SourceLink Proxy.fsx
amazingant / ProjectDetails.fsx
Last active September 23, 2015 18:40
Record definition for use with FAKE, useful for storing desired information about a project
View ProjectDetails.fsx
namespace Fake
type ProjectDetails =
/// Project name, useful for filtering against project files
Name : string;
/// Summary for AssemblyInfo and NuGet metadata
Summary : string;
/// Longer description for NuGet metadata
Description : string option;
amazingant / Iterative parser.fsx
Last active August 29, 2015 14:26
Attempts to handle MSBuild condition attributes
View Iterative parser.fsx
let input = @"$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*' And $(Configuration) == 'Debug'"
let rec parseWord (data : System.Text.StringBuilder) (input : string) (index : int) (inQuotes : bool) : string * int =
let substr = input.Substring(index)
let f i () = (data.ToString()), (index + i)
let ret = f 1
if input.Length = index
then f 0 ()
let c = input.[index]
amazingant /
Created July 19, 2015 17:33
Quick test snippet for finding out if two libraries expose the same public API

This is a short test of comparing the public API in two .NET binaries. There isn't any special comparison being done beyond determining whether or not the public APIs match perfectly.

To determine whether or not the two APIs match, build the .cs files like so:

csc /out:Lib1.dll /target:library 10_Lib1.cs
csc /out:Lib2.dll /target:library 20_Lib2.cs
amazingant /
Created June 23, 2015 13:15
Decompiled record update syntax to see what the IL is doing

Original code is in Record updates.fs, the IL output for the type is in, and the IL output for the function is in Also included ILSpy's interpretation of the function into C# code in func.cs.

amazingant / SinCos.fsx
Created June 17, 2015 13:22
Sine and cosine implementation in F# using the Taylor series?
View SinCos.fsx
open System
let degToRad deg = deg * (Math.PI / 180.0)
// This is a very slow implementation of the sine function, and could be easily
// optimized in a lot of ways, but I wanted to know how to calculate sine, and
// this works.
// Taken from the accepted answer at:
let sine angle places =
amazingant / Errors.fs
Last active September 14, 2020 17:27
F# code for getting attribute data off discriminated union cases
View Errors.fs
type FatalError(message: string) =
inherit System.Attribute()
member __.Message = message
type Errors =
| [<FatalError("The value specified is currently not available")>] UnknownValue
| NotAnError
let PrintErrorMessage : Errors -> string =
fun err ->
amazingant /
Last active August 29, 2015 14:08
Bash script that fetches issue descriptions from GitHub via curl and adds them into the branch listing from git.
#!/usr/bin/env bash
# To use this script, go into your GitHub account settings, go into the
# Applications section, and then under `Personal access tokens` click
# `Generate new token`. Name the token whatever you want, give it access
# to the `repo` and `public_repo` scopes (`user` and `gist` are also
# selected by default, but you don't need them for this).
# Take the generated token and store it in your personal .gitconfig
# (located at either ~/.gitconfig or ~/.config/git/config on OSX/*nix)

Keybase proof

I hereby claim:

  • I am amazingant on github.
  • I am amazingant ( on keybase.
  • I have a public key whose fingerprint is EBAF 1D9C B975 15EC 4BA5 F334 7A60 14E3 165D 4E15

To claim this, I am signing this object: