Skip to content

Instantly share code, notes, and snippets.

@mneedham
Created July 9, 2009 11:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mneedham/143578 to your computer and use it in GitHub Desktop.
Save mneedham/143578 to your computer and use it in GitHub Desktop.
let ApplyRegex pattern response = Regex.Split(response, "\n") |> Array.map (fun x -> Regex.Match(x, pattern))
let GetMatchingGroups = Array.filter (fun (x:Match) -> x.Success) >> Array.map (fun x -> x.Groups) >> Array.to_seq
let GetAgentsAndBuildTimes =
ApplyRegex "(.*\)),([0-9]+)," >>
GetMatchingGroups >>
Seq.map (fun group -> group.[1].Value, group.[2].Value ) >>
Seq.group_by (fun x -> fst x) >>
Seq.map (fun (agent, buildInfo) -> agent, (buildInfo |> Seq.map (fun x -> snd x)) )
let GetBuildTimes =
ApplyRegex ".*\),([0-9]+)," >>
GetMatchingGroups >>
Seq.map (fun g -> g.[1].Value)
let CreateGoogleGraphUri (values:seq<string>) =
let graphUrlSuffix = "http://chart.apis.google.com/chart?cht=lc&chxt=y&chxl=0:|0|400|800|1150&chs=500x200&chds=0,1150&chd=t:"
let dataPoints = (values |> Seq.fold (fun acc x -> acc + x + ",") "")
let graphUrl = sprintf "%s%s" graphUrlSuffix (dataPoints.Remove(dataPoints.Length-1))
new System.Uri(graphUrl)
let DownloadGraph fileLocation uri =
let webClient = new WebClient()
webClient.DownloadFileAsync(uri, fileLocation)
let CreateGraphOfBuildTimes =
GetBuildTimes >>
CreateGoogleGraphUri >>
DownloadGraph "c:\mark.jpg"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment