This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
///Url returned by GET /api/files/uploadToken | |
var url = "https://imupload.blob.core.windows.net/merchant-files/b21611714c8d4734a7686e86f7a8080d?sv=2014-02-14&sr=b&sig=05ssdgrshow383JVEmqk%2BDwrTlHqfEO16gApw%2BgK6%2F2k%3D&se=2014-12-02T17%3A13%3A16Z&sp=w"; | |
var request = WebRequest.CreateHttp(url); | |
request.Method = "PUT"; | |
request.Headers.Add("x-ms-blob-type:BlockBlob"); | |
using (var stream = File.OpenRead(@"C:\temp\test.json")) | |
using(var zipped = new GZipStream(request.GetRequestStream(), CompressionMode.Compress)) | |
stream.CopyTo(zipped); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type Resource<'a> = | Validated of 'a | Error of string list | |
type Schema = Resource<JsonSchema> option | |
type Json = Resource<string> option | |
type Api = { | |
title : string | |
description : string | |
baseUrl : string |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#r @"SampleProvider.dll" | |
type Birch = Sample.Sample<"birch"> | |
type Elm = Sample.Sample<"elm"> | |
let birch = Birch.birch() | |
let elm = Elm.elm() | |
elm.Branches <- ([|Elm.elm()|]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#load "ProvidedTypes-head.fs" | |
open Samples.FSharp.ProvidedTypes | |
open Microsoft.FSharp.Quotations | |
type A private() = static member Foo(bar : obj[]->'T) = bar ([||]) | |
let usualWay = typeof<A>.GetMethod("Foo").MakeGenericMethod([| typeof<string> |]) | |
Expr.Call(usualWay, [ <@@fun (_:obj[]) -> ""@@> ]) | |
let byBuilder = ProvidedTypeBuilder.MakeGenericMethod(typeof<A>.GetMethod("Foo"), [ typeof<string> ]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Utility methods | |
static member internal ToSqlParam(p : Parameter) = | |
let name = p.Name | |
let dbType = p.TypeInfo.SqlDbTypeId | |
<@@ | |
let r =SqlParameter( | |
name, | |
enum dbType, | |
Direction = %%Expr.Value p.Direction, | |
TypeName = %%Expr.Value p.TypeInfo.UdttName |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[19;2;4;3;12;18;16;8;5;17] | |
|> Seq.fold (fun (start,newStart,profit) i -> | |
let start = defaultArg start i | |
let newStart = defaultArg newStart i | |
let newProfit = i - newStart | |
if profit < newProfit then Some newStart, Some newStart,newProfit | |
else if start > i then Some start, Some i, profit | |
else Some start,Some newStart,profit) (None,None,0) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
open System | |
type Interval = | |
{ a:double; b:double } | |
static member (*) (x : Interval, y : Interval) = { a = x.a * y.a; b = x.b * y.b} | |
static member (/) (x : Interval, y : Interval) = { a = x.a / y.b; b = x.b / y.a} | |
static member (+) (x : Interval, y : Interval) = { a = x.a + y.a; b = x.b + y.b} | |
static member (-) (x : Interval, y : Interval) = { a = x.a - y.b; b = x.b - y.a} | |
static member (*) (x : Interval, y : double) = { a = x.a * y; b = x.b * y} | |
static member (/) (x : Interval, y : double) = { a = x.a / y; b = x.b / y} |