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
// no pattern matching but there are when clauses that return values | |
fun int2Bool (i:Int): Boolean = | |
when (i) { | |
0 -> false | |
else -> true | |
} | |
fun bool2Int (b:Boolean): Int = // so you can put functions before or after use - not order dependent | |
when (b) { | |
true -> 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
import java.sql.* | |
data class eProgProv(val AcaProg: String, val ProvName: String) | |
val eProgProvs = mutableListOf<eProgProv>() | |
fun inserteProgProv(cn: Connection, e: eProgProv ) { | |
val writeStmt = cn.createStatement() | |
fun escStr(s:String) = s.replace("'", "''") |
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
// running in fable.io/repl to check performance on 32 bit win 7 with chrome | |
type Agent<'T> = MailboxProcessor<'T> | |
let agent = | |
Agent.Start(fun inbox -> | |
async { while true do | |
let! msg = inbox.Receive() | |
printfn "got message '%s'" msg } ) | |
agent.Post "hello" | |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
set-executionpolicy unrestricted -s cu | |
$browser = New-Object System.Net.WebClient | |
$browser.Proxy.Credentials =[System.Net.CredentialCache]::DefaultNetworkCredentials | |
iex ($browser).downloadstring('https://get.scoop.sh') |
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);" |
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
# 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
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
// 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'' |