Skip to content

Instantly share code, notes, and snippets.

@voronoipotato
Created September 2, 2022 22:04
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 voronoipotato/ae6d53a7a52648a87aed6dd0445fb248 to your computer and use it in GitHub Desktop.
Save voronoipotato/ae6d53a7a52648a87aed6dd0445fb248 to your computer and use it in GitHub Desktop.
script that is both a powershell script, and a f# script, that invokes the F# script
#if false
return dotnet fsi --quiet --exec --use:"$(Get-Location)\$($MyInvocation.MyCommand.Name)" -- $args
#endif
// <#
//the first argument is the script name, so we get the tail
let args : string array = fsi.CommandLineArgs |> Array.tail
let hexByteToAscii (s:string) =
System.Convert.ToByte(s,16)
|> System.Convert.ToChar
let charsToString (chars:char[]) =
new string (chars)
let hexToAscii (value:string) =
value
|>Seq.chunkBySize 2
|>Seq.map ( hexByteToAscii << charsToString)
|>Seq.toArray
|>charsToString
let out = (hexToAscii args[0])
printf "%s" out
// #>
#if false
return dotnet fsi --quiet --exec --use:"$(Get-Location)\$($MyInvocation.MyCommand.Name)" -- $args
#endif
// <#
//the first argument is the script name, so we get the tail
let args : string array = fsi.CommandLineArgs |> Array.tail
let hexByteToAscii (s:string) =
System.Convert.ToByte(s,16)
|> System.Convert.ToChar
let charsToString (chars:char[]) =
new string (chars)
let hexToAscii (value:string) =
value
|>Seq.chunkBySize 2
|>Seq.map ( hexByteToAscii << charsToString)
|>Seq.toArray
|>charsToString
let out = (hexToAscii args[0])
printf "%s" out
// #>
@voronoipotato
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment