Skip to content

Instantly share code, notes, and snippets.

View jamessdixon's full-sized avatar

Jamie Dixon jamessdixon

View GitHub Profile
@jamessdixon
jamessdixon / ArtShowBizLogicChallenge
Created May 26, 2015 18:47
Art Show Business Logic Challenge Using FSharp
type Painting = {id:int;name:string;tags:string}
type ArtShow = {id:int;name:string;expectedAttendance:int;paintings:Painting list}
let painting0 = {id=0;
name="Starry Night";
tags="Impressionism;Nature"}
let painting1 = {id=1;
name="Sunday Afternoon on the Island of La Grande Jatte";
tags="Impressionism;Nature;LeisureActivities"}
let painting2 = {id=2;
@jamessdixon
jamessdixon / TAMGeoAndTheCounted
Created July 1, 2015 19:09
TAMGeoLocation and TheCounted Dataset
#r "../packages/FSharp.Data.2.2.2/lib/net40/FSharp.Data.dll"
open System
open System.IO
open System.Text
open FSharp.Data
[<Literal>]
let geoLocationSample = "..\Data\TAMUHttpGet.json"
type GeoLocationServiceContext = JsonProvider<geoLocationSample>
@jamessdixon
jamessdixon / TheCountedStateMap
Last active August 29, 2015 14:24
The Counted State Map
the.counted <- read.csv("./Data/TheCountedWithGeo.csv")
summary(the.counted)
#http://stackoverflow.com/questions/13420700/r-ggplot2-ggmap-concentric-circles-as-points
library(ggplot2)
library(maps)
all.states <- map_data("state")
plot <- ggplot()
plot <- plot + geom_polygon(data=all.states, aes(x=long, y=lat, group = group),
@jamessdixon
jamessdixon / gist:f81b230d91c3f500ae14
Created September 15, 2014 00:04
Consume an Azure ML API (Request/Response) using F#
#r @"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.Net.Http.dll"
#r @"..\packages\Microsoft.AspNet.WebApi.Client.5.2.2\lib\net45\System.Net.Http.Formatting.dll"
open System
open System.Net.Http
open System.Net.Http.Headers
open System.Net.Http.Formatting
open System.Collections.Generic
@jamessdixon
jamessdixon / MakeDecemberTenAgain
Created December 22, 2016 00:46
New Day Of Year Based On A 10 Month Calendar
open System
let getNewDate dayOfYear =
["Jan";"Feb";"Mar";"Apr";"May";"Jun";"Sep";"Oct";"Nov";"Dec"]
|> Seq.mapi(fun i m -> if i%2=0 then m, [1..36] else m, [1..37])
|> Seq.map(fun (m,ad) -> ad |> Seq.map(fun d -> m,d))
|> Seq.collect(fun a -> a)
|> Seq.mapi(fun i d -> i, d )
|> Seq.tryFind(fun (i,d) -> i = dayOfYear)
@jamessdixon
jamessdixon / gist:bffa8b1c2c3dc806dc41
Created December 17, 2014 11:13
DocumentDB walk-through using F#
#r "../packages/Microsoft.Azure.Documents.Client.0.9.1-preview/lib/net40/Microsoft.Azure.Documents.Client.dll"
#r "../packages/Newtonsoft.Json.4.5.11/lib/net40/Newtonsoft.Json.dll"
open System
open Microsoft.Azure.Documents
open Microsoft.Azure.Documents.Client
open Microsoft.Azure.Documents.Linq
let endpointUrl = "yourEndpoint"
@jamessdixon
jamessdixon / Programmic NLog Example Using FSharp
Created December 29, 2016 16:13
Programmic NLog Example Using FSharp
#r "../packages/NLog.4.4.1/lib/net45/NLog.dll"
open NLog
let config = new Config.LoggingConfiguration()
let target = new Targets.ColoredConsoleTarget("ConsoleTarget")
config.AddTarget(target)
let rule = new Config.LoggingRule()
type Customer = {Name:string; Email:string}
type Input = {Customer:Customer; MaxNameLength:int}
type Result<'t> =
| Good of 't
| Bad of string
let bind switchFunction =
fun twoTrackInput ->
match twoTrackInput with
@jamessdixon
jamessdixon / gist:b351af631ad02853bb51f40086361c43
Created July 4, 2017 01:27
UWA for IoT targeting a RP2: Blinkey
public sealed partial class MainPage : Page
{
GpioPin _pin = null;
Int32 _pinValue = 0;
public MainPage()
{
this.InitializeComponent();
Loaded += MainPage_Loaded;
}
@jamessdixon
jamessdixon / Age and Sex Analysis Of Microsoft USA MVPs
Created December 6, 2016 03:03
Age and Sex Analysis Of Microsoft USA MVPs
#r "WindowsBase.dll"
#r "System.Net.Http.dll"
#r "PresentationCore.dll"
#r "../packages/FSharp.Data.2.3.2/lib/net40/FSharp.Data.dll"
open System
open System.IO
open System.Web
open System.Net