This file contains hidden or 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
(* | |
From http://blog.oddhead.com/2006/10/30/implementing-hansons-market-maker/ | |
*) | |
open System | |
// --------------------------------------------------- | |
// first off some helper functionality to report messages as events, copied straight off Don Syme's blog: http://blogs.msdn.com/b/dsyme/archive/2010/01/10/async-and-parallel-design-patterns-in-f-reporting-progress-with-events-plus-twitter-sample.aspx |
This file contains hidden or 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 | |
open System.ServiceModel | |
open Microsoft.FSharp.Linq | |
open Microsoft.FSharp.Data.TypeProviders | |
(* bit dumb but because service requests authentication, and we can't do that in the wsdlservice tp, we have to download wsdl, load it up locally, set | |
binding up properly, then use tp *) | |
open System.Net | |
open System.IO | |
open System.Text |
This file contains hidden or 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 | |
open FSharp.Data | |
open System | |
open System.ServiceModel | |
open Microsoft.FSharp.Linq | |
open Microsoft.FSharp.Data.TypeProviders | |
(* execute the following commented stuff only once to get the wsdl, then leave commented | |
(* bit dumb but because service requests authentication, and we can't do that in the wsdlservice tp, we have to download wsdl, load it up locally, set |
This file contains hidden or 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 @"packages\NodaTime\lib\net35-Client\NodaTime.dll" | |
open NodaTime | |
SystemClock.Instance.Now | |
let pattern = NodaTime.Text.LocalDateTimePattern.CreateWithInvariantCulture("MM/dd/yyyy HH:mm") | |
pattern.Parse("11/05/2014 21:15") | |
let dt s = DateTime.ParseExact(s, "d/MM/yyyy h:mm:ss tt", CultureInfo.CurrentCulture) |
This file contains hidden or 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
let (>|>) x f = | |
let timer = new System.Diagnostics.Stopwatch() | |
timer.Start() | |
let r = f x | |
printfn "Elapsed Time: %i" timer.ElapsedMilliseconds | |
r | |
[1..1000] | |
>|> List.map (fun x -> [1..x] |> List.sum) | |
>|> List.max |
This file contains hidden or 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
// getting to grips with PrintfFormat | |
//let sscanf (pf:PrintfFormat<_,_,_,_,'t>) s : 't = | |
let explorePF (pf:PrintfFormat<'printer,'state,'residue,'result,'tuple>) s : string = | |
pf.Value | |
explorePF "(%s %% % %i)" "(somestring)" | |
explorePF "(%s %% %z %i)" "(somestring)" // error FS0741: Unable to parse format string 'Bad format specifier: 'z'' |
This file contains hidden or 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 | |
open System.IO | |
open System.Text.RegularExpressions | |
open System.Globalization | |
(* | |
For this example let's say we have data describing the processing of a batch of steps eg something like this: | |
BatchId | |
Start DateTime, End DateTime, Step Description |
This file contains hidden or 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
# needed to count number of rows populated in filenet database docversion and generic tables for a filenet migration analysis | |
# wasn't able to use sql server client tools so had to do this in powershell... | |
function Invoke-SQL { | |
param( | |
[string] $sqlCommand = $(throw "Please specify a query.") | |
) | |
$connectionString = "Server = someServer,4000; Network Library=DBMSSOCN; Initial catalog = somedb; User Id = someUser; Password = somePassword; Connection Timeout = 120" |
This file contains hidden or 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
1..10 | . {process{ $_; sleep 1 }} | |
function giveMeTwo {2} | |
$log = "Barney" | |
$src = "c:\temp" | |
1..10 | Split-Pipeline -Count 2 -Variable log,src -Function giveMeTwo {process{ write-host "Value: $_ from thread $([System.Threading.Thread]::CurrentThread.ManagedThreadId) for $log, $src" | |
write-host $(giveMeTwo) | |
sleep 1 }} |
This file contains hidden or 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
$Cred = Get-Credential -Message "Enter database credentials" -UserName $DBUser | |
function Invoke-SqlCmd { | |
param( | |
[string] $sqlCommand = $(throw "Please specify a query.") | |
) | |
$connectionString = "Server = someServer,1234; Network Library=DBMSSOCN; Initial catalog = $db; User Id = $($Cred.UserName); Password = $($Cred.GetNetworkCredential().Password);" |