Skip to content

Instantly share code, notes, and snippets.

View nightroman's full-sized avatar

Roman Kuzmin nightroman

  • UK
View GitHub Profile
// F# call via interface vs. record
type IFace =
abstract Test: int -> string -> unit
type IRecord = {
Test: int -> string -> unit
}
let myTest i s =
@nightroman
nightroman / .Turtle-Steps.md
Last active July 14, 2017 17:50
Turtle 16: Batch processing using command objects with responses

16: Batch processing using command objects with responses

The description is the same as the case 9 with the last disadvantage resolved. Namely

  • Only suitable when control flow is not based on the response from a previous command.
    • Case 16 solves this issue, commands have responses.

Below is the case 9 notes:

@nightroman
nightroman / Microsoft.VSCode_profile.ps1
Created May 19, 2017 14:59
My Microsoft.VSCode_profile.ps1
function prompt
{
#! now: last error for the color
$color = if ($?) { 10 } else { 12 }
# debug
if ($ExecutionContext.SessionState.PSVariable.GetValue('PSDebugContext')) {
return
}

FSharpx.Extras

// sequence of steps
type Step =
| Next
| Ask1 of string ref
| Ask2 of string ref
let steps = seq {
printfn "step 0"

Colorer hrd with colors

hrd.hrc

Allows to highlight console color codes using their literal colors.

The change was accepted, e.g. it was in 1.0.3.11. Then it was removed in 1.0.3.12, presumably due to regeneration. Sonar was informed.


open System
open ParserLibrary
open ParserLibrary.TextInput
[<EntryPoint>]
let entry args =
let r = run (opt spaces .>>. pint .>>. (manyChars (satisfy (fun _ -> true) "any"))) " -123 Z X"
printfn "%A" r
r |> printResult
@nightroman
nightroman / Credential.ps1
Created March 29, 2015 19:47
Get, export, and import credential
# credential file path
$CredentialPath = "$PSScriptRoot\credential.clixml"
# get and export credential
$credential = Get-Credential
$credential | Export-Clixml -LiteralPath $CredentialPath
# import credential
$credential = Import-Clixml -LiteralPath $CredentialPath
$credential
@nightroman
nightroman / Markdown.tasks.ps1
Created September 18, 2011 18:59
Invoke-Build tasks for markdown files (using Markdown.pl)
# Invoke-Build tasks for markdown files (using Markdown.pl)
# <https://gist.github.com/1225405>
<#
Task: Convert markdown files to HTML files (using Markdown.pl).
Requires:
* Perl script Markdown.pl <http://daringfireball.net/projects/markdown/>
* Either perl executable in the path or the predefined alias 'perl', e.g.:
Set-Alias perl "C:\Program Files\Git\bin\perl.exe"
@nightroman
nightroman / Markdown.tasks.ps1
Created September 17, 2011 10:31
Invoke-Build tasks for markdown files (using MarkdownSharp)
# Invoke-Build tasks for markdown files (using MarkdownSharp)
# <https://gist.github.com/1223828>
<#
Task: Convert markdown files to HTML files (using MarkdownSharp).
Requires:
* MarkdownSharp.dll and its environment variable $env:MarkdownSharp
* NuGet install MarkdownDeep.NET
* https://github.com/toptensoftware/MarkdownDeep