Skip to content

Instantly share code, notes, and snippets.

View lefthandedgoat's full-sized avatar

Chris Holt lefthandedgoat

View GitHub Profile
open System.Net
open Microsoft.FSharp.Control.WebExtensions
open System.Diagnostics
open System
let fetch name (url:string) =
printfn "fetching %s" name
let uri = new System.Uri(url)
use webClient = new WebClient()
let stopwatch = Stopwatch()
@lefthandedgoat
lefthandedgoat / gist:ef20c7843e021a4f93c4
Last active August 29, 2015 14:02
ntlm auth workaround for selenium using mike rodger's package

This works and I hope thats its good enough. I couldn't figure out how to just type in the boxes.

https://github.com/lefthandedgoat/ntlmAuthMVC

MVC App setup as an intranet app, with anonymous turned off, and windows auth turned on. I am not sure how comperable that is to azure auth, sorry.

Slightly modifed version of this https://github.com/mike-rogers/NtlmProxy (setup to allow for giving username and password, and added try/catch/swallow

Change authorize attributes to be whatever test account you setup locally https://github.com/lefthandedgoat/ntlmAuthMVC/blob/master/MvcApplication/Controllers/HomeController.cs#L7

#r "../packages/Selenium.WebDriver.2.42.0/lib/net40/WebDriver.dll"
#r "../packages/Selenium.Support.2.42.0/lib/net40/WebDriver.Support.dll"
#r "../packages/Newtonsoft.Json.6.0.1/lib/net40/Newtonsoft.Json.dll"
#r "../packages/SizSelCsZzz.0.3.36.0/lib/SizSelCsZzz.dll"
#r "../packages/canopy.0.9.11/lib/canopy.dll"
open canopy
start firefox
type foo = {
a : string
b : int
}
let foos =
[
{ a = "hello"; b = 1 }
@lefthandedgoat
lefthandedgoat / gist:40c93c448c2c86402f81
Created December 6, 2014 00:00
traverse recursive nodes and see the cost of recursion to build an execution plan for fast recursion next time!
module whatever
open runner
type DataElement = {
formula : Formula option
}
and FormulaVariable = {
dataElement : DataElement
}
//inference will make this a function with 2 int args and int as a result
let add this that = this + that
//we can use type annotations to explicitly qualify the argument's types
let add (this : int) (that : int) = this + that
//we can use type annotations to also explicitly qualify the return value's type
let add (this : int) (that : int) : int = this + that
//f# defaults to ints inference for addition, if we want floats we can provide that
@lefthandedgoat
lefthandedgoat / gist:006f9282e53b9ab29f6e
Last active August 29, 2015 14:22
common context stuff
module canopyExtensions
open canopy
open runner
let context name =
canopy.runner.context name
once (fun _ -> printfn "some common once function")
before (fun _ -> printfn "some common before function")
after (fun _ -> printfn "some common after function")
;; require package managers, but we'll avoid them if at all possible
(require 'package)
(push '("melpa" . "http://melpa.milkbox.net/packages/")
package-archives)
;;=====================================
;;plugins
;;=====================================
type SqlPart =
| select of string list
| from of string
| where of string list
let execute sqlParts =
let rec execute sqlParts sqlString =
match sqlParts with
| [] -> sqlString
| part :: tail -> execute tail (sqlString + (convertPartToString part))
@lefthandedgoat
lefthandedgoat / fsharpgravitykata
Created February 28, 2012 00:17
fsharp gravity kata
let floored block =
snd block = 0
let collision blocks block =
List.exists(fun b -> b = block) blocks
let otherblocks blocks block = List.filter(fun b -> b <> block) blocks
let rec fall blocks block =
let fallenBlock = (fst block, snd block - 1)