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.Collections.Generic | |
| // NOTE: it running in Fable/REPL you need "queue-polyfill.fs" | |
| let bfs idof fanout node = | |
| let queue = Queue([node]) | |
| let visited = HashSet() | |
| // DSL | |
| let enqueue = queue.Enqueue |
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
| namespace Bloxorz | |
| module BFS = | |
| open System.Collections.Generic | |
| type Queue<'a>(values: 'a seq) = | |
| let values = ResizeArray(values) | |
| member x.Count = values.Count | |
| member x.Enqueue value = values.Add(value) | |
| member x.Dequeue () = let result = values.[0] in values.RemoveAt(0); result |
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 | |
| let inline autoParse<'a when 'a : (static member TryParse : string * byref<'a> -> bool)> text = | |
| let mutable result = Unchecked.defaultof<'a> | |
| match (^a : (static member TryParse : string * byref<'a> -> bool) (text, &result)) with | |
| | true -> Some result | _ -> None | |
| // we don't need these two, they are just for readability | |
| let orFail = Option.get |
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
| <?xml version="1.0" encoding="utf-8"?> | |
| <Project Sdk="Microsoft.NET.Sdk"> | |
| <PropertyGroup> | |
| <TargetFramework>netstandard1.5</TargetFramework> | |
| <RootNamespace>Proto.Persistence.MySql</RootNamespace> | |
| </PropertyGroup> | |
| <PropertyGroup> | |
| <Version>0.1.14</Version> | |
| <AssemblyVersion>0.1.14</AssemblyVersion> | |
| <FileVersion>0.1.14</FileVersion> |
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
| Add-Type -AssemblyName System.IO.Compression.FileSystem | |
| function Unzip([string] $zipfile, [string] $outpath) { | |
| [System.IO.Compression.ZipFile]::ExtractToDirectory($zipfile, $outpath) | |
| } | |
| function Download([string] $url, [string] $path) { | |
| $temp = [System.IO.Path]::GetTempFileName() | |
| Invoke-WebRequest "$url" -OutFile "$temp" | |
| Unzip "$temp" "$path" |
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
| Param( | |
| [string] $root = "." | |
| ) | |
| $protoc_folder = "$PSScriptRoot/.tools/protoc" | |
| $protoc_executable = "$protoc_folder/bin/protoc.exe" | |
| $protoc_includes = "$protoc_folder/include" | |
| $protoc_version = "3.6.0" | |
| $protoc_url = "https://github.com/google/protobuf/releases/download/v$protoc_version/protoc-$protoc_version-win32.zip" |
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
| private static IObservable<string> ObserveConsole() => | |
| Observable.Create<string>( | |
| observer => { | |
| var input = new StreamReader(System.Console.OpenStandardInput()); | |
| return Observable | |
| .FromAsync(() => input.ReadLineAsync()) | |
| .Repeat() | |
| .TakeWhile(line => line != null) | |
| .Subscribe(observer!); | |
| }).Publish().RefCount(); |
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
| private static IObservable<T> Observe<T>( | |
| this NetMQSocket socket, | |
| ISocketPollableCollection poller, | |
| Func<NetMQSocket, T> reader) | |
| { | |
| IEnumerable<T> ReadMany(NetMQSocket sckt) | |
| { | |
| while (sckt.HasIn) | |
| yield return reader(sckt); | |
| } |
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
| rem This must be executed as administrator | |
| rem it requires double % if ran as batch file, but single % if copying-pasting lines | |
| assoc .ps1=PowerShell.Script | |
| ftype PowerShell.Script=powershell.exe -ExecutionPolicy RemoteSigned -File %%1 %%* | |
| setx PATHEXT %PATHEXT%;.PS1 | |
| rem This is just a test and may require clicking a checkbox (but only first time) | |
| echo Write-Host 'Hello from PS1' > %temp%\test.ps1 |
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 "System.Management.dll" | |
| module Process = | |
| open System | |
| open System.Diagnostics | |
| open System.Threading.Tasks | |
| open System.Management | |
| let fix (proc: Process option) = | |
| match proc with |